]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Fix error reporting when looking up storage pool sources
authorPeter Krempa <pkrempa@redhat.com>
Tue, 10 Jan 2017 17:29:54 +0000 (18:29 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 18 Jan 2017 09:45:15 +0000 (10:45 +0100)
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.

src/storage/storage_backend.c
src/storage/storage_backend_fs.c

index dc8f20c119d44657ff84a22f530491319f7c4095..868c98e16b5e04379a1a06a4e3424b883b655615 100644 (file)
@@ -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);
index f0ef07b2fae724e03a9b13eab9ac6de9653de61a..6f30351e5ade897543e41d910765a56f793b9d56 100644 (file)
@@ -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;