[libvirt] [PATCH 11/11] Fix error handling in virsh when listing storage volumes

Daniel P. Berrange berrange at redhat.com
Fri Nov 12 16:22:44 UTC 2010


virsh was not checking for a error code when listing storage
volumes. So when listing volumes in a pool that was shutoff,
no output was displayed

* tools/virsh.c: Fix error handling when listing volumes
---
 tools/virsh.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index a840758..49dcd6e 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -6738,6 +6738,12 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
     /* Determine the number of volumes in the pool */
     numVolumes = virStoragePoolNumOfVolumes(pool);
 
+    if (numVolumes < 0) {
+        vshError(ctl, "%s", _("Failed to list storage volumes"));
+        virStoragePoolFree(pool);
+        return FALSE;
+    }
+
     /* Retrieve the list of volume names in the pool */
     if (numVolumes > 0) {
         activeNames = vshCalloc(ctl, numVolumes, sizeof(*activeNames));
-- 
1.7.2.3




More information about the libvir-list mailing list