qapi: pluggable backend code generators
authorDaniel P. Berrangé <berrange@redhat.com>
Mon, 24 Feb 2025 18:20:30 +0000 (18:20 +0000)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 4 Mar 2025 07:02:29 +0000 (08:02 +0100)
commitdde279925c97b614e45351400bfcf9efaf732f9d
treebece213f1da14a5e25050742524c0bae64ccc65a
parent5e4c466e6ad7d79ef5492b13deb110bb5e90d7c0
qapi: pluggable backend code generators

The 'qapi.backend.QAPIBackend' class defines an API contract for code
generators. The current generator is put into a new class
'qapi.backend.QAPICBackend' and made to be the default impl.

A custom generator can be requested using the '-k' arg which takes a
fully qualified python class name

   qapi-gen.py -B the.python.module.QAPIMyBackend

This allows out of tree code to use the QAPI generator infrastructure
to create new language bindings for QAPI schemas. This has the caveat
that the QAPI generator APIs are not guaranteed stable, so consumers
of this feature may have to update their code to be compatible with
future QEMU releases.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20250224182030.2089959-1-berrange@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Error checking and messages tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi/backend.py [new file with mode: 0644]
scripts/qapi/main.py