[PATCHv8 1/2] qemu: conf Implement domain RBD storage pool support

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

 



This patch adds a helper function, qemuAddRBDPoolSourceHost, and
implements the usage of this function to allow RBD storage pools in QEMU
domain XML.

The new function grabs RBD monitor hosts from the storage pool
definition and applies them to the domain's disk definition at runtime.
This function is used by my modifications to qemuTranslateDiskSourcePool
similar to the function used by the iSCSI code.

My modifications to qemuTranslateDiskSourcePool is based heavily on the
existing iSCSI code, but modified to support RBD install. It will place
all relevant information into the domain's disk definition at runtime to
allow access to a RBD storage pool.

Signed-off-by: Adam Walters <adam@xxxxxxxxxxxxxxxxx>
---
 src/qemu/qemu_conf.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2c397b0..629ac62 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1251,6 +1251,45 @@ cleanup:
 }
 
 static int
+qemuAddRBDPoolSourceHost(virDomainDiskDefPtr def,
+                         virStoragePoolDefPtr pooldef)
+{
+    int ret = -1;
+    size_t i = 0;
+    char **tokens = NULL;
+
+    def->nhosts = pooldef->source.nhost;
+
+    if (VIR_ALLOC_N(def->hosts, def->nhosts) < 0)
+        goto cleanup;
+
+    for (i = 0; i < def->nhosts; i++) {
+        if (VIR_STRDUP(def->hosts[i].name, pooldef->source.hosts[i].name) < 0)
+            goto cleanup;
+
+        if (virAsprintf(&def->hosts[i].port, "%d",
+                        pooldef->source.hosts[i].port ?
+                        pooldef->source.hosts[i].port :
+                        6789) < 0)
+            goto cleanup;
+
+        /* Storage pools have not supported these 2 attributes yet,
+         * use the defaults.
+         */
+        def->hosts[i].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
+        def->hosts[i].socket = NULL;
+    }
+
+    def->protocol = VIR_DOMAIN_DISK_PROTOCOL_RBD;
+
+    ret = 0;
+
+cleanup:
+    virStringFreeList(tokens);
+    return ret;
+}
+
+static int
 qemuTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def,
                                 virStoragePoolDefPtr pooldef)
 {
@@ -1433,8 +1472,29 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
        }
        break;
 
-    case VIR_STORAGE_POOL_MPATH:
     case VIR_STORAGE_POOL_RBD:
+        if (def->startupPolicy) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("'startupPolicy' is only valid for "
+                             "'file' file volume"));
+            goto cleanup;
+        }
+
+        def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_NETWORK;
+        def->protocol = VIR_DOMAIN_DISK_PROTOCOL_RBD;
+
+        if (!(def->src = virStorageVolGetPath(vol)))
+            goto cleanup;
+
+        if (qemuTranslateDiskSourcePoolAuth(def, pooldef) < 0)
+            goto cleanup;
+
+        if (qemuAddRBDPoolSourceHost(def, pooldef) < 0)
+            goto cleanup;
+
+        break;
+
+    case VIR_STORAGE_POOL_MPATH:
     case VIR_STORAGE_POOL_SHEEPDOG:
     case VIR_STORAGE_POOL_GLUSTER:
     case VIR_STORAGE_POOL_LAST:
-- 
1.8.5.3

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