From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWQIe-0006Es-MH for qemu-devel@nongnu.org; Tue, 23 Sep 2014 09:38:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XWQIZ-0002r6-SD for qemu-devel@nongnu.org; Tue, 23 Sep 2014 09:38:36 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:29358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWQIZ-0002pM-5p for qemu-devel@nongnu.org; Tue, 23 Sep 2014 09:38:31 -0400 From: "Gonglei (Arei)" Date: Tue, 23 Sep 2014 13:38:08 +0000 Message-ID: <33183CC9F5247A488A2544077AF1902086DD9F8E@SZXEMA503-MBS.china.huawei.com> References: <1411477717-6988-1-git-send-email-arei.gonglei@huawei.com> <1411477717-6988-5-git-send-email-arei.gonglei@huawei.com> In-Reply-To: <1411477717-6988-5-git-send-email-arei.gonglei@huawei.com> Content-Language: zh-CN Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 4/7] qom: add description field in ObjectProperty struct List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Gonglei (Arei)" , "qemu-devel@nongnu.org" Cc: "Huangweidong (C)" , "aliguori@amazon.com" , "mst@redhat.com" , "armbru@redhat.com" , Luonengjun , "Huangpeng (Peter)" , "lcapitulino@redhat.com" , "stefanha@redhat.com" , "pbonzini@redhat.com" , "afaerber@suse.de" > Subject: [PATCH 4/7] qom: add description field in ObjectProperty struct >=20 > From: Gonglei >=20 > The descriptions can serve as documentation in the code, > and they can be used to provide better help. >=20 > Cc: Paolo Bonzini > Cc: Michael S. Tsirkin > Cc: Markus Armbruster > Signed-off-by: Gonglei > --- > include/qom/object.h | 15 +++++++++++++++ > qom/object.c | 12 ++++++++++++ > 2 files changed, 27 insertions(+) >=20 > 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); >=20 > + > +/** > + * 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); > } >=20 > +void object_property_set_description(Object *obj, const char *name, > + const char *description, Error > **errp) > +{ > + ObjectProperty *op; > + > + op =3D object_property_find(obj, name, errp); > + if (!op) { > + return; > + } > + op->description =3D 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 >=20 Oops, I forgot free op->description in object_property_del_all(), Will fix it in next version. Best regards, -Gonglei