@@ -37,8 +37,10 @@ static void test_pc_with_cpu_add(gconstpointer data)
qtest_start(args);
for (i = s->sockets * s->cores * s->threads; i < s->maxcpus; i++) {
- response = qmp("{ 'execute': 'cpu-add',"
- " 'arguments': { 'id': %d } }", i);
+ QDict *id = qdict_new();
+
+ qdict_put_int(id, "id", i);
+ response = qmp_cmd("cpu-add", id);
g_assert(response);
g_assert(!qdict_haskey(response, "error"));
QDECREF(response);
@@ -53,6 +55,7 @@ static void test_pc_without_cpu_add(gconstpointer data)
const PCTestData *s = data;
char *args;
QDict *response;
+ QDict *id = qdict_new();
args = g_strdup_printf("-machine %s -cpu %s "
"-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
@@ -60,9 +63,8 @@ static void test_pc_without_cpu_add(gconstpointer data)
s->sockets, s->cores, s->threads, s->maxcpus);
qtest_start(args);
- response = qmp("{ 'execute': 'cpu-add',"
- " 'arguments': { 'id': %d } }",
- s->sockets * s->cores * s->threads);
+ qdict_put_int(id, "id", s->sockets * s->cores * s->threads);
+ response = qmp_cmd("cpu-add", id);
g_assert(response);
g_assert(qdict_haskey(response, "error"));
QDECREF(response);
As argued elsewhere, it's less code to maintain if we convert from a dynamic string passed to qobject_from_jsonv() to instead use a hand-built QDict. Signed-off-by: Eric Blake <eblake@redhat.com> --- tests/pc-cpu-test.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)