On Mon, 9 Mar 2020 at 00:56, Pan Nengyuan <[email protected]> wrote: > > > > On 3/8/2020 9:29 PM, Peter Maydell wrote: > > On Thu, 5 Mar 2020 at 06:39, Pan Nengyuan <[email protected]> wrote: > >> - /* Init VIAs 1 and 2 */ > >> - sysbus_init_child_obj(OBJECT(dev), "via1", &m->mos6522_via1, > >> - sizeof(m->mos6522_via1), > >> TYPE_MOS6522_Q800_VIA1); > >> + qdev_set_parent_bus(DEVICE(&m->mos6522_via1), sysbus_get_default()); > >> + qdev_set_parent_bus(DEVICE(&m->mos6522_via2), sysbus_get_default()); > > > > Rather than manually setting the parent bus, you can use > > sysbus_init_child_obj() instead of object_initialize_child() -- > > it is a convenience function that does both object_initialize_child() > > and qdev_set_parent_bus() for you. > > Actually I used sysbus_init_child_obj() first, but it will fail to run > device-introspect-test. > Because qdev_set_parent_bus() will change 'info qtree' after we call > 'device-list-properties'. > Thus, I do it in the realize.
Could you explain more? My thought is that we should be using sysbus_init_child_obj() and we should be doing it in the init method. Why does that break the tests ? It's the same thing various other devices do. thanks -- PMM
