The new callback will be used in following "object: add object_property_set_defaut_{bool,str,int,uint}()" and "vl: print default value in object help" patches.
Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- include/qom/object.h | 17 +++++++++++++++++ qom/object.c | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index 29f47d3b35..ca47308ac4 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -367,6 +367,13 @@ typedef void (ObjectPropertyRelease)(Object *obj, */ typedef void (ObjectPropertyInit)(Object *obj, ObjectProperty *prop); +/** + * ObjectPropertyGetDefault: + * + * Get an allocated string representation of the default value. + */ +typedef char *(ObjectPropertyGetDefault)(ObjectProperty *prop); + struct ObjectProperty { gchar *name; @@ -377,6 +384,7 @@ struct ObjectProperty ObjectPropertyResolve *resolve; ObjectPropertyRelease *release; ObjectPropertyInit *init; + ObjectPropertyGetDefault *get_default; void *opaque; }; @@ -1233,6 +1241,15 @@ bool object_property_get_bool(Object *obj, const char *name, void object_property_set_int(Object *obj, int64_t value, const char *name, Error **errp); +/** + * object_property_get_defaut: + * @prop: the property to get default value + * + * Return an allocated string that represents the default property + * value or NULL. + */ +char *object_property_get_default(ObjectProperty *prop); + /** * object_property_get_int: * @obj: the object diff --git a/qom/object.c b/qom/object.c index 1e9113bfc8..b319db4ac6 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1429,6 +1429,15 @@ int64_t object_property_get_int(Object *obj, const char *name, return retval; } +char *object_property_get_default(ObjectProperty *prop) +{ + if (!prop->get_default) { + return NULL; + } + + return prop->get_default(prop); +} + void object_property_set_uint(Object *obj, uint64_t value, const char *name, Error **errp) { -- 2.25.0.rc1.20.g2443f3f80d.dirty