[libvirt] [PATCH] qemu: Avoid assigning unavailable migration ports

Ján Tomko jtomko at redhat.com
Thu Oct 17 13:26:07 UTC 2013


On 10/15/2013 02:42 PM, Jiri Denemark wrote:
> From: WangYufei <james.wangyufei at huawei.com>
> 
> 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 at huawei.com>
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
>  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




-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131017/d241d9d1/attachment-0001.sig>


More information about the libvir-list mailing list