]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: gluster: Use volume name as "<name>" field in the XML
authorPeter Krempa <pkrempa@redhat.com>
Tue, 4 Apr 2017 12:04:39 +0000 (14:04 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 4 Apr 2017 14:36:15 +0000 (16:36 +0200)
For native gluster pools the <dir> field denotes a directory inside the
pool. For the actual pool name the <name> field has to be used.

src/storage/storage_util.c
tests/virstorageutildata/gluster-parse-basic-native.xml
tests/virstorageutildata/gluster-parse-multivol-native.xml

index 1e44a2da4464b52cb379b11e4e0ef7fe40bc4c6d..7cc125a384cf87bfd1d4d61afe606493a2b7365e 100644 (file)
@@ -2846,6 +2846,7 @@ virStorageUtilGlusterExtractPoolSources(const char *host,
     xmlXPathContextPtr ctxt = NULL;
     xmlNodePtr *nodes = NULL;
     virStoragePoolSource *src = NULL;
+    char *volname;
     size_t i;
     int nnodes;
     int ret = -1;
@@ -2862,14 +2863,25 @@ virStorageUtilGlusterExtractPoolSources(const char *host,
         if (!(src = virStoragePoolSourceListNewSource(list)))
             goto cleanup;
 
-        if (!(src->dir = virXPathString("string(./name)", ctxt))) {
+        if (!(volname = virXPathString("string(./name)", ctxt))) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("failed to extract gluster volume name"));
             goto cleanup;
         }
 
-        if (pooltype == VIR_STORAGE_POOL_NETFS)
+        if (pooltype == VIR_STORAGE_POOL_NETFS) {
             src->format = VIR_STORAGE_POOL_NETFS_GLUSTERFS;
+            src->dir = volname;
+        } else if (pooltype == VIR_STORAGE_POOL_GLUSTER) {
+            src->name = volname;
+
+            if (VIR_STRDUP(src->dir, "/") < 0)
+                goto cleanup;
+        } else {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("unsupported gluster lookup"));
+            goto cleanup;
+        }
 
         if (VIR_ALLOC_N(src->hosts, 1) < 0)
             goto cleanup;
index fbde06f3b3b01c475b65c55cecb8610820b1c21f..895d0f3fdbd3703bce69e630d7278d6d39e53c6f 100644 (file)
@@ -1,6 +1,7 @@
 <sources>
   <source>
     <host name='testhost'/>
-    <dir path='vol0'/>
+    <dir path='/'/>
+    <name>vol0</name>
   </source>
 </sources>
index d2d8fefc6423e5d3365c855e738425d2d30aa1bc..c758ac5aa708ca3caf8c9f34f187764291a9f84f 100644 (file)
@@ -1,14 +1,17 @@
 <sources>
   <source>
     <host name='testhost'/>
-    <dir path='aaa'/>
+    <dir path='/'/>
+    <name>aaa</name>
   </source>
   <source>
     <host name='testhost'/>
-    <dir path='test'/>
+    <dir path='/'/>
+    <name>test</name>
   </source>
   <source>
     <host name='testhost'/>
-    <dir path='test1'/>
+    <dir path='/'/>
+    <name>test1</name>
   </source>
 </sources>