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
1 changed files with 4 additions and 0 deletions

View File

@ -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;
}