qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 07/18] qom: add child properties (composition


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH v2 07/18] qom: add child properties (composition) (v2)
Date: Thu, 08 Dec 2011 16:38:48 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0

Am 02.12.2011 21:20, schrieb Anthony Liguori:
> Child properties express a relationship of composition.
> 
> Signed-off-by: Anthony Liguori <address@hidden>
> ---
> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]