Bhyve used the '-A' flag to enable ACPI until it was deprecated by commit: https://cgit.freebsd.org/src/commit/?id=6a0e7f908802b86ca5d1c0b3c404b8391d0f626e
With that, ACPI tables are always generated. As this change is relatively new and there are likely systems that have bhyve(8) that requires using the '-A' flag, add a capability probing for that, and use this flag if it's supported. Signed-off-by: Roman Bogorodskiy <[email protected]> --- src/bhyve/bhyve_capabilities.c | 3 +++ src/bhyve/bhyve_capabilities.h | 1 + src/bhyve/bhyve_command.c | 7 ++++++- tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-acpiapic.args | 2 -- tests/bhyvexml2argvtest.c | 2 ++ 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index e4cfc6720b..d2a48ed30c 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -255,6 +255,9 @@ bhyveProbeCapsFromHelp(unsigned int *caps, char *binary) if (strstr(help, "-c vcpus") == NULL) *caps |= BHYVE_CAP_CPUTOPOLOGY; + if (strstr(help, "-A:") != NULL) + *caps |= BHYVE_CAP_ACPI; + return 0; } diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h index 500b235397..d5346df7ba 100644 --- a/src/bhyve/bhyve_capabilities.h +++ b/src/bhyve/bhyve_capabilities.h @@ -55,6 +55,7 @@ typedef enum { BHYVE_CAP_VIRTIO_9P = 1 << 9, BHYVE_CAP_VIRTIO_RND = 1 << 10, BHYVE_CAP_NVME = 1 << 11, + BHYVE_CAP_ACPI = 1 << 12, } virBhyveCapsFlags; int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps); diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 97a483d9a5..a13bdbed33 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -951,7 +951,12 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *driver, virDomainDef *def, virCommandAddArg(cmd, "-S"); /* Wire guest memory */ /* Options */ - if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON) + if ((def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON) && + (bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_ACPI)) + /* As of FreeBSD commit + * https://cgit.freebsd.org/src/commit/?id=6a0e7f908802b86ca5d1c0b3c404b8391d0f626e + * bhyve(8) generates ACPI tables unconditionally, so nothing needs to be done + * if the capability is missing. */ virCommandAddArg(cmd, "-A"); /* Create an ACPI table */ if (def->features[VIR_DOMAIN_FEATURE_MSRS] == VIR_TRISTATE_SWITCH_ON) { if (def->msrs_features[VIR_DOMAIN_MSRS_UNKNOWN] == VIR_DOMAIN_MSRS_UNKNOWN_IGNORE) diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-acpiapic.args b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-acpiapic.args index 146e3c6eee..26c96a5cee 100644 --- a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-acpiapic.args +++ b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-acpiapic.args @@ -1,8 +1,6 @@ bhyve \ -c 1 \ -m 214 \ --A \ --I \ -u \ -H \ -P \ diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index c7c18c3690..aacc3007ba 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -202,6 +202,8 @@ mymain(void) DO_TEST("base"); DO_TEST("wired"); DO_TEST("acpiapic"); + driver.bhyvecaps &= ~BHYVE_CAP_ACPI; + DO_TEST_FAILURE("acpiapic"); DO_TEST("disk-cdrom"); DO_TEST("disk-virtio"); DO_TEST("macaddr"); -- 2.52.0
