public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, armbru@redhat.com,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	qemu-rust@nongnu.org
Subject: Re: [PATCH v2 00/16] rust: QObject and QAPI bindings
Date: Mon, 23 Feb 2026 16:24:59 +0000	[thread overview]
Message-ID: <aZx_Wy1-eBsTEB1s@redhat.com> (raw)
In-Reply-To: <bedbf511-c46a-4468-bf65-cc452c621765@redhat.com>

On Mon, Feb 23, 2026 at 04:54:07PM +0100, Paolo Bonzini wrote:
> On 2/23/26 10:53, Daniel P. Berrangé wrote:
> > On Thu, Jan 08, 2026 at 02:10:27PM +0100, Paolo Bonzini wrote:
> > > This adds two related parts of the Rust bindings:
> > > 
> > > - QAPI code generator that creates Rust structs from the JSON
> > >    description.  The structs are *not* ABI compatible with the
> > >    C ones, instead they use native Rust data types.
> > > 
> > > - QObject bindings and (de)serialization support, which can be used to
> > >    convert QObjects to and from QAPI structs.
> > > 
> > > Unfortunately Rust code is not able to use visitors, other than by
> > > creating an intermediate QObject.  This is because of the different
> > > architecture of serde vs. QAPI visitors, and because visitor's
> > > dual-purpose functions, where the same function is used by both input and
> > > output visitors, rely heavily on the structs using the same representation
> > > as the visitor arguments (for example NUL-terminated strings).
> > > 
> > > The serde format implementation was co-authored by me and Marc-André.
> > > Marc-André did all the bug fixing and integration testing.
> > > 
> > > As an example of how this would be used, the marshaling functions for
> > > QMP commands would look like this:
> > 
> > Can you give more of the big picture about what follows this ?  From
> > this example you're showing, are you suggesting that you'll be soon
> > moving QMP command impls from C to Rust ?
> 
> The reasons for Marc-André and I to do this was just as an exploration. The
> patches show a different way to do what he had already tackled in 2022, and
> allow a direct comparison the relative benefits between a more Rust-focused
> approach and a more direct translation of QEMU's C code.
> 
> Marc-André indeed had command implementations in Rust and that would be an
> obvious next step to continue on the QAPI side.  On the other hand, the
> QObject part (without QAPI structs) also works as a step towards more QOM
> integration, especially with respect to properties and backends.  Having a
> full-blown QObject implementation to move around bools is perhaps
> over-engineered, but is also an easy way to make a generic implementation
> that works for all QAPI types.
> 
> The block layer also needs QAPI for option parsing, so Kevin's work on block
> layer bindings would also benefit from having this integration.
> 
> In other words, there is no real big picture from me other than "someone
> needs to do the hard part for others": QOM, QAPI and the build system are
> the three central components from which all other bindings branch out.  Zhao
> and Marc-André have helped a lot with this work, and they also showed how to
> use these hard parts (see Zhao's vm-memory work and Marc-André's GStreamer
> backend), now it's also time for others to try and to take inspiration from
> Rust for improving the C side of things.

I guess the thing I'm wondering about when I ask about the big picture
is to understand tne interoperability implications of this impl approach,
given the starting point that the Rust & C structs are *not* ABI compatible.


If we're anticipating that the Rust usage flows up from a Rust QMP command
handler, then the data is in the Rust struct right from the entry point
and perhaps the interoperability needs are reduced in scope.

If we're anticipating a calls back & forth between C & Rust code, that
directly handle the deserialized structs, then we have an open interop
question. Is the implication that we round-trip via JSON every time we
need to swap between a Rust struct and C struct for a given type ? Or
will we have a direct struct<->struct conversion mechanism ? Or is there
something else entirely ?

