diff mbox

[10/23] migration: Introduce migrate_fd_completed() for consistency

Message ID 958232891ad666aa1376196a734232f313ffa37c.1316782367.git.quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela Sept. 23, 2011, 12:56 p.m. UTC
This function is a bit different of the others that change the state,
in the sense that if migrate_fd_cleanup() returns an error, it set the
status to error, not completed.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/migration.c b/migration.c
index 740483d..40fda7d 100644
--- a/migration.c
+++ b/migration.c
@@ -318,6 +318,18 @@  void migrate_fd_error(MigrationState *s)
     migrate_fd_cleanup(s);
 }

+static void migrate_fd_completed(MigrationState *s)
+{
+    DPRINTF("setting completed state\n");
+    if (migrate_fd_cleanup(s) < 0) {
+        s->state = MIG_STATE_ERROR;
+    } else {
+        s->state = MIG_STATE_COMPLETED;
+        runstate_set(RSTATE_POST_MIGRATE);
+    }
+    notifier_list_notify(&migration_state_notifiers, NULL);
+}
+
 static void migrate_fd_put_notify(void *opaque)
 {
     MigrationState *s = opaque;
@@ -376,13 +388,7 @@  static void migrate_fd_put_ready(void *opaque)
         if (qemu_savevm_state_complete(s->mon, s->file) < 0) {
             migrate_fd_error(s);
         } else {
-            if (migrate_fd_cleanup(s) < 0) {
-                migrate_fd_error(s);
-            } else {
-                s->state = MIG_STATE_COMPLETED;
-                runstate_set(RSTATE_POST_MIGRATE);
-                notifier_list_notify(&migration_state_notifiers, NULL);
-            }
+            migrate_fd_completed(s);
         }
         if (s->get_status(s) != MIG_STATE_COMPLETED) {
             if (old_vm_running) {