From 9345c2bfcf941ff90a09ce1d824847bb7b0418db Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Tue, 3 Nov 2015 11:30:23 -0500 Subject: [PATCH] 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. --- 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 2ba6e2774c..15470e8bea 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; }