]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuxml2argvtest: Don't re-parse and re-generate commandline for QAPI schema validation
authorPeter Krempa <pkrempa@redhat.com>
Wed, 19 Oct 2022 15:10:45 +0000 (17:10 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 20 Oct 2022 07:34:42 +0000 (09:34 +0200)
The removal of the special internal flag for '-netdev' validatition now
allows us to use the same virCommand object for validation of the
schema.

Pass it into the validator instead of re-parsing and re-generating
everything.

This improved the runtime of qemuxml2argvtest by ~25% on my box.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
tests/qemuxml2argvtest.c

index de69cd426ab36030a60d7988d5fee470ff5c8718..7ede68d5558a26c9e5b80606e431182b3a5bceb2 100644 (file)
@@ -548,17 +548,11 @@ testCompareXMLToArgvValidateSchemaCommand(GStrv args,
 
 
 static int
-testCompareXMLToArgvValidateSchema(virQEMUDriver *drv,
-                                   const char *migrateURI,
-                                   struct testQemuInfo *info,
-                                   unsigned int flags)
+testCompareXMLToArgvValidateSchema(virCommand *cmd,
+                                   struct testQemuInfo *info)
 {
     g_auto(GStrv) args = NULL;
-    g_autoptr(virDomainObj) vm = NULL;
-    qemuDomainObjPrivate *priv = NULL;
     GHashTable *schema = NULL;
-    g_autoptr(virCommand) cmd = NULL;
-    unsigned int parseFlags = info->parseFlags;
 
     /* comment out with line comment to enable schema checking for non _CAPS tests
     if (!info->schemafile)
@@ -580,23 +574,6 @@ testCompareXMLToArgvValidateSchema(virQEMUDriver *drv,
     if (!schema)
         return 0;
 
-    if (!(vm = virDomainObjNew(driver.xmlopt)))
-        return -1;
-
-    parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
-    if (!(vm->def = virDomainDefParseFile(info->infile,
-                                          driver.xmlopt,
-                                          NULL, parseFlags)))
-        return -1;
-
-    priv = vm->privateData;
-
-    if (virBitmapParse("0-3", &priv->autoNodeset, 4) < 0)
-        return -1;
-
-    if (!(cmd = testCompareXMLToArgvCreateArgs(drv, vm, migrateURI, info, flags)))
-        return -1;
-
     if (virCommandGetArgList(cmd, &args) < 0)
         return -1;
 
@@ -762,7 +739,7 @@ testCompareXMLToArgv(const void *data)
         goto cleanup;
     }
 
-    if (testCompareXMLToArgvValidateSchema(&driver, migrateURI, info, flags) < 0)
+    if (testCompareXMLToArgvValidateSchema(cmd, info) < 0)
         goto cleanup;
 
     if (virCommandToStringBuf(cmd, &actualBuf, true, false) < 0)