Re: [RFC PATCH 003/134] qdev: Reintroduce qdev_new() with a mandatory QOM parent
Philippe Mathieu-Daudé <[email protected]>
| Newsgroups | org.nongnu.qemu-riscv,org.nongnu.qemu-arm,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
On 12/7/26 00:34, Alexander Graf wrote: > The previous commit vacated the qdev_new()/qdev_try_new() names. > Reintroduce them with the signature we actually want: > > DeviceState *qdev_new(Object *parent, const char *id, > const char *type); > > which is the qdev-layer, heap-allocated dual of > object_initialize_child(): the returned device is created and > immediately added to the QOM composition tree as a child of @parent > under @id. > > Refcount contract: the initial reference is transferred to the > child<> property of @parent, so on return the caller does not hold a > reference. Pair with qdev_realize() (not qdev_realize_and_unref()), > matching object_initialize_child()'s convention. > > qdev_new_orphan() remains for callers that set the parent themselves > before realize (notably qdev_device_add(), which parents under > /machine/peripheral via qdev_set_id()). Later patches convert the > remaining orphan callers subsystem by subsystem. > > Suggested-by: Markus Armbruster <[email protected]> > Assisted-by: Kiro > Signed-off-by: Alexander Graf <[email protected]> > --- > hw/core/qdev.c | 19 +++++++++++++++++++ > include/hw/core/qdev.h | 34 ++++++++++++++++++++++++++++++++++ > 2 files changed, 53 insertions(+) Reviewed-by: Philippe Mathieu-Daudé <[email protected]>