@samitouri / QOSamiQemu / commits / 3b0f7a0834

hw/acpi: generic_event_device: Don't call qdev_get_machine in initfn

Calling qdev_get_machine() in the acpi_ged_initfn function would result in the following assert ../hw/core/qdev.c:858: qdev_get_machine: Assertion `dev' failed. when trying to run ./qemu-system-aarch64 -S -display none -M virt -device acpi-ged,help as the machine wasn't created yet. We call qdev_get_machine() to obtain the ram slots of the machine. So instead of initialising the GED in the init let's instead do it in the realise where the machine will exist. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Tested-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20260312043158.4191378-8-alistair.francis@wdc.com> [thuth: Replaced soc_init with acpi_ged_initfn in the patch description] Signed-off-by: Thomas Huth <thuth@redhat.com>

Alistair Francis committed Mar 12, 2026 at 14:31 UTC 3b0f7a083439e7765828de53aa6b380cf9fc1077
1 file changed +3 -2
hw/acpi/generic_event_device.c
+3 -2
@@ -506,6 +506,9 @@ static void acpi_ged_realize(DeviceState *dev, Error **errp)
506 uint32_t ged_events;
507 int i;
508
509 + acpi_memory_hotplug_init(&s->container_memhp, OBJECT(dev),
510 + &s->memhp_state, 0);
511 +
512 if (pcihp_state->use_acpi_hotplug_bridge) {
513 s->ged_event_bitmap |= ACPI_GED_PCI_HOTPLUG_EVT;
514 }
@@ -568,8 +571,6 @@ static void acpi_ged_initfn(Object *obj)
571 memory_region_init(&s->container_memhp, OBJECT(dev), "memhp container",
572 MEMORY_HOTPLUG_IO_LEN);
573 sysbus_init_mmio(sbd, &s->container_memhp);
571 - acpi_memory_hotplug_init(&s->container_memhp, OBJECT(dev),
572 - &s->memhp_state, 0);
574
575 memory_region_init_io(&ged_st->regs, obj, &ged_regs_ops, ged_st,
576 TYPE_ACPI_GED "-regs", ACPI_GED_REG_COUNT);