From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: Luiz Capitulino <lcapitulino@redhat.com>
Cc: aliguori@linux.vnet.ibm.com,
Anthony Liguori <aliguori@us.ibm.com>,
agl@linux.vnet.ibm.com, qemu-devel@nongnu.org,
Jes.Sorensen@redhat.com
Subject: [Qemu-devel] Re: [RFC][PATCH v1 05/12] qapi: fix handling for null-return async callbacks
Date: Mon, 28 Mar 2011 12:59:36 -0500 [thread overview]
Message-ID: <4D90CC88.5070904@linux.vnet.ibm.com> (raw)
In-Reply-To: <20110328134747.5c9fbc8e@doriath>
On 03/28/2011 11:47 AM, Luiz Capitulino wrote:
> On Fri, 25 Mar 2011 16:22:16 -0500
> Anthony Liguori<aliguori@us.ibm.com> wrote:
>
>> On 03/25/2011 02:47 PM, Michael Roth wrote:
>>> Async commands like 'guest-ping' have NULL retvals. Handle these by
>>> inserting an empty dictionary in the response's "return" field.
>>>
>>> Signed-off-by: Michael Roth<mdroth@linux.vnet.ibm.com>
>>> ---
>>> qmp-core.c | 5 ++++-
>>> 1 files changed, 4 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/qmp-core.c b/qmp-core.c
>>> index e33f7a4..9f3d182 100644
>>> --- a/qmp-core.c
>>> +++ b/qmp-core.c
>>> @@ -922,9 +922,12 @@ void qmp_async_complete_command(QmpCommandState *cmd, QObject *retval, Error *er
>>> rsp = qdict_new();
>>> if (err) {
>>> qdict_put_obj(rsp, "error", error_get_qobject(err));
>>> - } else {
>>> + } else if (retval) {
>>> qobject_incref(retval);
>>> qdict_put_obj(rsp, "return", retval);
>>> + } else {
>>> + /* add empty "return" dict, this is the standard for NULL returns */
>>> + qdict_put_obj(rsp, "return", QOBJECT(qdict_new()));
>>
>> Luiz, I know we decided to return empty dicts because it lets us extend
>> things better, but did we want to rule out the use of a 'null' return
>> value entirely?
>
> For asynchronous commands you mean? No we didn't.
>
> *iirc*, what happens today is that no command using this api is truly async,
> for two reasons. First, changing from sync to async can break clients (that
> happened to query-balloon). Second, although I can't remember the exact
> details, the api that exists in the tree today is limited.
>
> But for a new thing, like QAPI, having different semantics for async commands
> seems the right thing to be done (ie. delaying the response).
>
>>
>> For a command like this, I can't imagine ever wanting to extend the
>> return value...
I think this is another topic, but also one we should hash out a bit better.
Currently the plan is that the C API not expose asynchronicity,
underneath the covers the library will issue the request, then do a
blocking read for the response. So the API call will block till
completion, and no other command's will be serviced through the same
underlying session until it is completed or cancelled.
For the JSON-based clients, the behavior is different. You have an
optional tag you can pass in for an async command, and after issuing
one, you can immediately begin issuing other async or non-async
commands. As a result, the responses you receive will not necessarily be
in FIFO order.
The upside to this is you can implement async commands on the client
side without using separate threads, and can exploit some level of
concurrency being able to do work within a session while a slower
host->guest command completes. The downsides are that:
1) There is some inconsistency between this and the C API semantics.
2) The "optional" tags are basically required tags, at least for async
commands, unless the client side does something to force synchronicity.
One option would be to disable the QMP session's read handler once a
JSON object is received, and not re-enable it until we send the
response. This would enforce FIFO-ordering. It might also add reduce the
potential for a client being able to blow up our TX buffers by issuing
lots of requests and not handling the responses in a timely enough
manner (have seen this just from piping responses to stdout).
Thoughts?
next prev parent reply other threads:[~2011-03-28 18:01 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-25 19:47 [Qemu-devel] [RFC][PATCH v1 00/11] QEMU Guest Agent: QMP-based host/guest communication (virtagent) Michael Roth
2011-03-25 19:47 ` [Qemu-devel] [RFC][PATCH v1 01/12] json-lexer: make lexer error-recovery more deterministic Michael Roth
2011-03-25 21:18 ` [Qemu-devel] " Anthony Liguori
2011-03-25 19:47 ` [Qemu-devel] [RFC][PATCH v1 02/12] json-streamer: add handling for JSON_ERROR token/state Michael Roth
2011-03-25 19:47 ` [Qemu-devel] [RFC][PATCH v1 03/12] json-parser: add handling for NULL token list Michael Roth
2011-03-25 19:47 ` [Qemu-devel] [RFC][PATCH v1 04/12] qapi: fix function name typo in qmp-gen.py Michael Roth
2011-03-25 19:47 ` [Qemu-devel] [RFC][PATCH v1 05/12] qapi: fix handling for null-return async callbacks Michael Roth
2011-03-25 21:22 ` [Qemu-devel] " Anthony Liguori
2011-03-28 16:47 ` Luiz Capitulino
2011-03-28 17:01 ` Anthony Liguori
2011-03-28 17:06 ` Luiz Capitulino
2011-03-28 17:19 ` Anthony Liguori
2011-03-28 17:27 ` Luiz Capitulino
2011-03-28 17:39 ` Anthony Liguori
2011-03-28 17:59 ` Michael Roth [this message]
2011-03-28 18:27 ` Anthony Liguori
2011-03-28 20:42 ` Michael Roth
2011-03-28 20:45 ` Anthony Liguori
2011-03-25 19:47 ` [Qemu-devel] [RFC][PATCH v1 06/12] qmp proxy: build qemu with guest proxy dependency Michael Roth
2011-03-25 19:47 ` [Qemu-devel] [RFC][PATCH v1 07/12] qmp proxy: core code for proxying qmp requests to guest Michael Roth
2011-03-25 21:27 ` [Qemu-devel] " Anthony Liguori
2011-03-25 21:56 ` Michael Roth
2011-03-28 19:05 ` Anthony Liguori
2011-03-28 19:57 ` Michael Roth
2011-03-25 19:47 ` [Qemu-devel] [RFC][PATCH v1 08/12] qemu-char: add qmp_proxy chardev Michael Roth
2011-03-25 21:29 ` [Qemu-devel] " Anthony Liguori
2011-03-25 22:11 ` Michael Roth
2011-03-28 17:45 ` Anthony Liguori
2011-03-29 18:54 ` Michael Roth
2011-03-25 19:47 ` [Qemu-devel] [RFC][PATCH v1 09/12] guest agent: core marshal/dispatch interfaces Michael Roth
2011-03-25 19:47 ` [Qemu-devel] [RFC][PATCH v1 10/12] guest agent: qemu-ga daemon Michael Roth
2011-04-01 9:45 ` [Qemu-devel] " Jes Sorensen
2011-03-25 19:47 ` [Qemu-devel] [RFC][PATCH v1 11/12] guest agent: guest-side command implementations Michael Roth
2011-03-25 19:47 ` [Qemu-devel] [RFC][PATCH v1 12/12] guest agent: build qemu-ga, add QEMU-wide gio dep Michael Roth
2011-03-25 20:42 ` [Qemu-devel] Re: [RFC][PATCH v1 00/11] QEMU Guest Agent: QMP-based host/guest communication (virtagent) Michael Roth
2011-03-25 22:03 ` Anthony Liguori
2011-03-25 22:36 ` Michael Roth
2011-03-28 17:03 ` Anthony Liguori
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=4D90CC88.5070904@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=Jes.Sorensen@redhat.com \
--cc=agl@linux.vnet.ibm.com \
--cc=aliguori@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@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;
as well as URLs for NNTP newsgroup(s).