diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 0b49b9e0..63df5ef5 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1489,6 +1489,11 @@ class QemuVM(BaseNode): command.extend(["-smp", "cpus={}".format(self._cpus)]) if self._run_with_kvm(self.qemu_path, self._options): command.extend(["-enable-kvm"]) + version = yield from self.manager.get_qemu_version(self.qemu_path) + # Issue on some combo Intel CPU + KVM + Qemu 2.4.0 + # https://github.com/GNS3/gns3-server/issues/685 + if version and parse_version(version) >= parse_version("2.4.0"): + command.extend(["-machine smm=off"]) command.extend(["-boot", "order={}".format(self._boot_priority)]) cdrom_option = self._cdrom_option() command.extend(cdrom_option) diff --git a/gns3server/compute/virtualbox/virtualbox_vm.py b/gns3server/compute/virtualbox/virtualbox_vm.py index 7f172362..06723fd9 100644 --- a/gns3server/compute/virtualbox/virtualbox_vm.py +++ b/gns3server/compute/virtualbox/virtualbox_vm.py @@ -265,7 +265,7 @@ class VirtualBoxVM(BaseNode): log.debug("Stop result: {}".format(result)) log.info("VirtualBox VM '{name}' [{id}] stopped".format(name=self.name, id=self.id)) - # yield from asyncio.sleep(0.5) # give some time for VirtualBox to unlock the VM + yield from asyncio.sleep(0.5) # give some time for VirtualBox to unlock the VM try: # deactivate the first serial port yield from self._modify_vm("--uart1 off") diff --git a/tests/compute/qemu/test_qemu_vm.py b/tests/compute/qemu/test_qemu_vm.py index 972ec1eb..60841a6c 100644 --- a/tests/compute/qemu/test_qemu_vm.py +++ b/tests/compute/qemu/test_qemu_vm.py @@ -22,7 +22,7 @@ import os import sys import stat import re -from tests.utils import asyncio_patch +from tests.utils import asyncio_patch, AsyncioMagicMock from unittest import mock @@ -436,6 +436,65 @@ def test_build_command(vm, loop, fake_qemu_binary, port_manager): ] +def test_build_command_kvm(linux_platform, vm, loop, fake_qemu_binary, port_manager): + """ + Qemu 2.4 introduce an issue with KVM + """ + vm._run_with_kvm = MagicMock(return_value=True) + vm.manager.get_qemu_version = AsyncioMagicMock(return_value="2.3.2") + os.environ["DISPLAY"] = "0:0" + with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process: + cmd = loop.run_until_complete(asyncio.async(vm._build_command())) + assert cmd == [ + fake_qemu_binary, + "-name", + "test", + "-m", + "256M", + "-smp", + "cpus=1", + "-enable-kvm", + "-boot", + "order=c", + "-serial", + "telnet:127.0.0.1:{},server,nowait".format(vm.console), + "-net", + "none", + "-device", + "e1000,mac={}".format(vm._mac_address) + ] + + +def test_build_command_kvm_2_4(linux_platform, vm, loop, fake_qemu_binary, port_manager): + """ + Qemu 2.4 introduce an issue with KVM + """ + vm._run_with_kvm = MagicMock(return_value=True) + vm.manager.get_qemu_version = AsyncioMagicMock(return_value="2.4.2") + os.environ["DISPLAY"] = "0:0" + with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process: + cmd = loop.run_until_complete(asyncio.async(vm._build_command())) + assert cmd == [ + fake_qemu_binary, + "-name", + "test", + "-m", + "256M", + "-smp", + "cpus=1", + "-enable-kvm", + "-machine smm=off", + "-boot", + "order=c", + "-serial", + "telnet:127.0.0.1:{},server,nowait".format(vm.console), + "-net", + "none", + "-device", + "e1000,mac={}".format(vm._mac_address) + ] + + @pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows") def test_build_command_without_display(vm, loop, fake_qemu_binary):