Am 25.01.2013 12:46, schrieb Paolo Bonzini:
> Remove knowledge of QOM innards. The common part of pci_bus_new and
> pci_bus_new_inplace is moved to a new function pci_bus_init.
>
> Signed-off-by: Paolo Bonzini <[email protected]>
> ---
> hw/pci/pci.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 5fd1bcf..82b0ef8 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -274,13 +274,12 @@ int pci_find_domain(const PCIBus *bus)
> return -1;
> }
>
> -void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
> +static void pci_bus_init(PCIBus *bus, DeviceState *parent,
> const char *name,
> MemoryRegion *address_space_mem,
> MemoryRegion *address_space_io,
> uint8_t devfn_min)
> {
> - qbus_create_inplace(&bus->qbus, TYPE_PCI_BUS, parent, name);
> assert(PCI_FUNC(devfn_min) == 0);
> bus->devfn_min = devfn_min;
> bus->address_space_mem = address_space_mem;
> @@ -293,6 +292,17 @@ void pci_bus_new_inplace(PCIBus *bus, DeviceState
> *parent,
> vmstate_register(NULL, -1, &vmstate_pcibus, bus);
> }
>
> +void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
> + const char *name,
> + MemoryRegion *address_space_mem,
> + MemoryRegion *address_space_io,
> + uint8_t devfn_min)
> +{
> + qbus_create_inplace(BUS(bus), TYPE_PCI_BUS, parent, name);
This needs to be (BusState*) as-is. The object initialization is done
inside qbus_create_inplace() after BUS(), resulting in an assertion.
In a previous version I therefore suggested to change the argument type
to void* to avoid such casts.
Otherwise looking good.
Regards,
Andreas
> + pci_bus_init(bus, parent, name, address_space_mem,
> + address_space_io, devfn_min);
> +}
> +
> PCIBus *pci_bus_new(DeviceState *parent, const char *name,
> MemoryRegion *address_space_mem,
> MemoryRegion *address_space_io,
> @@ -300,10 +310,9 @@ PCIBus *pci_bus_new(DeviceState *parent, const char
> *name,
> {
> PCIBus *bus;
>
> - bus = g_malloc0(sizeof(*bus));
> - pci_bus_new_inplace(bus, parent, name, address_space_mem,
> - address_space_io, devfn_min);
> - OBJECT(bus)->free = g_free;
> + bus = PCI_BUS(qbus_create(TYPE_PCI_BUS, parent, name));
> + pci_bus_init(bus, parent, name, address_space_mem,
> + address_space_io, devfn_min);
> return bus;
> }
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg