#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,
goto cleanup;
if (rc != 0) {
- VIR_INFO("failed to query host '%s' for gluster volumes: %s",
- host, outbuf);
ret = 0;
goto cleanup;
}
&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];
src->format = pooltype;
}
- ret = 0;
+ ret = nnodes;
cleanup:
VIR_FREE(nodes);
virStoragePoolSourcePtr source = NULL;
char *ret = NULL;
size_t i;
- int retNFS = -1, retGluster = -1;
+ int retNFS = -1;
+ int retGluster = 0;
virCheckFlags(0, NULL);
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;