All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/8] qapi: add generator for Golang interface
@ 2022-04-01 22:40 Victor Toso
  2022-04-01 22:40 ` [RFC PATCH v1 1/8] qapi: golang: Generate qapi's enum types in Go Victor Toso
                   ` (10 more replies)
  0 siblings, 11 replies; 71+ messages in thread
From: Victor Toso @ 2022-04-01 22:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: John Snow, Eric Blake, Markus Armbruster

Hi,

Happy 1st April. Not a joke :) /* ugh, took me too long to send */

This series is about adding a generator in scripts/qapi to produce
Go data structures that can be used to communicate with QEMU over
QMP.


* Why Go?

There are quite a few Go projects that interact with QEMU over QMP
and they endup using a mix of different libraries with their own
code.


** Which projects?

The ones I've found so far:

- podman machine
  https://github.com/containers/podman/tree/main/pkg/machine/qemu

- kata-containers (govmm)
  https://github.com/kata-containers/kata-containers/tree/main/src/runtime/pkg/govmm

- lxd
  https://github.com/lxc/lxd/tree/master/lxd/instance/drivers

- kubevirt (plain json strings)
  https://github.com/kubevirt/kubevirt

(let me know if you know others)


* But Why?

I'm particularly interested in 3 out of 4 of the projects above and
only Kubevirt uses libvirt to handle QEMU. That means that every
QEMU releases where a QMP command, event or other data struct is
added, removed or changed, those projects need to check what changed
in QEMU and then address those changes in their projects, if needed.

The idea behind generating Go data structures is that we can keep a
Go module which can have releases that follow QEMU releases.

The project that uses this Go module, only need to bump the module
version and it shall receive all the changes in their own vendored
code base.


* Status

There are a few rough edges to work on but this is usable. The major
thing I forgot to add is handling Error from Commands. It'll be the
first thing I'll work on next week.

If you want to start using this Today you can fetch it in at

    https://gitlab.com/victortoso/qapi-go/

