Skip to content

Commit 94cdd73

Browse files
committed
memory snapshots correct clean up container memory regions
1 parent 30362a9 commit 94cdd73

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

qemu/softmmu/memory.c

+7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
void memory_region_transaction_begin(void);
3030
static void memory_region_transaction_commit(MemoryRegion *mr);
31+
static void memory_region_destructor_container(MemoryRegion *mr);
3132

3233
typedef struct AddrRange AddrRange;
3334

@@ -87,6 +88,7 @@ static void make_contained(struct uc_struct *uc, MemoryRegion *current)
8788
hwaddr addr = current->addr;
8889
MemoryRegion *container = g_new(MemoryRegion, 1);
8990
memory_region_init(uc, container, int128_get64(current->size));
91+
container->destructor = memory_region_destructor_container;
9092
memory_region_del_subregion(uc->system_memory, current);
9193
memory_region_add_subregion_overlap(container, 0, current, current->priority);
9294
memory_region_add_subregion(uc->system_memory, addr, container);
@@ -1091,6 +1093,11 @@ static void memory_region_destructor_ram(MemoryRegion *mr)
10911093
qemu_ram_free(mr->uc, mr->ram_block);
10921094
}
10931095

1096+
static void memory_region_destructor_container(MemoryRegion *mr)
1097+
{
1098+
memory_region_filter_subregions(mr, 0);
1099+
}
1100+
10941101
void memory_region_init(struct uc_struct *uc,
10951102
MemoryRegion *mr,
10961103
uint64_t size)

0 commit comments

Comments
 (0)