Received: from eggs.gnu.org ([208.118.235.92]:39993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Te5n7-0005c2-W6 for qemu-devel@nongnu.org; Thu, 29 Nov 2012 10:12:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Te5n3-0002Gd-Lb for qemu-devel@nongnu.org; Thu, 29 Nov 2012 10:12:41 -0500 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:44734) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Te5n3-000273-2M for qemu-devel@nongnu.org; Thu, 29 Nov 2012 10:12:37 -0500 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 29 Nov 2012 20:42:28 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qATFCKAm36896806 for ; Thu, 29 Nov 2012 20:42:25 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qATKg8Bi025578 for ; Fri, 30 Nov 2012 07:42:11 +1100 From: Anthony Liguori Date: Thu, 29 Nov 2012 09:12:12 -0600 Message-Id: <1354201932-9329-1-git-send-email-aliguori@us.ibm.com> Subject: [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: qemu-devel@nongnu.org Cc: Peter Maydell , Anthony Liguori , Konrad Frederic 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; -- 1.8.0