yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From d6d76951c7e02baad0ee5944d4a6b5a5468d0d40 Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <d6d76951c7e02baad0ee5944d4a6b5a5468d0d40.1387382496.git.minovotn@redhat.com>
0a122b
In-Reply-To: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
0a122b
References: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
0a122b
From: Nigel Croxon <ncroxon@redhat.com>
0a122b
Date: Thu, 14 Nov 2013 22:52:53 +0100
0a122b
Subject: [PATCH 17/46] rdma: allow state transitions between other states
0a122b
 besides ACTIVE
0a122b
0a122b
RH-Author: Nigel Croxon <ncroxon@redhat.com>
0a122b
Message-id: <1384469598-13137-18-git-send-email-ncroxon@redhat.com>
0a122b
Patchwork-id: 55705
0a122b
O-Subject: [RHEL7.0 PATCH 17/42] rdma: allow state transitions between other states besides ACTIVE
0a122b
Bugzilla: 1011720
0a122b
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
0a122b
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
0a122b
Bugzilla: 1011720
0a122b
https://bugzilla.redhat.com/show_bug.cgi?id=1011720
0a122b
0a122b
>From commit ID:
0a122b
commit d58f574bf39796ed2396dfd1e308352fbb03f944
0a122b
Author: Michael R. Hines <mrhines@us.ibm.com>
0a122b
Date:   Mon Jul 22 10:01:56 2013 -0400
0a122b
0a122b
    rdma: allow state transitions between other states besides ACTIVE
0a122b
0a122b
    This patch is in preparation for the next ones: Until now the MIG_STATE_SETUP
0a122b
    state was not really a 'formal' state. It has been used as a 'zero' state
0a122b
    and QEMU has been unconditionally transitioning into this state when
0a122b
    the QMP migrate command was called. In preparation for timing this state,
0a122b
    we have to make this state a a 'real' state which actually gets transitioned
0a122b
    from later in the migration_thread() from SETUP => ACTIVE, rather than just
0a122b
    automatically dropping into this state at the beginninig of the migration.
0a122b
0a122b
    This means that the state transition function (migration_finish_set_state())
0a122b
    needs to be capable of transitioning from valid states _other_ than just
0a122b
    MIG_STATE_ACTIVE.
0a122b
0a122b
    The function is in fact already capable of doing that, but was not allowing the
0a122b
    old state to be a parameter specified as an input.
0a122b
0a122b
    This patch fixes that and only makes the transition if the current state
0a122b
    matches the old state that the caller intended to transition from.
0a122b
0a122b
    Reviewed-by: Juan Quintela <quintela@redhat.com>
0a122b
    Tested-by: Michael R. Hines <mrhines@us.ibm.com>
0a122b
    Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
0a122b
    Signed-off-by: Juan Quintela <quintela@redhat.com>
0a122b
---
0a122b
 migration.c |   12 ++++++------
0a122b
 1 files changed, 6 insertions(+), 6 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 migration.c | 12 ++++++------
0a122b
 1 file changed, 6 insertions(+), 6 deletions(-)
0a122b
0a122b
diff --git a/migration.c b/migration.c
0a122b
index 2fa0237..e885bb7 100644
0a122b
--- a/migration.c
0a122b
+++ b/migration.c
0a122b
@@ -296,9 +296,9 @@ static void migrate_fd_cleanup(void *opaque)
0a122b
     notifier_list_notify(&migration_state_notifiers, s);
0a122b
 }
0a122b
 
0a122b
-static void migrate_finish_set_state(MigrationState *s, int new_state)
0a122b
+static void migrate_set_state(MigrationState *s, int old_state, int new_state)
0a122b
 {
0a122b
-    if (atomic_cmpxchg(&s->state, MIG_STATE_ACTIVE, new_state) == new_state) {
0a122b
+    if (atomic_cmpxchg(&s->state, old_state, new_state) == new_state) {
0a122b
         trace_migrate_set_state(new_state);
0a122b
     }
0a122b
 }
0a122b
@@ -316,7 +316,7 @@ static void migrate_fd_cancel(MigrationState *s)
0a122b
 {
0a122b
     DPRINTF("cancelling migration\n");
0a122b
 
0a122b
-    migrate_finish_set_state(s, MIG_STATE_CANCELLED);
0a122b
+    migrate_set_state(s, s->state, MIG_STATE_CANCELLED);
0a122b
 }
0a122b
 
0a122b
 void add_migration_state_change_notifier(Notifier *notify)
0a122b
@@ -578,19 +578,19 @@ static void *migration_thread(void *opaque)
0a122b
                 qemu_mutex_unlock_iothread();
0a122b
 
0a122b
                 if (ret < 0) {
0a122b
-                    migrate_finish_set_state(s, MIG_STATE_ERROR);
0a122b
+                    migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_ERROR);
0a122b
                     break;
0a122b
                 }
0a122b
 
0a122b
                 if (!qemu_file_get_error(s->file)) {
0a122b
-                    migrate_finish_set_state(s, MIG_STATE_COMPLETED);
0a122b
+                    migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_COMPLETED);
0a122b
                     break;
0a122b
                 }
0a122b
             }
0a122b
         }
0a122b
 
0a122b
         if (qemu_file_get_error(s->file)) {
0a122b
-            migrate_finish_set_state(s, MIG_STATE_ERROR);
0a122b
+            migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_ERROR);
0a122b
             break;
0a122b
         }
0a122b
         current_time = qemu_get_clock_ms(rt_clock);
0a122b
-- 
0a122b
1.7.11.7
0a122b