mirror of https://gitee.com/openkylin/libvirt.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.
This commit is contained in:
parent
77346f2787
commit
9345c2bfcf
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue