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

[libvirt] [PATCH 2/2] bhyve: add volumes support



Update bhyveBuildDiskArgStr to support volumes:

 - Make virBhyveProcessBuildBhyveCmd take virConnectPtr as the
   first argument instead of bhyveConnPtr as virConnectPtr is
   needed for virDomainTranslateDiskSourcePool,
 - Add virDomainTranslateDiskSourcePool call to
   virBhyveProcessBuildBhyveCmd,
 - Allow disks of type VIR_STORAGE_TYPE_VOLUME
---
 src/bhyve/bhyve_command.c | 8 ++++++--
 src/bhyve/bhyve_command.h | 5 +++--
 src/bhyve/bhyve_driver.c  | 2 +-
 src/bhyve/bhyve_process.c | 2 +-
 tests/bhyvexml2argvtest.c | 5 ++++-
 5 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index e2940e8..e9fe1b7 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -184,7 +184,8 @@ bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
         return -1;
     }
 
-    if (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) {
+    if ((virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) &&
+        (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_VOLUME)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("unsupported disk type"));
         return -1;
@@ -209,7 +210,7 @@ bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
 }
 
 virCommandPtr
-virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
+virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
                              virDomainDefPtr def, bool dryRun)
 {
     /*
@@ -263,6 +264,9 @@ virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
     for (i = 0; i < def->ndisks; i++) {
         virDomainDiskDefPtr disk = def->disks[i];
 
+        if (virDomainTranslateDiskSourcePool(conn, disk) < 0)
+            goto error;
+
         if (bhyveBuildDiskArgStr(def, disk, cmd) < 0)
             goto error;
     }
diff --git a/src/bhyve/bhyve_command.h b/src/bhyve/bhyve_command.h
index 31de97a..5b0045c 100644
--- a/src/bhyve/bhyve_command.h
+++ b/src/bhyve/bhyve_command.h
@@ -29,8 +29,9 @@
 
 # define BHYVE_CONFIG_FORMAT_ARGV "bhyve-argv"
 
-virCommandPtr virBhyveProcessBuildBhyveCmd(bhyveConnPtr,
-                             virDomainDefPtr def, bool dryRun);
+virCommandPtr virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
+                                           virDomainDefPtr def,
+                                           bool dryRun);
 
 virCommandPtr
 virBhyveProcessBuildDestroyCmd(bhyveConnPtr driver,
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index eb8f9af..dcaf847 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -692,7 +692,7 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
     if (!(loadcmd = virBhyveProcessBuildLoadCmd(privconn, def)))
         goto cleanup;
 
-    if (!(cmd = virBhyveProcessBuildBhyveCmd(privconn, def, true)))
+    if (!(cmd = virBhyveProcessBuildBhyveCmd(conn, def, true)))
         goto cleanup;
 
     virBufferAdd(&buf, virCommandToString(loadcmd), -1);
diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index 168202e..03c72e1 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -137,7 +137,7 @@ virBhyveProcessStart(virConnectPtr conn,
         goto cleanup;
 
     /* Call bhyve to start the VM */
-    if (!(cmd = virBhyveProcessBuildBhyveCmd(driver,
+    if (!(cmd = virBhyveProcessBuildBhyveCmd(conn,
                                              vm->def,
                                              false)))
         goto cleanup;
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index 408c73a..b9be378 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -23,8 +23,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
     virDomainDefPtr vmdef = NULL;
     virDomainObj vm;
     virCommandPtr cmd = NULL;
+    virConnectPtr conn;
     int ret = -1;
 
+    if (!(conn = virGetConnect()))
+        goto out;
 
     if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,
                                         1 << VIR_DOMAIN_VIRT_BHYVE,
@@ -33,7 +36,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
 
     vm.def = vmdef;
 
-    if (!(cmd = virBhyveProcessBuildBhyveCmd(&driver, vmdef, false)))
+    if (!(cmd = virBhyveProcessBuildBhyveCmd(conn, vmdef, false)))
         goto out;
 
     if (!(actualargv = virCommandToString(cmd)))
-- 
1.9.0


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