pmb.qemu: use -cpu host for KVM, make configurable with --cpu (!1886)

For KVM the code is run pretty much natively on the host CPU, so all
CPU extensions available on the host CPU can be also used inside the VM.
To expose that information to the VM we should pass "-cpu host", so the
VM is aware of which CPU is in use.

For CPU emulation, QEMU uses a rather minimal CPU on x86_64 by default.
It does not have support for SSE3/4 etc, which may be required for some
applications to work properly (e.g. Android in Anbox). Add a --cpu flag
to make the emulated CPU configurable. Useful values are for example
--cpu max to emulate all implemented CPU features.
This commit is contained in:
Minecrell 2020-03-10 16:14:50 +01:00 committed by Oliver Smith
parent 76dcf8aa0b
commit 7bbc507416
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
2 changed files with 10 additions and 0 deletions

View File

@ -126,6 +126,12 @@ def arguments_qemu(subparser):
ret.add_argument("--no-kvm", dest="qemu_kvm", default=True, action='store_false',
help="Avoid using hardware-assisted virtualization with KVM "
"even when available (SLOW!)")
ret.add_argument("--cpu", dest="qemu_cpu",
help="Override emulated QEMU CPU. By default, the host CPU "
"will be emulated when using KVM and the QEMU default otherwise "
"(usually a CPU with minimal features). "
"A useful value is 'max' (emulate all features that are available), "
"use --cpu help to get a list of possible values from QEMU.")
ret.add_argument("--tablet", dest="qemu_tablet", action='store_true',
default=False, help="Use 'tablet' instead of 'mouse' input "

View File

@ -146,9 +146,13 @@ def command_qemu(args, arch, img_path):
native = args.arch_native == args.deviceinfo["arch"]
if args.qemu_kvm and native and os.path.exists("/dev/kvm"):
command += ["-enable-kvm"]
command += ["-cpu", "host"]
else:
logging.info("WARNING: QEMU is not using KVM and will run slower!")
if args.qemu_cpu:
command += ["-cpu", args.qemu_cpu]
display = args.qemu_display
if display != "none":
display += ",gl=" + ("on" if args.qemu_gl else "off")