[libvirt] [PATCH 4/7] storage: Introduce virStoragePoolObjNumOfStoragePools
Michal Privoznik
mprivozn at redhat.com
Mon Apr 10 11:52:48 UTC 2017
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 at redhat.com>
> ---
> 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
More information about the libvir-list
mailing list