diff mbox series

[PULL,14/21] migration: provide ram_state_cleanup

Message ID 20171023160800.20540-15-quintela@redhat.com
State New
Headers show
Series [PULL,01/21] migration: Fix migrate_test_apply for multifd parameters | expand

Commit Message

Juan Quintela Oct. 23, 2017, 4:07 p.m. UTC
From: Peter Xu <peterx@redhat.com>

There are two Mutexes that are created but not yet destroyed for
RAMState.  Fix that.

Since we are at it, provide helper function to clean up RAMState.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/ram.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/migration/ram.c b/migration/ram.c
index 13f4b3d101..d91e8787ae 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1576,6 +1576,15 @@  static void xbzrle_load_cleanup(void)
     XBZRLE.decoded_buf = NULL;
 }
 
+static void ram_state_cleanup(RAMState **rsp)
+{
+    migration_page_queue_free(*rsp);
+    qemu_mutex_destroy(&(*rsp)->bitmap_mutex);
+    qemu_mutex_destroy(&(*rsp)->src_page_req_mutex);
+    g_free(*rsp);
+    *rsp = NULL;
+}
+
 static void ram_save_cleanup(void *opaque)
 {
     RAMState **rsp = opaque;
@@ -1605,10 +1614,8 @@  static void ram_save_cleanup(void *opaque)
         XBZRLE.zero_target_page = NULL;
     }
     XBZRLE_cache_unlock();
-    migration_page_queue_free(*rsp);
     compress_threads_save_cleanup();
-    g_free(*rsp);
-    *rsp = NULL;
+    ram_state_cleanup(rsp);
 }
 
 static void ram_state_reset(RAMState *rs)