[libvirt] [PATCHv8.1 5/7] bhyve: Probe grub-bhyve for --cons-dev capability

Conrad Meyer cse.cem at gmail.com
Tue Nov 11 15:35:06 UTC 2014


---
 src/bhyve/bhyve_capabilities.c | 37 +++++++++++++++++++++++++++++++++++++
 src/bhyve/bhyve_capabilities.h |  6 ++++++
 2 files changed, 43 insertions(+)

diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index 132ce91..6e9a943 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -23,6 +23,7 @@
 #include <sys/utsname.h>
 
 #include "viralloc.h"
+#include "virfile.h"
 #include "virlog.h"
 #include "virstring.h"
 #include "cpu/cpu.h"
@@ -104,3 +105,39 @@ virBhyveCapsBuild(void)
     virObjectUnref(caps);
     return NULL;
 }
+
+int
+virBhyveProbeGrubCaps(unsigned *caps)
+{
+    char *binary, *help;
+    virCommandPtr cmd;
+    int ret, exit;
+
+    ret = 0;
+    *caps = 0;
+    cmd = NULL;
+    help = NULL;
+
+    binary = virFindFileInPath("grub-bhyve");
+    if (binary == NULL)
+        goto out;
+    if (!virFileIsExecutable(binary))
+        goto out;
+
+    cmd = virCommandNew(binary);
+    virCommandAddArg(cmd, "--help");
+    virCommandSetOutputBuffer(cmd, &help);
+    if (virCommandRun(cmd, &exit) < 0) {
+        ret = -1;
+        goto out;
+    }
+
+    if (strstr(help, "--cons-dev") != NULL)
+        *caps |= BHYVE_GRUB_CAP_CONSDEV;
+
+ out:
+    VIR_FREE(help);
+    virCommandFree(cmd);
+    VIR_FREE(binary);
+    return ret;
+}
diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h
index c52e0d0..a559d2a 100644
--- a/src/bhyve/bhyve_capabilities.h
+++ b/src/bhyve/bhyve_capabilities.h
@@ -26,4 +26,10 @@
 
 virCapsPtr virBhyveCapsBuild(void);
 
+/* These are bit flags: */
+enum {
+    BHYVE_GRUB_CAP_CONSDEV = 0x00000001,
+};
+int virBhyveProbeGrubCaps(unsigned *caps);
+
 #endif
-- 
1.9.3




More information about the libvir-list mailing list