[libvirt] [PATCH] qemu: Add a capability flag for -no-acpi

Currently non-x86 guests must have <acpi/> defined in <features> to prevent libvirt from running qemu with -no-acpi. Although it works, it is a hack. Instead add a capability flag which indicates whether qemu understands the -no-acpi option. Use it to control whether libvirt emits -no-acpi. Current versions of qemu always display -no-acpi in their help output, so this patch has no effect. However the development version of qemu has been modified such that -no-acpi is only displayed when it is actually supported. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e69d601..de2bc13 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -142,6 +142,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST, "cache-unsafe", /* 75 */ "rombar", "ich9-ahci", + "no-acpi", ); struct qemu_feature_flags { @@ -1066,6 +1067,8 @@ qemuCapsComputeCmdFlags(const char *help, qemuCapsSet(flags, QEMU_CAPS_RTC_TD_HACK); if (strstr(help, "-no-hpet")) qemuCapsSet(flags, QEMU_CAPS_NO_HPET); + if (strstr(help, "-no-acpi")) + qemuCapsSet(flags, QEMU_CAPS_NO_ACPI); if (strstr(help, "-no-kvm-pit-reinjection")) qemuCapsSet(flags, QEMU_CAPS_NO_KVM_PIT); if (strstr(help, "-tdf")) diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 00e5214..08d8457 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -115,6 +115,7 @@ enum qemuCapsFlags { QEMU_CAPS_DRIVE_CACHE_UNSAFE = 75, /* Is cache=unsafe supported? */ QEMU_CAPS_PCI_ROMBAR = 76, /* -device rombar=0|1 */ QEMU_CAPS_ICH9_AHCI = 77, /* -device ich9-ahci */ + QEMU_CAPS_NO_ACPI = 78, /* -no-acpi */ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 92a5955..b241147 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4035,8 +4035,10 @@ qemuBuildCommandLine(virConnectPtr conn, if (monitor_json && qemuCapsGet(qemuCaps, QEMU_CAPS_NO_SHUTDOWN)) virCommandAddArg(cmd, "-no-shutdown"); - if (!(def->features & (1 << VIR_DOMAIN_FEATURE_ACPI))) - virCommandAddArg(cmd, "-no-acpi"); + if (qemuCapsGet(qemuCaps, QEMU_CAPS_NO_ACPI)) { + if (!(def->features & (1 << VIR_DOMAIN_FEATURE_ACPI))) + virCommandAddArg(cmd, "-no-acpi"); + } if (!def->os.bootloader) { /* -- 1.7.7.3

On 12/19/2011 06:08 PM, Michael Ellerman wrote:
Currently non-x86 guests must have <acpi/> defined in <features> to prevent libvirt from running qemu with -no-acpi. Although it works, it is a hack.
Instead add a capability flag which indicates whether qemu understands the -no-acpi option. Use it to control whether libvirt emits -no-acpi.
Current versions of qemu always display -no-acpi in their help output, so this patch has no effect. However the development version of qemu has been modified such that -no-acpi is only displayed when it is actually supported.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au> --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-)
ACK and pushed, after fixing 'make check' to work with the new feature bit (see below). Meanwhile, I see nothing wrong with going one further - if we can tell from the qemu binary and/or the domain XML which target architecture the guest will be running in, then we could auto-disable acpi on non-x86 guests, even when qemu -help output mistakenly includes a useless -no-acpi for that architecture, so that you could avoid the <acpi/> hack even when targetting qemu that doesn't yet make the -help output context sensitive. But I'll let you do that as a separate patch. Here's what I squashed - note that I cheated a bit, and blindly enabled the new capability bit for all qemu xml tests; it was faster than adding QEMU_CAPS_NO_ACPI to the bulk of the test entries in qemuxml2argvtest.c, or editing more than 100 .argv files to remove the -no-acpi argument. But if you ever expand that test to cover non-x86 XML->argv conversions, then we should probably go with the longer approach of enabling the capability per-test where it matters, rather than globally enabling it for the duration of the test. diff --git i/tests/qemuhelptest.c w/tests/qemuhelptest.c index 4258fc9..f31c903 100644 --- i/tests/qemuhelptest.c +++ w/tests/qemuhelptest.c @@ -81,11 +81,12 @@ static int testHelpStrParsing(const void *data) goto cleanup; if (STRNEQ(got, expected)) { - fprintf(stderr, - "%s: computed flags do not match: got %s, expected %s\n", - info->name, got, expected); + if (virTestGetVerbose() || virTestGetDebug()) + fprintf(stderr, + "%s: computed flags do not match: got %s, expected %s\n", + info->name, got, expected); - if (getenv("VIR_TEST_DEBUG")) + if (virTestGetDebug()) printMismatchedFlags(flags, info->flags); goto cleanup; @@ -145,7 +146,8 @@ mymain(void) QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, QEMU_CAPS_DRIVE, - QEMU_CAPS_NAME); + QEMU_CAPS_NAME, + QEMU_CAPS_NO_ACPI); DO_TEST("kvm-74", 9001, 1, 74, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -158,7 +160,8 @@ mymain(void) QEMU_CAPS_DRIVE_FORMAT, QEMU_CAPS_MEM_PATH, QEMU_CAPS_TDF, - QEMU_CAPS_NO_SHUTDOWN); + QEMU_CAPS_NO_SHUTDOWN, + QEMU_CAPS_NO_ACPI); DO_TEST("kvm-83-rhel56", 9001, 1, 83, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -185,7 +188,8 @@ mymain(void) QEMU_CAPS_DRIVE_READONLY, QEMU_CAPS_SMBIOS_TYPE, QEMU_CAPS_SPICE, - QEMU_CAPS_NO_SHUTDOWN); + QEMU_CAPS_NO_SHUTDOWN, + QEMU_CAPS_NO_ACPI); DO_TEST("qemu-0.10.5", 10005, 0, 0, QEMU_CAPS_KQEMU, QEMU_CAPS_VNC_COLON, @@ -205,7 +209,8 @@ mymain(void) QEMU_CAPS_RTC_TD_HACK, QEMU_CAPS_NO_HPET, QEMU_CAPS_VGA_NONE, - QEMU_CAPS_NO_SHUTDOWN); + QEMU_CAPS_NO_SHUTDOWN, + QEMU_CAPS_NO_ACPI); DO_TEST("qemu-kvm-0.10.5", 10005, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -231,7 +236,8 @@ mymain(void) QEMU_CAPS_TDF, QEMU_CAPS_NESTING, QEMU_CAPS_VGA_NONE, - QEMU_CAPS_NO_SHUTDOWN); + QEMU_CAPS_NO_SHUTDOWN, + QEMU_CAPS_NO_ACPI); DO_TEST("kvm-86", 10050, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -257,7 +263,8 @@ mymain(void) QEMU_CAPS_NESTING, QEMU_CAPS_SMBIOS_TYPE, QEMU_CAPS_VGA_NONE, - QEMU_CAPS_NO_SHUTDOWN); + QEMU_CAPS_NO_SHUTDOWN, + QEMU_CAPS_NO_ACPI); DO_TEST("qemu-kvm-0.11.0-rc2", 10092, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -288,7 +295,8 @@ mymain(void) QEMU_CAPS_NAME_PROCESS, QEMU_CAPS_SMBIOS_TYPE, QEMU_CAPS_VGA_NONE, - QEMU_CAPS_NO_SHUTDOWN); + QEMU_CAPS_NO_SHUTDOWN, + QEMU_CAPS_NO_ACPI); DO_TEST("qemu-0.12.1", 12001, 0, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -320,7 +328,8 @@ mymain(void) QEMU_CAPS_MIGRATE_QEMU_FD, QEMU_CAPS_DRIVE_AIO, QEMU_CAPS_NO_SHUTDOWN, - QEMU_CAPS_PCI_ROMBAR); + QEMU_CAPS_PCI_ROMBAR, + QEMU_CAPS_NO_ACPI); DO_TEST("qemu-kvm-0.12.1.2-rhel60", 12001, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -366,7 +375,8 @@ mymain(void) QEMU_CAPS_PIIX4_USB_UHCI, QEMU_CAPS_USB_HUB, QEMU_CAPS_NO_SHUTDOWN, - QEMU_CAPS_PCI_ROMBAR); + QEMU_CAPS_PCI_ROMBAR, + QEMU_CAPS_NO_ACPI); DO_TEST("qemu-kvm-0.12.3", 12003, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -405,7 +415,8 @@ mymain(void) QEMU_CAPS_MIGRATE_QEMU_FD, QEMU_CAPS_DRIVE_AIO, QEMU_CAPS_NO_SHUTDOWN, - QEMU_CAPS_PCI_ROMBAR); + QEMU_CAPS_PCI_ROMBAR, + QEMU_CAPS_NO_ACPI); DO_TEST("qemu-kvm-0.13.0", 13000, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -460,7 +471,8 @@ mymain(void) QEMU_CAPS_PCI_OHCI, QEMU_CAPS_USB_HUB, QEMU_CAPS_NO_SHUTDOWN, - QEMU_CAPS_PCI_ROMBAR); + QEMU_CAPS_PCI_ROMBAR, + QEMU_CAPS_NO_ACPI); DO_TEST("qemu-kvm-0.12.1.2-rhel61", 12001, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -511,7 +523,8 @@ mymain(void) QEMU_CAPS_PIIX4_USB_UHCI, QEMU_CAPS_USB_HUB, QEMU_CAPS_NO_SHUTDOWN, - QEMU_CAPS_PCI_ROMBAR); + QEMU_CAPS_PCI_ROMBAR, + QEMU_CAPS_NO_ACPI); DO_TEST("qemu-kvm-0.12.1.2-rhel62-beta", 12001, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -570,7 +583,8 @@ mymain(void) QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_USB_HUB, QEMU_CAPS_NO_SHUTDOWN, - QEMU_CAPS_PCI_ROMBAR); + QEMU_CAPS_PCI_ROMBAR, + QEMU_CAPS_NO_ACPI); DO_TEST("qemu-1.0", 1000000, 0, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -632,7 +646,8 @@ mymain(void) QEMU_CAPS_USB_HUB, QEMU_CAPS_NO_SHUTDOWN, QEMU_CAPS_PCI_ROMBAR, - QEMU_CAPS_ICH9_AHCI); + QEMU_CAPS_ICH9_AHCI, + QEMU_CAPS_NO_ACPI); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git i/tests/qemuxml2argvtest.c w/tests/qemuxml2argvtest.c index 228d052..e1221eb 100644 --- i/tests/qemuxml2argvtest.c +++ w/tests/qemuxml2argvtest.c @@ -145,6 +145,7 @@ static int testCompareXMLToArgvFiles(const char *xml, qemuCapsSetList(extraFlags, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, + QEMU_CAPS_NO_ACPI, QEMU_CAPS_LAST); if (qemudCanonicalizeMachine(&driver, vmdef) < 0) diff --git i/tests/qemuxmlnstest.c w/tests/qemuxmlnstest.c index 86cf974..0432cc4 100644 --- i/tests/qemuxmlnstest.c +++ w/tests/qemuxmlnstest.c @@ -89,6 +89,7 @@ static int testCompareXMLToArgvFiles(const char *xml, qemuCapsSetList(extraFlags, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, + QEMU_CAPS_NO_ACPI, QEMU_CAPS_LAST); if (qemudCanonicalizeMachine(&driver, vmdef) < 0) -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Michael Ellerman