[libvirt-php][PATCH 13/14] examples: Don't fetch volume count for inactive pools

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 examples/libvirt.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/examples/libvirt.php b/examples/libvirt.php
index 96aac6e..32d8314 100644
--- a/examples/libvirt.php
+++ b/examples/libvirt.php
@@ -456,12 +456,16 @@ class Libvirt {
         if (!is_string($otmp2))
             return $this->_set_last_error();
         $tmp = libvirt_storagepool_get_info($res);
-        $tmp['volume_count'] = sizeof( libvirt_storagepool_list_volumes($res) );
         $tmp['active'] = libvirt_storagepool_is_active($res);
         $tmp['path'] = $path;
         $tmp['permissions'] = $perms;
         $tmp['id_user'] = $otmp1;
         $tmp['id_group'] = $otmp2;
+        if ($tmp['active']) {
+            $tmp['volume_count'] = sizeof( libvirt_storagepool_list_volumes($res) );
+        } else {
+            $tmp['volume_count'] = 0;
+        }
 
         return $tmp;
     }
-- 
2.8.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]