Leaving interpolation into JSON to qobject_from_jsonf() is more robust than building QMP input manually; however, we have a few places where code is already creating a QDict to interpolate individual arguments, which cannot be reproduced with the qobject_from_jsonf() parser. Expose a public wrapper qmp_args_dict() for the internal helper qmp_args_dict_async() that we needed earlier for qmp_args(), and fix a test to use the new helper.
Signed-off-by: Eric Blake <ebl...@redhat.com> --- tests/libqtest.h | 9 +++++++++ tests/libqtest.c | 6 ++++++ tests/device-introspect-test.c | 3 +-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/libqtest.h b/tests/libqtest.h index 86ca7fa581..193adf1eb9 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -499,6 +499,15 @@ QDict *qmp_cmd(const char *cmd); void qmp_cmd_async(const char *cmd); /** + * qmp_args_dict: + * @cmd: QMP command to send to QEMU. + * @args: Arguments for the command; will have reference count reduced. + * + * Sends a QMP message to QEMU and returns the response. + */ +QDict *qmp_args_dict(const char *cmd, QDict *args); + +/** * qmp_args: * @cmd: QMP command to send to QEMU. * @fmt...: Arguments for the command; formats arguments through diff --git a/tests/libqtest.c b/tests/libqtest.c index 49786cf2d7..5012ecf929 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -875,6 +875,12 @@ static void qmp_args_dict_async(const char *cmd, QDict *args) qtest_qmp_send(global_qtest, "{'execute':%s, 'arguments':%p}", cmd, args); } +QDict *qmp_args_dict(const char *cmd, QDict *args) +{ + qmp_args_dict_async(cmd, args); + return qtest_qmp_receive(global_qtest); +} + QDict *qmp_args(const char *cmd, const char *fmt, ...) { va_list ap; diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c index e1fcd3b6c6..d2de4a5fc0 100644 --- a/tests/device-introspect-test.c +++ b/tests/device-introspect-test.c @@ -36,8 +36,7 @@ static QList *qom_list_types(const char *implements, bool abstract) if (implements) { qdict_put_str(args, "implements", implements); } - resp = qmp("{'execute': 'qom-list-types'," - " 'arguments': %p }", args); + resp = qmp_args_dict("qom-list-types", args); g_assert(qdict_haskey(resp, "return")); ret = qdict_get_qlist(resp, "return"); QINCREF(ret); -- 2.13.3