[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [RFC][PATCH v1 05/12] qapi: fix handling for null-retur

From: Anthony Liguori
Subject: [Qemu-devel] Re: [RFC][PATCH v1 05/12] qapi: fix handling for null-return async callbacks
Date: Fri, 25 Mar 2011 16:22:16 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8

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<address@hidden>
  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) {
          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 a command like this, I can't imagine ever wanting to extend the return value...


Anthony Liguori

      if (cmd->tag) {
          qdict_put_obj(rsp, "tag", cmd->tag);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]