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

Michal Privoznik mprivozn at redhat.com
Fri Jul 8 13:23:22 UTC 2016


Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 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




More information about the libvir-list mailing list