Signed-off-by: Md Haris Iqbal <haris.p...@gmail.com>
---
 include/migration/migration.h | 5 +++++
 migration/migration.c         | 2 ++
 migration/savevm.c            | 5 +++++
 3 files changed, 12 insertions(+)

diff --git a/include/migration/migration.h b/include/migration/migration.h
index 4e4c0c8..5533832 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -145,6 +145,11 @@ struct MigrationState
     int state;
     /* Old style params from 'migrate' command */
     MigrationParams params;
+    /*
+     * Don't need 2 variables for recovery.
+     * Clean this up, use a single variable with different states.
+     */
+    bool recovered_once;
     bool in_recovery;
 
     /* State related to return path */
diff --git a/migration/migration.c b/migration/migration.c
index 7cd3344..6faa483 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1042,6 +1042,7 @@ MigrationState *migrate_init(const MigrationParams 
*params)
     s->xfer_limit = 0;
     s->cleanup_bh = 0;
     s->to_dst_file = NULL;
+    s->recovered_once = false;
     s->in_recovery = false;
     s->state = MIGRATION_STATUS_NONE;
     s->params = *params;
@@ -1925,6 +1926,7 @@ static void *migration_thread(void *opaque)
                 if(ret == 0) {
                     current_active_state = MIGRATION_STATUS_POSTCOPY_ACTIVE;
                     runstate_set(RUN_STATE_FINISH_MIGRATE);
+                    s->recovered_once = true;
                     qemu_file_clear_error(s->to_dst_file);
                     continue;
                 }
diff --git a/migration/savevm.c b/migration/savevm.c
index 79f601c..aa4f777 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -986,6 +986,11 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f)
 {
     SaveStateEntry *se;
     int ret;
+    MigrationState *ms = migrate_get_current();
+
+    if (ms->recovered_once) {
+        qemu_savevm_command_send(f, MIG_CMD_POSTCOPY_RECOVERY, 0, NULL);
+    }
 
     QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
         if (!se->ops || !se->ops->save_live_complete_postcopy) {
-- 
2.7.4


Reply via email to