[libvirt] [PATCHv2 2/3] qemu: conf: Parse RBD storage pool from domain xml

Adam Walters adam at pandorasboxen.com
Mon Dec 2 21:36:01 UTC 2013


Modify switch statement in qemuTranslateDiskSourcePool
to parse the storage pool definition for RBD pools
instead of throwing an error. I do throw errors for
any other usage case of VIR_STORAGE_VOL_NETWORK, as my
code does not cover their use cases currently. Once I
have the ability to test such usage cases, I will
revisit those possibilities.
---
 src/qemu/qemu_conf.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index e2154c6..024d40f 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1416,6 +1416,32 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
 
         break;
     case VIR_STORAGE_VOL_NETWORK:
+        if (!(poolxml = virStoragePoolGetXMLDesc(pool, 0)))
+            goto cleanup;
+
+        if (!(pooldef = virStoragePoolDefParseString(poolxml)))
+            goto cleanup;
+
+        def->srcpool->pooltype = pooldef->type;
+        if (pooldef->type == VIR_STORAGE_POOL_RBD) {
+            if (!def->srcpool->mode)
+                def->srcpool->mode = VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT;
+
+            if (qemuAddRBDPoolSourceHost(def, pooldef) < 0)
+                goto cleanup;
+
+            if (!(def->src = virStorageVolGetPath(vol)))
+                goto cleanup;
+
+            if (qemuTranslateDiskSourcePoolAuth(def, pooldef) < 0)
+                goto cleanup;
+        } else {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("Unsupported network volume type"));
+            goto cleanup;
+        }
+
+        break;
     case VIR_STORAGE_VOL_NETDIR:
     case VIR_STORAGE_VOL_LAST:
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-- 
1.8.4.2




More information about the libvir-list mailing list