On Wed, Dec 12, 2018 at 06:08:33PM +0100, Peter Krempa wrote:
Extract the disk mirroring startup code from the loop into a separate function to allow cleaner cleanup paths. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_migration.c | 85 +++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 30 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 5f4fcb4bad..9d165e27aa 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -890,6 +890,58 @@ qemuMigrationSrcNBDStorageCopyDriveMirror(virQEMUDriverPtr driver, } +static int +qemuMigrationSrcNBDStorageCopyOne(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainDiskDefPtr disk, + const char *host, + int port, + unsigned long long mirror_speed, + unsigned int mirror_flags, + const char *tlsAlias, + unsigned int flags) +{ + qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); + char *diskAlias = NULL; + int rc; + int ret = -1; + + if (!(diskAlias = qemuAliasDiskDriveFromDisk(disk))) + goto cleanup; + + qemuBlockJobSyncBeginDisk(disk); + + if (flags & VIR_MIGRATE_TLS) { + rc = qemuMigrationSrcNBDStorageCopyBlockdev(driver, vm, + disk, diskAlias, + host, port, + mirror_speed, + mirror_flags, + tlsAlias); + } else { + rc = qemuMigrationSrcNBDStorageCopyDriveMirror(driver, vm, diskAlias, + host, port, + mirror_speed, + mirror_flags); + } + + if (rc < 0) { + qemuBlockJobSyncEndDisk(vm, QEMU_ASYNC_JOB_MIGRATION_OUT, disk); + goto cleanup; + } +
+ VIR_FREE(diskAlias);
You can drop this line now that the success path will fall through to cleanup instead of leading to another iteration of the loop.
+ diskPriv->migrating = true; + diskPriv->blockjob->started = true; + + ret = 0; + + cleanup: + VIR_FREE(diskAlias); + return ret; +} +
Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx> Jano
Attachment:
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list