diff mbox

[45/46] End of migration for postcopy

Message ID 1404495717-4239-46-git-send-email-dgilbert@redhat.com
State New
Headers show

Commit Message

Dr. David Alan Gilbert July 4, 2014, 5:41 p.m. UTC
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Tweak the end of migration cleanup; we don't want to close stuff down
at the end of the main stream, since the postcopy is still sending pages
on the other thread.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 migration.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff mbox

Patch

diff --git a/migration.c b/migration.c
index fc8911d..5a85d03 100644
--- a/migration.c
+++ b/migration.c
@@ -190,6 +190,26 @@  static void process_incoming_migration_co(void *opaque)
 
     ret = qemu_loadvm_state(f);
 
+    if (mis->postcopy_ram_state == POSTCOPY_RAM_INCOMING_ADVISE) {
+        /*
+         * Where a migration had postcopy enabled (and thus went to advise)
+         * but managed to complete within the precopy period
+         */
+        postcopy_ram_incoming_cleanup(mis);
+    }
+
+    DPRINTF("%s: ret=%d postcopy_ram_state=%d", __func__, ret,
+            mis->postcopy_ram_state);
+    if ((ret >= 0) &&
+        (mis->postcopy_ram_state > POSTCOPY_RAM_INCOMING_ADVISE)) {
+        /*
+         * Postcopy was started, cleanup should happen at the end of the
+         * postcopy thread.
+         */
+        DPRINTF("process_incoming_migration_co: exiting main branch");
+        return;
+    }
+
     f->mis = NULL;
     qemu_fclose(f);
     free_xbzrle_decoded_buf();