[PATCHv2 1/3] qemu: config: Add qemuAddRBDPoolSourceHost helper function

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

 



Add a function to grab the RBD hosts from a pool definition and add
them to the disk definition. This function allows the addition of
RBD storage pool functionality.
---
 src/qemu/qemu_conf.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 557ccc5..e2154c6 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1247,6 +1247,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)
 {
-- 
1.8.4.2

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