mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 09:55:18 +00:00
qemuMigrationCookieAddNBD: Exit early if there are no disks
Refactor the logic to skip the body of the function if there's nothing to do. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
6eab924daa
commit
bdff9d4513
@ -464,8 +464,13 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
|
||||
if (VIR_ALLOC(mig->nbd) < 0)
|
||||
return -1;
|
||||
|
||||
if (vm->def->ndisks &&
|
||||
VIR_ALLOC_N(mig->nbd->disks, vm->def->ndisks) < 0)
|
||||
mig->nbd->port = priv->nbdPort;
|
||||
mig->flags |= QEMU_MIGRATION_COOKIE_NBD;
|
||||
|
||||
if (vm->def->ndisks == 0)
|
||||
return 0;
|
||||
|
||||
if (VIR_ALLOC_N(mig->nbd->disks, vm->def->ndisks) < 0)
|
||||
return -1;
|
||||
mig->nbd->ndisks = 0;
|
||||
|
||||
@ -496,9 +501,6 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
|
||||
mig->nbd->ndisks++;
|
||||
}
|
||||
|
||||
mig->nbd->port = priv->nbdPort;
|
||||
mig->flags |= QEMU_MIGRATION_COOKIE_NBD;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virHashFree(stats);
|
||||
|
Loading…
x
Reference in New Issue
Block a user