diff mbox

[11/28] migration: Introduce migrate_fd_completed() for consistenncy

Message ID a2a8c6fea063914ddac14888abd57956f71219a5.1298492768.git.quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela Feb. 23, 2011, 9:47 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 |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/migration.c b/migration.c
index ed6e626..9be6bb0 100644
--- a/migration.c
+++ b/migration.c
@@ -318,6 +318,17 @@  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;
+    }
+    notifier_list_notify(&migration_state_notifiers);
+}
+
 static void migrate_fd_put_notify(void *opaque)
 {
     MigrationState *s = opaque;
@@ -371,12 +382,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;
-                notifier_list_notify(&migration_state_notifiers);
-            }
+            migrate_fd_completed(s);
         }
         if (s->get_status(s) != MIG_STATE_COMPLETED) {
             if (old_vm_running) {