> Subject: [PATCH 4/7] qom: add description field in ObjectProperty struct > > From: Gonglei <arei.gong...@huawei.com> > > The descriptions can serve as documentation in the code, > and they can be used to provide better help. > > Cc: Paolo Bonzini <pbonz...@redhat.com> > Cc: Michael S. Tsirkin <m...@redhat.com> > Cc: Markus Armbruster <arm...@redhat.com> > Signed-off-by: Gonglei <arei.gong...@huawei.com> > --- > include/qom/object.h | 15 +++++++++++++++ > qom/object.c | 12 ++++++++++++ > 2 files changed, 27 insertions(+) > > diff --git a/include/qom/object.h b/include/qom/object.h > index 8a05a81..ddc600d 100644 > --- a/include/qom/object.h > +++ b/include/qom/object.h > @@ -338,6 +338,7 @@ typedef struct ObjectProperty > { > gchar *name; > gchar *type; > + gchar *description; > ObjectPropertyAccessor *get; > ObjectPropertyAccessor *set; > ObjectPropertyResolve *resolve; > @@ -1274,6 +1275,20 @@ void object_property_add_alias(Object *obj, const > char *name, > Object *target_obj, const char > *target_name, > Error **errp); > > + > +/** > + * object_property_set_description: > + * @obj: the object to set a property's description to > + * @name: the name of the property > + * @description: the description of the property on the object > + * @errp: if an error occurs, a pointer to an area to store the error > + * > + * Set an object property's description. > + * > + */ > +void object_property_set_description(Object *obj, const char *name, > + const char *description, Error > **errp); > + > /** > * object_child_foreach: > * @obj: the object whose children will be navigated > diff --git a/qom/object.c b/qom/object.c > index 81542fb..b889db3 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -1676,6 +1676,18 @@ out: > g_free(prop_type); > } > > +void object_property_set_description(Object *obj, const char *name, > + const char *description, Error > **errp) > +{ > + ObjectProperty *op; > + > + op = object_property_find(obj, name, errp); > + if (!op) { > + return; > + } > + op->description = description ? g_strdup(description) : NULL; > +} > + > static void object_instance_init(Object *obj) > { > object_property_add_str(obj, "type", qdev_get_type, NULL, NULL); > -- > 1.7.12.4 >
Oops, I forgot free op->description in object_property_del_all(), Will fix it in next version. Best regards, -Gonglei