mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
parallels: split parallelsStorageVolumeDelete function
Move part, which deletes existing volume, to a new function parallelsStorageVolumeDefRemove so that we can use it later in parallels_driver.c Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
This commit is contained in:
parent
a9bd9b94e1
commit
944705e28f
@ -1443,42 +1443,12 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int parallelsStorageVolumeDefRemove(virStoragePoolObjPtr privpool,
|
||||||
parallelsStorageVolumeDelete(virStorageVolPtr vol, unsigned int flags)
|
virStorageVolDefPtr privvol)
|
||||||
{
|
{
|
||||||
parallelsConnPtr privconn = vol->conn->privateData;
|
|
||||||
virStoragePoolObjPtr privpool;
|
|
||||||
virStorageVolDefPtr privvol;
|
|
||||||
size_t i;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *xml_path = NULL;
|
char *xml_path = NULL;
|
||||||
|
size_t i;
|
||||||
virCheckFlags(0, -1);
|
|
||||||
|
|
||||||
parallelsDriverLock(privconn);
|
|
||||||
privpool = virStoragePoolObjFindByName(&privconn->pools, vol->pool);
|
|
||||||
parallelsDriverUnlock(privconn);
|
|
||||||
|
|
||||||
if (privpool == NULL) {
|
|
||||||
parallelsPoolNotFoundError(vol->pool);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
privvol = virStorageVolDefFindByName(privpool, vol->name);
|
|
||||||
|
|
||||||
if (privvol == NULL) {
|
|
||||||
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
|
||||||
_("no storage vol with matching name '%s'"), vol->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!virStoragePoolObjIsActive(privpool)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is not active"), vol->pool);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
privpool->def->allocation -= privvol->allocation;
|
privpool->def->allocation -= privvol->allocation;
|
||||||
privpool->def->available = (privpool->def->capacity -
|
privpool->def->available = (privpool->def->capacity -
|
||||||
@ -1513,12 +1483,56 @@ parallelsStorageVolumeDelete(virStorageVolPtr vol, unsigned int flags)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(xml_path);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
parallelsStorageVolumeDelete(virStorageVolPtr vol, unsigned int flags)
|
||||||
|
{
|
||||||
|
parallelsConnPtr privconn = vol->conn->privateData;
|
||||||
|
virStoragePoolObjPtr privpool;
|
||||||
|
virStorageVolDefPtr privvol;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
parallelsDriverLock(privconn);
|
||||||
|
privpool = virStoragePoolObjFindByName(&privconn->pools, vol->pool);
|
||||||
|
parallelsDriverUnlock(privconn);
|
||||||
|
|
||||||
|
if (privpool == NULL) {
|
||||||
|
parallelsPoolNotFoundError(vol->pool);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
privvol = virStorageVolDefFindByName(privpool, vol->name);
|
||||||
|
|
||||||
|
if (privvol == NULL) {
|
||||||
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
||||||
|
_("no storage vol with matching name '%s'"), vol->name);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!virStoragePoolObjIsActive(privpool)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
_("storage pool '%s' is not active"), vol->pool);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (parallelsStorageVolumeDefRemove(privpool, privvol))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (privpool)
|
if (privpool)
|
||||||
virStoragePoolObjUnlock(privpool);
|
virStoragePoolObjUnlock(privpool);
|
||||||
VIR_FREE(xml_path);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,5 +62,7 @@ void parallelsDriverLock(parallelsConnPtr driver);
|
|||||||
void parallelsDriverUnlock(parallelsConnPtr driver);
|
void parallelsDriverUnlock(parallelsConnPtr driver);
|
||||||
virStorageVolPtr parallelsStorageVolumeLookupByPathLocked(virConnectPtr conn,
|
virStorageVolPtr parallelsStorageVolumeLookupByPathLocked(virConnectPtr conn,
|
||||||
const char *path);
|
const char *path);
|
||||||
|
int parallelsStorageVolumeDefRemove(virStoragePoolObjPtr privpool,
|
||||||
|
virStorageVolDefPtr privvol);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user