From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Victor Toso <victortoso@redhat.com>
Cc: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
John Snow <jsnow@redhat.com>
Subject: Re: [PATCH v1 0/9] qapi-go: add generator for Golang interface
Date: Thu, 28 Sep 2023 14:40:27 +0100 [thread overview]
Message-ID: <ZRWCSzrqDojlPOO4@redhat.com> (raw)
In-Reply-To: <20230927112544.85011-1-victortoso@redhat.com>
On Wed, Sep 27, 2023 at 01:25:35PM +0200, Victor Toso wrote:
> Hi, long time no see!
>
> This patch series intent is to introduce a generator that produces a Go
> module for Go applications to interact over QMP with QEMU.
snip
> Victor Toso (9):
> 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: structs: Address 'null' members
> 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
> docs: add notes on Golang code generator
>
> docs/devel/qapi-golang-code-gen.rst | 341 +++++++++
> scripts/qapi/golang.py | 1047 +++++++++++++++++++++++++++
> scripts/qapi/main.py | 2 +
> 3 files changed, 1390 insertions(+)
> create mode 100644 docs/devel/qapi-golang-code-gen.rst
> create mode 100644 scripts/qapi/golang.py
So the formatting of the code is kinda all over the place eg
func (s *StrOrNull) ToAnyOrAbsent() (any, bool) {
if s != nil {
if s.IsNull {
return nil, false
} else if s.S != nil {
return *s.S, false
}
}
return nil, true
}
ought to be
func (s *StrOrNull) ToAnyOrAbsent() (any, bool) {
if s != nil {
if s.IsNull {
return nil, false
} else if s.S != nil {
return *s.S, false
}
}
return nil, true
}
I'd say we should add a 'make check-go' target, wired into 'make check'
that runs 'go fmt' on the generated code to validate that we generated
correct code. Then fix the generator to actually emit the reqired
format.
Having said that, this brings up the question of how we expect apps to
consume the Go code. Generally an app would expect to just add the
module to their go.mod file, and have the toolchain download it on
the fly during build.
If we assume a go namespace under qemu.org, we'll want one or more
modules. Either we have one module, containing APIs for all of QEMU,
QGA, and QSD, or we have separate go modules for each. I'd probably
tend towards the latter, since it means we can version them separately
which might be useful if we're willing to break API in one of them,
but not the others.
IOW, integrating this directly into qemu.git as a build time output
is not desirable in this conext though, as 'go build' can't consume
that.
IOW, it would push towards
go-qemu.git
go-qga.git
go-qsd.git
and at time of each QEMU release, we would need to invoke the code
generator, and store its output in the respective git modules.
This would also need the generator application to be a standalone
tool, separate from the C QAPI generator.
Finally Go apps would want to do
import (
qemu.org/go/qemu
qemu.org/go/qga
qemu.org/go/gsd
)
and would need us to create the "https://qemu.org/go/qemu" page
containing dummy HTML content with
<meta name="go-import" content="qemu.org/go/qemu git https://gitlab.com/qemu-project/go-qemu.git@/>
and likewise for the other modules.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2023-09-28 13:41 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 11:25 [PATCH v1 0/9] qapi-go: add generator for Golang interface Victor Toso
2023-09-27 11:25 ` [PATCH v1 1/9] qapi: golang: Generate qapi's enum types in Go Victor Toso
2023-09-28 13:52 ` Daniel P. Berrangé
2023-09-28 14:20 ` Markus Armbruster
2023-09-28 14:34 ` Daniel P. Berrangé
2023-09-29 12:07 ` Victor Toso
2023-10-02 19:07 ` John Snow
2023-10-02 20:09 ` John Snow
2023-10-04 12:43 ` Victor Toso
2023-10-04 16:23 ` John Snow
2023-10-04 12:28 ` Victor Toso
2023-09-27 11:25 ` [PATCH v1 2/9] qapi: golang: Generate qapi's alternate " Victor Toso
2023-09-28 14:51 ` Daniel P. Berrangé
2023-09-29 12:23 ` Victor Toso
2023-09-29 12:37 ` Daniel P. Berrangé
2023-10-02 21:48 ` John Snow
2023-10-04 17:01 ` Victor Toso
2023-10-02 20:36 ` John Snow
2023-10-04 16:46 ` Victor Toso
2023-09-27 11:25 ` [PATCH v1 3/9] qapi: golang: Generate qapi's struct " Victor Toso
2023-09-28 14:06 ` Daniel P. Berrangé
2023-09-29 13:29 ` Victor Toso
2023-09-29 13:33 ` Daniel P. Berrangé
2023-09-27 11:25 ` [PATCH v1 4/9] qapi: golang: structs: Address 'null' members Victor Toso
2023-09-27 11:25 ` [PATCH v1 5/9] qapi: golang: Generate qapi's union types in Go Victor Toso
2023-09-28 14:21 ` Daniel P. Berrangé
2023-09-29 13:41 ` Victor Toso
2023-10-11 13:27 ` Victor Toso
2023-09-27 11:25 ` [PATCH v1 6/9] qapi: golang: Generate qapi's event " Victor Toso
2023-09-27 11:25 ` [PATCH v1 7/9] qapi: golang: Generate qapi's command " Victor Toso
2023-09-28 14:32 ` Daniel P. Berrangé
2023-09-29 13:53 ` Victor Toso
2023-10-14 14:26 ` Victor Toso
2023-09-27 11:25 ` [PATCH v1 8/9] qapi: golang: Add CommandResult type to Go Victor Toso
2023-09-28 15:03 ` Daniel P. Berrangé
2023-09-29 13:55 ` Victor Toso
2023-09-27 11:25 ` [PATCH v1 9/9] docs: add notes on Golang code generator Victor Toso
2023-09-28 13:22 ` Daniel P. Berrangé
2023-09-29 12:00 ` Victor Toso
2023-09-27 11:38 ` [PATCH v1 0/9] qapi-go: add generator for Golang interface Victor Toso
2023-09-28 13:40 ` Daniel P. Berrangé [this message]
2023-09-28 13:54 ` Daniel P. Berrangé
2023-09-29 14:08 ` Victor Toso
2023-09-29 14:17 ` Victor Toso
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=ZRWCSzrqDojlPOO4@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=jsnow@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=victortoso@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).