QMP queue
These two fixes are not hugely important, but they are pretty isolated anyway.
The changes (since 110db9b48c0a6379fca122801c3ae48e349aa6d4) are available in the following repository:
git://repo.or.cz/qemu/qmp-unstable.git queue/qmp
Michael Roth (1):
qapi: fix leak in unit tests
Zhangleiqiang (1):
qmp: fix handling of cmd with Equals in qmp-shell
QMP/qmp-shell | 2 ++ tests/test-visitor-serialization.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 2/2] qapi: fix leak in unit tests
From: Michael Roth <[email protected]>
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().
--- tests/test-visitor-serialization.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tests/test-visitor-serialization.c +7 -2
@@ -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); }
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 1/2] qmp: fix handling of cmd with Equals in qmp-shell
In reply to Luiz CapitulinoFrom: Zhangleiqiang <[email protected]>
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.
--- QMP/qmp-shell | 2 ++ 1 file changed, 2 insertions(+)
QMP/qmp-shell +2 -0
@@ -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':
Signature · 1 line
1.8.1.4