Implement the BHACE_CAP_LPC_BOOTROM capability by checking the stderr output of 'bhyve -l bootrom'. If the bootrom option is unsupported, this will contain the following output: bhyve: invalid lpc device configuration 'bootrom' On newer bhyve versions that do support specifying a bootrom image, the standard help will be printed. --- src/bhyve/bhyve_capabilities.c | 28 ++++++++++++++++++++++++++++ src/bhyve/bhyve_capabilities.h | 1 + 2 files changed, 29 insertions(+) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index cf764c0..5d0485e 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -166,6 +166,31 @@ bhyveProbeCapsRTC_UTC(unsigned int *caps, char *binary) return ret; } +static int +bhyveProbeCapsLPC_Bootrom(unsigned int *caps, char *binary) +{ + char *error; + virCommandPtr cmd = NULL; + int ret = 0, exit; + + cmd = virCommandNew(binary); + virCommandAddArgList(cmd, "-l", "bootrom", NULL); + virCommandSetErrorBuffer(cmd, &error); + if (virCommandRun(cmd, &exit) < 0) { + ret = -1; + goto out; + } + + if (strstr(error, "bhyve: invalid lpc device configuration 'bootrom'") == NULL) + *caps |= BHYVE_CAP_LPC_BOOTROM; + + out: + VIR_FREE(error); + virCommandFree(cmd); + return ret; +} + + int virBhyveProbeCaps(unsigned int *caps) { @@ -181,6 +206,9 @@ virBhyveProbeCaps(unsigned int *caps) if ((ret = bhyveProbeCapsRTC_UTC(caps, binary))) goto out; + if ((ret = bhyveProbeCapsLPC_Bootrom(caps, binary))) + goto out; + out: VIR_FREE(binary); return ret; diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h index 0eb22a4..5ea3294 100644 --- a/src/bhyve/bhyve_capabilities.h +++ b/src/bhyve/bhyve_capabilities.h @@ -33,6 +33,7 @@ typedef enum { typedef enum { BHYVE_CAP_RTC_UTC = 1, + BHYVE_CAP_LPC_BOOTROM = 2, } virBhyveCapsFlags; int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps); -- 2.7.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list