Received: from eggs.gnu.org ([2001:4830:134:3::10]:35819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCAow-00043m-74 for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCAos-00023U-7d for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59584) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cCAos-00021t-1f for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:30 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 149E77EBBC for ; Wed, 30 Nov 2016 19:45:29 +0000 (UTC) From: Eric Blake Date: Wed, 30 Nov 2016 13:44:45 -0600 Message-Id: <1480535094-23831-28-git-send-email-eblake@redhat.com> In-Reply-To: <1480535094-23831-1-git-send-email-eblake@redhat.com> References: <1480535094-23831-1-git-send-email-eblake@redhat.com> Subject: [Qemu-devel] [PATCH 27/36] qtest: Avoid dynamic JSON in qmp_cmd() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com, pbonzini@redhat.com 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 --- tests/libqtest.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index ba329c0..22bf0ad 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -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) -- 2.7.4