From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Te5uT-0000Yh-57 for qemu-devel@nongnu.org; Thu, 29 Nov 2012 10:20:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Te5uJ-000533-Gz for qemu-devel@nongnu.org; Thu, 29 Nov 2012 10:20:17 -0500 Received: from greensocs.com ([87.106.252.221]:38944 helo=s15328186.onlinehome-server.info) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Te5uJ-0004xz-Ay for qemu-devel@nongnu.org; Thu, 29 Nov 2012 10:20:07 -0500 Message-ID: <50B77D40.8020109@greensocs.com> Date: Thu, 29 Nov 2012 16:20:32 +0100 From: Konrad Frederic MIME-Version: 1.0 References: <1354201932-9329-1-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1354201932-9329-1-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qdev: relax bus type check in qdev_device_add() (v2) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Peter Maydell , qemu-devel@nongnu.org On 29/11/2012 16:12, Anthony Liguori wrote: > We are currently checking for an exact type match. Use QOM dynamic_cast to > check for a compatible type instead. > > Cc: Konrad Frederic > Cc: Peter Maydell > Signed-off-by: Anthony Liguori > --- > v1 -> v2: > - also add cast to qbus_find_recursive (Peter) > - simplify by doing object_dynamic_cast instead of messing with classes > --- > hw/qdev-monitor.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c > index 479eecd..a1b4d6a 100644 > --- a/hw/qdev-monitor.c > +++ b/hw/qdev-monitor.c > @@ -289,8 +289,7 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name, > if (name&& (strcmp(bus->name, name) != 0)) { > match = 0; > } > - if (bus_typename&& > - (strcmp(object_get_typename(OBJECT(bus)), bus_typename) != 0)) { > + if (bus_typename&& !object_dynamic_cast(OBJECT(bus), bus_typename)) { > match = 0; > } > if (match) { > @@ -435,7 +434,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) > if (!bus) { > return NULL; > } > - if (strcmp(object_get_typename(OBJECT(bus)), k->bus_type) != 0) { > + if (!object_dynamic_cast(OBJECT(bus), k->bus_type)) { > qerror_report(QERR_BAD_BUS_FOR_DEVICE, > driver, object_get_typename(OBJECT(bus))); > return NULL; That seems to work. Thanks, Fred.