mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
storage: Introduce virStoragePoolObjNumOfVolumes
Unify the NumOfVolumes 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@redhat.com>
This commit is contained in:
parent
8d04ea1661
commit
4a440e4366
@ -195,6 +195,26 @@ virStorageVolDefFindByName(virStoragePoolObjPtr pool,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virStoragePoolObjNumOfVolumes(virStorageVolDefListPtr volumes,
|
||||
virConnectPtr conn,
|
||||
virStoragePoolDefPtr pooldef,
|
||||
virStoragePoolVolumeACLFilter aclfilter)
|
||||
{
|
||||
int nvolumes = 0;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < volumes->count; i++) {
|
||||
virStorageVolDefPtr def = volumes->objs[i];
|
||||
if (aclfilter && !aclfilter(conn, pooldef, def))
|
||||
continue;
|
||||
nvolumes++;
|
||||
}
|
||||
|
||||
return nvolumes;
|
||||
}
|
||||
|
||||
|
||||
virStoragePoolObjPtr
|
||||
virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools,
|
||||
virStoragePoolDefPtr def)
|
||||
|
@ -108,6 +108,17 @@ virStorageVolDefFindByName(virStoragePoolObjPtr pool,
|
||||
void
|
||||
virStoragePoolObjClearVols(virStoragePoolObjPtr pool);
|
||||
|
||||
typedef bool
|
||||
(*virStoragePoolVolumeACLFilter)(virConnectPtr conn,
|
||||
virStoragePoolDefPtr pool,
|
||||
virStorageVolDefPtr def);
|
||||
|
||||
int
|
||||
virStoragePoolObjNumOfVolumes(virStorageVolDefListPtr volumes,
|
||||
virConnectPtr conn,
|
||||
virStoragePoolDefPtr pooldef,
|
||||
virStoragePoolVolumeACLFilter aclfilter);
|
||||
|
||||
virStoragePoolObjPtr
|
||||
virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools,
|
||||
virStoragePoolDefPtr def);
|
||||
|
@ -1005,6 +1005,7 @@ virStoragePoolObjListFree;
|
||||
virStoragePoolObjLoadAllConfigs;
|
||||
virStoragePoolObjLoadAllState;
|
||||
virStoragePoolObjLock;
|
||||
virStoragePoolObjNumOfVolumes;
|
||||
virStoragePoolObjRemove;
|
||||
virStoragePoolObjSaveDef;
|
||||
virStoragePoolObjSourceFindDuplicate;
|
||||
|
@ -1390,7 +1390,6 @@ storagePoolNumOfVolumes(virStoragePoolPtr obj)
|
||||
{
|
||||
virStoragePoolObjPtr pool;
|
||||
int ret = -1;
|
||||
size_t i;
|
||||
|
||||
if (!(pool = virStoragePoolObjFromStoragePool(obj)))
|
||||
return -1;
|
||||
@ -1403,12 +1402,9 @@ storagePoolNumOfVolumes(virStoragePoolPtr obj)
|
||||
_("storage pool '%s' is not active"), pool->def->name);
|
||||
goto cleanup;
|
||||
}
|
||||
ret = 0;
|
||||
for (i = 0; i < pool->volumes.count; i++) {
|
||||
if (virStoragePoolNumOfVolumesCheckACL(obj->conn, pool->def,
|
||||
pool->volumes.objs[i]))
|
||||
ret++;
|
||||
}
|
||||
|
||||
ret = virStoragePoolObjNumOfVolumes(&pool->volumes, obj->conn, pool->def,
|
||||
virStoragePoolNumOfVolumesCheckACL);
|
||||
|
||||
cleanup:
|
||||
virStoragePoolObjUnlock(pool);
|
||||
|
@ -4808,7 +4808,8 @@ testStoragePoolNumOfVolumes(virStoragePoolPtr pool)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = privpool->volumes.count;
|
||||
ret = virStoragePoolObjNumOfVolumes(&privpool->volumes, pool->conn,
|
||||
privpool->def, NULL);
|
||||
|
||||
cleanup:
|
||||
if (privpool)
|
||||
|
Loading…
Reference in New Issue
Block a user