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

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

 



Update bhyveBuildDiskArgStr to support volumes:

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

diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index e2940e8..cb9ddcb 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;
     }
@@ -290,7 +294,7 @@ virBhyveProcessBuildDestroyCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
 }
 
 virCommandPtr
-virBhyveProcessBuildLoadCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
+virBhyveProcessBuildLoadCmd(virConnectPtr conn,
                             virDomainDefPtr def)
 {
     virCommandPtr cmd;
@@ -304,6 +308,9 @@ virBhyveProcessBuildLoadCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
 
     disk = def->disks[0];
 
+    if (virDomainTranslateDiskSourcePool(conn, disk) < 0)
+        return NULL;
+
     if ((disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) &&
         (disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -311,7 +318,8 @@ virBhyveProcessBuildLoadCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
         return NULL;
     }
 
-    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 NULL;
diff --git a/src/bhyve/bhyve_command.h b/src/bhyve/bhyve_command.h
index 31de97a..5b323bf 100644
--- a/src/bhyve/bhyve_command.h
+++ b/src/bhyve/bhyve_command.h
@@ -29,15 +29,16 @@
 
 # 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,
                                virDomainDefPtr def);
 
 virCommandPtr
-virBhyveProcessBuildLoadCmd(bhyveConnPtr driver,
+virBhyveProcessBuildLoadCmd(virConnectPtr conn,
                             virDomainDefPtr def);
 
 #endif /* __BHYVE_COMMAND_H__ */
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index eb8f9af..d2f9c73 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -689,10 +689,10 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
     if (bhyveDomainAssignAddresses(def, NULL) < 0)
         goto cleanup;
 
-    if (!(loadcmd = virBhyveProcessBuildLoadCmd(privconn, def)))
+    if (!(loadcmd = virBhyveProcessBuildLoadCmd(conn, 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..6b5403d 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;
@@ -151,7 +151,7 @@ virBhyveProcessStart(virConnectPtr conn,
     /* Now bhyve command is constructed, meaning the
      * domain is ready to be started, so we can build
      * and execute bhyveload command */
-    if (!(load_cmd = virBhyveProcessBuildLoadCmd(driver, vm->def)))
+    if (!(load_cmd = virBhyveProcessBuildLoadCmd(conn, vm->def)))
         goto cleanup;
     virCommandSetOutputFD(load_cmd, &logfd);
     virCommandSetErrorFD(load_cmd, &logfd);
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

--
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]