Convert the *_orphan() device-creation calls in hw/ufs to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions. Per-site rationale (reviewers: dispute the modeling here): hw/ufs/lu.c:475 | qdev_new | OBJECT(lu) | "ufs-scsi" | ufs-lu realize path; the LU device owns the wrapped scsi-hd (bus is not parent). Re-parent from bus to lu; drop _and_unref Link: https://lore.kernel.org/qemu-devel/[email protected]/ AI-used-for: code (refactoring) Signed-off-by: Alexander Graf <[email protected]> --- hw/ufs/lu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/ufs/lu.c b/hw/ufs/lu.c index 219f74e4f3..4e5621f224 100644 --- a/hw/ufs/lu.c +++ b/hw/ufs/lu.c @@ -472,8 +472,7 @@ static void ufs_init_scsi_device(UfsLu *lu, BlockBackend *blk, Error **errp) * The ufs-lu is the device that is wrapping the scsi-hd. It owns a virtual * SCSI bus that serves the scsi-hd. */ - scsi_dev = qdev_new_orphan("scsi-hd"); - object_property_add_child(OBJECT(&lu->bus), "ufs-scsi", OBJECT(scsi_dev)); + scsi_dev = qdev_new(OBJECT(lu), "ufs-scsi", "scsi-hd"); qdev_prop_set_uint32(scsi_dev, "physical_block_size", UFS_BLOCK_SIZE); qdev_prop_set_uint32(scsi_dev, "logical_block_size", UFS_BLOCK_SIZE); @@ -484,7 +483,7 @@ static void ufs_init_scsi_device(UfsLu *lu, BlockBackend *blk, Error **errp) return; } - if (!qdev_realize_and_unref(scsi_dev, &lu->bus.qbus, errp)) { + if (!qdev_realize(scsi_dev, &lu->bus.qbus, errp)) { object_unparent(OBJECT(scsi_dev)); return; } -- 2.47.1
