On Fri, Jun 05, 2026 at 09:43:28AM +0100, Daniel P. Berrangé wrote: > On Thu, Jun 04, 2026 at 07:11:17PM -0400, Peter Xu wrote: > > Firstly, qdev_class_add_property() function almost has nothing to do with > > DeviceClass, it's a bridge between Property and object properties. > > > > Change the 1st parameter of it, so that it can be used without DeviceClass > > context at all. When at it, remove the "name" field because it's always > > prop->name. > > > > Export it for non-qdev use cases. > > > > Signed-off-by: Peter Xu <[email protected]> > > --- > > include/hw/core/qdev-properties.h | 10 ++++++++++ > > hw/core/qdev-properties.c | 7 +++---- > > 2 files changed, 13 insertions(+), 4 deletions(-) > > > > diff --git a/include/hw/core/qdev-properties.h > > b/include/hw/core/qdev-properties.h > > index 779acb31b6..fec2aaac4d 100644 > > --- a/include/hw/core/qdev-properties.h > > +++ b/include/hw/core/qdev-properties.h > > @@ -283,6 +283,16 @@ void error_set_from_qdev_prop_error(Error **errp, int > > ret, Object *obj, > > */ > > void qdev_property_add_static(DeviceState *dev, const Property *prop); > > > > +/** > > + * object_class_add_property: > > + * @oc: Object class to operate on. > > + * @prop: The qdev property definition. > > + * > > + * Add a Property to @oc. This is the bridge to convert a Property into > > + * an object class property (as in ObjectClass.properties). > > + */ > > +void object_class_add_property(ObjectClass *oc, const Property *prop); > > I'm really not a fan of this. > > Having both object_class_add_property and object_class_property_add > methods is horrendous naming. > > Methods named with an "object_class_" prefix must live in qom/object.c & > include/qom/object.h not in qdev. If doing that though, then the entire > "Property" concept would need to live in QOM code too, but I don't think > that is either desirable or neccessary. > > AFAICT, the MigrationState class init method could just call the > existing object_class_property_add methods as any other non-qdev > Object impl does.
I think I somehow missed the fact that qom does actually support setters/getters for some default types too.. with default val API: object_property_add_uint64_ptr() object_property_set_default_uint() ... I'll give it a shot. -- Peter Xu
