All the memory_region_allocate_system_memory() pass a MachineState argument. Add an assertion to ensure the new boards/machines added set this argument, so all system memory object have the machine as its QOM owner.
Signed-off-by: Philippe Mathieu-Daudé <phi...@redhat.com> --- hw/core/numa.c | 4 +--- include/hw/boards.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/core/numa.c b/hw/core/numa.c index 2e29e4bfe0..3e07e94d00 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -527,9 +527,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, MachineState *ms, uint64_t addr = 0; int i; - if (!ms) { - ms = MACHINE(qdev_get_machine()); - } + g_assert(ms); if (ms->numa_state == NULL || ms->numa_state->num_nodes == 0 || !have_memdevs) { diff --git a/include/hw/boards.h b/include/hw/boards.h index 3b6cb82b6c..31ab6e7586 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -14,7 +14,7 @@ /** * memory_region_allocate_system_memory - Allocate a board's main memory * @mr: the #MemoryRegion to be initialized - * @ms: the #MachineState object that own the system memory + * @ms: the #MachineState object that own the system memory (must not be NULL) * @name: name of the memory region * @ram_size: size of the region in bytes * -- 2.21.0