From ac1cb3cd7c1d9232ce1663e469d519319f4ed812 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 17 Oct 2025 04:36:08 -0400 Subject: [PATCH] lib/qemu.c: Add -cpu max when testing for KVM via QMP On RHEL 10.2 aarch64 (only) we see: $ echo '{ "execute": "qmp_capabilities" }' '{ "execute": "query-kvm" }' '{ "execute": "quit" }' | QEMU_AUDIO_DRV=none "/usr/libexec/qemu-kvm" -display none -machine "virt,accel=kvm:hvf:tcg" -qmp stdio qemu-kvm: invalid accelerator hvf qemu-kvm: falling back to KVM {"QMP": {"version": {"qemu": {"micro": 0, "minor": 1, "major": 9}, "package": "qemu-kvm-9.1.0-15.el10_0.4"}, "capabilities": ["oob"]}} qemu-kvm: warning: CPU model cortex-a57-arm-cpu is deprecated -- use 'host' / 'max' qemu-kvm: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument Unfortunately we cannot use guestfs_int_get_cpu_model (as that requires us to already know if KVM is supported), so we just have to guess that -cpu max will work, at least enough for QMP to work. Fixes: https://issues.redhat.com/browse/RHEL-121076 Reported-by: Xiang Hua Chen --- lib/qemu.c | 1 + tests/disks/debug-qemu.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/qemu.c b/lib/qemu.c index 15e729839..b8cc9c5a1 100644 --- a/lib/qemu.c +++ b/lib/qemu.c @@ -80,6 +80,7 @@ generic_qmp_test (guestfs_h *g, const char *qmp_command, char **outp) guestfs_int_cmd_add_string_unquoted (cmd, "QEMU_AUDIO_DRV=none "); guestfs_int_cmd_add_string_quoted (cmd, g->hv); guestfs_int_cmd_add_string_unquoted (cmd, " -display none"); + guestfs_int_cmd_add_string_unquoted (cmd, " -cpu max"); guestfs_int_cmd_add_string_unquoted (cmd, " -machine "); guestfs_int_cmd_add_string_quoted (cmd, #ifdef MACHINE_TYPE diff --git a/tests/disks/debug-qemu.sh b/tests/disks/debug-qemu.sh index e6e80abe3..96c90553b 100755 --- a/tests/disks/debug-qemu.sh +++ b/tests/disks/debug-qemu.sh @@ -25,7 +25,7 @@ fi # The direct backend runs qemu ... -qmp stdio to query for KVM. For # the test to pass we have to provide an answer here. -if [ "x$5" = "x-qmp" ]; then +if [ "x$7" = "x-qmp" ]; then # Consume stdin first. cat >/dev/null # Write some fake output.