Patchwork [01/34] migration: fix migration_bitmap leak

login
register
mail settings
Submitter Juan Quintela
Date Dec. 19, 2012, 12:33 p.m.
Message ID <1355920437-29882-2-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/207330/
State New
Headers show

Comments

Juan Quintela - Dec. 19, 2012, 12:33 p.m.
From: Paolo Bonzini <pbonzini@redhat.com>

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 arch_init.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Patch

diff --git a/arch_init.c b/arch_init.c
index 83dcc53..0d7844c 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -535,9 +535,13 @@  static void sort_ram_list(void)

 static void migration_end(void)
 {
-    memory_global_dirty_log_stop();
+    if (migration_bitmap) {
+        memory_global_dirty_log_stop();
+        g_free(migration_bitmap);
+        migration_bitmap = NULL;
+    }

-    if (migrate_use_xbzrle()) {
+    if (XBZRLE.cache) {
         cache_fini(XBZRLE.cache);
         g_free(XBZRLE.cache);
         g_free(XBZRLE.encoded_buf);
@@ -689,13 +693,10 @@  static int ram_save_complete(QEMUFile *f, void *opaque)
         }
         bytes_transferred += bytes_sent;
     }
-    memory_global_dirty_log_stop();
+    migration_end();

     qemu_put_be64(f, RAM_SAVE_FLAG_EOS);

-    g_free(migration_bitmap);
-    migration_bitmap = NULL;
-
     return 0;
 }