From: "Marc-André Lureau" <mlureau@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
qemu-devel@nongnu.org, kraxel@redhat.com, armbru@redhat.com,
"Jeff Cody" <jcody@redhat.com>, "John Snow" <jsnow@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 00/25] qmp: add async command type
Date: Mon, 23 Jan 2017 06:27:29 -0500 (EST) [thread overview]
Message-ID: <10505721.4200193.1485170849535.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20170123105502.GH29186@stefanha-x1.localdomain>
Hi
----- Original Message -----
> On Wed, Jan 18, 2017 at 08:03:07PM +0400, Marc-André Lureau wrote:
> > Hi,
>
> CCing Jeff Cody and John Snow, who have been working on generalizing
> Block Job APIs to generic background jobs. There is some overlap
> between async commands and background jobs.
If you say so :) Did I miss a proposal or a discussion for async qmp commands?
> > One of initial design goals of QMP was to have "asynchronous command
> > completion" (http://wiki.qemu.org/Features/QAPI). Unfortunately, that
> > goal was not fully achieved, and some broken bits left were removed
> > progressively until commit 65207c59d that removed async command
> > support.
> >
> > Note that qmp events are asynchronous messages, and must be handled
> > appropriately by the client: dispatch both reply and events after a
> > command is sent for example.
> >
> > The benefits of async commands that can be trade-off depending on the
> > requirements are:
> >
> > 1) allow the command handler to re-enter the main loop if the command
> > cannot be handled synchronously, or if it is long-lasting. This is
> > currently not possible and make some bugs such as rhbz#1230527 tricky
> > (see below) to solve. Furthermore, many QMP commands do IO and could
> > be considered 'slow' and blocking today.
> >
> > 2) allow concurrent commands and events. This mainly implies hanlding
> > concurrency in qemu and out-of-order replies for the client. As noted
> > earlier, a good qmp client already has to handle dispatching of
> > received messages (reply and events).
> >
> > The traditional approach to solving the above in qemu is the following
> > scheme:
> > -> { "execute": "do-foo" }
> > <- { "return": {} }
> > <- { "event": "FOO_DONE" }
> >
> > It has several flaws:
> > - FOO_DONE event has no semantic link with do-foo in the qapi
> > schema. It is not simple to generalize that pattern when writing
> > qmp clients. It makes documentation and usage harder.
> > - the FOO_DONE event has no clear association with the command that
> > triggered it: commands/events have to come up with additional
> > specific association schemes (ids, path etc)
> > - FOO_DONE is broadcasted to all clients, but they may have no way to
> > interprete it or interest in it, or worse it may conflict with their
> > own commands.
> > - the arguably useless empty reply return
> >
> > For some cases, it makes sense to use that scheme, or a more complete
> > one: to have an "handler" associated with an on-going operation, that
> > can be queried, modified, cancelled etc (block jobs etc). Also, some
> > operations have a global side-effect, in which case that cmd+event
> > scheme is right, as all clients are listening for global events.
> >
> > However, for the simple case where a client want to perform a "local
> > context" operation (dump, query etc), QAPI can easily do better
> > without resorting to this pattern: it can send the reply when the
> > operation is done. That would make QAPI schema, usage and
> > documentation more obvious.
> >
> > The following series implements an async solution, by introducing a
> > context associated with a command, it can:
> > - defer the return
> > - return only to the caller (no broadcasted event)
>
> As long as replies/events have ids then clients can discard messages for
> ids they do not own.
There is no guarantee about id conflict between clients, the id is generated by the client, usually with a simple increment. Although we could check for id conflicts in qemu, I think it is unnecessary and costly (for both client & server)
> Let's err on the side of broadcasting so that
> clients can receive events after reconnecting to the monitor.
Sorry, what do you mean?
> Is there a specific case where broadcasting causes problems?
Fortunately, it seems all events today are global state change events, and not command replies (otherwise we could have reply conflicts). It was suggested to me to use the do-foo/FOO_DONE pattern, but it is not suitable for async command replies (see flaws above).
next prev parent reply other threads:[~2017-01-23 11:27 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-18 16:03 [Qemu-devel] [PATCH v2 00/25] qmp: add async command type Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 01/25] tests: start generic qemu-qmp tests Marc-André Lureau
2017-01-18 16:14 ` Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 02/25] tests: change /0.15/* tests to /qmp/* Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 03/25] qmp: teach qmp_dispatch() to take a pre-filled QDict Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 04/25] qmp: use a return callback for the command reply Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 05/25] qmp: add QmpClient Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 06/25] qmp: add qmp_return_is_cancelled() Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 07/25] qmp: introduce async command type Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 08/25] qapi: ignore top-level 'id' field Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 09/25] qmp: take 'id' from request Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 10/25] qmp: check that async command have an 'id' Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 11/25] scripts: learn 'async' qapi commands Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 12/25] tests: add dispatch async tests Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 13/25] monitor: add 'async' capability Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 14/25] monitor: add !qmp pre-conditions Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 15/25] monitor: suspend when running async and client has no async Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 16/25] qmp: update qmp-spec about async capability Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 17/25] qtest: add qtest-timeout Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 18/25] qtest: add qtest_init_qmp_caps() Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 19/25] tests: add tests for async and non-async clients Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 20/25] qapi: improve 'screendump' documentation Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 21/25] console: graphic_hw_update return true if async Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 22/25] console: add graphic_hw_update_done() Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 23/25] console: make screendump async Marc-André Lureau
2017-01-19 8:20 ` Gerd Hoffmann
2017-01-20 13:07 ` Marc-André Lureau
2017-01-23 12:04 ` Gerd Hoffmann
2017-01-23 12:35 ` Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 24/25] qtest: add /qemu-qmp/screendump test Marc-André Lureau
2017-01-18 16:03 ` [Qemu-devel] [PATCH v2 25/25] qmp: move json-message-parser and check to QmpClient Marc-André Lureau
2017-01-18 17:35 ` [Qemu-devel] [PATCH v2 00/25] qmp: add async command type no-reply
2017-01-23 10:55 ` Stefan Hajnoczi
2017-01-23 11:27 ` Marc-André Lureau [this message]
2017-01-24 11:43 ` Stefan Hajnoczi
2017-01-24 18:43 ` Marc-André Lureau
2017-01-30 13:43 ` Stefan Hajnoczi
2017-01-30 18:18 ` Marc-André Lureau
2017-01-31 7:43 ` Gerd Hoffmann
2017-01-31 8:18 ` Markus Armbruster
2017-02-01 16:25 ` Stefan Hajnoczi
2017-02-01 20:25 ` Marc-André Lureau
2017-02-02 10:13 ` Stefan Hajnoczi
2017-01-25 15:16 ` Markus Armbruster
2017-04-24 19:10 ` Markus Armbruster
2017-04-25 0:06 ` John Snow
2017-04-25 6:55 ` Markus Armbruster
2017-04-25 9:13 ` Daniel P. Berrange
2017-04-25 10:22 ` Kevin Wolf
2017-04-28 15:55 ` Marc-André Lureau
2017-04-28 19:13 ` Kevin Wolf
2017-05-02 8:30 ` Gerd Hoffmann
2017-05-02 9:05 ` Marc-André Lureau
2017-05-02 10:42 ` Kevin Wolf
2017-05-04 19:01 ` Markus Armbruster
2017-05-05 9:00 ` Marc-André Lureau
2017-05-05 12:35 ` Markus Armbruster
2017-05-05 12:54 ` Marc-André Lureau
2017-05-05 13:50 ` Markus Armbruster
2017-05-05 12:27 ` Kevin Wolf
2017-05-05 12:51 ` 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=10505721.4200193.1485170849535.JavaMail.zimbra@redhat.com \
--to=mlureau@redhat.com \
--cc=armbru@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
--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).