[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 33/36] qtest: Avoid dynamic JSON in test-x86-cpuid-c
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH 33/36] qtest: Avoid dynamic JSON in test-x86-cpuid-compat |
Date: |
Wed, 30 Nov 2016 13:44:51 -0600 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH 16/36] qapi: Promote blockdev-change-medium arguments to QAPI type, (continued)
- [Qemu-devel] [PATCH 16/36] qapi: Promote blockdev-change-medium arguments to QAPI type, Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 14/36] qapi: Use simpler QAPI_TO_QOBJECT(), Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 20/36] qtest: Avoid dynamic JSON in device-introspect-test, Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 26/36] qtest: Drop unused qtest_qmp_async(), Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 21/36] qtest: Avoid dynamic JSON in tmp105-test, Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 28/36] qapi: Factor out JSON string escaping, Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 24/36] qtest: Drop unused qmp_fdv(), Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 27/36] qtest: Avoid dynamic JSON in qmp_cmd(), Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 18/36] qtest: Avoid dynamic JSON in fdc-test, Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 33/36] qtest: Avoid dynamic JSON in test-x86-cpuid-compat,
Eric Blake <=
- [Qemu-devel] [PATCH 35/36] qapi: Rip out dynamic JSON parser escape sequence support, Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 31/36] qtest: Document calling conventions, Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 15/36] blockdev: Use simpler QAPI_TO_QOBJECT(), Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 34/36] qapi: Rip out dynamic JSON parser frontend, Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 32/36] qtest: Avoid dynamic JSON in qom-test, Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 17/36] qtest: Avoid dynamic JSON in ahci-test, Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 36/36] qapi: Rip out dynamic JSON parser backend, Eric Blake, 2016/11/30
- [Qemu-devel] [PATCH 02/36] qdict: Add convenience helpers for wrapped puts, Eric Blake, 2016/11/30