All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Sergio Lopez Pascual" <slp@redhat.com>,
	"Hajnoczi, Stefan" <stefanha@gmail.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Bonzini, Paolo" <pbonzini@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"John Snow" <jsnow@redhat.com>
Subject: Re: [PATCH] PoC: Rust binding for QAPI (qemu-ga only, for now)
Date: Tue, 22 Sep 2020 17:52:23 +0100	[thread overview]
Message-ID: <20200922165223.GT1989025@redhat.com> (raw)
In-Reply-To: <874knpluez.fsf@dusky.pond.sub.org>

On Tue, Sep 22, 2020 at 05:09:56PM +0200, Markus Armbruster wrote:
> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> 
> > Hi
> >
> > On Mon, Sep 21, 2020 at 1:16 PM Markus Armbruster <armbru@redhat.com> wrote:
> >>
> >> We've made use of this extensively.  See also
> >> docs/devel/qapi-code-gen.txt section "Compatibility considerations."
> >>
> >> How do such changes affect clients of the proposed D-Bus interface?
> >
> > The introspection XML will always reflect the expected signature. You
> > should bump your interface version whenever you make incompatible
> > changes.
> 
> How do "interface versions" work?  Client's and server's version need to
> match, or else no go?

Yes, both client and server need to support the same "interface" in order
to talk to each other. If a service makes an incompatible API change, then
then change the interface name. It is common to include a number in the
interface name.

Of course some changes can be made in a backwards compatible manner so
don't require changing the interface. eg adding new methods, adding
new signals (aka async events), adding new properties.

Adding/changing/removing parameters  in an existing method is what
causes an interface incompatability.

You can potentially mitigate the inability to change parameters by
modelling parameters in a variety of ways.

Many of the tricks common in traditional C libraries for future
proofing API designs will apply equally well to DBus APIs.

For example, instead of modelling everything as a distinct positional
parameter, you can model them as optional named parameters. These would
be exposed as an array(map(string-variant)) - basically think of it as a
hash table. This is a half-way house between very strongly typed and very
weakly typed worlds.  Libvirt takes this approach with some of our C APIs
that we expect to grow parameters over time.

A variant on this is to expose some data in a custom document format
as a single parameter. For example if there was an API requesting a
description of a block backend properties, instead of having a DBus
API where all the block backend props were explicitly modelled, just
have a single string parameter that returns a JSON/XML doc. You can
extend that doc at will without impacting the DBus API. Again libvirt
takes this approach with our XML doc schema.

A final useful technique is to have a generic "int flags" parameter as
a way to express new functional behaviour by defining extra flags.


The challenge with all these ideas is figuring out whether there's
a viable way to map them into how we describe the current QMP protocol.
I don't think there's a especially good answer to do a 100% automated
mapping from QMP to DBus, while keeping extensibility and also maximising
strong type checking benefits. There's a tradeoff between extensibility
and strong typing that needs some intelligent thought on a case by case
basis IMHO.

For an automated mapping, either we go fully strong typed and accept
that we'll be breaking DBus interface compatibility continually, or
we go full weakly typed and accept that clients won't get much type
validation benefits at build time.

It is the inherant problem with using something weakly typed as the
master specification and trying to translate it to something strongly
typed.

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:[~2020-09-22 16:54 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
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é [this message]
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=20200922165223.GT1989025@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=marcandre.lureau@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.