qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] hw/sysbus.h: New sysbus_init_child() helper


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 1/2] hw/sysbus.h: New sysbus_init_child() helper function
Date: Tue, 20 Feb 2018 13:13:49 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 16/02/2018 18:40, Philippe Mathieu-Daudé wrote:
> we can keep object_initialize() when no parent,
> and add object_initialize_child(, const char *childname, Object *parent)
> 'parent' last because all previous args are child-related.
> 
>>
>>> +    qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
>> and then assuming we don't create sysbus devices, nor should be able to,
>> which are not attached to sysbus_get_default() this one can go sysbus' 
>> instance_init()
> good idea.
> 

Either last or first, like

        object_initialize_child(Object *parent, const char *childname,
                                void *data, size_t size,
                                const char *typename);

I'm not sure about moving qdev_set_parent_bus to instance_init().  It
would be a bit different from other buses and possibly confusing.

Potentially there could be a "hierarchy" of *_initialize_child
functions, adding or removing arguments as needed for the specific kind
of bus:

        /* adds qdev_set_parent_bus */
        device_initialize_child(Object *parent, const char *childname,
                                BusState *bus, void *data, size_t size,
                                const char *typename);
        /* uses sysbus_get_default() */
        sysbus_initialize_child(Object *parent, const char *childname,
                                void *data, size_t size,
                                const char *typename);
        /* initializes "addr" property too */
        pci_initialize_child(Object *parent, const char *childname,
                             BusState *bus, int addr,
                             void *data, size_t size,
                             const char *typename);

Thanks,

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]