]> xenbits.xensource.com Git - libvirt.git/commitdiff
bhyve: Probe grub-bhyve for --cons-dev capability
authorConrad Meyer <cse.cem@gmail.com>
Tue, 11 Nov 2014 15:35:06 +0000 (10:35 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 12 Nov 2014 08:55:22 +0000 (09:55 +0100)
src/bhyve/bhyve_capabilities.c
src/bhyve/bhyve_capabilities.h

index 132ce9169e2de7da6f61e8e67dfc207c6a2eeb66..fff0312681e9629fe489c33ac96de4ab8f1a7894 100644 (file)
@@ -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(virBhyveGrubCapsFlags *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;
+}
index c52e0d0415c7f7c2823ff5b3863e97c6a0fc13a1..ccd8eb6cf23c3d946928afe60af04a13725d3e31 100644 (file)
 
 virCapsPtr virBhyveCapsBuild(void);
 
+/* These are bit flags: */
+typedef enum {
+    BHYVE_GRUB_CAP_CONSDEV = 1,
+} virBhyveGrubCapsFlags;
+
+int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps);
+
 #endif