memory_map_init() creates the "system" and "io" root memory regions after qemu_create_machine() has instantiated current_machine, so qdev_get_machine() is available as owner.
The IGVM backend creates guest-memory regions on behalf of the confidential-guest machine it carries in ctx->machine_state; use that as owner. subpage_init() and io_mem_init() pass name==NULL and thus never QOM-parent their MemoryRegion; leave owner NULL there. No functional change intended. Assisted-by: Kiro Signed-off-by: Alexander Graf <[email protected]> --- backends/igvm.c | 6 ++++-- system/physmem.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backends/igvm.c b/backends/igvm.c index 80e87fe602..544a51b70e 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -256,13 +256,15 @@ static void *qigvm_prepare_memory(QIgvm *ctx, uint64_t addr, uint64_t size, igvm_pages = g_new0(MemoryRegion, 1); if (ctx->machine_state->cgs && ctx->machine_state->cgs->require_guest_memfd) { - if (!memory_region_init_ram_guest_memfd(igvm_pages, NULL, + if (!memory_region_init_ram_guest_memfd(igvm_pages, + OBJECT(ctx->machine_state), region_name, size, errp)) { g_free(igvm_pages); return NULL; } } else { - if (!memory_region_init_ram(igvm_pages, NULL, region_name, size, + if (!memory_region_init_ram(igvm_pages, OBJECT(ctx->machine_state), + region_name, size, errp)) { g_free(igvm_pages); return NULL; diff --git a/system/physmem.c b/system/physmem.c index c21ea92915..8466885994 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3100,11 +3100,11 @@ static void memory_map_init(void) { system_memory = g_malloc(sizeof(*system_memory)); - memory_region_init(system_memory, NULL, "system", UINT64_MAX); + memory_region_init(system_memory, qdev_get_machine(), "system", UINT64_MAX); address_space_init(&address_space_memory, system_memory, "memory"); system_io = g_malloc(sizeof(*system_io)); - memory_region_init_io(system_io, NULL, &unassigned_io_ops, NULL, "io", + memory_region_init_io(system_io, qdev_get_machine(), &unassigned_io_ops, NULL, "io", 65536); address_space_init(&address_space_io, system_io, "I/O"); } -- 2.47.1
