qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.crosthwaite@xilinx.com, mtosatti@redhat.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 2/2] qom: add object_property_add_alias
Date: Tue, 10 Jun 2014 20:31:03 +0200	[thread overview]
Message-ID: <53974EE7.7090000@redhat.com> (raw)
In-Reply-To: <1401967435-17751-3-git-send-email-pbonzini@redhat.com>

Il 05/06/2014 13:23, Paolo Bonzini ha scritto:
> Similar to object_property_add_link, alias properties provide an
> alternative, non-canonical path to an object.  In fact, external
> observers cannot distinguish alias properties from other links.
>
> Aliases differ from links in that they are immutable and typically
> managed by the target of the alias  in order to add a link to itself
> at a well-known location.  For example, a real-time clock device might
> add a link to itself at "/machine/rtc".  Such well-known locations can
> then expose a standard set of properties that can be accessed via the
> "qom-get" and "qom-set" commands.

Heh, another object_property_add_alias is in flight (from Stefan, for 
dataplane).  Luckily it is possible to share the more generic alias 
property implementation for object aliases too, with just an extra NULL 
argument before the Error**.  I'll post the patches as soon as Andreas 
comes back.

Paolo

> +void object_property_add_alias(Object *obj, const char *name,
> +                               Object *dest, Error **errp);
> +
>  typedef enum {
>      /* Unref the link pointer when the property is deleted */
>      OBJ_PROP_LINK_UNREF_ON_RELEASE = 0x1,
> diff --git a/qom/object.c b/qom/object.c
> index fcdd0da..46d60c8 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -1036,6 +1036,19 @@ out:
>      g_free(type);
>  }
>
> +void object_property_add_alias(Object *obj, const char *name,
> +                               Object *dest, Error **errp)
> +{
> +    gchar *type;
> +
> +    type = g_strdup_printf("link<%s>", object_get_typename(OBJECT(dest)));
> +
> +    object_property_add_full(obj, name, type, object_get_child_property, NULL,
> +                             object_resolve_child_property,
> +                             NULL, dest, errp);
> +    g_free(type);
> +}
> +
>  void object_property_allow_set_link(Object *obj, const char *name,
>                                      Object *val, Error **errp)
>  {
>

  reply	other threads:[~2014-06-10 18:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05 11:23 [Qemu-devel] [RFC PATCH 0/2] qom: custom link properties Paolo Bonzini
2014-06-05 11:23 ` [Qemu-devel] [PATCH 1/2] qom: add a generic mechanism to resolve paths Paolo Bonzini
2014-06-06  5:54   ` Peter Crosthwaite
2014-06-05 11:23 ` [Qemu-devel] [PATCH 2/2] qom: add object_property_add_alias Paolo Bonzini
2014-06-10 18:31   ` Paolo Bonzini [this message]
2014-06-05 19:14 ` [Qemu-devel] [RFC PATCH 0/2] qom: custom link properties Marcelo Tosatti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53974EE7.7090000@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=afaerber@suse.de \
    --cc=mtosatti@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).