From e79ccbae1c2006dca20043334d13abb58bae9edb Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 22 May 2023 13:43:53 +0200 Subject: [PATCH] qemuMonitorJSONTestAttachOneChardev: Rewrite using qemuMonitorTestAddItemVerbatim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'qemuMonitorTestAddItemExpect' doesn't do QMP schema validation. Since it's the only use we can reimplement it using 'qemuMonitorTestAddItemVerbatim' which does schema validation and remove the old code instead. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- tests/qemumonitorjsontest.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 3dabd5c00d..f6b6da372c 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -618,9 +618,18 @@ testQemuMonitorJSONAttachChardev(const void *opaque) if (data->expectargs) { g_autofree char *jsonreply = g_strdup_printf("{\"return\": {%s}}", NULLSTR_EMPTY(data->reply)); + g_autofree char *jsoncommand = NULL; + char *n; - if (qemuMonitorTestAddItemExpect(test, "chardev-add", - data->expectargs, true, jsonreply) < 0) + jsoncommand = g_strdup_printf("{\"execute\": \"chardev-add\", \"arguments\": %s, \"id\" : \"libvirt-1\"}", data->expectargs); + + /* data->expectargs has ' instead of " */ + for (n = jsoncommand; *n; n++) { + if (*n == '\'') + *n = '"'; + } + + if (qemuMonitorTestAddItemVerbatim(test, jsoncommand, NULL, jsonreply) < 0) return -1; }