All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "P. Berrange, Daniel" <berrange@redhat.com>,
	Sergio Lopez Pascual <slp@redhat.com>,
	"Hajnoczi, Stefan" <stefanha@gmail.com>,
	Markus Armbruster <armbru@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>, John Snow <jsnow@redhat.com>
Subject: Re: [PATCH] PoC: Rust binding for QAPI (qemu-ga only, for now)
Date: Tue, 29 Sep 2020 11:45:58 +0400	[thread overview]
Message-ID: <CAJ+F1CLowpdHaJ58Vt7GYukAYvYAfuEJvnuw_ZM5kO_4=gh9XA@mail.gmail.com> (raw)
In-Reply-To: <9d6215d4-d0cd-67e4-3048-77127194f7e8@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2887 bytes --]

Hi

On Tue, Sep 22, 2020 at 9:08 PM Paolo Bonzini <pbonzini@redhat.com> wrote:

> On 22/09/20 18:35, Marc-André Lureau wrote:
> > The D-Bus specification doesn't detail versioning much. What is
> > recommended is to have the version number as part of the interface name
> > (kinda like soname):
> > http://0pointer.de/blog/projects/versioning-dbus.html (this is
> > documented in several places iirc)
> >
> > So a QEMU D-Bus interface could have a name like org.qemu.Qemu51,
> > org.qemu.Qemu52.. for example, if we can't provide better API
> stability...
>
> That would be a problem for backports.
>
>
Yes..  Backports could expose a subset of the new version interface? Or the
interface can be divided for each Qmp command. (unorthodox)

It seems to me that the bindings issue is only a problem if we insist on
> having positional arguments like we do for C, but if we can avoid
> functions with a zillion arguments we could.  For example in Rust, it's
> idiomatic to use the builder pattern
>
>     let thread = thread::Builder::new()
>         .name("foo".into())
>         .stack_size(65536)
>         .spawn(run_thread)?;
>     thread.join()?;
>
> and I think the same would work in Go or even C++.  It would look like
>
>    qapi::qga::commands::GuestShutdown::new()
>        .mode("halt")
>        .invoke_on(qapi_channel)?;
>
>
Or simply use the same approach as qapi-rs (
https://github.com/arcnmx/qapi-rs) which is  simply generating data
structures based on the schema, and not binding commands to Rust functions
for ex.

qga.execute(&qga::guest_shutdown { mode: Some(GuestShutdownMode::Halt) })

Less idiomatic, but it also works around the optional arguments and
ordering issue.

In both cases, the client interface should be versionized (since some
fields may be added or becoming optional, return value may appear etc), and
only at runtime can you actually verify what is actually supported.

In Python, you can use keyword arguments and there are even keyword-only
> arguments ("def f(*, key1, key2)"), like
>
>     qapi.qga.GuestFileOpen(path="/etc/passwd").invoke_on(qapi_channel);
>
>
Yes, the python binding will have a similar issue. And if we want to add
typing to the mix, representing everything as a dict is not going to help
much. Fortunately, there are other options I believe. But I would rather
aim for the obvious, having non-optional & ordered arguments, and
interface/methods versioning.

When you do something like this QMP-style APIs are not a problem.
> FlatBuffers is another serialization format that supports this kind of
> extensibility (https://google.github.io/flatbuffers/ explicitly compares
> it to JSON, even).
>

Well, I wouldn't say it's not a problem. It makes working with QMP as a
client quite an unpleasant experience overall imho...

-- 
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 4273 bytes --]

  reply	other threads:[~2020-09-29  7:53 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10 17:48 [PATCH] PoC: Rust binding for QAPI (qemu-ga only, for now) marcandre.lureau
2020-09-11 10:24 ` Paolo Bonzini
2020-09-11 13:08   ` Paolo Bonzini
2020-09-11 14:00     ` Marc-André Lureau
2020-09-11 15:17       ` Paolo Bonzini
2020-09-29 17:55         ` Marc-André Lureau
2020-09-29 18:23           ` Paolo Bonzini
2020-09-30  9:15             ` Marc-André Lureau
2020-09-30 14:02               ` Paolo Bonzini
2020-09-11 10:46 ` Daniel P. Berrangé
2020-09-11 11:03   ` Marc-André Lureau
2020-09-11 11:28   ` Paolo Bonzini
2020-09-11 11:31     ` Daniel P. Berrangé
2020-09-11 14:19     ` John Snow
2020-09-11 14:17 ` Marc-André Lureau
2020-09-21  9:16 ` Markus Armbruster
2020-09-21  9:30   ` Paolo Bonzini
2020-09-22 14:59     ` Markus Armbruster
2020-09-21 10:04   ` Marc-André Lureau
2020-09-22 15:09     ` Markus Armbruster
2020-09-22 16:35       ` Marc-André Lureau
2020-09-22 17:08         ` Paolo Bonzini
2020-09-29  7:45           ` Marc-André Lureau [this message]
2020-09-29 10:14             ` Paolo Bonzini
2020-09-29 10:34               ` Marc-André Lureau
2020-09-29 11:00                 ` Paolo Bonzini
2020-09-29 11:34                   ` Marc-André Lureau
2020-09-30  7:34                     ` Markus Armbruster
2020-09-30  7:51                       ` Marc-André Lureau
2020-09-30 13:14                         ` Paolo Bonzini
2020-09-22 16:52       ` Daniel P. Berrangé
2020-09-23 11:51         ` Markus Armbruster
2020-09-21 10:11   ` Marc-André Lureau
2020-09-22 15:37     ` Markus Armbruster
2020-09-22 16:25       ` Marc-André Lureau
2020-09-24  7:31         ` 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='CAJ+F1CLowpdHaJ58Vt7GYukAYvYAfuEJvnuw_ZM5kO_4=gh9XA@mail.gmail.com' \
    --to=marcandre.lureau@gmail.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=slp@redhat.com \
    --cc=stefanha@gmail.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 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.