From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42461 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q3ESv-0004SC-8G for qemu-devel@nongnu.org; Fri, 25 Mar 2011 17:22:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q3ESZ-0000VK-Ik for qemu-devel@nongnu.org; Fri, 25 Mar 2011 17:22:20 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:60958) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q3ESZ-0000VE-Bt for qemu-devel@nongnu.org; Fri, 25 Mar 2011 17:22:19 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e37.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p2PLJc8k029472 for ; Fri, 25 Mar 2011 15:19:38 -0600 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p2PLMIjK110524 for ; Fri, 25 Mar 2011 15:22:18 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p2PLMHrh026344 for ; Fri, 25 Mar 2011 15:22:18 -0600 Message-ID: <4D8D0788.7070700@us.ibm.com> Date: Fri, 25 Mar 2011 16:22:16 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1301082479-4058-1-git-send-email-mdroth@linux.vnet.ibm.com> <1301082479-4058-6-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1301082479-4058-6-git-send-email-mdroth@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [RFC][PATCH v1 05/12] qapi: fix handling for null-return async callbacks List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth Cc: aliguori@linux.vnet.ibm.com, Luiz Capitulino , agl@linux.vnet.ibm.com, qemu-devel@nongnu.org, Jes.Sorensen@redhat.com 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 > --- > 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 a command like this, I can't imagine ever wanting to extend the return value... Regards, Anthony Liguori > } > if (cmd->tag) { > qdict_put_obj(rsp, "tag", cmd->tag);