diff options
Diffstat (limited to 'qom/object.c')
-rw-r--r-- | qom/object.c | 41 |
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) |