migration: Introduce ram_bitmaps_destroy()

We will use it in ram_init_bitmaps() to clear the allocated bitmaps when
support for error reporting is added to memory_global_dirty_log_start().

Signed-off-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240320064911.545001-11-clg@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
Cédric Le Goater 2024-03-20 07:49:06 +01:00 committed by Peter Xu
parent 3688fec892
commit 92c20b2fc5

View File

@ -2438,10 +2438,23 @@ static void xbzrle_cleanup(void)
XBZRLE_cache_unlock(); XBZRLE_cache_unlock();
} }
static void ram_bitmaps_destroy(void)
{
RAMBlock *block;
RAMBLOCK_FOREACH_NOT_IGNORED(block) {
g_free(block->clear_bmap);
block->clear_bmap = NULL;
g_free(block->bmap);
block->bmap = NULL;
g_free(block->file_bmap);
block->file_bmap = NULL;
}
}
static void ram_save_cleanup(void *opaque) static void ram_save_cleanup(void *opaque)
{ {
RAMState **rsp = opaque; RAMState **rsp = opaque;
RAMBlock *block;
/* We don't use dirty log with background snapshots */ /* We don't use dirty log with background snapshots */
if (!migrate_background_snapshot()) { if (!migrate_background_snapshot()) {
@ -2458,12 +2471,7 @@ static void ram_save_cleanup(void *opaque)
} }
} }
RAMBLOCK_FOREACH_NOT_IGNORED(block) { ram_bitmaps_destroy();
g_free(block->clear_bmap);
block->clear_bmap = NULL;
g_free(block->bmap);
block->bmap = NULL;
}
xbzrle_cleanup(); xbzrle_cleanup();
compress_threads_save_cleanup(); compress_threads_save_cleanup();