qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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>,
	Andrea Bolognani <abologna@redhat.com>
Subject: Re: [PATCH v4 00/11]
Date: Mon, 17 Feb 2025 13:13:06 +0000	[thread overview]
Message-ID: <Z7M14rif3RGFOXbM@redhat.com> (raw)
In-Reply-To: <20250214202944.69897-1-victortoso@redhat.com>

On Fri, Feb 14, 2025 at 09:29:33PM +0100, Victor Toso wrote:
> Hi again,
> 
> This patch series intent is to introduce a generator that produces a Go
> module for Go applications to interact over QMP with QEMU.
> 
> Previous version (10 Jan 2025)
>     https://lists.gnu.org/archive/html/qemu-devel/2025-01/msg01530.html
> 
> The generated code was mostly tested using existing examples in the QAPI
> documentation, 192 instances that might have multiple QMP messages each.

snip

> 1. Daniel wrote a demo on top of v3 and proposed changes that would
>    result in more interesting module to build on top:
>    https://lists.gnu.org/archive/html/qemu-devel/2025-01/msg03052.html
>    
>    I've implemented all the suggestions that are relevant for this
>    introductory series, they are:
> 
>   a. New struct type Message, that shall be used for a 1st level
>      unmarshalling of the JSON message.
>   b. Removal of Marshal/Unmarshal code in both Events and Comands,
>      together with utility code that is not relevant anymore.
>   c. Declaration of 3 new interfaces:
>     i.   Events
>     ii.  Commands
>     iii. CommandsAsync
> 
> 2. I've moved the code to a new folder: scripts/qapi/golang. This
>    allowed me to move templates out of golang.py, keeping go related
>    code self-contained in the new directory.

When I think about the code generator and how this will all
evolve over time, I have a strong feeling that none of this
should be in qemu.git.

Taking those three interfaces in (1)(c), when we come to actually
generate implementations of them, the generated code is going to
be intimately tied to the client/server API framework we need to
plumb into.

IMHO qemu.git should not have any knowledge of this, as it will
create a bidirectional dependency betweeen qemu.git and the
qemu-go.git repo, requiring them to evolve in lockstep.

We'll need 3 releases of the Go code per year, to match the
introduction the new QAPI schema versions, but outside that I
think there ought to be the freedom to have other Go releases
independently.

The need for this to be part of qemu.git is fairly narrow. It
provides a new hook into the QAPI generator code, and the QAPI
generator is not installed by 'make install', it is in-tree
only.

Can we solve this linkage ? We would need to be able to:

 * Have a mechanism for the QAPI code generator to load
   new genrator backends
 * Have a mechanism to tell the QAPI code generator to
   only run a single backend.
 * Have a mechanism to consume the QAPI code genrfator
   from outside qemu.git

The first point there could be addressable using the python "entry-points"
concept

  https://packaging.python.org/en/latest/specifications/entry-points/
  https://setuptools.pypa.io/en/latest/pkg_resources.html#entry-points

Or, alternatively by passing the name of a python module on the CLI.

The second point is just a bit of glue code to wire up a new CLI arg

The third point either involves having 'make install' put the QAPI
code generator into /usr/share/qemu, or /usr/lib/python3.x. The
latter would be if QAPI code generator were a formally release python
module on pypi. The former would be if we're just trying a QAPI code
generator as a local tool, not for pypi. A fallback would be to
consume qemu.git as a git submodule from qapi-go.git. The gitmodule
commit would not have to match the version of the QAPI schema we are
generating code for.

The least effort approach would be making QAPI code genrator accept
a python module name, and call it via a git submodule. This would
avoid declaring a long term support policy for the QAPI code gen
python APIs as a blocker.

> 
> 3. As mentioned in (2), created protocol.go and utils.go that are 100%
>    hand generated Go code. Message mentioned in (1a) is under
>    protocol.go
> 
> 4. Defined license using SPDX-License-Identifier.
>   a. Every Go source code written by hand is 100% MIT-0
>   b. Every Go source code generated is dual licensed as MIT-0 and
>      GPL-2.0-or-later
>   c. The binary code is expected to be MIT-0 only but not really
>      relevant for this series.
> 
>   If you want more information, please check the thread:
>   https://lists.gnu.org/archive/html/qemu-devel/2024-11/msg01621.html
> 
> 5. I've renamed the generated files.
>   a. Any type related file is now prefixed with "gen_type_"
>   b. Any interface related file is prefixed as "gen_iface_"
> 
> 6. Relevant changes were made to the doc but it is not complete. I plan
>    that follow-up proposals would add to the documentation.
> 
> 7. Improvements to the generator were made to.
> 
> 8. Also worth to mention that resulting generated code does not have any
>    diff with gofmt and goimport tools, as requested in the past.

With 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 :|



  parent reply	other threads:[~2025-02-17 13:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-14 20:29 [PATCH v4 00/11] Victor Toso
2025-02-14 20:29 ` [PATCH v4 01/11] qapi: golang: first level unmarshalling type Victor Toso
2025-02-14 20:29 ` [PATCH v4 02/11] qapi: golang: Generate enum type Victor Toso
2025-02-14 20:29 ` [PATCH v4 03/11] qapi: golang: Generate alternate types Victor Toso
2025-02-14 20:29 ` [PATCH v4 04/11] qapi: golang: Generate struct types Victor Toso
2025-02-14 20:29 ` [PATCH v4 05/11] qapi: golang: structs: Address nullable members Victor Toso
2025-02-14 20:29 ` [PATCH v4 06/11] qapi: golang: Generate union type Victor Toso
2025-02-14 20:29 ` [PATCH v4 07/11] qapi: golang: Generate event type Victor Toso
2025-02-14 20:29 ` [PATCH v4 08/11] qapi: golang: Generate Event interface Victor Toso
2025-02-14 20:29 ` [PATCH v4 09/11] qapi: golang: Generate command type Victor Toso
2025-02-14 20:29 ` [PATCH v4 10/11] qapi: golang: Generate Command sync/async interfaces Victor Toso
2025-02-14 20:29 ` [PATCH v4 11/11] docs: add notes on Golang code generator Victor Toso
2025-02-17 13:13 ` Daniel P. Berrangé [this message]
2025-02-20  8:06   ` [PATCH v4 00/11] Markus Armbruster
2025-02-17 14:58 ` Daniel P. Berrangé
2025-02-17 16:52   ` Victor Toso
2025-03-07 11:25     ` Victor Toso
2025-03-07 11:33       ` Daniel P. Berrangé

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=Z7M14rif3RGFOXbM@redhat.com \
    --to=berrange@redhat.com \
    --cc=abologna@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).