1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

storage: Cleanup failures virStorageBackendCreateExecCommand

After a successful qemu-img/qcow-create of the backing file, if we
fail to stat the file, change it owner/group, or mode, then the
cleanup path should remove the file.
This commit is contained in:
John Ferlan 2015-11-03 11:30:23 -05:00
parent 77346f2787
commit 9345c2bfcf

View File

@ -714,6 +714,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
_("failed to create %s"), vol->target.path); _("failed to create %s"), vol->target.path);
goto cleanup; goto cleanup;
} }
filecreated = true;
} }
uid = (vol->target.perms->uid != st.st_uid) ? vol->target.perms->uid uid = (vol->target.perms->uid != st.st_uid) ? vol->target.perms->uid
@ -740,6 +741,9 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
ret = 0; ret = 0;
cleanup: cleanup:
if (ret < 0 && filecreated)
virFileRemove(vol->target.path, vol->target.perms->uid,
vol->target.perms->gid);
return ret; return ret;
} }