I feel a bit lost in how to evaluate this series without seeing some
real world usage, in a way that exposes the possible implications of
the lack of C/Rust ABI compat in the structs.

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



  reply	other threads:[~2026-02-23 16:25 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-08 13:10 [PATCH v2 00/16] rust: QObject and QAPI bindings Paolo Bonzini
2026-01-08 13:10 ` [PATCH v2 01/16] rust/qobject: add basic bindings Paolo Bonzini
2026-02-24 10:03   ` Markus Armbruster
2026-02-24 10:35     ` Paolo Bonzini
2026-02-24 13:33       ` Markus Armbruster
2026-02-25  8:05         ` Paolo Bonzini
2026-01-08 13:10 ` [PATCH v2 02/16] subprojects: add serde Paolo Bonzini
2026-01-08 13:10 ` [PATCH v2 03/16] rust/qobject: add Serialize implementation Paolo Bonzini
2026-02-24 10:29   ` Markus Armbruster
2026-02-24 10:48     ` Paolo Bonzini
2026-02-24 13:41       ` Markus Armbruster
2026-01-08 13:10 ` [PATCH v2 04/16] rust/qobject: add Serializer (to_qobject) implementation Paolo Bonzini
2026-01-08 13:10 ` [PATCH v2 05/16] rust/qobject: add Deserialize implementation Paolo Bonzini
2026-01-08 13:10 ` [PATCH v2 06/16] rust/qobject: add Deserializer (from_qobject) implementation Paolo Bonzini
2026-01-08 13:10 ` [PATCH v2 07/16] rust/qobject: add from/to JSON bindings for QObject Paolo Bonzini
2026-01-15 13:17   ` Zhao Liu
2026-01-08 13:10 ` [PATCH v2 08/16] rust/qobject: add Display/Debug Paolo Bonzini
2026-01-15 13:19   ` Zhao Liu
2026-01-08 13:10 ` [PATCH v2 09/16] scripts/qapi: add QAPISchemaIfCond.rsgen() Paolo Bonzini
2026-01-19  6:58   ` Zhao Liu
2026-02-25  6:48   ` Markus Armbruster
2026-02-25  7:53     ` Paolo Bonzini
2026-01-08 13:10 ` [PATCH v2 10/16] scripts/qapi: add QAPISchemaType.is_predefined Paolo Bonzini
2026-02-25  7:33   ` Markus Armbruster
2026-02-25  8:01     ` Paolo Bonzini
2026-02-25  8:44       ` Markus Armbruster
2026-02-26 14:12         ` Paolo Bonzini
2026-01-08 13:10 ` [PATCH v2 11/16] scripts/qapi: pull c_name from camel_to_upper to caller Paolo Bonzini
2026-01-19  7:05   ` Zhao Liu
2026-02-25  8:32   ` Markus Armbruster
2026-01-08 13:10 ` [PATCH v2 12/16] scripts/qapi: generate high-level Rust bindings Paolo Bonzini
2026-02-23 12:36   ` Markus Armbruster
2026-02-23 16:11     ` Paolo Bonzini
2026-02-24 13:46       ` Markus Armbruster
2026-02-25 14:39   ` Markus Armbruster
2026-03-03 10:00     ` Paolo Bonzini
2026-03-03 12:31       ` Markus Armbruster
2026-03-03 15:55         ` Paolo Bonzini
2026-03-04  8:09           ` Markus Armbruster
2026-03-03  9:19   ` Markus Armbruster
2026-03-03 13:17     ` Paolo Bonzini
2026-01-08 13:10 ` [PATCH v2 13/16] scripts/rustc_args: add --no-strict-cfg Paolo Bonzini
2026-01-08 13:10 ` [PATCH v2 14/16] rust/util: build QAPI types Paolo Bonzini
2026-01-08 13:10 ` [PATCH v2 15/16] scripts/qapi: add serde attributes Paolo Bonzini
2026-01-08 13:10 ` [PATCH v2 16/16] rust/tests: QAPI integration tests Paolo Bonzini
2026-02-17  8:10 ` [PATCH v2 00/16] rust: QObject and QAPI bindings Paolo Bonzini
2026-02-19 13:39 ` Markus Armbruster
2026-02-19 16:28   ` Paolo Bonzini
2026-02-23  9:53 ` Daniel P. Berrangé
2026-02-23 15:54   ` Paolo Bonzini
2026-02-23 16:24     ` Daniel P. Berrangé [this message]
2026-02-23 19:03       ` Paolo Bonzini
2026-02-24 14:06 ` Markus Armbruster
2026-02-24 17:28   ` Paolo Bonzini
2026-02-26 12:42     ` Markus Armbruster

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=aZx_Wy1-eBsTEB1s@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-rust@nongnu.org \
    /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