[PATCH] storage: add RBD support to disk source pool translation

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

 



Domains can now reference disks of type 'volume' with an underlying RBD pool.
It won't allow mapping snapshots, pools don't list them yet, only COW clones.

 - virStorageTranslateDiskSourcePool: add case to copy RBD attributes
 - virStorageAddRBDPoolSourceHost: new helper to copy monitor hosts
---
 src/storage/storage_driver.c | 49 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 394e4d4..8c27f4b 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -3173,6 +3173,39 @@ virStorageAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
 
 
 static int
+virStorageAddRBDPoolSourceHost(virDomainDiskDefPtr def,
+                                virStoragePoolDefPtr pooldef)
+{
+    int ret = -1;
+    size_t i;
+
+    if (pooldef->source.nhost > 0) {
+        def->src->nhosts = pooldef->source.nhost;
+
+        if (VIR_ALLOC_N(def->src->hosts, def->src->nhosts) < 0)
+            goto cleanup;
+
+        for (i = 0; i < def->src->nhosts; i++) {
+            if (VIR_STRDUP(def->src->hosts[i].name,
+                                        pooldef->source.hosts[i].name) < 0)
+                goto cleanup;
+
+            if (pooldef->source.hosts[i].port) {
+                if (virAsprintf(&def->src->hosts[i].port, "%d",
+                                        pooldef->source.hosts[i].port) < 0)
+                    goto cleanup;
+            }
+        }
+    }
+
+    ret = 0;
+
+ cleanup:
+    return ret;
+}
+
+
+static int
 virStorageTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def,
                                       virStoragePoolSourcePtr source)
 {
@@ -3324,8 +3357,22 @@ virStorageTranslateDiskSourcePool(virConnectPtr conn,
        }
        break;
 
-    case VIR_STORAGE_POOL_MPATH:
     case VIR_STORAGE_POOL_RBD:
+        if (!(def->src->path = virStorageVolGetPath(vol)))
+            goto cleanup;
+
+        def->src->srcpool->actualtype = VIR_STORAGE_TYPE_NETWORK;
+        def->src->protocol = VIR_STORAGE_NET_PROTOCOL_RBD;
+
+        if (virStorageTranslateDiskSourcePoolAuth(def, &pooldef->source) < 0)
+            goto cleanup;
+
+        if (virStorageAddRBDPoolSourceHost(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:
-- 
2.1.4

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