From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHD3z-00067U-Ie for qemu-devel@nongnu.org; Thu, 07 Jan 2016 11:05:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHD3t-0002lx-Ir for qemu-devel@nongnu.org; Thu, 07 Jan 2016 11:05:23 -0500 Received: from mail-vk0-x234.google.com ([2607:f8b0:400c:c05::234]:32815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHD3t-0002hU-Fl for qemu-devel@nongnu.org; Thu, 07 Jan 2016 11:05:17 -0500 Received: by mail-vk0-x234.google.com with SMTP id i129so38283442vkb.0 for ; Thu, 07 Jan 2016 08:05:17 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <72794c95e3ccdadd4db71fe83d9c1855a91148ae.1450570397.git.crosthwaite.peter@gmail.com> References: <72794c95e3ccdadd4db71fe83d9c1855a91148ae.1450570397.git.crosthwaite.peter@gmail.com> From: Peter Maydell Date: Thu, 7 Jan 2016 16:04:55 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH v6 1/6] qdev: get_child_bus(): Use QOM lookup if available List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite Cc: Paolo Bonzini , Peter Crosthwaite , qemu-arm , QEMU Developers , Alistair Francis On 20 December 2015 at 05:43, Peter Crosthwaite wrote: > qbus_realize() adds busses as a QOM child of the device in addition to > adding it to the qdev bus list. Change get_child_bus() to use the QOM > child if it is available. This takes priority over the bus-list, but > the child object is checked for type correctness. > > This prepares support for aliasing of buses. The use case is SoCs, > where a SoC container needs to present buses to the board level, but > the buses are implemented by controller IP we already model as self > contained qbus-containing devices. > > Signed-off-by: Peter Crosthwaite > --- > Currently qbus_realize() ignores errors from object_property_add_child, > so it is hard to guarantee that the QOM linkage is reliable. If it were > the case that that object_property_add_child was supposed to be error > asserting, we could remove the old bus-list strcmp iterator altogether. > > hw/core/qdev.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index b3ad467..c96c464 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -581,6 +581,12 @@ void qdev_pass_gpios(DeviceState *dev, DeviceState *container, > BusState *qdev_get_child_bus(DeviceState *dev, const char *name) > { > BusState *bus; > + Object *child = object_resolve_path_component(OBJECT(dev), name); > + > + bus = (BusState *)object_dynamic_cast(child, TYPE_BUS); > + if (bus) { > + return bus; > + } > > QLIST_FOREACH(bus, &dev->child_bus, sibling) { > if (strcmp(name, bus->name) == 0) { This looks OK to me (and I like the effective API you get for devices using things), but I don't know enough QOM/qdev internals to be completely confident giving it a reviewed-by. thanks -- PMM