From: Paolo Bonzini <pbonzini@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>,
"Markus Armbruster" <armbru@redhat.com>
Cc: John Snow <jsnow@redhat.com>,
"Hajnoczi, Stefan" <stefanha@gmail.com>,
"P. Berrange, Daniel" <berrange@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>,
Sergio Lopez Pascual <slp@redhat.com>
Subject: Re: [PATCH] PoC: Rust binding for QAPI (qemu-ga only, for now)
Date: Tue, 22 Sep 2020 19:08:03 +0200 [thread overview]
Message-ID: <9d6215d4-d0cd-67e4-3048-77127194f7e8@redhat.com> (raw)
In-Reply-To: <CAJ+F1CLCT3RpZF8JDYayqkKxFu76vy+q6GUjofZV3JF_YDvxng@mail.gmail.com>
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.
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)?;
with some kind of double dispatch implementation:
trait QAPIChannel {
...
fn invoke(command: dyn QAPISerialization)
-> dyn QAPISerialization;
}
impl GuestShutdown {
fn<T: QAPIChannel> invoke_on(t: T) -> () {
let args = self.as_qapi_serialization();
t.invoke(args);
// could "return from_qapi_serialization(result)", likewise
}
}
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);
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).
Paolo
next prev parent reply other threads:[~2020-09-22 17:09 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 [this message]
2020-09-29 7:45 ` Marc-André Lureau
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=9d6215d4-d0cd-67e4-3048-77127194f7e8@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=jsnow@redhat.com \
--cc=marcandre.lureau@gmail.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 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).