On 10/15/2013 02:42 PM, Jiri Denemark wrote: > From: WangYufei <james.wangyufei@xxxxxxxxxx> > > https://bugzilla.redhat.com/show_bug.cgi?id=1019053 > > When we migrate vms concurrently, there's a chance that libvirtd on > destination assigns the same port for different migrations, which will > lead to migration failure during prepare phase on destination. So we use > virPortAllocator here to solve the problem. > > Signed-off-by: WangYufei <james.wangyufei@xxxxxxxxxx> > Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> > --- > src/qemu/qemu_command.h | 3 +++ > src/qemu/qemu_conf.h | 6 +++--- > src/qemu/qemu_domain.h | 1 + > src/qemu/qemu_driver.c | 6 ++++++ > src/qemu/qemu_migration.c | 39 +++++++++++++++++++++++++-------------- > 5 files changed, 38 insertions(+), 17 deletions(-) > > diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c > index 38edadb..a77aeb7 100644 > --- a/src/qemu/qemu_migration.c > +++ b/src/qemu/qemu_migration.c > @@ -2550,8 +2556,8 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver, > * to be a correct hostname which refers to the target machine). > */ > if (uri_in == NULL) { > - this_port = QEMUD_MIGRATION_FIRST_PORT + port++; > - if (port == QEMUD_MIGRATION_NUM_PORTS) port = 0; > + if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0) > + goto cleanup; > > /* Get hostname */ > if ((hostname = virGetHostname()) == NULL) If all the ports are occupied, virPortAllocatorAcquire will return 0, but set the port to 0. We need to report an error if (port == 0) > @@ -2607,16 +2613,16 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver, > > if (uri->port == 0) { > /* Generate a port */ > - this_port = QEMUD_MIGRATION_FIRST_PORT + port++; > - if (port == QEMUD_MIGRATION_NUM_PORTS) > - port = 0; > + if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0) > + goto cleanup; > Same here. Jan
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list