[libvirt] [PATCH 2/4] storage: gluster: Report error if no volumes were found in pool lookup

Peter Krempa pkrempa at redhat.com
Tue Jan 10 18:44:57 UTC 2017


Similarly to the 'netfs' pool, return an error if the host does not have
any volumes.
---
 src/storage/storage_backend_gluster.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index ae0611543..0bd40f742 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -490,6 +490,7 @@ virStorageBackendGlusterFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
                                     };
     virStoragePoolSourcePtr source = NULL;
     char *ret = NULL;
+    int rc;
     size_t i;

     virCheckFlags(0, NULL);
@@ -510,11 +511,18 @@ virStorageBackendGlusterFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
         goto cleanup;
     }

-    if (virStorageBackendFindGlusterPoolSources(source->hosts[0].name,
-                                                0, /* currently ignored */
-                                                &list) < 0)
+    if ((rc = virStorageBackendFindGlusterPoolSources(source->hosts[0].name,
+                                                      0, /* currently ignored */
+                                                      &list)) < 0)
         goto cleanup;

+    if (rc == 0) {
+        virReportError(VIR_ERR_OPERATION_FAILED,
+                       _("no storage pools were found on host '%s'"),
+                       source->hosts[0].name);
+        goto cleanup;
+    }
+
     if (!(ret = virStoragePoolSourceListFormat(&list)))
         goto cleanup;

-- 
2.11.0




More information about the libvir-list mailing list