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
2 changed files with 20 additions and 14 deletions

View File

@ -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"]