]> xenbits.xensource.com Git - libvirt.git/commitdiff
bhyve: detect 32 SATA devices per controller support
authorFabian Freyer <fabian.freyer@physik.tu-berlin.de>
Thu, 5 Jan 2017 12:21:52 +0000 (16:21 +0400)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Mon, 30 Jan 2017 16:48:42 +0000 (20:48 +0400)
Introduce a BHYVE_CAP_AHCI32SLOT capability that shows
if 32 devices per SATA controller are supported, and
a bhyveProbeCapsAHCI32Slot function that probes it.

src/bhyve/bhyve_capabilities.c
src/bhyve/bhyve_capabilities.h

index 10c33b9d714449b0fde3c483c46bef5093d9c276..83e3ae1b4bbdc22b5b22d6985fdf3171c91fc966 100644 (file)
@@ -168,19 +168,13 @@ virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps)
     return ret;
 }
 
-int
-virBhyveProbeCaps(unsigned int *caps)
+static int
+bhyveProbeCapsRTC_UTC(unsigned int *caps, char *binary)
 {
-    char *binary, *help;
+    char *help;
     virCommandPtr cmd = NULL;
     int ret = 0, exit;
 
-    binary = virFindFileInPath("bhyve");
-    if (binary == NULL)
-        goto out;
-    if (!virFileIsExecutable(binary))
-        goto out;
-
     cmd = virCommandNew(binary);
     virCommandAddArg(cmd, "-h");
     virCommandSetErrorBuffer(cmd, &help);
@@ -195,6 +189,53 @@ virBhyveProbeCaps(unsigned int *caps)
  out:
     VIR_FREE(help);
     virCommandFree(cmd);
+    return ret;
+}
+
+static int
+bhyveProbeCapsAHCI32Slot(unsigned int *caps, char *binary)
+{
+    char *error;
+    virCommandPtr cmd = NULL;
+    int ret = 0, exit;
+
+    cmd = virCommandNew(binary);
+    virCommandAddArgList(cmd, "-s", "0,ahci", NULL);
+    virCommandSetErrorBuffer(cmd, &error);
+    if (virCommandRun(cmd, &exit) < 0) {
+        ret = -1;
+        goto out;
+    }
+
+    if (strstr(error, "pci slot 0:0: unknown device \"ahci\"") == NULL)
+        *caps |= BHYVE_CAP_AHCI32SLOT;
+
+ out:
+    VIR_FREE(error);
+    virCommandFree(cmd);
+    return ret;
+}
+
+
+int
+virBhyveProbeCaps(unsigned int *caps)
+{
+    char *binary;
+    int ret = 0;
+
+    binary = virFindFileInPath("bhyve");
+    if (binary == NULL)
+        goto out;
+    if (!virFileIsExecutable(binary))
+        goto out;
+
+    if ((ret = bhyveProbeCapsRTC_UTC(caps, binary)))
+        goto out;
+
+    if ((ret = bhyveProbeCapsAHCI32Slot(caps, binary)))
+        goto out;
+
+ out:
     VIR_FREE(binary);
     return ret;
 }
index 8e7646dfa86073949dea09937cd57d2b1ffd8f16..55581bd682f93e3b87173f6380e245f9c77855bc 100644 (file)
@@ -37,7 +37,8 @@ typedef enum {
 } virBhyveGrubCapsFlags;
 
 typedef enum {
-    BHYVE_CAP_RTC_UTC = 1,
+    BHYVE_CAP_RTC_UTC = 1 << 0,
+    BHYVE_CAP_AHCI32SLOT = 1 << 1,
 } virBhyveCapsFlags;
 
 int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps);