Skip to content

RFC QOM/QAPI integration part 1

Kevin Wolf qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest12 patches 24 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12qapi: Add visit_next_struct_member()include/qapi/visitor-impl.h include/qapi/visitor.h qapi/qapi-visit-core.c +2 more+28 -00 replies
2/12qom: Create object_configure()qom/object_interfaces.c+6 -72 replies
3/12qom: Make object_configure() publicinclude/qom/object.h qom/object.c qom/object_interfaces.c+20 -170 replies
4/12qom: Add instance_config() to TypeInfoinclude/qom/object.h qom/object.c+19 -00 replies
5/12rng-random: Implement .instance_configbackends/rng-random.c+17 -100 replies
6/12rng-backend: Implement .instance_configbackends/rng.c+25 -60 replies
7/12qapi: Allow defining QOM classesscripts/qapi/expr.py scripts/qapi/schema.py+93 -12 replies
8/12qapi: Create qom-config:... type for classesscripts/qapi/schema.py+50 -102 replies
9/12qapi/qom: Convert rng-backend/random to classqapi/qom.json+16 -62 replies
10/12qapi: Generate QOM config marshalling codebackends/rng-random.c backends/rng.c qapi/meson.build +2 more+104 -262 replies
11/12qapi/qom: Add class definition for rng-builtinqapi/qom.json+11 -10 replies
12/12qapi/qom: Add class definition for rng-egdbackends/rng-egd.c qapi/qom.json+13 -170 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 00/12] QOM/QAPI integration part 1

This series adds QOM class definitions to the QAPI schema, introduces a new TypeInfo.instance_config() callback that configures the object at creation time (instead of setting properties individually) and is separate from runtime property setters (which often used to be not really tested for runtime use), and finally generates a marshalling function for .instance_config() from the QAPI schema that makes this a natural C interface rather than a visitor based one.

This is loosely based on Paolo's old proposal in the wiki:
https://wiki.qemu.org/Features/QOM-QAPI_integration

The series is in a rather early stage and I don't really have any automated tests or documentation in this series yet. I'm also only converting the class hierarchy for the random number generator backends to show what the result looks like, the other objects still need to be done.

So the question to you isn't whether this is mergeable (it isn't), but whether you think this is the right approach for starting to integrate QOM and QAPI better.

You'll also see that this doesn't really remove the duplication between property definitions in the code and configuration struct definitions in the QAPI schema yet (because we want to keep at least a read-only runtime property for every configuration option), but at least they mean somewhat different things now (creation vs. runtime) instead of being completely redundant.

Possible future steps:

* Define at least those properties to the schema that correspond to a config option. For both setters and getters for each option, we'll probably want to select in the schema between 'not available', 'automatically generated function' and 'manually implemented'.

Other runtime properties could be either left in the code or added to the schema as well. Either way, we need to figure out how to best describe these things in the schema.

* Getting rid of the big 'object-add' union: While the union is not too bad for the rather small number of user-creatable objects, it wouldn't scale at all for devices.

My idea there is that we could define something like this:

{ 'struct': 'ObjectOptions',

    'data': {
        'id': 'str',
        'config': { 'type': 'qom-config-any:user-creatable',
                    'embed': true } } }

Obviously this would be an extension of the schema language to add an 'embed' option (another hopefully more acceptable attempt to flatten things...), so I'd like to hear opinions on this first before I go to implement it.

Also note that 'qom-config-any:user-creatable' is new, too. The 'qom-config:...' types introduced by this series don't work for subclasses, but only for the exact class.

On the external interface, the new 'qom-config-any:...' type including subclasses would basically behave (and be introspected) like the union we have today, just without being defined explicitly.

As for the C representation for configurations that include subclasses, I'm imagining a struct that just contains the qom_type string (so we can call the right handler) and a pointer to the real config (that is treated as opaque by the generic code).

I could probably add more, but let's just start with this for discussion now.

Kevin Wolf (12):
qapi: Add visit_next_struct_member()
qom: Create object_configure()
qom: Make object_configure() public
qom: Add instance_config() to TypeInfo
rng-random: Implement .instance_config
rng-backend: Implement .instance_config
qapi: Allow defining QOM classes
qapi: Create qom-config:... type for classes
qapi/qom: Convert rng-backend/random to class
qapi: Generate QOM config marshalling code
qapi/qom: Add class definition for rng-builtin
qapi/qom: Add class definition for rng-egd

 qapi/qom.json                |  46 ++++++++++-----
 include/qapi/visitor-impl.h  |   3 +
 include/qapi/visitor.h       |   2 +
 include/qom/object.h         |   7 +++
 backends/rng-egd.c           |  18 +++---
 backends/rng-random.c        |  18 +++---
 backends/rng.c               |  22 ++++++--
 qapi/qapi-visit-core.c       |   6 ++
 qapi/qobject-input-visitor.c |  16 ++++++
 qom/object.c                 |  32 +++++++++++
 qom/object_interfaces.c      |  22 +-------
 scripts/qapi/expr.py         |  28 ++++++++-
 scripts/qapi/main.py         |   2 +
 scripts/qapi/qom.py          |  91 ++++++++++++++++++++++++++++++
 scripts/qapi/schema.py       | 106 +++++++++++++++++++++++++++++++++++
 qapi/meson.build             |   3 +
 qapi/trace-events            |   1 +
 17 files changed, 362 insertions(+), 61 deletions(-)
 create mode 100644 scripts/qapi/qom.py
Signature · 1 line
2.31.1