On Thu, Nov 19, 2020 at 01:39:50PM +0100, Markus Armbruster wrote: > Eduardo Habkost <ehabk...@redhat.com> writes: > > > Based-on: 20201104160021.2342108-1-ehabk...@redhat.com > > Git branch: > > https://gitlab.com/ehabkost/qemu/-/commits/work/qdev-qlit-defaults > > > > This extend qlit.h to support all QNum types (signed int, > > unsigned int, and double), and use QLitObject to represent field > > property defaults. > > > > It allows us to get rid of most type-specific .set_default_value > > functions for QOM property types. > > What's left?
Enums. Enums properties are a mess to implement, and I plan to tackle them later. On all other cases, the external representation of the property value is similar to the internal representation. In the case of enums, the external representation is a string, but the internal representation is an integer. > > I'm asking because if you create a new way to get rid of most of an old > way, you're still left with two ways, which may or may not be an > improvement. I don't think this is an accurate description. We had five different ways of doing this[1]. I replaced four of them with the new qlit-based mechanism, and now we have two. [1] The five different ways were: qdev_propinfo_set_default_value_enum, qdev_propinfo_set_default_value_int, qdev_propinfo_set_default_value_uint, set_default_uuid_auto, and set_default_value_bool. > > Moving defaults from code to data sounds attractive to me. Data is > easier to reason about than code. For QAPI, we've been talking about > defining defaults in the schema for a long time, but nobody has gotten > around to finish an implementation. -- Eduardo