From 74bc9066bc2cf61dd12994ea3b73401d33112656 Mon Sep 17 00:00:00 2001 From: Zhangleiqiang Date: Mon, 6 May 2013 08:31:23 +0000 Subject: qmp: fix handling of cmd with Equals in qmp-shell qmp: fix handling of cmd with equal mark in qmp-shell qmp-shell splits the argument and value of input command by equal mark("="). But there are commands whose values include equal mark themselves, and the json built by qmp-shell will not correct. For example, when using NBD as the target of block-backup command, the input "block-backup target=nbd+unix:///drive0?socket=/tmp/nbd.sock" will fail, because the json built will be as follows: { "execute":"block-backup", "arguments":{"target":"nbd+unix:///drive0?socket"} } Fix it by joining the sections split by equal mark excluding the first section in __build_cmd function when the length of sections is larger than two. Signed-off-by: zhangleiqiang Signed-off-by: Luiz Capitulino --- QMP/qmp-shell | 2 ++ 1 file changed, 2 insertions(+) diff --git a/QMP/qmp-shell b/QMP/qmp-shell index d126e63ad1..73cb3b6cef 100755 --- a/QMP/qmp-shell +++ b/QMP/qmp-shell @@ -99,6 +99,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): for arg in cmdargs[1:]: opt = arg.split('=') try: + if(len(opt) > 2): + opt[1] = '='.join(opt[1:]) value = int(opt[1]) except ValueError: if opt[1] == 'true': -- cgit v1.2.3 From ad7f375df681503baa6ebef065818868e1216976 Mon Sep 17 00:00:00 2001 From: Michael Roth Date: Thu, 9 May 2013 21:20:57 -0500 Subject: qapi: fix leak in unit tests qmp_output_get_qobject() increments the qobject's reference count. Since we currently pass this straight into qobject_to_json() so we can feed the data into a QMP input visitor, we never actually free the underlying qobject when qmp_output_visitor_cleanup() is called. This causes leaks on all of the QMP serialization tests. Fix this by holding a pointer to the qobject and decref'ing it before returning from qmp_deserialize(). Signed-off-by: Michael Roth Signed-off-by: Luiz Capitulino --- tests/test-visitor-serialization.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test-visitor-serialization.c b/tests/test-visitor-serialization.c index e84926f97c..8c8adac6a9 100644 --- a/tests/test-visitor-serialization.c +++ b/tests/test-visitor-serialization.c @@ -657,11 +657,16 @@ static void qmp_deserialize(void **native_out, void *datap, VisitorFunc visit, Error **errp) { QmpSerializeData *d = datap; - QString *output_json = qobject_to_json(qmp_output_get_qobject(d->qov)); - QObject *obj = qobject_from_json(qstring_get_str(output_json)); + QString *output_json; + QObject *obj_orig, *obj; + + obj_orig = qmp_output_get_qobject(d->qov); + output_json = qobject_to_json(obj_orig); + obj = qobject_from_json(qstring_get_str(output_json)); QDECREF(output_json); d->qiv = qmp_input_visitor_new(obj); + qobject_decref(obj_orig); qobject_decref(obj); visit(qmp_input_get_visitor(d->qiv), native_out, errp); } -- cgit v1.2.3