0a122b
From 089e31ac09be32fce980da9b76da856ce83fe4ff Mon Sep 17 00:00:00 2001
0a122b
From: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
0a122b
Date: Wed, 15 Jan 2014 19:42:27 +0100
0a122b
Subject: [PATCH 01/34] avoid a bogus COMPLETED->CANCELLED transition
0a122b
0a122b
RH-Author: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
0a122b
Message-id: <1389814948-3983-2-git-send-email-dgilbert@redhat.com>
0a122b
Patchwork-id: 56730
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH 1/2] avoid a bogus COMPLETED->CANCELLED transition
0a122b
Bugzilla: 1053699
0a122b
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
0a122b
RH-Acked-by: Juan Quintela <quintela@redhat.com>
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
0a122b
From: "Zhanghaoyu (A)" <haoyu.zhang@huawei.com>
0a122b
0a122b
Avoid a bogus COMPLETED->CANCELLED transition.
0a122b
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.
0a122b
0a122b
Signed-off-by: Zeng Junliang <zengjunliang@huawei.com>
0a122b
Signed-off-by: Zhang Haoyu <haoyu.zhang@huawei.com>
0a122b
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Signed-off-by: Juan Quintela <quintela@redhat.com>
0a122b
(cherry picked from commit 6f2b811a61810a7fd9f9a5085de223f66b823342)
0a122b
---
0a122b
 migration.c | 9 ++++++++-
0a122b
 1 file changed, 8 insertions(+), 1 deletion(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 migration.c |    9 ++++++++-
0a122b
 1 files changed, 8 insertions(+), 1 deletions(-)
0a122b
0a122b
diff --git a/migration.c b/migration.c
0a122b
index ef9a61f..735f7ca 100644
0a122b
--- a/migration.c
0a122b
+++ b/migration.c
0a122b
@@ -324,9 +324,16 @@ void migrate_fd_error(MigrationState *s)
0a122b
 
0a122b
 static void migrate_fd_cancel(MigrationState *s)
0a122b
 {
0a122b
+    int old_state ;
0a122b
     DPRINTF("cancelling migration\n");
0a122b
 
0a122b
-    migrate_set_state(s, s->state, MIG_STATE_CANCELLED);
0a122b
+    do {
0a122b
+        old_state = s->state;
0a122b
+        if (old_state != MIG_STATE_SETUP && old_state != MIG_STATE_ACTIVE) {
0a122b
+            break;
0a122b
+        }
0a122b
+        migrate_set_state(s, old_state, MIG_STATE_CANCELLED);
0a122b
+    } while (s->state != MIG_STATE_CANCELLED);
0a122b
 }
0a122b
 
0a122b
 void add_migration_state_change_notifier(Notifier *notify)
0a122b
-- 
0a122b
1.7.1
0a122b