qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 3/5] qom: allow creating an alias of a child<> p


From: Peter Crosthwaite
Subject: Re: [Qemu-devel] [PATCH 3/5] qom: allow creating an alias of a child<> property
Date: Tue, 17 Jun 2014 23:28:30 +1000

On Thu, Jun 12, 2014 at 2:49 AM, Paolo Bonzini <address@hidden> wrote:
> An object must have a single parent, so creating an alias of
> a child<> property breaks assumptions about objects having
> a single canonical path.  Fix this problem by turning these
> aliases into links.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
>  qom/object.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index e146ae5..ddf781e 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -1575,22 +1575,31 @@ void object_property_add_alias(Object *obj, const 
> char *name,
>  {
>      AliasProperty *prop;
>      ObjectProperty *target_prop;
> +    gchar *prop_type;
>
>      target_prop = object_property_find(target_obj, target_name, errp);
>      if (!target_prop) {
>          return;
>      }
>
> +    if (object_property_is_child(target_prop)) {
> +        prop_type = g_strdup_printf("link%s", target_prop->type + 5);

strlen("child") ? Or some comment to explain the magic 5.

Otherwise:

Reviewed-by: Peter Crosthwaite <address@hidden>

Longer term, should "child" and "link" be macrofied and these
hardcoded strlen's be fixed to avoid difficult developer traps if
anyone ever tries to change the literal strings?

Regards,
Peter


> +    } else {
> +        prop_type = g_strdup(target_prop->type);
> +    }
> +
>      prop = g_malloc(sizeof(*prop));
>      prop->target_obj = target_obj;
>      prop->target_name = target_name;
>
> -    object_property_add_full(obj, name, target_prop->type,
> +    object_property_add_full(obj, name, prop_type,
>                               property_get_alias,
>                               property_set_alias,
>                               property_resolve_alias,
>                               property_release_alias,
>                               prop, errp);
> +
> +    g_free(prop_type);
>  }
>
>  static void object_instance_init(Object *obj)
> --
> 1.8.3.1
>
>
>



reply via email to

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