There are quite a few tests that I took from the examples in the
qapi schema. Coverage using go's cover tool is giving `28.6% of
statements`

I've uploaded the a static generated godoc output of the above Go
module here:

    https://fedorapeople.org/~victortoso/qapi-go/rfc/victortoso.com/qapi-go/pkg/qapi/


* License

While the generator (golang.py in this series) is GPL v2, the
generated code needs to be compatible with other Golang projects,
such as the ones mentioned above. My intention is to keep a Go
module with a MIT license.


* Disclaimer to reviewers

This is my first serious python project so there'll be lots of
suggetions that I'll be happy to take and learn from.


Thanks for taking a look, let me know if you have questions, ideas
or suggestions.

Cheers,
Victor

Victor Toso (8):
  qapi: golang: Generate qapi's enum types in Go
  qapi: golang: Generate qapi's alternate types in Go
  qapi: golang: Generate qapi's struct types in Go
  qapi: golang: Generate qapi's union types in Go
  qapi: golang: Generate qapi's event types in Go
  qapi: golang: Generate qapi's command types in Go
  qapi: golang: Add CommandResult type to Go
  qapi: golang: document skip function visit_array_types

 qapi/meson.build       |   1 +
 scripts/qapi/golang.py | 727 +++++++++++++++++++++++++++++++++++++++++
 scripts/qapi/main.py   |   2 +
 3 files changed, 730 insertions(+)
 create mode 100644 scripts/qapi/golang.py

-- 
2.35.1



^ permalink raw reply	[flat|nested] 71+ messages in thread

end of thread, other threads:[~2022-06-01 13:54 UTC | newest]

Thread overview: 71+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 22:40 [RFC PATCH v1 0/8] qapi: add generator for Golang interface Victor Toso
2022-04-01 22:40 ` [RFC PATCH v1 1/8] qapi: golang: Generate qapi's enum types in Go Victor Toso
2022-05-10 10:06   ` Daniel P. Berrangé
2022-05-10 11:15     ` Victor Toso
2022-05-10 11:19       ` Daniel P. Berrangé
2022-05-10 11:28         ` Victor Toso
2022-05-10 11:39           ` Daniel P. Berrangé
2022-04-01 22:40 ` [RFC PATCH v1 2/8] qapi: golang: Generate qapi's alternate " Victor Toso
2022-05-10 10:10   ` Daniel P. Berrangé
2022-05-10 11:21     ` Victor Toso
2022-05-10 11:28       ` Daniel P. Berrangé
2022-04-01 22:40 ` [RFC PATCH v1 3/8] qapi: golang: Generate qapi's struct " Victor Toso
2022-04-01 22:41 ` [RFC PATCH v1 4/8] qapi: golang: Generate qapi's union " Victor Toso
2022-05-10 10:26   ` Daniel P. Berrangé
2022-05-10 11:32     ` Victor Toso
2022-05-10 11:42       ` Daniel P. Berrangé
2022-04-01 22:41 ` [RFC PATCH v1 5/8] qapi: golang: Generate qapi's event " Victor Toso
2022-05-10 10:42   ` Daniel P. Berrangé
2022-05-10 11:38     ` Victor Toso
2022-04-01 22:41 ` [RFC PATCH v1 6/8] qapi: golang: Generate qapi's command " Victor Toso
2022-04-01 22:41 ` [RFC PATCH v1 7/8] qapi: golang: Add CommandResult type to Go Victor Toso
2022-04-01 22:41 ` [RFC PATCH v1 8/8] qapi: golang: document skip function visit_array_types Victor Toso
2022-04-19 18:12 ` [RFC PATCH v1 0/8] qapi: add generator for Golang interface Andrea Bolognani
2022-04-19 18:42   ` Andrea Bolognani
2022-04-28 13:50   ` Markus Armbruster
2022-04-29 13:15     ` Andrea Bolognani
2022-05-02  7:21       ` Markus Armbruster
2022-05-02  9:04         ` Andrea Bolognani
2022-05-02 11:46           ` Markus Armbruster
2022-05-02 14:01             ` Andrea Bolognani
2022-05-03  7:57               ` Markus Armbruster
2022-05-03  9:40                 ` Andrea Bolognani
2022-05-03 11:04                   ` Kevin Wolf
2022-05-10  9:55                   ` Daniel P. Berrangé
2022-05-11  6:15                   ` Markus Armbruster
2022-05-09 18:53               ` Victor Toso
2022-05-10  8:06                 ` Markus Armbruster
2022-05-10 11:48                   ` Victor Toso
2022-05-10  9:52               ` Daniel P. Berrangé
2022-05-10 15:25                 ` Andrea Bolognani
2022-05-11 13:45                 ` Markus Armbruster
2022-05-09 10:21   ` Victor Toso
2022-05-10 17:37     ` Andrea Bolognani
2022-05-10 18:02       ` Daniel P. Berrangé
2022-04-26 11:14 ` Markus Armbruster
2022-05-09 10:52   ` Victor Toso
2022-05-10  8:53   ` Daniel P. Berrangé
2022-05-10  9:06     ` Victor Toso
2022-05-10  9:17       ` Daniel P. Berrangé
2022-05-10  9:32         ` Daniel P. Berrangé
2022-05-10 10:50           ` Victor Toso
2022-05-10 10:57             ` Daniel P. Berrangé
2022-05-10 12:02     ` Markus Armbruster
2022-05-10 12:34       ` Daniel P. Berrangé
2022-05-10 12:51         ` Daniel P. Berrangé
2022-05-11 14:17           ` Markus Armbruster
2022-05-11 14:41             ` Daniel P. Berrangé
2022-05-11 15:38           ` Andrea Bolognani
2022-05-11 15:50             ` Daniel P. Berrangé
2022-05-11 16:22               ` Andrea Bolognani
2022-05-11 16:32                 ` Daniel P. Berrangé
2022-05-18  8:10               ` Victor Toso
2022-05-18  8:51                 ` Daniel P. Berrangé
2022-05-18  9:01                   ` Victor Toso
2022-05-11 14:17         ` Markus Armbruster
2022-05-18  8:55           ` Victor Toso
2022-05-18 12:30             ` Markus Armbruster
2022-05-25 13:49               ` Andrea Bolognani
2022-05-25 14:10                 ` Markus Armbruster
2022-06-01 13:53                 ` Victor Toso
2022-05-10 10:47 ` Daniel P. Berrangé

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.