Patchwork [09/28] migration: Introduce MIG_STATE_NONE

login
register
mail settings
Submitter Juan Quintela
Date Feb. 23, 2011, 9:47 p.m.
Message ID <f138a65a8cb1ab99046605d3491bd1d6ea2902dc.1298492768.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/84243/
State New
Headers show

Comments

Juan Quintela - Feb. 23, 2011, 9:47 p.m.
Use MIG_STATE_ACTIVE only when migration has really started

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration.c |    6 +++++-
 migration.h |   11 +++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

Patch

diff --git a/migration.c b/migration.c
index e8e593d..45cc263 100644
--- a/migration.c
+++ b/migration.c
@@ -239,6 +239,9 @@  void do_info_migrate(Monitor *mon, QObject **ret_data)
         MigrationState *s = current_migration;

         switch (s->get_status(current_migration)) {
+        case MIG_STATE_NONE:
+            /* no migration has happened ever */
+            break;
         case MIG_STATE_ACTIVE:
             qdict = qdict_new();
             qdict_put(qdict, "status", qstring_from_str("active"));
@@ -467,6 +470,7 @@  void migrate_fd_connect(MigrationState *s)
 {
     int ret;

+    s->state = MIG_STATE_ACTIVE;
     s->file = qemu_fopen_ops_buffered(s,
                                       s->bandwidth_limit,
                                       migrate_fd_put_buffer,
@@ -498,7 +502,7 @@  static MigrationState *migrate_create_state(Monitor *mon,
     s->shared = inc;
     s->mon = NULL;
     s->bandwidth_limit = bandwidth_limit;
-    s->state = MIG_STATE_ACTIVE;
+    s->state = MIG_STATE_NONE;

     if (!detach) {
         migrate_fd_monitor_suspend(s, mon);
diff --git a/migration.h b/migration.h
index b633f55..266c9f0 100644
--- a/migration.h
+++ b/migration.h
@@ -18,10 +18,13 @@ 
 #include "qemu-common.h"
 #include "notify.h"

-#define MIG_STATE_ERROR		-1
-#define MIG_STATE_COMPLETED	0
-#define MIG_STATE_CANCELLED	1
-#define MIG_STATE_ACTIVE	2
+enum migration_state {
+    MIG_STATE_ERROR,
+    MIG_STATE_NONE,
+    MIG_STATE_CANCELLED,
+    MIG_STATE_ACTIVE,
+    MIG_STATE_COMPLETED,
+};

 typedef struct MigrationState MigrationState;