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. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- Changes over v2: - The 'filecreated' was kept from the previous patch, but we still need to set it once virCommandRun and stat() agree the file was created. - Use virFileRemove and not just unlink in order to delete the file. If this was a root squash created file, then the only way to remove it properly is via virFileRemove src/storage/storage_backend.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 2ba6e27..15470e8 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -714,6 +714,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, _("failed to create %s"), vol->target.path); goto cleanup; } + filecreated = true; } uid = (vol->target.perms->uid != st.st_uid) ? vol->target.perms->uid @@ -740,6 +741,9 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, ret = 0; cleanup: + if (ret < 0 && filecreated) + virFileRemove(vol->target.path, vol->target.perms->uid, + vol->target.perms->gid); return ret; } -- 2.1.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list