Re: [PATCH 4/7] storage: Introduce virStoragePoolObjNumOfStoragePools

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

 



On 04/06/2017 01:48 PM, John Ferlan wrote:
Unify the NumOf[Defined]StoragePools API into virstorageobj.c from
storage_driver and test_driver.  The only real difference between the
two is the test driver doesn't call using the aclfilter API.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/virstorageobj.c     | 24 ++++++++++++++++++++++++
 src/conf/virstorageobj.h     |  9 +++++++++
 src/libvirt_private.syms     |  1 +
 src/storage/storage_driver.c | 22 ++++------------------
 src/test/test_driver.c       | 17 ++++++-----------
 5 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 2484517..f0201aa 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -556,6 +556,30 @@ virStoragePoolObjDeleteDef(virStoragePoolObjPtr pool)
 }


+int
+virStoragePoolObjNumOfStoragePools(virStoragePoolObjListPtr pools,
+                                   virConnectPtr conn,
+                                   bool wantActive,
+                                   virStoragePoolObjListACLFilter aclfilter)
+{
+    int npools = 0;
+    size_t i;
+
+    for (i = 0; i < pools->count; i++) {
+        virStoragePoolObjPtr obj = pools->objs[i];
+        virStoragePoolObjLock(obj);
+        if (!aclfilter || aclfilter(conn, obj->def)) {
+            if ((wantActive && virStoragePoolObjIsActive(obj)) ||
+                (!wantActive && !virStoragePoolObjIsActive(obj)))

Again, if (wantActive == virStoragePoolObjIsActive()) ...

+                npools++;
+        }
+        virStoragePoolObjUnlock(obj);
+    }
+
+    return npools;
+}
+
+

Michal

--
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]
  Powered by Linux