Received: from eggs.gnu.org ([2001:4830:134:3::10]:35853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCAoy-00046q-A8 for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCAow-00026B-1V for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34446) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cCAov-00025h-Lr for qemu-devel@nongnu.org; Wed, 30 Nov 2016 14:45:33 -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 CC98031B332 for ; Wed, 30 Nov 2016 19:45:32 +0000 (UTC) From: Eric Blake Date: Wed, 30 Nov 2016 13:44:51 -0600 Message-Id: <1480535094-23831-34-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 33/36] qtest: Avoid dynamic JSON in test-x86-cpuid-compat List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com, pbonzini@redhat.com As argued elsewhere, it's less code to maintain if we convert from a dynamic string passed to qobject_from_jsonv() to instead use hand-built QDict. Signed-off-by: Eric Blake --- Optional; the "%s" handling in earlier patches is sufficient to handle this without hand-built QDict, so it is a judgment call which version is more legible. --- tests/test-x86-cpuid-compat.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c index 79a2e69..bce5c8a 100644 --- a/tests/test-x86-cpuid-compat.c +++ b/tests/test-x86-cpuid-compat.c @@ -4,6 +4,7 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qbool.h" +#include "qapi/qmp/qstring.h" #include "libqtest.h" static char *get_cpu0_qom_path(void) @@ -25,11 +26,14 @@ static char *get_cpu0_qom_path(void) static QObject *qom_get(const char *path, const char *prop) { - QDict *resp = qmp("{ 'execute': 'qom-get'," - " 'arguments': { 'path': %s," - " 'property': %s } }", - path, prop); - QObject *ret = qdict_get(resp, "return"); + QDict *args = qdict_new(); + QDict *resp; + QObject *ret; + + qdict_put_str(args, "path", path); + qdict_put_str(args, "property", prop); + resp = qmp_cmd("qom-get", args); + ret = qdict_get(resp, "return"); qobject_incref(ret); QDECREF(resp); return ret; -- 2.7.4