mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
storage: Attempt error recovery in virStorageBackendDiskCreateVol
During virStorageBackendDiskCreateVol if virStorageBackendDiskReadPartitions fails, then we were leaving with an error and a partition on the disk for which there was no corresponding volume and used space on the disk which could be reclaimable through direct parted activity. On a subsequent restart, reload, or refresh the volume may magically appear too.
This commit is contained in:
parent
1e79ad6d35
commit
290ffcfbbc
@ -654,6 +654,13 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
if (!vol->target.path) {
|
||||||
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
|
_("volume target path empty for source path '%s'"),
|
||||||
|
pool->def->source.devices[0].path);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (virFileResolveLink(vol->target.path, &devpath) < 0) {
|
if (virFileResolveLink(vol->target.path, &devpath) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Couldn't read volume target path '%s'"),
|
_("Couldn't read volume target path '%s'"),
|
||||||
@ -709,7 +716,7 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virStorageBackendDiskCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
virStorageBackendDiskCreateVol(virConnectPtr conn,
|
||||||
virStoragePoolObjPtr pool,
|
virStoragePoolObjPtr pool,
|
||||||
virStorageVolDefPtr vol)
|
virStorageVolDefPtr vol)
|
||||||
{
|
{
|
||||||
@ -756,8 +763,16 @@ virStorageBackendDiskCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
VIR_FREE(vol->target.path);
|
VIR_FREE(vol->target.path);
|
||||||
|
|
||||||
/* Fetch actual extent info, generate key */
|
/* Fetch actual extent info, generate key */
|
||||||
if (virStorageBackendDiskReadPartitions(pool, vol) < 0)
|
if (virStorageBackendDiskReadPartitions(pool, vol) < 0) {
|
||||||
|
/* Best effort to remove the partition. Ignore any errors
|
||||||
|
* since we could be calling this with vol->target.path == NULL
|
||||||
|
*/
|
||||||
|
virErrorPtr save_err = virSaveLastError();
|
||||||
|
ignore_value(virStorageBackendDiskDeleteVol(conn, pool, vol, 0));
|
||||||
|
virSetError(save_err);
|
||||||
|
virFreeError(save_err);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
res = 0;
|
res = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user