1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

storage: Pull volume removal from pool in storageVolDeleteInternal

Create a helper function to remove volume from the pool.
This commit is contained in:
John Ferlan 2015-10-08 16:33:16 -04:00
parent 2265e7dd14
commit a1703557fd

View File

@ -1619,6 +1619,25 @@ storagePoolLookupByTargetPath(virConnectPtr conn,
}
static void
storageVolRemoveFromPool(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol)
{
size_t i;
for (i = 0; i < pool->volumes.count; i++) {
if (pool->volumes.objs[i] == vol) {
VIR_INFO("Deleting volume '%s' from storage pool '%s'",
vol->name, pool->def->name);
virStorageVolDefFree(vol);
VIR_DELETE_ELEMENT(pool->volumes.objs, i, pool->volumes.count);
break;
}
}
}
static int
storageVolDeleteInternal(virStorageVolPtr obj,
virStorageBackendPtr backend,
@ -1627,7 +1646,6 @@ storageVolDeleteInternal(virStorageVolPtr obj,
unsigned int flags,
bool updateMeta)
{
size_t i;
int ret = -1;
if (!backend->deleteVol) {
@ -1651,16 +1669,7 @@ storageVolDeleteInternal(virStorageVolPtr obj,
}
}
for (i = 0; i < pool->volumes.count; i++) {
if (pool->volumes.objs[i] == vol) {
VIR_INFO("Deleting volume '%s' from storage pool '%s'",
vol->name, pool->def->name);
virStorageVolDefFree(vol);
VIR_DELETE_ELEMENT(pool->volumes.objs, i, pool->volumes.count);
break;
}
}
storageVolRemoveFromPool(pool, vol);
ret = 0;
cleanup: