mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
storage: Fix error reporting when looking up storage pool sources
In commit 4090e15399
we went back from reporting no errors if no storage
pools were found on a given host to reporting a bad error. And only in
cases when gluster was not installed.
Report a less bad error in case there are no volumes. Also report the
error when gluster is installed but no volumes were found, since
virStorageBackendFindGlusterPoolSources would return success in that
case.
This commit is contained in:
parent
7ab0080bed
commit
7bdb4b8fda
@ -2549,6 +2549,16 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
|
||||
|
||||
#ifdef GLUSTER_CLI
|
||||
/**
|
||||
* virStorageBackendFindGlusterPoolSources:
|
||||
* @host: host to detect volumes on
|
||||
* @pooltype: src->format is set to this value
|
||||
* @list: list of storage pool sources to be filled
|
||||
*
|
||||
* Looks up gluster volumes on @host and fills them to @list.
|
||||
*
|
||||
* Returns number of volumes on the host on success, or -1 on error.
|
||||
*/
|
||||
int
|
||||
virStorageBackendFindGlusterPoolSources(const char *host,
|
||||
int pooltype,
|
||||
@ -2578,8 +2588,6 @@ virStorageBackendFindGlusterPoolSources(const char *host,
|
||||
goto cleanup;
|
||||
|
||||
if (rc != 0) {
|
||||
VIR_INFO("failed to query host '%s' for gluster volumes: %s",
|
||||
host, outbuf);
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
@ -2588,11 +2596,8 @@ virStorageBackendFindGlusterPoolSources(const char *host,
|
||||
&ctxt)))
|
||||
goto cleanup;
|
||||
|
||||
if ((nnodes = virXPathNodeSet("//volumes/volume", ctxt, &nodes)) <= 0) {
|
||||
VIR_INFO("no gluster volumes available on '%s'", host);
|
||||
ret = 0;
|
||||
if ((nnodes = virXPathNodeSet("//volumes/volume", ctxt, &nodes)) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (i = 0; i < nnodes; i++) {
|
||||
ctxt->node = nodes[i];
|
||||
@ -2616,7 +2621,7 @@ virStorageBackendFindGlusterPoolSources(const char *host,
|
||||
src->format = pooltype;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
ret = nnodes;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(nodes);
|
||||
|
@ -281,7 +281,8 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE
|
||||
virStoragePoolSourcePtr source = NULL;
|
||||
char *ret = NULL;
|
||||
size_t i;
|
||||
int retNFS = -1, retGluster = -1;
|
||||
int retNFS = -1;
|
||||
int retGluster = 0;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
@ -306,14 +307,21 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE
|
||||
retNFS = virStorageBackendFileSystemNetFindNFSPoolSources(&state);
|
||||
|
||||
# ifdef GLUSTER_CLI
|
||||
retGluster =
|
||||
virStorageBackendFindGlusterPoolSources(state.host,
|
||||
VIR_STORAGE_POOL_NETFS_GLUSTERFS,
|
||||
&state.list);
|
||||
retGluster = virStorageBackendFindGlusterPoolSources(state.host,
|
||||
VIR_STORAGE_POOL_NETFS_GLUSTERFS,
|
||||
&state.list);
|
||||
|
||||
if (retGluster < 0)
|
||||
goto cleanup;
|
||||
|
||||
# endif
|
||||
/* If both fail, then we won't return an empty list - return an error */
|
||||
if (retNFS < 0 && retGluster < 0)
|
||||
if (retNFS < 0 && retGluster == 0) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
_("no storage pools were found on host '%s'"),
|
||||
state.host);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!(ret = virStoragePoolSourceListFormat(&state.list)))
|
||||
goto cleanup;
|
||||
|
Loading…
Reference in New Issue
Block a user