On Thu, Sep 16, 2021 at 01:17:07PM +0200, Markus Armbruster wrote: > Commit 6287d827d4 "monitor: allow device_del to accept QOM paths" > extended find_device_state() to accept QOM paths in addition to qdev > IDs. This added a checked conversion to TYPE_DEVICE at the end, which > duplicates the check done for the qdev ID case earlier, except it sets > a *different* error: GenericError "ID is not a hotpluggable device" > when passed a QOM path, and DeviceNotFound "Device 'ID' not found" > when passed a qdev ID. Fortunately, the latter won't happen as long > as we add only devices to /machine/peripheral/. > > Earlier, commit b6cc36abb2 "qdev: device_del: Search for to be > unplugged device in 'peripheral' container" rewrote the lookup by qdev > ID to use QOM instead of qdev_find_recursive(), so it can handle > buss-less devices. It does so by constructing an absolute QOM path. > Works, but object_resolve_path_component() is easier. Switching to it > also gets rid of the unclean duplication described above. > > While there, avoid converting to TYPE_DEVICE twice, first to check > whether it's possible, and then for real. > > Signed-off-by: Markus Armbruster <arm...@redhat.com> > --- > softmmu/qdev-monitor.c | 13 +++++-------- > 1 file changed, 5 insertions(+), 8 deletions(-)
Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|