aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2020-01-10 19:30:28 +0400
committerPaolo Bonzini <pbonzini@redhat.com>2020-01-24 20:59:14 +0100
commit4a8d57989b9de26d608684ed349adf02436a0a94 (patch)
tree52ea66253f3d284a7beda1af24242ad51f953a9c /qom
parent9941d37b4d159da0f18edbd2bd7b9fd19484a286 (diff)
object: express const link with link property
Let's not mix child property and link property callbacks, as this is confusing, use LinkProperty with DIRECT flag to hold the target pointer. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20200110153039.1379601-16-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/qom/object.c b/qom/object.c
index a9760d5276..b2bc87b0dc 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1844,19 +1844,23 @@ static void object_release_link_property(Object *obj, const char *name,
g_free(prop);
}
-void object_property_add_link(Object *obj, const char *name,
- const char *type, Object **targetp,
- void (*check)(const Object *, const char *,
- Object *, Error **),
- ObjectPropertyLinkFlags flags,
- Error **errp)
+static void object_add_link_prop(Object *obj, const char *name,
+ const char *type, void *ptr,
+ void (*check)(const Object *, const char *,
+ Object *, Error **),
+ ObjectPropertyLinkFlags flags,
+ Error **errp)
{
Error *local_err = NULL;
LinkProperty *prop = g_malloc(sizeof(*prop));
gchar *full_type;
ObjectProperty *op;
- prop->targetp = targetp;
+ if (flags & OBJ_PROP_LINK_DIRECT) {
+ prop->target = ptr;
+ } else {
+ prop->targetp = ptr;
+ }
prop->check = check;
prop->flags = flags;
@@ -1880,20 +1884,21 @@ out:
g_free(full_type);
}
+void object_property_add_link(Object *obj, const char *name,
+ const char *type, Object **targetp,
+ void (*check)(const Object *, const char *,
+ Object *, Error **),
+ ObjectPropertyLinkFlags flags,
+ Error **errp)
+{
+ object_add_link_prop(obj, name, type, targetp, check, flags, errp);
+}
+
void object_property_add_const_link(Object *obj, const char *name,
Object *target, Error **errp)
{
- char *link_type;
- ObjectProperty *op;
-
- link_type = g_strdup_printf("link<%s>", object_get_typename(target));
- op = object_property_add(obj, name, link_type,
- object_get_child_property, NULL,
- NULL, target, errp);
- if (op != NULL) {
- op->resolve = object_resolve_child_property;
- }
- g_free(link_type);
+ object_add_link_prop(obj, name, object_get_typename(target), target,
+ NULL, OBJ_PROP_LINK_DIRECT, errp);
}
gchar *object_get_canonical_path_component(Object *obj)