mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
storage: Fix XPath for looking up gluster volume name
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
This commit is contained in:
parent
69cc498676
commit
5df6992e1c
@ -2862,7 +2862,7 @@ virStorageUtilGlusterExtractPoolSources(const char *host,
|
|||||||
if (!(src = virStoragePoolSourceListNewSource(list)))
|
if (!(src = virStoragePoolSourceListNewSource(list)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(src->dir = virXPathString("string(//name)", ctxt))) {
|
if (!(src->dir = virXPathString("string(./name)", ctxt))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("failed to extract gluster volume name"));
|
_("failed to extract gluster volume name"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
14
tests/virstorageutildata/gluster-parse-multivol-native.xml
Normal file
14
tests/virstorageutildata/gluster-parse-multivol-native.xml
Normal file
@ -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>
|
17
tests/virstorageutildata/gluster-parse-multivol-netfs.xml
Normal file
17
tests/virstorageutildata/gluster-parse-multivol-netfs.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<host name='testhost'/>
|
||||||
|
<dir path='aaa'/>
|
||||||
|
<format type='glusterfs'/>
|
||||||
|
</source>
|
||||||
|
<source>
|
||||||
|
<host name='testhost'/>
|
||||||
|
<dir path='test'/>
|
||||||
|
<format type='glusterfs'/>
|
||||||
|
</source>
|
||||||
|
<source>
|
||||||
|
<host name='testhost'/>
|
||||||
|
<dir path='test1'/>
|
||||||
|
<format type='glusterfs'/>
|
||||||
|
</source>
|
||||||
|
</sources>
|
32
tests/virstorageutildata/gluster-parse-multivol-src.xml
Normal file
32
tests/virstorageutildata/gluster-parse-multivol-src.xml
Normal file
@ -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>
|
@ -101,6 +101,8 @@ mymain(void)
|
|||||||
|
|
||||||
DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE("basic");
|
DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE("basic");
|
||||||
DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS("basic");
|
DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS("basic");
|
||||||
|
DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE("multivol");
|
||||||
|
DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS("multivol");
|
||||||
|
|
||||||
#undef DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE
|
#undef DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE
|
||||||
#undef DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS
|
#undef DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user