> > > diff --git a/include/qom/object.h b/include/qom/object.h
> > > index 856b12e7289c..1b77429aa28b 100644
> > > --- a/include/qom/object.h
> > > +++ b/include/qom/object.h
> > > @@ -109,6 +109,30 @@ typedef enum {
> > > * will automatically add a getter and a setter to this property.
> > > */
> > > OBJ_PROP_FLAG_READWRITE = (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE),
> > > + /*
> > > + * The property was explicitly set by an external user.
> > > + *
> > > + * This flag is set whenever the property is modified via external
> > > interfaces
> > > + * (CLI, QMP, HMP). It allows internal code to distinguish whether
> > > the
> > > + * property has been modified by the user.
> > > + *
> > > + * Once set, this flag persists even if the property value is
> > > subsequently
> > > + * overwritten by internal logic. It is NOT automatically cleared
> > > and must
> > > + * be explicitly cleared using object_property_clear_flags().
> > > + */
> > > + OBJ_PROP_FLAG_USER_SET = BIT(2),
> > > + /*
> > > + * The property is deprecated and will be removed in the future
> > > version.
> > > + *
> > > + * Any setting to this property by the user will raise a deprecation
> > > warning.
> > > + */
> > > + OBJ_PROP_FLAG_DEPRECATED = BIT(3),
> > > + /*
> > > + * The property is internal only and cannot be set by the user.
> > > + *
> > > + * Any setting to this property by the user will raise an error.
> > > + */
> > > + OBJ_PROP_FLAG_INTERNAL = BIT(4),
> > > } ObjectPropertyFlags;
> >
> > I don't think this single enum design is very desirable, as it is mixing up
> > pieces of information with three distinct lifetimes / scopes.
In general, I treat all these flags as access control.
* OBJ_PROP_FLAD_{READ,WRITE,READWRITE} control read/write access -
though I haven't done anything else, and I don't recheck against these
flags when executing set/get accessors.
* OBJ_PROP_FLAG_{DEPRECATED,INTERNAL} are access restrictions for
external users, from warning to error.
The above flags are initialized at property initialization stage.
* OBJ_PROP_FLAG_USER_SET - is a dynamic flag, which is set only when
external user sets the property. It is used to check against
OBJ_PROP_FLAG_{DEPRECATED,INTERNAL}.
In previous RFC [*], I split OBJ_PROP_FLAD_{READ,WRITE,READWRITE} from
other flags. But I think since they're all property flags, splitting
them up would just make things more fragmented.
[*]:
https://lore.kernel.org/qemu-devel/[email protected]/
> > The OBJ_PROP_FLAD_{READ,WRITE,READWRITE} values are scoped to the execution
> > of the property adder methods.
> >
> > The OBJ_PROP_FLAG_{DEPRECATED,INTERNAL} values are scoped to the lifetime
> > of the class.
> >
> > The OBJ_PROP_FLAG_USER_SET value is scoped to the lifetime of the instance.
Hmm, I'm not sure about class/instance lifetime. All these flags are
attached to property and don't distinguish object class or object
instance.
* Both object_class_property_add_full() and object_property_add_full
could set flags.
* But there're only object_property_{get,check,set,clear}_flags, w/o
object_class level variants, since object_property_find() could
search property of both class & instance.
> In fact, with my comment on the later patch, OBJ_PROP_FLAG_DEPRECATED should
> not be modelled as a boolean flag at all. We need to record a const char*
> deprecation_note internally, so that warn_report can provide useful info
> to the user. We can turn that into a "bool deprecated" flag in the QAPI
> command response for querying properties.
Yes, I think that's good. If we could reach agreement on USER_SET at
least, I'll explore whether hints can be converted into QAPI flags,
since all of this ultimately relies on detecting user input.
In another point, the USER_SET detecting mechanism could be extended to
support several internal/deprecated mechanisms or features, so I think
it's useful...
Thanks,
Zhao