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