@@ -138,7 +138,7 @@ typedef struct GSIState {
qemu_irq x86_allocate_cpu_irq(void);
void gsi_handler(void *opaque, int n, int level);
-void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
+void ioapic_init_gsi(GSIState *gsi_state, Object *parent);
DeviceState *ioapic_init_secondary(GSIState *gsi_state);
/* pc_sysfw.c */
@@ -175,7 +175,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)
&error_abort);
isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
- ioapic_init_gsi(gsi_state, "machine");
+ ioapic_init_gsi(gsi_state, OBJECT(mms));
if (ioapics > 1) {
x86ms->ioapic2 = ioapic_init_secondary(gsi_state);
}
@@ -109,6 +109,7 @@ static void pc_init1(MachineState *machine,
X86MachineState *x86ms = X86_MACHINE(machine);
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
+ Object *phb = NULL;
PCIBus *pci_bus = NULL;
ISABus *isa_bus;
Object *piix4_pm = NULL;
@@ -192,8 +193,6 @@ static void pc_init1(MachineState *machine,
}
if (pcmc->pci_enabled) {
- Object *phb;
-
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
rom_memory = pci_memory;
@@ -320,8 +319,8 @@ static void pc_init1(MachineState *machine,
pc_i8259_create(isa_bus, gsi_state->i8259_irq);
}
- if (pcmc->pci_enabled) {
- ioapic_init_gsi(gsi_state, "i440fx");
+ if (phb) {
+ ioapic_init_gsi(gsi_state, phb);
}
if (tcg_enabled()) {
@@ -286,8 +286,8 @@ static void pc_q35_init(MachineState *machine)
pc_i8259_create(isa_bus, gsi_state->i8259_irq);
}
- if (pcmc->pci_enabled) {
- ioapic_init_gsi(gsi_state, "q35");
+ if (phb) {
+ ioapic_init_gsi(gsi_state, OBJECT(phb));
}
if (tcg_enabled()) {
@@ -636,20 +636,19 @@ void gsi_handler(void *opaque, int n, int level)
}
}
-void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name)
+void ioapic_init_gsi(GSIState *gsi_state, Object *parent)
{
DeviceState *dev;
SysBusDevice *d;
unsigned int i;
- assert(parent_name);
+ assert(parent);
if (kvm_ioapic_in_kernel()) {
dev = qdev_new(TYPE_KVM_IOAPIC);
} else {
dev = qdev_new(TYPE_IOAPIC);
}
- object_property_add_child(object_resolve_path(parent_name, NULL),
- "ioapic", OBJECT(dev));
+ object_property_add_child(parent, "ioapic", OBJECT(dev));
d = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(d, &error_fatal);
sysbus_mmio_map(d, 0, IO_APIC_DEFAULT_ADDRESS);
Rather than taking a QOM name which has to be resolved, let's pass the parent directly as pointer. This simplifies the code. Signed-off-by: Bernhard Beschow <shentey@gmail.com> --- include/hw/i386/x86.h | 2 +- hw/i386/microvm.c | 2 +- hw/i386/pc_piix.c | 7 +++---- hw/i386/pc_q35.c | 4 ++-- hw/i386/x86.c | 7 +++---- 5 files changed, 10 insertions(+), 12 deletions(-)