On Mon, 4 May 2020 at 16:11, Paolo Bonzini <pbonz...@redhat.com> wrote:
>
> On 04/05/20 16:38, Markus Armbruster wrote:
> > makes no progreess because OBJECT(dev)->parent is still null, and
> > therefore object_unparent() does nothing.
> >
> > Possible culprit: qdev_try_create() calls qdev_set_parent_bus(), which
> > adds the device to the bus, but leaves ->parent null.  If this isn't
> > wrong outright, it's at least a dangerous state.
> >
> > Work-around: call qdev_set_id(dev, NULL) right after qdev_create().
> > This sets ->parent.
>
> That's a good one, and especially a safe one, since it matches
> qdev_device_add.  It has the disadvantage of having to touch all
> qdev_create() calls.

qdev_create() is supposed to be a "board code etc uses this to
create devices" function; I don't think we should impose extra
usage requirements like "you must immediately afterwards call this
function you weren't calling before". If qdev_set_id() needs to
be called, why not call it inside qdev_create() ?

thanks
-- PMM

Reply via email to