From: John Ferlan Date: Tue, 3 Nov 2015 16:30:23 +0000 (-0500) Subject: storage: Cleanup failures virStorageBackendCreateExecCommand X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=9345c2bfcf941ff90a09ce1d824847bb7b0418db;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git 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. --- diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 2ba6e2774..15470e8be 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; }