]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuMonitorJSONTestAttachOneChardev: Rewrite using qemuMonitorTestAddItemVerbatim
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 May 2023 11:43:53 +0000 (13:43 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 2 Jun 2023 07:41:25 +0000 (09:41 +0200)
'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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/qemumonitorjsontest.c

index 3dabd5c00d5f97d8746a1a1118d77e1fae0de2f9..f6b6da372c219f9e2d75c38988da3c9d97c613f3 100644 (file)
@@ -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;
     }