From patchwork Thu Nov 29 15:12:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 202767 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F0F9C2C0093 for ; Fri, 30 Nov 2012 02:12:54 +1100 (EST) Received: from localhost ([::1]:53189 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Te5nI-0005cJ-Ez for incoming@patchwork.ozlabs.org; Thu, 29 Nov 2012 10:12:52 -0500 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 d28relay03.in.ibm.com (9.184.220.60) by e28smtp04.in.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 29 Nov 2012 20:42:27 +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 Received: from titi.austin.rr.com (sig-9-65-217-29.mts.ibm.com [9.65.217.29]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id qATKg43I025417; Fri, 30 Nov 2012 07:42:05 +1100 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Thu, 29 Nov 2012 09:12:12 -0600 Message-Id: <1354201932-9329-1-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.8.0 x-cbid: 12112915-5564-0000-0000-000005912C91 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.4 Cc: Peter Maydell , Anthony Liguori , Konrad Frederic Subject: [Qemu-devel] [PATCH] qdev: relax bus type check in qdev_device_add() (v2) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Andreas Färber --- 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;