thebeanogamer / rpms / qemu-kvm

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