Merge pull request #1934 from GNS3/handle_no-kvm_deprecated

Handle -no-kvm param deprecated in Qemu >= v5.2
pull/1938/head
Jeremy Grossmann 3 years ago committed by GitHub
commit 6cf268ca93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -829,20 +829,26 @@ class QemuVM(BaseNode):
id=self._id,
options=options))
if not sys.platform.startswith("linux"):
if "-no-kvm" in options:
options = options.replace("-no-kvm", "")
if "-enable-kvm" in options:
# "-no-kvm" and "-no-hax' are deprecated since Qemu v5.2
if "-no-kvm" in options:
options = options.replace("-no-kvm", "-machine accel=tcg")
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", "")
else:
if "-no-hax" in options:
options = options.replace("-no-hax", "")
if "-enable-hax" in options:
else:
options = options.replace("-enable-kvm", "-machine accel=kvm")
if "-enable-hax" in options:
if not sys.platform.startswith("win"):
# HAXM is only available on Windows
options = options.replace("-enable-hax", "")
if "-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
else:
options = options.replace("-enable-hax", "-machine accel=hax")
self._options = options.strip()
@property
@ -2078,7 +2084,7 @@ class QemuVM(BaseNode):
if require_kvm is not None:
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
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"]

@ -207,7 +207,7 @@ class QEMUHandler:
enable_kvm = qemu_manager.config.get_section_config("Qemu").getboolean("enable_kvm")
if enable_kvm is not None:
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()
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")

Loading…
Cancel
Save