@@ -493,13 +493,22 @@ QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
QDict *qtest_qmp_cmd(QTestState *s, const char *cmd, QDict *args)
{
QDict *dict = qdict_new();
+ QString *qstr;
+ QDict *result;
if (!args) {
args = qdict_new();
}
qdict_put_str(dict, "execute", cmd);
qdict_put(dict, "arguments", args);
- return qtest_qmp(s, "%p", QOBJECT(dict));
+ qstr = qobject_to_json(QOBJECT(dict));
+
+ qmp_fd_send(s->qmp_fd, qstring_get_str(qstr));
+ result = qtest_qmp_receive(s);
+
+ QDECREF(dict);
+ QDECREF(qstr);
+ return result;
}
void qtest_qmp_discard_response(QTestState *s, const char *json)
When qmp_cmd() was first added, we used a shortcut of a format string of "%p" to pass the QObject intact through the varargs. But now that we have a way to directly invoke strings, we can altogether avoid the no-op trip through the parser by just flattening to a string ourselves. Signed-off-by: Eric Blake <eblake@redhat.com> --- tests/libqtest.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)