From 63edcc1c34fe86f5c0cd30e776c72259f810898c Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 10 Nov 2015 16:25:02 +0100 Subject: [PATCH] Fix duplicate of -no-kvm options Fix #356 --- gns3server/modules/qemu/qemu_vm.py | 2 +- tests/modules/qemu/test_qemu_vm.py | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/gns3server/modules/qemu/qemu_vm.py b/gns3server/modules/qemu/qemu_vm.py index a2bcca0b..7e4c002c 100644 --- a/gns3server/modules/qemu/qemu_vm.py +++ b/gns3server/modules/qemu/qemu_vm.py @@ -659,7 +659,7 @@ class QemuVM(BaseVM): options = options.replace("-no-kvm", "") if "-enable-kvm" in options: options = options.replace("-enable-kvm", "") - elif "-icount" in options: + elif "-icount" in options and ("-no-kvm" not in options): # automatically add the -no-kvm option if -icount is detected # to help with the migration of ASA VMs created before version 1.4 options = "-no-kvm " + options diff --git a/tests/modules/qemu/test_qemu_vm.py b/tests/modules/qemu/test_qemu_vm.py index d2dbbe2d..e0187cce 100644 --- a/tests/modules/qemu/test_qemu_vm.py +++ b/tests/modules/qemu/test_qemu_vm.py @@ -431,12 +431,32 @@ def test_hdd_disk_image(vm, tmpdir): assert vm.hdd_disk_image == str(tmpdir / "QEMU" / "test") -def test_options(vm): +def test_options(linux_platform, vm): vm.kvm = False vm.options = "-usb" assert vm.options == "-usb" assert vm.kvm is False + vm.options = "-no-kvm" + assert vm.options == "-no-kvm" + + vm.options = "-enable-kvm" + assert vm.options == "-enable-kvm" + + vm.options = "-icount 12" + assert vm.options == "-no-kvm -icount 12" + + vm.options = "-icount 12 -no-kvm" + assert vm.options == "-icount 12 -no-kvm" + + +def test_options_windows(windows_platform, vm): + vm.options = "-no-kvm" + assert vm.options == "" + + vm.options = "-enable-kvm" + assert vm.options == "" + def test_get_qemu_img(vm, tmpdir):