qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 01/49] avoid a bogus COMPLETED->CANCELLED transition


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 01/49] avoid a bogus COMPLETED->CANCELLED transition
Date: Mon, 13 Jan 2014 18:39:46 +0100

From: "Zhanghaoyu (A)" <address@hidden>

Avoid a bogus COMPLETED->CANCELLED transition.
There is a period of time from the timing of setting COMPLETED state to that of 
migration thread exits, so during which it's problematic in 
COMPLETED->CANCELLED transition.

Signed-off-by: Zeng Junliang <address@hidden>
Signed-off-by: Zhang Haoyu <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
 migration.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/migration.c b/migration.c
index 2b1ab20..fd73b97 100644
--- a/migration.c
+++ b/migration.c
@@ -326,9 +326,16 @@ void migrate_fd_error(MigrationState *s)

 static void migrate_fd_cancel(MigrationState *s)
 {
+    int old_state ;
     DPRINTF("cancelling migration\n");

-    migrate_set_state(s, s->state, MIG_STATE_CANCELLED);
+    do {
+        old_state = s->state;
+        if (old_state != MIG_STATE_SETUP && old_state != MIG_STATE_ACTIVE) {
+            break;
+        }
+        migrate_set_state(s, old_state, MIG_STATE_CANCELLED);
+    } while (s->state != MIG_STATE_CANCELLED);
 }

 void add_migration_state_change_notifier(Notifier *notify)
-- 
1.8.4.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]