Skip to content

Commit

Permalink
migration: provide ram_state_cleanup
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
xzpeter authored and Juan Quintela committed Oct 23, 2017
1 parent 7d00ee6 commit 7d7c96b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions migration/ram.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7d7c96b

Please sign in to comment.