[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/4] migration: provide ram_state_cleanup
From: |
Peter Xu |
Subject: |
[Qemu-devel] [PATCH 2/4] migration: provide ram_state_cleanup |
Date: |
Thu, 19 Oct 2017 14:31:58 +0800 |
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 <address@hidden>
---
migration/ram.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index fd8e14c59b..72c48e76e9 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1566,6 +1566,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;
@@ -1595,10 +1604,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)
--
2.13.5