From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYg5T-0005jG-RJ for qemu-devel@nongnu.org; Thu, 08 Dec 2011 10:40:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RYg5S-0006yK-Jx for qemu-devel@nongnu.org; Thu, 08 Dec 2011 10:40:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYg5S-0006yC-B1 for qemu-devel@nongnu.org; Thu, 08 Dec 2011 10:40:42 -0500 Message-ID: <4EE0DA08.6030001@redhat.com> Date: Thu, 08 Dec 2011 16:38:48 +0100 From: Kevin Wolf MIME-Version: 1.0 References: <1322857256-14951-1-git-send-email-aliguori@us.ibm.com> <1322857256-14951-8-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1322857256-14951-8-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 07/18] qom: add child properties (composition) (v2) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Peter Maydell , Stefan Hajnoczi , Jan Kiszka , qemu-devel@nongnu.org, Luiz Capitulino , Gerd Hoffman , Markus Armbruster Am 02.12.2011 21:20, schrieb Anthony Liguori: > Child properties express a relationship of composition. > > Signed-off-by: Anthony Liguori > --- > v1 -> v2 > - fix comments (Kevin) > - add a reference when adding a child property (Kevin) > --- > hw/qdev.c | 26 ++++++++++++++++++++++++++ > hw/qdev.h | 20 ++++++++++++++++++++ > 2 files changed, 46 insertions(+), 0 deletions(-) > > diff --git a/hw/qdev.c b/hw/qdev.c > index 2519f00..fa6b489 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -1174,6 +1174,32 @@ DeviceState *qdev_get_root(void) > return qdev_root; > } > > +static void qdev_get_child_property(DeviceState *dev, Visitor *v, void *opaque, > + const char *name, Error **errp) > +{ > + DeviceState *child = opaque; > + gchar *path; > + > + path = qdev_get_canonical_path(child); > + visit_type_str(v, &path, name, errp); > + g_free(path); > +} > + > +void qdev_property_add_child(DeviceState *dev, const char *name, > + DeviceState *child, Error **errp) > +{ > + gchar *type; > + > + type = g_strdup_printf("child<%s>", child->info->name); > + > + qdev_property_add(dev, name, type, qdev_get_child_property, > + NULL, NULL, child, errp); > + > + qdev_ref(dev); Shouldn't you increase the refcount for child rather than dev? Kevin