XBZRLE encoded migration introduced a MRU page cache
meachnism. Unfortunately, cached items where never freed in
case of a collision in the page cache on cache_insert().
This lead to out of memory conditions during XBZRLE migration
if the page cache was small and there where a lot of collisions
in the cache.
Signed-off-by: Peter Lieven <[email protected]>
Signed-off-by: Orit Wasserman <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Juan Quintela <[email protected]>
/* actual update of entry */
it = cache_get_by_addr(cache, addr);
+ /* free old cached data if any */
+ g_free(it->it_data);
+
if (!it->it_data) {
cache->num_items++;
}