From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYvrb-0006Ro-Vs for qemu-devel@nongnu.org; Tue, 30 Sep 2014 07:45:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XYvrX-0001Io-3m for qemu-devel@nongnu.org; Tue, 30 Sep 2014 07:45:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2464) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYvrW-0001IS-SN for qemu-devel@nongnu.org; Tue, 30 Sep 2014 07:44:59 -0400 Date: Tue, 30 Sep 2014 14:48:13 +0300 From: "Michael S. Tsirkin" Message-ID: <20140930114813.GH7089@redhat.com> References: <1412046159-5144-1-git-send-email-arei.gonglei@huawei.com> <1412046159-5144-3-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1412046159-5144-3-git-send-email-arei.gonglei@huawei.com> Subject: Re: [Qemu-devel] [PATCH v4 2/5] qom: add description field in ObjectProperty struct List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com Cc: weidong.huang@huawei.com, aliguori@amazon.com, armbru@redhat.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com, afaerber@suse.de On Tue, Sep 30, 2014 at 11:02:36AM +0800, arei.gonglei@huawei.com wrote: > From: Gonglei > > The descriptions can serve as documentation in the code, > and they can be used to provide better help. > > When we call object_property_add_alias() adding alias properties to > the source object on the target Object, set the object property's > description to the source object property's. I think by the above you mean "Copy property descriptions when copying alias properties"? > Cc: Paolo Bonzini > Cc: Michael S. Tsirkin > Cc: Markus Armbruster > Signed-off-by: Gonglei > --- > include/qom/object.h | 15 +++++++++++++++ > qom/object.c | 20 ++++++++++++++++++++ > 2 files changed, 35 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); > > + Avoid duplicate empty lines please. > +/** > + * object_property_set_description: > + * @obj: the object to set a property's description to do you mean "the object owning the property"? > + * @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 575291f..a751367 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -369,6 +369,7 @@ static void object_property_del_all(Object *obj) > > g_free(prop->name); > g_free(prop->type); > + g_free(prop->description); > g_free(prop); > } > } > @@ -803,6 +804,7 @@ void object_property_del(Object *obj, const char *name, Error **errp) > > g_free(prop->name); > g_free(prop->type); > + g_free(prop->description); > g_free(prop); > } > > @@ -1672,10 +1674,28 @@ void object_property_add_alias(Object *obj, const char *name, > } > op->resolve = property_resolve_alias; > > + object_property_set_description(obj, name, > + target_prop->description, > + &error_abort); > + > 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; > + } > + > + g_free(op->description); > + op->description = g_strdup(description); > +} > + > static void object_instance_init(Object *obj) > { > object_property_add_str(obj, "type", qdev_get_type, NULL, NULL); > -- > 2.0.4 >