1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-01 04:38:12 +00:00

Merge pull request #1934 from GNS3/handle_no-kvm_deprecated

Handle -no-kvm param deprecated in Qemu >= v5.2
This commit is contained in:
Jeremy Grossmann 2021-07-27 17:37:41 +09:30 committed by GitHub
commit 6cf268ca93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 14 deletions

View File

@ -829,20 +829,26 @@ class QemuVM(BaseNode):
id=self._id, id=self._id,
options=options)) options=options))
if not sys.platform.startswith("linux"): # "-no-kvm" and "-no-hax' are deprecated since Qemu v5.2
if "-no-kvm" in options: if "-no-kvm" in options:
options = options.replace("-no-kvm", "") options = options.replace("-no-kvm", "-machine accel=tcg")
if "-enable-kvm" in options: if "-no-hax" in options:
options = options.replace("-no-hax", "-machine accel=tcg")
if "-enable-kvm" in options:
if not sys.platform.startswith("linux"):
# KVM can only be enabled on Linux
options = options.replace("-enable-kvm", "") options = options.replace("-enable-kvm", "")
else: else:
if "-no-hax" in options: options = options.replace("-enable-kvm", "-machine accel=kvm")
options = options.replace("-no-hax", "")
if "-enable-hax" in options: if "-enable-hax" in options:
if not sys.platform.startswith("win"):
# HAXM is only available on Windows
options = options.replace("-enable-hax", "") options = options.replace("-enable-hax", "")
if "-icount" in options and ("-no-kvm" not in options): else:
# automatically add the -no-kvm option if -icount is detected options = options.replace("-enable-hax", "-machine accel=hax")
# to help with the migration of ASA VMs created before version 1.4
options = "-no-kvm " + options
self._options = options.strip() self._options = options.strip()
@property @property
@ -2078,7 +2084,7 @@ class QemuVM(BaseNode):
if require_kvm is not None: if require_kvm is not None:
require_hardware_accel = require_kvm require_hardware_accel = require_kvm
if enable_hardware_accel and "-no-kvm" not in options and "-no-hax" not in options: if enable_hardware_accel and "-machine accel=tcg" not in options:
# Turn OFF hardware acceleration for non x86 architectures # Turn OFF hardware acceleration for non x86 architectures
if sys.platform.startswith("win"): if sys.platform.startswith("win"):
supported_binaries = ["qemu-system-x86_64.exe", "qemu-system-x86_64w.exe", "qemu-system-i386.exe", "qemu-system-i386w.exe"] supported_binaries = ["qemu-system-x86_64.exe", "qemu-system-x86_64w.exe", "qemu-system-i386.exe", "qemu-system-i386w.exe"]

View File

@ -207,7 +207,7 @@ class QEMUHandler:
enable_kvm = qemu_manager.config.get_section_config("Qemu").getboolean("enable_kvm") enable_kvm = qemu_manager.config.get_section_config("Qemu").getboolean("enable_kvm")
if enable_kvm is not None: if enable_kvm is not None:
hardware_accel = enable_kvm hardware_accel = enable_kvm
if hardware_accel and "-no-kvm" not in vm.options and "-no-hax" not in vm.options: if hardware_accel and "-machine accel=tcg" not in vm.options:
pm = ProjectManager.instance() pm = ProjectManager.instance()
if pm.check_hardware_virtualization(vm) is False: if pm.check_hardware_virtualization(vm) is False:
raise aiohttp.web.HTTPConflict(text="Cannot start VM with hardware acceleration (KVM/HAX) enabled because hardware virtualization (VT-x/AMD-V) is already used by another software like VMware or VirtualBox") raise aiohttp.web.HTTPConflict(text="Cannot start VM with hardware acceleration (KVM/HAX) enabled because hardware virtualization (VT-x/AMD-V) is already used by another software like VMware or VirtualBox")