From: Markus Armbruster <armbru@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: marcandre.lureau@redhat.com, qemu-devel@nongnu.org,
Michael Roth <michael.roth@amd.com>,
John Snow <jsnow@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Eric Blake <eblake@redhat.com>
Subject: Re: ObjectPropertyInfo design
Date: Wed, 28 Oct 2026 14:39:08 +0100 [thread overview]
Message-ID: <87fqxqj66b.fsf@pond.sub.org> (raw)
In-Reply-To: <at-MMBGue0-1q5jG@redhat.com> ("Daniel P. Berrangé"'s message of "Mon, 26 Oct 2026 17:21:52 +0000")
Daniel P. Berrangé <berrange@redhat.com> writes:
> On Thu, Oct 22, 2026 at 04:04:44PM +0200, Markus Armbruster wrote:
>> Marc-André's series evolves ObjectPropertyInfo and ObjectPropertyValue:
>> it adds member @qapi-type and changes many values of member @type.
>>
>> I'd like to take a step back and discuss design. I trimmed Cc:
>> accordingly.
>>
>>
>> = The current interface
>>
>> qom-list returns information on an object's properties, one
>> ObjectPropertyInfo per property.
>>
>> qom-list-properties returns information on properties an instance of a
>> type is known to have[*], one ObjectPropertyInfo per property.
>
> This is
Yes?
>> qom-list-get returns information on the properties of several objects,
>> one ObjectPropertyValue per property.
>
> Since 'qom-list-properties' is really introspecting types, rather
> than instances, I'd add its companion:
>
> query-qmp-schema returns information on properties from
> user creatable QOM objects, via the ObjectOptions union
> which handles data of arbitary complexity and nesting,
> with strictly QAPI types only. Obviously missing QDev
> and other internal only types.
Yes. Ideally, it would cover everything, but QOM's design and the sheer
amount of QOM types and properties has kept that well out of reach. QOM
introspection filled the gap, but badly. Marc-André's work makes it
less bad.
>> * @description is rarely present (I see under 15% in a quick test). The
>> description text is commonly misleading for QMP. For instance, qdev
>> bool properties have description "on/off". The possible values are
>> actually JSON false and true.
>
> With query-qmp-schema we have a description for 100% of properties,
> enforced by the QAPI schema parser. Only applies to UserCreatable QOM
> objects though.
Yes.
QAPI schema doc comments are mandatory, and they get validated against
the schema code. They become the "QEMU QMP Reference Manual".
QOM property description strings are optional, and they are not checked
in any way. They are used in help intended for humans.
> I see descriptions as primarily a documentation thing for humans, and
> perhaps for machines which are trying to generate code frmo QAPI
> schema and want to use descriptions for docs. These are both static
> querying tasks.
>
> I don't see descriptions as useful for mgmt apps at runtime for
> deployed QEMus.
Noted.
>> * @default-value can be useful with qom-list-properties, which operates
>> on types. I doubt it is with qom-list, which operates on objects.
>
> Likewise, IMHO this is useful info statically, but not at runtime.
Noted.
>> Let's pretend @description doesn't exist, and @default-value exists only
>> with qom-list-properties.
>>
>> This makes qom-list-get strictly more powerful than qom-list, so let's
>> further pretend qom-list doesn't exist.
>>
>>
>> = Simplified interface for the sake of discussion
>>
>> qom-list-properties returns information on properties an instance of a
>> type is known to have[*]: @name, @type, and maybe @default-value.
>
> In the ideal world 'qom-list-properties' would not need to exist,
> but it has to for the forseeable future, since none of QDev is
> modelled in QAPI schema currently.
Yes.
>> qom-list-get returns information on the properties of several objects:
>> @name, @type, and maybe @value.
>>
>>
>> = The meaning of @type
>>
>> Three cases:
>>
>> 1. For a child property (created with object_property_add_child() etc.),
>> @type is "child<T>", where T is the child's QOM type.
>>
>> 2. For a link property (created with object_class_property_add_link()
>> etc.), @type is "link<T>", where T is the target's QOM type.
>>
>> 3. For other properties, @type can be anything. We commonly use QAPI
>> type names (occasionally misspelled), and also "well-known" (but
>> undocumented) non-QAPI names for primitive types. Every now and
>> then, developers get lazy and use values like "list", or creative and
>> use values like "guest statistics". Nobody has gotten sufficiently
>> masochistic to use values starting with "child<" or "link<" so far,
>> although nothing would stop that.
>>
>> Cases 1 and 2 go against the QAPI/QMP design maxim "don't encode stuff
>> in strings".
>
> They're not particular nice internally either as part of QDev/QOM.
> ie this is gross as a design approach:
>
> static inline bool object_property_is_child(ObjectProperty *prop)
> {
> return strstart(prop->type, "child<", NULL);
> }
I can top that!
/* Go from link<FOO> to FOO. */
type = object_property_get_type(obj, name, NULL);
target_type = g_strndup(&type[5], strlen(type) - 6);
>> Case 3 is is hard to use for anything. You're forced into stupid and
>> brittle hardcoding.
>>
>> Marc-André's work adds a new optional member @qapi_type that refers to a
>> QAPI type in the output of query-qmp-schema. It's present for a large
>> subset of case 3. When it's present, @type should not be used.
>>
>> It also cleans up many crap cases of 3, but without making it robust. I
>> understand this isn't something the series tries to do, it's just
>> something that's easier to do than not to do. If it creates
>> compatibility problems, we have to not do it. I hope it doesn't.
>>
>>
>> = Can we do better?
>>
>> What information are we trying to convey? Four cases:
>>
>> 1. Child property: the child's QOM type
>>
>> 2. Link property: the target's QOM type
>>
>> 3. QAPI-backed property: the property's QAPI type
>>
>> 4. Other property: we have nothing useful to offer
>>
>> Case 4 should go away eventually.
>>
>> How would we encode this in QAPI on a green field? With a union, of
>> course:
>>
>> { 'enum': 'ObjectPropertyKind',
>> 'data': [ 'child', 'link', 'qapi', 'other'] }
>>
>> { 'struct': 'ObjectPropertyInfoLink',
>> 'data': { 'qom-type': 'str' } }
>>
>> { 'struct': 'ObjectPropertyInfoQAPI',
>> 'data': { 'qapi-type': 'str' } }
>>
>> { 'union': 'ObjectProperty...',
>> 'base': { 'kind': 'ObjectPropertyKind',
>> ... more ... },
>> 'discriminator': 'kind',
>> 'data': {
>> 'child': 'ObjectPropertyInfoLink',
>> 'link': 'ObjectPropertyInfoLink',
>> 'qapi': 'ObjectPropertyInfoQAPI' } }
>>
>> To make this a compatible evolution of ObjectPropertyInfo, we need
>> ... more ... to be
>>
>> 'type': 'str',
>> '*description': 'str'
>> '*default-value': 'any',
>>
>> Sadly, we need to duplicate the union for ObjectPropertyValue. There,
>> ... more ... needs to be
>>
>> 'type': 'str',
>> '*value': 'any'
>>
>> We should deprecate @type. I'd also deprecate @description.
>>
>> Thoughts?
>
> We currently have
>
> { 'enum': 'ObjectType', .... }
>
> which provides a name in QMP schema for every QOM type that
> implements UserCreatable.
>
> We could relatively easily extend that to cover *all* QOM
> types in existance, with some judicous grepping of TypeInfo
> classes.
>
> It would be nice if we could enforce at runtime though that
> anything passed to type_register() was listed in 'ObjectType'
> enum to catch omissions. Not sure if there are any unexpected
> dragons if we make type_register() check the type name
> against 'ObjectType_lookup' from qapi-types-qom.h ?
Can't see why that wouldn't work.
We use strings instead of a C enum for type names, because a C enum
would be conflict magnet, and also a "recompile the world" header.
Strings weaken the type checker, and also risk typos. The #define
TYPE_FOO "foo" reduce that risk. Since we don't always use them, we
always have to grep both for TYPE_FOO and "foo".
If we enumerate all the type names in a QAPI enum, we generate such a C
enum, but use it only to check the strings. Still a conflict magnet,
but at least not a "recompile the world" header.
> Then your
>
>> { 'struct': 'ObjectPropertyInfoLink',
>> 'data': { 'qom-type': 'str' } }
>
> could at least reference 'ObjectType' instead of 'str'
Yes. There are a few more, e.g. CompatProperty member @qom-type.
> and be
> aligned more with query-qmp-schema.
What do you mean by that?
prev parent reply other threads:[~2026-10-28 13:39 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 10:45 [PATCH v7 00/65] Hi marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 01/65] qapi/schema: Rename .lookup_entity() and tighten return type marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 02/65] qapi: Ease access to introspection names marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 03/65] qapi/introspect: Simplify masked name comment emission slighly marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 04/65] qapi/introspect: Don't elide types marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 05/65] qapi: QAPISchemaVisitor.visit_needed() is now unused, drop marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 06/65] qapi/introspect: Tweak integer type masking marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 07/65] qapi: add QAPITypeInfo struct definition Marc-André Lureau
2026-10-23 8:39 ` Markus Armbruster
2026-10-20 10:45 ` [PATCH v7 08/65] qapi/gen: fix _module_basename for multi-dash 'what' parameters Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 09/65] qapi: add type-infos generator Marc-André Lureau
2026-10-23 13:47 ` Markus Armbruster
2026-10-23 13:47 ` Markus Armbruster via
2026-10-23 13:47 ` Markus Armbruster via
2026-10-23 13:47 ` Markus Armbruster via qemu development
2026-10-20 10:45 ` [PATCH v7 10/65] meson: add qapi-type-infos-*.c/h to build Marc-André Lureau
2026-10-23 10:54 ` Markus Armbruster
2026-10-20 10:45 ` [PATCH v7 11/65] qom: add qapi_type field to ObjectProperty Marc-André Lureau
2026-10-23 13:54 ` Markus Armbruster
2026-10-20 10:45 ` [PATCH v7 12/65] qapi/qom: add qapi-type field to ObjectPropertyInfo Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 13/65] qom/qmp: populate qapi-type in QMP handlers Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 14/65] qom/qmp: populate description & default-value in qom_property_info() Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 15/65] qom: add object_property_set_default_enum() Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 16/65] qom: add object_{class_}property_add_qapi Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 17/65] qom: add object_{class_}property_add_qapi_enum Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 18/65] tests: update check-qom-proplist for QAPI-aware property registration Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 19/65] qom: convert QAPI enum properties to QAPI-aware registration Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 20/65] qom: convert struct " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 21/65] x86: convert OnOffAuto " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 22/65] microvm: " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 23/65] pc: convert OnOffAuto vmport property " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 24/65] arm/virt: convert OnOffAuto acpi " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 25/65] riscv/virt: convert OnOffAuto properties " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 26/65] loongarch/virt: " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 27/65] hostmem-file: convert OnOffAuto rom property " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 28/65] sev: convert OnOffAuto legacy-vm-type " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 29/65] whpx: convert OnOffAuto hyperv " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 30/65] whpx: convert OnOffAuto arch properties " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 31/65] accel/kvm: convert OnOffSplit property " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 32/65] whpx: " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 33/65] hw/ppc/spapr_caps: fix property type name Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 34/65] ppc/spapr-caps: convert to QAPI-aware property registration Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 35/65] net/colo-compare: fix compare_timeout setter visitor type Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 36/65] net/colo-compare: fix max_queue_size " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 37/65] hw/misc/xlnx-versal-trng: add missing getter for fips-fault-events Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 38/65] qom: convert scalar properties to QAPI-aware registration Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 39/65] i386/cpu: convert strList property " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 40/65] accel/hvf: convert OnOffSplit " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 41/65] i386/x86: convert SgxEPCList " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 42/65] virtio-balloon: convert guest-stats property to QAPI type Marc-André Lureau
2026-10-20 12:59 ` Markus Armbruster
2026-10-20 10:46 ` [PATCH v7 43/65] qom: replace object_property_add_tm with StructTm " Marc-André Lureau
2026-10-20 13:25 ` Markus Armbruster
2026-10-20 10:46 ` [PATCH v7 44/65] hw/nvdimm: convert UUID property to QAPI-aware registration Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 45/65] hw/s390-virtio-ccw: convert loadparm " Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 46/65] hw/ppc/spapr_drc: convert fdt " Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 47/65] hw/s390x: convert BootCertificatesList " Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 48/65] hw/gpio/pca955x: use QAPI enums for led and pin properties Marc-André Lureau
2026-10-20 20:28 ` Miles Glenn
2026-10-20 10:46 ` [PATCH v7 49/65] include: add QEMU_REPEAT helper macro Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 50/65] hw/gpio/pca955x: convert pin/led property to QAPI-aware enum Marc-André Lureau
2026-10-20 20:41 ` Miles Glenn
2026-10-20 10:46 ` [PATCH v7 51/65] hw/pci: change the busnr type to uint8 Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 52/65] qdev: add qapi_type field to PropertyInfo with fallback registration Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 53/65] qdev: convert core PropertyInfo definitions to use qapi_type Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 54/65] qdev: adjust PciDevfn declared type Marc-André Lureau
2026-10-23 10:04 ` Daniel P. Berrangé
2026-10-23 11:39 ` Marc-André Lureau
2026-10-23 12:04 ` Michael S. Tsirkin
2026-10-27 14:54 ` Markus Armbruster
2026-10-27 15:08 ` Daniel P. Berrangé
2026-10-28 7:13 ` Markus Armbruster
2026-10-29 15:11 ` Daniel P. Berrangé
2026-10-20 10:46 ` [PATCH v7 55/65] qdev: convert system PropertyInfo definitions to use qapi_type Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 56/65] hw: convert device-local " Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 57/65] target/riscv: convert " Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 58/65] qdev: " Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 59/65] qdev: introduce typed array PropertyInfos Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 60/65] qdev: simplify DEFINE_PROP_ARRAY and remove generic array PropertyInfo Marc-André Lureau
2026-10-21 14:45 ` Markus Armbruster
2026-10-20 10:46 ` [PATCH v7 61/65] qdev: remove deprecated PropertyInfo.type and .enum_table fields Marc-André Lureau
2026-10-29 10:30 ` Markus Armbruster
2026-10-20 10:46 ` [PATCH v7 62/65] hw/i386: convert PCSouthBridgeOption to QAPI enum Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 63/65] qom: remove old enum property registration API Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 64/65] qom: use QAPITypeInfo in object_property_get_enum Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 65/65] tests/qmp-cmd-test: assert qapi-type resolves in query-qmp-schema Marc-André Lureau
2026-10-21 16:29 ` Property types changed in this series (was: [PATCH v7 00/65] Hi) Markus Armbruster
2026-10-22 6:49 ` Property types changed in this series Markus Armbruster
2026-10-22 8:29 ` Ján Tomko
2026-10-22 14:04 ` ObjectPropertyInfo design (was: [PATCH v7 00/65] Hi) Markus Armbruster
2026-10-23 12:52 ` Marc-André Lureau
2026-10-28 11:44 ` ObjectPropertyInfo design Markus Armbruster
2026-10-29 13:44 ` Markus Armbruster
2026-10-29 13:54 ` Marc-André Lureau
2026-10-26 17:21 ` ObjectPropertyInfo design (was: [PATCH v7 00/65] Hi) Daniel P. Berrangé
2026-10-28 13:39 ` Markus Armbruster [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fqxqj66b.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.