Message ID | 1431352157-40283-12-git-send-email-pbonzini@redhat.com |
---|---|
State | New |
Headers | show |
On 05/11/15 15:48, Paolo Bonzini wrote: > Suggested-by: Eduardo Habkost <ehabkost@redhat.com> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > include/qom/object.h | 18 ++++++++++++++++++ > qom/object.c | 16 ++++++++++++++++ > 2 files changed, 34 insertions(+) > > diff --git a/include/qom/object.h b/include/qom/object.h > index d2d7748..0505f20 100644 > --- a/include/qom/object.h > +++ b/include/qom/object.h > @@ -1290,6 +1290,24 @@ void object_property_add_alias(Object *obj, const char *name, > Error **errp); > > /** > + * object_property_add_const_link: > + * @obj: the object to add a property to > + * @name: the name of the property > + * @target: the object to be referred by the link > + * @errp: if an error occurs, a pointer to an area to store the error > + * > + * Add an unmodifiable link for a property on an object. This function will > + * add a property of type link<TYPE> where TYPE is the type of @target. > + * > + * The caller must ensure that @target stays alive as long as > + * this property exists. In the case @target is a child of @obj, > + * this will be the case. Otherwise, the caller is responsible for > + * taking a reference. > + */ > +void object_property_add_const_link(Object *obj, const char *name, > + Object *target, Error **errp); > + > +/** > * object_property_set_description: > * @obj: the object owning the property > * @name: the name of the property > diff --git a/qom/object.c b/qom/object.c > index b8dff43..ba89518 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -1266,6 +1266,22 @@ out: > g_free(full_type); > } > > +void object_property_add_const_link(Object *obj, const char *name, > + Object *target, Error **errp) > +{ > + char *link_type; > + ObjectProperty *op; > + git-am complained about trailing whitespace on the line above. (Sorry that's all I can "contribute" now; I'll start using the series for developing OVMF further on.) Thanks Laszlo > + 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); > +} > + > gchar *object_get_canonical_path_component(Object *obj) > { > ObjectProperty *prop = NULL; >
Andreas, Eduardo, can you review and ack this one? On 11/05/2015 15:48, Paolo Bonzini wrote: > Suggested-by: Eduardo Habkost <ehabkost@redhat.com> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > include/qom/object.h | 18 ++++++++++++++++++ > qom/object.c | 16 ++++++++++++++++ > 2 files changed, 34 insertions(+) > > diff --git a/include/qom/object.h b/include/qom/object.h > index d2d7748..0505f20 100644 > --- a/include/qom/object.h > +++ b/include/qom/object.h > @@ -1290,6 +1290,24 @@ void object_property_add_alias(Object *obj, const char *name, > Error **errp); > > /** > + * object_property_add_const_link: > + * @obj: the object to add a property to > + * @name: the name of the property > + * @target: the object to be referred by the link > + * @errp: if an error occurs, a pointer to an area to store the error > + * > + * Add an unmodifiable link for a property on an object. This function will > + * add a property of type link<TYPE> where TYPE is the type of @target. > + * > + * The caller must ensure that @target stays alive as long as > + * this property exists. In the case @target is a child of @obj, > + * this will be the case. Otherwise, the caller is responsible for > + * taking a reference. > + */ > +void object_property_add_const_link(Object *obj, const char *name, > + Object *target, Error **errp); > + > +/** > * object_property_set_description: > * @obj: the object owning the property > * @name: the name of the property > diff --git a/qom/object.c b/qom/object.c > index b8dff43..ba89518 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -1266,6 +1266,22 @@ out: > g_free(full_type); > } > > +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); > +} > + > gchar *object_get_canonical_path_component(Object *obj) > { > ObjectProperty *prop = NULL; >
On Mon, May 11, 2015 at 03:48:57PM +0200, Paolo Bonzini wrote: > Suggested-by: Eduardo Habkost <ehabkost@redhat.com> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Assuming that the whitespace warning Laszlo pointed out will be fixed: Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Am 19.05.2015 um 21:14 schrieb Eduardo Habkost: > On Mon, May 11, 2015 at 03:48:57PM +0200, Paolo Bonzini wrote: >> Suggested-by: Eduardo Habkost <ehabkost@redhat.com> >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > > Assuming that the whitespace warning Laszlo pointed out will be fixed: > > Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Three spaces deleted and commit message extended, applied to qom-next: https://github.com/afaerber/qemu-cpu/commits/qom-next Thanks, Andreas
diff --git a/include/qom/object.h b/include/qom/object.h index d2d7748..0505f20 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1290,6 +1290,24 @@ void object_property_add_alias(Object *obj, const char *name, Error **errp); /** + * object_property_add_const_link: + * @obj: the object to add a property to + * @name: the name of the property + * @target: the object to be referred by the link + * @errp: if an error occurs, a pointer to an area to store the error + * + * Add an unmodifiable link for a property on an object. This function will + * add a property of type link<TYPE> where TYPE is the type of @target. + * + * The caller must ensure that @target stays alive as long as + * this property exists. In the case @target is a child of @obj, + * this will be the case. Otherwise, the caller is responsible for + * taking a reference. + */ +void object_property_add_const_link(Object *obj, const char *name, + Object *target, Error **errp); + +/** * object_property_set_description: * @obj: the object owning the property * @name: the name of the property diff --git a/qom/object.c b/qom/object.c index b8dff43..ba89518 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1266,6 +1266,22 @@ out: g_free(full_type); } +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); +} + gchar *object_get_canonical_path_component(Object *obj) { ObjectProperty *prop = NULL;
Suggested-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- include/qom/object.h | 18 ++++++++++++++++++ qom/object.c | 16 ++++++++++++++++ 2 files changed, 34 insertions(+)