mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
storageBackendCreatePloop: Refactor cleanup
Get rid of the 'cleanup' label and 'created' variable. Signed-off-by: Yi Li <yili@winhong.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
0d49a565e5
commit
b66f26c342
@ -563,7 +563,6 @@ storageBackendCreatePloop(virStoragePoolObjPtr pool G_GNUC_UNUSED,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
bool created = false;
|
|
||||||
g_autoptr(virCommand) cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
g_autofree char *create_tool = NULL;
|
g_autofree char *create_tool = NULL;
|
||||||
|
|
||||||
@ -607,7 +606,7 @@ storageBackendCreatePloop(virStoragePoolObjPtr pool G_GNUC_UNUSED,
|
|||||||
0)) < 0) {
|
0)) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("error creating directory for ploop volume"));
|
_("error creating directory for ploop volume"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
cmd = virCommandNewArgList(create_tool, "init", "-s", NULL);
|
cmd = virCommandNewArgList(create_tool, "init", "-s", NULL);
|
||||||
virCommandAddArgFormat(cmd, "%lluM", VIR_DIV_UP(vol->target.capacity,
|
virCommandAddArgFormat(cmd, "%lluM", VIR_DIV_UP(vol->target.capacity,
|
||||||
@ -620,10 +619,8 @@ storageBackendCreatePloop(virStoragePoolObjPtr pool G_GNUC_UNUSED,
|
|||||||
cmd = virCommandNewArgList("cp", "-r", inputvol->target.path,
|
cmd = virCommandNewArgList("cp", "-r", inputvol->target.path,
|
||||||
vol->target.path, NULL);
|
vol->target.path, NULL);
|
||||||
}
|
}
|
||||||
created = true;
|
|
||||||
ret = virCommandRun(cmd, NULL);
|
ret = virCommandRun(cmd, NULL);
|
||||||
cleanup:
|
if (ret < 0)
|
||||||
if (ret < 0 && created)
|
|
||||||
virFileDeleteTree(vol->target.path);
|
virFileDeleteTree(vol->target.path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user