[PATCH 3/3] storage: Fix XPath for looking up gluster volume name

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

 



Use the relative lookup specifier rather than the global one. Otherwise
only the first name would be looked up. Add a test case to cover the
scenario.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1436574
---
 src/storage/storage_util.c                         |  2 +-
 .../gluster-parse-multivol-dst.xml                 | 14 ++++++++++
 .../gluster-parse-multivol-src.xml                 | 32 ++++++++++++++++++++++
 tests/virstorageutiltest.c                         |  1 +
 4 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 tests/virstorageutildata/gluster-parse-multivol-dst.xml
 create mode 100644 tests/virstorageutildata/gluster-parse-multivol-src.xml

diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 8459e9d5b..e949fc3d4 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -2862,7 +2862,7 @@ virStorageUtilGlusterExtractPoolSources(const char *host,
         if (!(src = virStoragePoolSourceListNewSource(list)))
             goto cleanup;

-        if (!(src->dir = virXPathString("string(//name)", ctxt))) {
+        if (!(src->dir = virXPathString("string(./name)", ctxt))) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("failed to extract gluster volume name"));
             goto cleanup;
diff --git a/tests/virstorageutildata/gluster-parse-multivol-dst.xml b/tests/virstorageutildata/gluster-parse-multivol-dst.xml
new file mode 100644
index 000000000..d2d8fefc6
--- /dev/null
+++ b/tests/virstorageutildata/gluster-parse-multivol-dst.xml
@@ -0,0 +1,14 @@
+<sources>
+  <source>
+    <host name='testhost'/>
+    <dir path='aaa'/>
+  </source>
+  <source>
+    <host name='testhost'/>
+    <dir path='test'/>
+  </source>
+  <source>
+    <host name='testhost'/>
+    <dir path='test1'/>
+  </source>
+</sources>
diff --git a/tests/virstorageutildata/gluster-parse-multivol-src.xml b/tests/virstorageutildata/gluster-parse-multivol-src.xml
new file mode 100644
index 000000000..0c1f9d10e
--- /dev/null
+++ b/tests/virstorageutildata/gluster-parse-multivol-src.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--- note that the XML file is truncated -->
+<cliOutput>
+  <opRet>0</opRet>
+  <opErrno>0</opErrno>
+  <opErrstr/>
+  <volInfo>
+    <volumes>
+      <volume>
+        <name>aaa</name>
+        <id>d0b219d4-4169-4907-8994-d2e2434854ed</id>
+        <status>0</status>
+        <statusStr>Created</statusStr>
+        <snapshotCount>0</snapshotCount>
+      </volume>
+      <volume>
+        <name>test</name>
+        <id>32826068-2320-4b62-a825-2554edb7f020</id>
+        <status>1</status>
+        <statusStr>Started</statusStr>
+        <snapshotCount>0</snapshotCount>
+      </volume>
+      <volume>
+        <name>test1</name>
+        <id>dfa070f4-b12f-4166-8d68-041b73127abc</id>
+        <status>0</status>
+        <statusStr>Created</statusStr>
+      </volume>
+      <count>3</count>
+    </volumes>
+  </volInfo>
+</cliOutput>
diff --git a/tests/virstorageutiltest.c b/tests/virstorageutiltest.c
index 0d4ede6c2..90f86233d 100644
--- a/tests/virstorageutiltest.c
+++ b/tests/virstorageutiltest.c
@@ -93,6 +93,7 @@ mymain(void)
         ret = -1

     DO_TEST_GLUSTER_LOOKUP("basic");
+    DO_TEST_GLUSTER_LOOKUP("multivol");

 #undef DO_TEST_GLUSTER_LOOKUP

-- 
2.12.1

--
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]
  Powered by Linux