qemuMigrationDstPrecreateStorage: Refactor cleanup

Use automatic pointer freeing for 'conn' and remove the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2023-12-06 14:32:09 +01:00
parent 16832e0dd2
commit 9864486966

View File

@ -440,9 +440,8 @@ qemuMigrationDstPrecreateStorage(virDomainObj *vm,
const char **migrate_disks, const char **migrate_disks,
bool incremental) bool incremental)
{ {
int ret = -1; g_autoptr(virConnect) conn = NULL;
size_t i = 0; size_t i = 0;
virConnectPtr conn = NULL;
if (!nbd || !nbd->ndisks) if (!nbd || !nbd->ndisks)
return 0; return 0;
@ -459,7 +458,7 @@ qemuMigrationDstPrecreateStorage(virDomainObj *vm,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to find disk target '%1$s' for non-shared-storage migration"), _("unable to find disk target '%1$s' for non-shared-storage migration"),
nbd->disks[i].target); nbd->disks[i].target);
goto cleanup; return -1;
} }
if (disk->src->type == VIR_STORAGE_TYPE_NVME) { if (disk->src->type == VIR_STORAGE_TYPE_NVME) {
@ -479,20 +478,16 @@ qemuMigrationDstPrecreateStorage(virDomainObj *vm,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("pre-creation of storage target '%1$s' for incremental storage migration of disk '%2$s' is not supported"), _("pre-creation of storage target '%1$s' for incremental storage migration of disk '%2$s' is not supported"),
NULLSTR(diskSrcPath), nbd->disks[i].target); NULLSTR(diskSrcPath), nbd->disks[i].target);
goto cleanup; return -1;
} }
VIR_DEBUG("Proceeding with disk source %s", NULLSTR(diskSrcPath)); VIR_DEBUG("Proceeding with disk source %s", NULLSTR(diskSrcPath));
if (qemuMigrationDstPrecreateDisk(&conn, if (qemuMigrationDstPrecreateDisk(&conn, disk, nbd->disks[i].capacity) < 0)
disk, nbd->disks[i].capacity) < 0) return -1;
goto cleanup;
} }
ret = 0; return 0;
cleanup:
virObjectUnref(conn);
return ret;
} }