thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
0a122b
From 8495376b2f1376da64faa0a62a8ec06a4499d735 Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <8495376b2f1376da64faa0a62a8ec06a4499d735.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:54 +0100
0a122b
Subject: [PATCH 18/46] rdma: introduce MIG_STATE_NONE and change
0a122b
 MIG_STATE_SETUP state transition
0a122b
0a122b
RH-Author: Nigel Croxon <ncroxon@redhat.com>
0a122b
Message-id: <1384469598-13137-19-git-send-email-ncroxon@redhat.com>
0a122b
Patchwork-id: 55699
0a122b
O-Subject: [RHEL7.0 PATCH 18/42] rdma: introduce MIG_STATE_NONE and change MIG_STATE_SETUP state transition
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 29ae8a4133082e16970c9d4be09f4b6a15034617
0a122b
Author: Michael R. Hines <mrhines@us.ibm.com>
0a122b
Date:   Mon Jul 22 10:01:57 2013 -0400
0a122b
0a122b
    rdma: introduce MIG_STATE_NONE and change MIG_STATE_SETUP state transition
0a122b
0a122b
    As described in the previous patch, until now, the MIG_STATE_SETUP
0a122b
    state was not really a 'formal' state. It has been used as a 'zero' state
0a122b
    (what we're calling 'NONE' here) and QEMU has been unconditionally transitioning
0a122b
    into this state when the QMP migration command was called. Instead we want to
0a122b
    introduce MIG_STATE_NONE, which is our starting state in the state machine, and
0a122b
    then immediately transition into the MIG_STATE_SETUP state when the QMP migrate
0a122b
    command is issued.
0a122b
0a122b
    In order to do this, we must delay the transition into MIG_STATE_ACTIVE until
0a122b
    later in the migration_thread(). This is done to be able to timestamp the amount of
0a122b
    time spent in the SETUP state for proper accounting to the user during
0a122b
    an RDMA migration.
0a122b
0a122b
    Furthermore, the management software, until now, has never been aware of the
0a122b
    existence of the SETUP state whatsoever. This must change, because, timing of this
0a122b
    state implies that the state actually exists.
0a122b
0a122b
    These two patches cannot be separated because the 'query_migrate' QMP
0a122b
    switch statement needs to know how to handle this new state transition.
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 |   21 ++++++++++++++-------
0a122b
 1 files changed, 14 insertions(+), 7 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 migration.c | 21 ++++++++++++++-------
0a122b
 1 file changed, 14 insertions(+), 7 deletions(-)
0a122b
0a122b
diff --git a/migration.c b/migration.c
0a122b
index e885bb7..ddbfd45 100644
0a122b
--- a/migration.c
0a122b
+++ b/migration.c
0a122b
@@ -36,7 +36,8 @@
0a122b
 #endif
0a122b
 
0a122b
 enum {
0a122b
-    MIG_STATE_ERROR,
0a122b
+    MIG_STATE_ERROR = -1,
0a122b
+    MIG_STATE_NONE,
0a122b
     MIG_STATE_SETUP,
0a122b
     MIG_STATE_CANCELLED,
0a122b
     MIG_STATE_ACTIVE,
0a122b
@@ -63,7 +64,7 @@ static NotifierList migration_state_notifiers =
0a122b
 MigrationState *migrate_get_current(void)
0a122b
 {
0a122b
     static MigrationState current_migration = {
0a122b
-        .state = MIG_STATE_SETUP,
0a122b
+        .state = MIG_STATE_NONE,
0a122b
         .bandwidth_limit = MAX_THROTTLE,
0a122b
         .xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE,
0a122b
         .mbps = -1,
0a122b
@@ -184,9 +185,13 @@ MigrationInfo *qmp_query_migrate(Error **errp)
0a122b
     MigrationState *s = migrate_get_current();
0a122b
 
0a122b
     switch (s->state) {
0a122b
-    case MIG_STATE_SETUP:
0a122b
+    case MIG_STATE_NONE:
0a122b
         /* no migration has happened ever */
0a122b
         break;
0a122b
+    case MIG_STATE_SETUP:
0a122b
+        info->has_status = true;
0a122b
+        info->status = g_strdup("setup");
0a122b
+        break;
0a122b
     case MIG_STATE_ACTIVE:
0a122b
         info->has_status = true;
0a122b
         info->status = g_strdup("active");
0a122b
@@ -258,7 +263,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
0a122b
     MigrationState *s = migrate_get_current();
0a122b
     MigrationCapabilityStatusList *cap;
0a122b
 
0a122b
-    if (s->state == MIG_STATE_ACTIVE) {
0a122b
+    if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP) {
0a122b
         error_set(errp, QERR_MIGRATION_ACTIVE);
0a122b
         return;
0a122b
     }
0a122b
@@ -401,7 +406,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
0a122b
     }
0a122b
 #endif
0a122b
 
0a122b
-    if (s->state == MIG_STATE_ACTIVE) {
0a122b
+    if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP) {
0a122b
         error_set(errp, QERR_MIGRATION_ACTIVE);
0a122b
         return;
0a122b
     }
0a122b
@@ -551,6 +556,8 @@ static void *migration_thread(void *opaque)
0a122b
     DPRINTF("beginning savevm\n");
0a122b
     qemu_savevm_state_begin(s->file, &s->params);
0a122b
 
0a122b
+    migrate_set_state(s, MIG_STATE_SETUP, MIG_STATE_ACTIVE);
0a122b
+
0a122b
     while (s->state == MIG_STATE_ACTIVE) {
0a122b
         int64_t current_time;
0a122b
         uint64_t pending_size;
0a122b
@@ -641,8 +648,8 @@ static void *migration_thread(void *opaque)
0a122b
 
0a122b
 void migrate_fd_connect(MigrationState *s)
0a122b
 {
0a122b
-    s->state = MIG_STATE_ACTIVE;
0a122b
-    trace_migrate_set_state(MIG_STATE_ACTIVE);
0a122b
+    s->state = MIG_STATE_SETUP;
0a122b
+    trace_migrate_set_state(MIG_STATE_SETUP);
0a122b
 
0a122b
     /* This is a best 1st approximation. ns to ms */
0a122b
     s->expected_downtime = max_downtime/1000000;
0a122b
-- 
0a122b
1.7.11.7
0a122b