]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuxmlconftest: Use virCommandArgListAccess in testCompareXMLToArgvValidateSchema
authorPeter Krempa <pkrempa@redhat.com>
Wed, 13 May 2026 13:10:55 +0000 (15:10 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 25 May 2026 11:28:57 +0000 (13:28 +0200)
Access the args directly rather than fetching a copy since we have a new
helper now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/qemuxmlconftest.c

index ff27bed74000bba9d118229ef0eea98b22f47092..ab6274801316b07d1ce8426183bab2a58a0d625d 100644 (file)
@@ -31,6 +31,9 @@
 #define LIBVIRT_QEMU_PROCESSPRIV_H_ALLOW
 #include "qemu/qemu_processpriv.h"
 
+#define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW
+#include "util/vircommandpriv.h"
+
 #include "testutilsqemu.h"
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
@@ -282,16 +285,26 @@ static const struct testValidateSchemaCommandData commands[] = {
 };
 
 static int
-testCompareXMLToArgvValidateSchemaCommand(GStrv args,
-                                          GHashTable *schema)
+testCompareXMLToArgvValidateSchema(virCommand *cmd,
+                                   testQemuInfo *info)
 {
-    GStrv arg;
+    char **args;
+    size_t nargs;
+    size_t a;
+
+    if (!info->qmpSchema)
+        return 0;
 
-    for (arg = args; *arg; arg++) {
-        const char *curcommand = *arg;
-        const char *curargs = *(arg + 1);
+    virCommandArgListAccess(cmd, &args, &nargs);
+
+    for (a = 0; a < nargs; a++) {
+        const char *curcommand = args[a];
+        const char *curargs = NULL;
         size_t i;
 
+        if (a + 1 < nargs)
+            curargs = args[a + 1];
+
         for (i = 0; i < G_N_ELEMENTS(commands); i++) {
             const struct testValidateSchemaCommandData *command = commands + i;
             g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
@@ -307,7 +320,7 @@ testCompareXMLToArgvValidateSchemaCommand(GStrv args,
             }
 
             if (*curargs != '{') {
-                arg++;
+                a++;
                 break;
             }
 
@@ -315,7 +328,7 @@ testCompareXMLToArgvValidateSchemaCommand(GStrv args,
                 return -1;
 
             if (testQEMUSchemaValidateCommand(command->schema, jsonargs,
-                                              schema, false, false,
+                                              info->qmpSchema, false, false,
                                               command->allowIncomplete,
                                               &debug) < 0) {
                 VIR_TEST_VERBOSE("failed to validate '%s %s' against QAPI schema: %s",
@@ -323,7 +336,7 @@ testCompareXMLToArgvValidateSchemaCommand(GStrv args,
                 return -1;
             }
 
-            arg++;
+            a++;
         }
     }
 
@@ -331,25 +344,6 @@ testCompareXMLToArgvValidateSchemaCommand(GStrv args,
 }
 
 
-static int
-testCompareXMLToArgvValidateSchema(virCommand *cmd,
-                                   testQemuInfo *info)
-{
-    g_auto(GStrv) args = NULL;
-
-    if (!info->qmpSchema)
-        return 0;
-
-    if (virCommandGetArgList(cmd, &args) < 0)
-        return -1;
-
-    if (testCompareXMLToArgvValidateSchemaCommand(args, info->qmpSchema) < 0)
-        return -1;
-
-    return 0;
-}
-
-
 static int
 testInfoCheckDuplicate(testQemuInfo *info)
 {