[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC V2 7/9] qom: add object_property_is_set
From: |
Marcel Apfelbaum |
Subject: |
Re: [Qemu-devel] [PATCH RFC V2 7/9] qom: add object_property_is_set |
Date: |
Mon, 03 Mar 2014 14:09:21 +0200 |
On Mon, 2014-03-03 at 11:13 +0100, Paolo Bonzini wrote:
> Il 02/03/2014 14:07, Marcel Apfelbaum ha scritto:
> > Sometimes is not enough to get property's value,
> > but it is needed to know if the value was actually set.
> >
> > This is especially useful when querying bool properties
> > and having different defaults on different scenarios.
> >
> > Signed-off-by: Marcel Apfelbaum <address@hidden>
>
> I suggested some replacements for this in the review to patch 8/9.
>
> The problem is that tristate properties implemented with
> object_property_is_set cannot be "round-trip"-ped out and back in of QEMU.
I understand, I will go with required/allowed getters.
Thanks,
Marcel
>
> Paolo
>
> > ---
> > include/qom/object.h | 11 +++++++++++
> > qom/object.c | 12 ++++++++++++
> > 2 files changed, 23 insertions(+)
> >
> > diff --git a/include/qom/object.h b/include/qom/object.h
> > index 9c7c361..4a4f026 100644
> > --- a/include/qom/object.h
> > +++ b/include/qom/object.h
> > @@ -319,6 +319,7 @@ typedef struct ObjectProperty
> > {
> > gchar *name;
> > gchar *type;
> > + bool is_set;
> > ObjectPropertyAccessor *get;
> > ObjectPropertyAccessor *set;
> > ObjectPropertyRelease *release;
> > @@ -931,6 +932,16 @@ void object_property_set(Object *obj, struct Visitor
> > *v, const char *name,
> > Error **errp);
> >
> > /**
> > + * object_property_is_set:
> > + * @obj: the object
> > + * @name: the name of the property
> > + * @errp: returns an error if this function fails
> > + *
> > + * Returns: true if object's property is set, false otherwise.
> > + */
> > +bool object_property_is_set(Object *obj, const char *name,
> > + Error **errp);
> > +/**
> > * object_property_parse:
> > * @obj: the object
> > * @string: the string that will be used to parse the property value.
> > diff --git a/qom/object.c b/qom/object.c
> > index 660859c..5b9d8af 100644
> > --- a/qom/object.c
> > +++ b/qom/object.c
> > @@ -817,9 +817,21 @@ void object_property_set(Object *obj, Visitor *v,
> > const char *name,
> > error_set(errp, QERR_PERMISSION_DENIED);
> > } else {
> > prop->set(obj, v, prop->opaque, name, errp);
> > + prop->is_set = true;
> > }
> > }
> >
> > +bool object_property_is_set(Object *obj, const char *name,
> > + Error **errp)
> > +{
> > + ObjectProperty *prop = object_property_find(obj, name, errp);
> > + if (prop == NULL) {
> > + return false;
> > + }
> > +
> > + return prop->is_set;
> > +}
> > +
> > void object_property_set_str(Object *obj, const char *value,
> > const char *name, Error **errp)
> > {
> >
>