From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKD2u-0001fS-8v for qemu-devel@nongnu.org; Fri, 15 Jan 2016 17:40:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aKD2r-0007Bv-24 for qemu-devel@nongnu.org; Fri, 15 Jan 2016 17:40:40 -0500 Received: from mail-sn1nam02on0060.outbound.protection.outlook.com ([104.47.36.60]:18336 helo=NAM02-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKD2q-0007Bn-SC for qemu-devel@nongnu.org; Fri, 15 Jan 2016 17:40:36 -0500 From: Alistair Francis Date: Fri, 15 Jan 2016 14:38:10 -0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v7 1/6] qdev: get_child_bus(): Use QOM lookup if available List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, crosthwaitepeter@gmail.com, alistair.francis@xilinx.com From: Peter Crosthwaite 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 Acked-by: Alistair Francis --- hw/core/qdev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 2c7101d..75d1227 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -580,6 +580,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) { -- 2.5.0