From patchwork Wed Apr 18 20:56:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 153600 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 05DDAB6EE6 for ; Thu, 19 Apr 2012 07:23:41 +1000 (EST) Received: from localhost ([::1]:54520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKbxG-0000aG-Fv for incoming@patchwork.ozlabs.org; Wed, 18 Apr 2012 16:58:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKbwi-0007gF-Nx for qemu-devel@nongnu.org; Wed, 18 Apr 2012 16:57:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SKbwf-0007EZ-VV for qemu-devel@nongnu.org; Wed, 18 Apr 2012 16:57:48 -0400 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:59713 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKbwf-0007Dw-Oi for qemu-devel@nongnu.org; Wed, 18 Apr 2012 16:57:45 -0400 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4/Debian-2ubuntu2) with ESMTP id q3IKvcRM019440; Wed, 18 Apr 2012 15:57:39 -0500 Received: (from anthony@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id q3IKvbgo019438; Wed, 18 Apr 2012 15:57:37 -0500 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 18 Apr 2012 15:56:48 -0500 Message-Id: <1334782613-5421-10-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1334782613-5421-1-git-send-email-aliguori@us.ibm.com> References: <1334782613-5421-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 70.123.132.139 Cc: Wanpeng Li , Paolo Bonzini , Anthony Liguori , Andreas Faerber , Peter Maydell Subject: [Qemu-devel] [PATCH 09/14] qdev: connect some links and move type to object 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 This makes sysbus part of the root hierarchy and all busses children of their respective parent DeviceState. Signed-off-by: Anthony Liguori --- hw/qdev.c | 11 +++++------ qom/object.c | 12 ++++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 26e6f09..b5eef22 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -427,6 +427,7 @@ static void do_qbus_create_inplace(BusState *bus, const char *typename, if (parent) { QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling); parent->num_child_bus++; + object_property_add_child(OBJECT(parent), bus->name, OBJECT(bus), NULL); } else if (bus != main_system_bus) { /* TODO: once all bus devices are qdevified, only reset handler for main_system_bus should be registered here. */ @@ -456,6 +457,8 @@ static void main_system_bus_create(void) /* assign main_system_bus before qbus_create_inplace() * in order to make "if (bus != main_system_bus)" work */ main_system_bus = qbus_create(TYPE_SYSTEM_BUS, NULL, "main-system-bus"); + object_property_add_child(object_get_root(), "sysbus", + OBJECT(main_system_bus), NULL); } void qbus_free(BusState *bus) @@ -537,11 +540,6 @@ char *qdev_get_dev_path(DeviceState *dev) return NULL; } -static char *qdev_get_type(Object *obj, Error **errp) -{ - return g_strdup(object_get_typename(obj)); -} - /** * Legacy property handling */ @@ -657,7 +655,8 @@ static void device_initfn(Object *obj) qdev_add_properties(dev, dc->props); - object_property_add_str(OBJECT(dev), "type", qdev_get_type, NULL, NULL); + object_property_add_link(OBJECT(dev), "parent_bus", TYPE_BUS, + (Object **)&dev->parent_bus, NULL); } /* Unlink device from bus and free the structure. */ diff --git a/qom/object.c b/qom/object.c index 94928c5..0268f2a 100644 --- a/qom/object.c +++ b/qom/object.c @@ -256,12 +256,24 @@ static void object_interface_init(Object *obj, InterfaceImpl *iface) obj->interfaces = g_slist_prepend(obj->interfaces, iface_obj); } +static char *object_get_typename_dup(Object *obj, Error **errp) +{ + return g_strdup(object_get_typename(obj)); +} + +static void object_base_init(Object *obj) +{ + object_property_add_str(obj, "type", object_get_typename_dup, NULL, NULL); +} + static void object_init_with_type(Object *obj, TypeImpl *ti) { int i; if (type_has_parent(ti)) { object_init_with_type(obj, type_get_parent(ti)); + } else { + object_base_init(obj); } for (i = 0; i < ti->num_interfaces; i++) {