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.
+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)
{