[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] qemu_migrate: Fix assign the same port when migrating concurrently



From: WangYufei <james wangyufei huawei com>
Date: Fri, 27 Sep 2013 11:53:57 +0800
Subject: [PATCH] qemu_migrate: Fix assign the same port when migrating concurrently
 
When we migrate vms concurrently, there's a chance that libvirtd on destination assign the same port for different migrations, which will lead to migration failed during migration prepare phase on destination. So we change the port increase to atomic operation to solve the problem.
 
Signed-off-by: WangYufei <james wangyufei huawei com>
---
src/qemu/qemu_migration.c |    5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
 
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 3a1aab7..0f496f4 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -57,6 +57,7 @@
#include "virhook.h"
#include "virstring.h"
#include "virtypedparam.h"
+#include "viratomic.h"
 
#define VIR_FROM_THIS VIR_FROM_QEMU
 
@@ -2521,7 +2522,7 @@ 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++;
+        this_port = QEMUD_MIGRATION_FIRST_PORT + virAtomicIntInc(&port);
         if (port == QEMUD_MIGRATION_NUM_PORTS) port = 0;
 
         /* Get hostname */
@@ -2578,7 +2579,7 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
 
         if (uri->port == 0) {
             /* Generate a port */
-            this_port = QEMUD_MIGRATION_FIRST_PORT + port++;
+            this_port = QEMUD_MIGRATION_FIRST_PORT + virAtomicIntInc(&port);
             if (port == QEMUD_MIGRATION_NUM_PORTS)
                 port = 0;
 
--
1.7.3.1.msysgit.0
 
Best Regards,
-WangYufei
 
 
 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]