Paolo Bonzini <pbonz...@redhat.com> writes: > On 20/05/20 16:42, Markus Armbruster wrote: >> If something goes >> wrong there, we execute >> >> fail: >> error_propagate(errp, local_err); >> if (unattached_parent) { >> /* >> * Beware, this doesn't just revert >> * object_property_add_child(), it also runs bus_remove()! >> */ >> object_unparent(OBJECT(dev)); >> unattached_count--; >> } >> >> and bus_remove() drops the reference count to zero. > > Whoa whoa... I didn't expect this from a failure to realize.
Me neither. But by the time I understood what's going on here, my appetite for big, structural QOM changes was pretty much gone, so I merely added the "Beware" comment. > I think we should move the whole /machine/unattached dance into > qdev_realize, and just assert that a device being realized already has a > parent. Then the ref/unref _will_ be unnecessary. In the meanwhile, I > agree to either keep it or move it inside device_set_realized. Could be done on top. I might try for v2, if I can find the time.