qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/2] qom: add object_property_add_alias


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 2/2] qom: add object_property_add_alias
Date: Tue, 10 Jun 2014 20:31:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

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 via email to

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