[PATCH 1/6] bhyve: virBhyveProbeCaps: BHYVE_CAP_LPC_BOOTROM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Fabian Freyer <fabian.freyer@xxxxxxxxxxxxxxxxxxx>

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 | 25 +++++++++++++++++++++++++
 src/bhyve/bhyve_capabilities.h |  1 +
 2 files changed, 26 insertions(+)

diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index 1dc0593af..13b4835a8 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -239,6 +239,28 @@ bhyveProbeCapsNetE1000(unsigned int *caps, char *binary)
     return ret;
 }
 
+static int
+bhyveProbeCapsLPC_Bootrom(unsigned int *caps, char *binary)
+{
+    char *error;
+    virCommandPtr cmd = NULL;
+    int ret = -1, exit;
+
+    cmd = virCommandNew(binary);
+    virCommandAddArgList(cmd, "-l", "bootrom", NULL);
+    virCommandSetErrorBuffer(cmd, &error);
+    if (virCommandRun(cmd, &exit) < 0)
+        goto cleanup;
+
+    if (strstr(error, "bhyve: invalid lpc device configuration 'bootrom'") == NULL)
+        *caps |= BHYVE_CAP_LPC_BOOTROM;
+
+ cleanup:
+    VIR_FREE(error);
+    virCommandFree(cmd);
+    return ret;
+}
+
 int
 virBhyveProbeCaps(unsigned int *caps)
 {
@@ -260,6 +282,9 @@ virBhyveProbeCaps(unsigned int *caps)
     if ((ret = bhyveProbeCapsNetE1000(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 690feadb8..746c77181 100644
--- a/src/bhyve/bhyve_capabilities.h
+++ b/src/bhyve/bhyve_capabilities.h
@@ -40,6 +40,7 @@ typedef enum {
     BHYVE_CAP_RTC_UTC = 1 << 0,
     BHYVE_CAP_AHCI32SLOT = 1 << 1,
     BHYVE_CAP_NET_E1000 = 1 << 2,
+    BHYVE_CAP_LPC_BOOTROM = 1 << 3,
 } virBhyveCapsFlags;
 
 int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps);
-- 
2.11.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux