diff mbox

[29/36] qapi: take 'id' from request

Message ID 1443189844-20341-30-git-send-email-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau Sept. 25, 2015, 2:03 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Copy 'id' from request to reply dict. This can be done earlier, such as
done by the monitor (because the qemu monitor may reply directly without
qmp_dispatch), but is now done as well in qmp_dispatch() as convenience
for other users such as QGA and tests.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qapi/qmp-dispatch.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index 73ba3ad..44bd1e8 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -175,7 +175,8 @@  void qmp_dispatch(QmpClient *client, QObject *request, QDict *rsp)
 {
     Error *err = NULL;
     QmpReturn *qret = g_new0(QmpReturn, 1);
-    QObject *ret;
+    QObject *ret, *id;
+    QDict *req;
 
     assert(client);
 
@@ -183,6 +184,14 @@  void qmp_dispatch(QmpClient *client, QObject *request, QDict *rsp)
     qret->client = client;
     QLIST_INSERT_HEAD(&client->pending, qret, link);
 
+    req = qobject_to_qdict(request);
+    id = qdict_get(req, "id");
+    if (id) {
+        qobject_incref(id);
+        qdict_del(req, "id");
+        qdict_put_obj(qret->rsp, "id", id);
+    }
+
     ret = do_qmp_dispatch(request, qret, &err);
 
     if (err) {