QMP: Return an empty dict by default
authorLuiz Capitulino <lcapitulino@redhat.com>
Fri, 18 Dec 2009 15:25:00 +0000 (13:25 -0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Sat, 19 Dec 2009 14:26:02 +0000 (08:26 -0600)
Currently, when a regular command doesn't have any data to output,
QMP will emit:

{ "return": "OK" }

Returning an empty dict is better though, because dicts can support
some protocol changes in a compatible way.

So, with this commit we will return:

{ "return": {} }

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
monitor.c

index f4d77e2..129badc 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -286,7 +286,8 @@ static void monitor_protocol_emitter(Monitor *mon, QObject *data)
             qobject_incref(data);
             qdict_put_obj(qmp, "return", data);
         } else {
-            qdict_put(qmp, "return", qstring_from_str("OK"));
+            /* return an empty QDict by default */
+            qdict_put(qmp, "return", qdict_new());
         }
     } else {
         /* error response */