From patchwork Fri Dec 2 20:20:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 128978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5B0DA1007D4 for ; Sat, 3 Dec 2011 08:07:59 +1100 (EST) Received: from localhost ([::1]:42219 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWZdB-00049a-35 for incoming@patchwork.ozlabs.org; Fri, 02 Dec 2011 15:22:49 -0500 Received: from eggs.gnu.org ([140.186.70.92]:32909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWZbu-0001Dv-5i for qemu-devel@nongnu.org; Fri, 02 Dec 2011 15:21:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RWZbn-0007kg-Jt for qemu-devel@nongnu.org; Fri, 02 Dec 2011 15:21:24 -0500 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:49926 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWZbn-0007kX-0Z for qemu-devel@nongnu.org; Fri, 02 Dec 2011 15:21:23 -0500 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4/Debian-2ubuntu1) with ESMTP id pB2KLFmh015013; Fri, 2 Dec 2011 14:21:15 -0600 Received: (from anthony@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id pB2KLD6Y015012; Fri, 2 Dec 2011 14:21:13 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Fri, 2 Dec 2011 14:20:42 -0600 Message-Id: <1322857256-14951-5-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1322857256-14951-1-git-send-email-aliguori@us.ibm.com> References: <1322857256-14951-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: Kevin Wolf , Peter Maydell , Anthony Liguori , Stefan Hajnoczi , Jan Kiszka , Markus Armbruster , Luiz Capitulino , Gerd Hoffman Subject: [Qemu-devel] [PATCH v2 04/18] qom: introduce root device 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 is based on Jan's suggestion for how to do unique naming. The root device is the root of composition. All devices are reachable via child<> links from this device. Signed-off-by: Anthony Liguori --- Makefile.objs | 2 +- hw/container.c | 20 ++++++++++++++++++++ hw/qdev.c | 12 ++++++++++++ hw/qdev.h | 8 ++++++++ 4 files changed, 41 insertions(+), 1 deletions(-) create mode 100644 hw/container.c diff --git a/Makefile.objs b/Makefile.objs index d7a6539..10e794c 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -279,7 +279,7 @@ hw-obj-$(CONFIG_LSI_SCSI_PCI) += lsi53c895a.o hw-obj-$(CONFIG_ESP) += esp.o hw-obj-y += dma-helpers.o sysbus.o isa-bus.o -hw-obj-y += qdev-addr.o +hw-obj-y += qdev-addr.o container.o # VGA hw-obj-$(CONFIG_VGA_PCI) += vga-pci.o diff --git a/hw/container.c b/hw/container.c new file mode 100644 index 0000000..9cbf399 --- /dev/null +++ b/hw/container.c @@ -0,0 +1,20 @@ +#include "sysbus.h" + +static int container_initfn(SysBusDevice *dev) +{ + return 0; +} + +static SysBusDeviceInfo container_info = { + .init = container_initfn, + .qdev.name = "container", + .qdev.size = sizeof(SysBusDevice), + .qdev.no_user = 1, +}; + +static void container_init(void) +{ + sysbus_register_withprop(&container_info); +} + +device_init(container_init); diff --git a/hw/qdev.c b/hw/qdev.c index 6f77af9..bb0b9f7 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -1161,3 +1161,15 @@ void qdev_property_add_legacy(DeviceState *dev, Property *prop, g_free(type); } + +DeviceState *qdev_get_root(void) +{ + static DeviceState *qdev_root; + + if (!qdev_root) { + qdev_root = qdev_create(NULL, "container"); + qdev_init_nofail(qdev_root); + } + + return qdev_root; +} diff --git a/hw/qdev.h b/hw/qdev.h index 3b629d4..52aadd2 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -482,4 +482,12 @@ const char *qdev_property_get_type(DeviceState *dev, const char *name, */ void qdev_property_add_legacy(DeviceState *dev, Property *prop, Error **errp); +/** + * @qdev_get_root - returns the root device of the composition tree + * + * Returns: + * The root of the composition tree. + */ +DeviceState *qdev_get_root(void); + #endif