1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Workaround a bug with KVM, Qemu >= 2.4 and Intel CPU

Fix #685
This commit is contained in:
Julien Duponchelle 2016-09-21 19:25:15 +02:00
parent de2dad20d5
commit 2bbdbeaa82
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 65 additions and 1 deletions

View File

@ -1424,6 +1424,11 @@ class QemuVM(BaseVM):
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)

View File

@ -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
@ -434,6 +434,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):