]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorTestProcessCommandDefaultValidate: Use testQEMUSchemaValidateCommand
authorPeter Krempa <pkrempa@redhat.com>
Wed, 4 Mar 2020 09:22:25 +0000 (10:22 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 20 May 2020 06:53:29 +0000 (08:53 +0200)
Remove the ad-hoc command validation in favor of the new helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/qemumonitortestutils.c

index 4ca29ab061b04f545942999e9f95c3d472836111..df780643dd95d47e4ba975807dba0f43f5e51203 100644 (file)
@@ -537,9 +537,6 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
                                              virJSONValuePtr args)
 {
     g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
-    virJSONValuePtr schemaroot;
-    g_autoptr(virJSONValue) emptyargs = NULL;
-    g_autofree char *schemapath = NULL;
 
     if (!test->qapischema)
         return 0;
@@ -555,20 +552,13 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
     if (STREQ(cmdname, "device_add"))
         return 0;
 
-    schemapath = g_strdup_printf("%s/arg-type", cmdname);
-
-    if (virQEMUQAPISchemaPathGet(schemapath, test->qapischema, &schemaroot) < 0 ||
-        !schemaroot) {
-        qemuMonitorTestError("command '%s' not found in QAPI schema", cmdname);
-        return -1;
-    }
+    if (testQEMUSchemaValidateCommand(cmdname, args, test->qapischema, &debug) < 0) {
+        if (virTestGetDebug() == 2) {
+            g_autofree char *argstr = NULL;
 
-    if (!args)
-        args = emptyargs = virJSONValueNewObject();
+            if (args)
+                argstr = virJSONValueToString(args, true);
 
-    if (testQEMUSchemaValidate(args, schemaroot, test->qapischema, &debug) < 0) {
-        if (virTestGetDebug() == 2) {
-            g_autofree char *argstr = virJSONValueToString(args, true);
             fprintf(stderr,
                     "\nfailed to validate arguments of '%s' against QAPI schema\n"
                     "args:\n%s\nvalidator output:\n %s\n",