From patchwork Wed Mar 28 14:34:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 149236 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 52F84B6FA2 for ; Thu, 29 Mar 2012 01:34:40 +1100 (EST) Received: from localhost ([::1]:56267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCtxN-0006QD-Ob for incoming@patchwork.ozlabs.org; Wed, 28 Mar 2012 10:34:37 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCtxG-0006PV-RN for qemu-devel@nongnu.org; Wed, 28 Mar 2012 10:34:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCtxE-00005Y-9f for qemu-devel@nongnu.org; Wed, 28 Mar 2012 10:34:30 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:63127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCtxE-00005F-1c for qemu-devel@nongnu.org; Wed, 28 Mar 2012 10:34:28 -0400 Received: by pbcuo5 with SMTP id uo5so2162681pbc.4 for ; Wed, 28 Mar 2012 07:34:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to; bh=jIL5G5wdygXYTfDlWsihAKMz5GXgl10FVsJjZc64EbE=; b=xL3HGqQl9L27Llv4k0RhLGDyCEWbkLZ+Jxxu6Z4IfqVCUljL3fNwa4+hnu8oDLjFrR iVRKxdZv6E/k3yxFTiMgABS1+lEN9S8Noi1IRAwZ9Yl397mqD9ZyvQeX69NjJnYvJNfx s7g5CDgGoA/IvihkH6lMmmHCsYHrrZyw3PiMU6P3RFbJ/u6JXmavhx0VXjGlUhQqsFwb hI94bKDPflvIy5ELEwhn0CG9IURsMvzZQmIWAORDmhX56h1cKaE+74KJC7qSPx3P/RBn 9Kj7vKlTu01FDL+xDupoa7W6gxs7YSNRi3AjvlNNCf6ZbXe2pzxmryG3+qCvRJmkS7tS NjiQ== Received: by 10.68.131.1 with SMTP id oi1mr71804579pbb.102.1332945265650; Wed, 28 Mar 2012 07:34:25 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-182-16.ip50.fastwebnet.it. [93.34.182.16]) by mx.google.com with ESMTPS id h10sm2825597pbe.12.2012.03.28.07.34.21 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 28 Mar 2012 07:34:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 28 Mar 2012 16:34:12 +0200 Message-Id: <1332945252-19025-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.9.1 In-reply-to: <4F7319CF.50909@suse.de> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: aliguori@linux.vnet.ibm.com, aliguori@us.ibm.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v2 4/4] qdev: put all devices under /machine 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 Avoid cluttering too much the QOM root. Signed-off-by: Paolo Bonzini --- v1->v2: add qdev_get_machine() and use it. hw/piix_pci.c | 2 +- hw/ppc_prep.c | 2 +- hw/qdev-monitor.c | 4 ++-- hw/qdev.c | 13 ++++++++++++- hw/qdev.h | 2 ++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/hw/piix_pci.c b/hw/piix_pci.c index 9017565..179d9a6 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -276,7 +276,7 @@ static PCIBus *i440fx_common_init(const char *device_name, b = pci_bus_new(&s->busdev.qdev, NULL, pci_address_space, address_space_io, 0); s->bus = b; - object_property_add_child(object_get_root(), "i440fx", OBJECT(dev), NULL); + object_property_add_child(qdev_get_machine(), "i440fx", OBJECT(dev), NULL); qdev_init_nofail(dev); d = pci_create_simple(b, 0, device_name); diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index 86c9336..9d8e659 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -615,7 +615,7 @@ static void ppc_prep_init (ram_addr_t ram_size, sys = sysbus_from_qdev(dev); pcihost = DO_UPCAST(PCIHostState, busdev, sys); pcihost->address_space = get_system_memory(); - object_property_add_child(object_get_root(), "raven", OBJECT(dev), NULL); + object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL); qdev_init_nofail(dev); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0"); if (pci_bus == NULL) { diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 031cb83..4783366 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -180,7 +180,7 @@ static Object *qdev_get_peripheral(void) static Object *dev; if (dev == NULL) { - dev = container_get("/peripheral"); + dev = container_get("/machine/peripheral"); } return dev; @@ -191,7 +191,7 @@ static Object *qdev_get_peripheral_anon(void) static Object *dev; if (dev == NULL) { - dev = container_get("/peripheral-anon"); + dev = container_get("/machine/peripheral-anon"); } return dev; diff --git a/hw/qdev.c b/hw/qdev.c index f5c716e..0d3c0fc 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -157,7 +157,7 @@ int qdev_init(DeviceState *dev) static int unattached_count = 0; gchar *name = g_strdup_printf("device[%d]", unattached_count++); - object_property_add_child(container_get("/unattached"), name, + object_property_add_child(container_get("/machine/unattached"), name, OBJECT(dev), NULL); g_free(name); } @@ -668,6 +668,17 @@ void device_reset(DeviceState *dev) } } +Object *qdev_get_machine(void) +{ + static Object *dev; + + if (dev == NULL) { + dev = container_get("/machine"); + } + + return dev; +} + static TypeInfo device_type_info = { .name = TYPE_DEVICE, .parent = TYPE_OBJECT, diff --git a/hw/qdev.h b/hw/qdev.h index 9cc3f98..a8df42f 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -349,6 +349,8 @@ BusInfo *qdev_get_bus_info(DeviceState *dev); Property *qdev_get_props(DeviceState *dev); +Object *qdev_get_machine(void); + /* FIXME: make this a link<> */ void qdev_set_parent_bus(DeviceState *dev, BusState *bus);