]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuxml2xmltest: Remove pointless inactive->active testing
authorPeter Krempa <pkrempa@redhat.com>
Fri, 15 Dec 2023 21:51:48 +0000 (22:51 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 17 Jan 2024 16:31:12 +0000 (17:31 +0100)
'virDomainDefFormatInternalSetRootName' which is the top level XML
formatter function has the following condition as the very first thing:

     if (def->id == -1)
         flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;

This makes it pointless to separately do inactive->active and
inactive->inactive XML -> XML testing as both will be in the end treated
as inactive->inactive.

This patch adds a warning to virDomainDefFormatInternalSetRootName and
removes the second pointless invocation of the test from
qemuxml2xmtest.

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

index 6211d2a51b095125e6aa86559db2639afe6d843f..50e3847ddca9439388a30f7d3954bffb4f6ad344 100644 (file)
@@ -27722,6 +27722,8 @@ virDomainDefFormatInternalSetRootName(virDomainDef *def,
         return -1;
     }
 
+    /* When changing this condition, beware that tests such as qemuxml*test
+     * were optimized based on this predicate and may need to be fixed. */
     if (def->id == -1)
         flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;
 
index a1355b7b925e8c34626fefabc19d40100407b6eb..7020b3ab1be340e8dbb782bcc71006e5838a58b1 100644 (file)
 static virQEMUDriver driver;
 
 static int
-testXML2XMLCommon(const testQemuInfo *info)
+testXML2XMLInactive(const void *opaque)
 {
+    const testQemuInfo *info = opaque;
+
     if (testQemuInfoInitArgs((testQemuInfo *) info) < 0)
         return -1;
 
@@ -30,17 +32,10 @@ testXML2XMLCommon(const testQemuInfo *info)
     if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
         return -1;
 
-    return 0;
-}
-
-
-static int
-testXML2XMLActive(const void *opaque)
-{
-    const testQemuInfo *info = opaque;
-
-    if (testXML2XMLCommon(info) < 0 ||
-        testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt,
+    /* we deliberately format the XML as live to catch potential test regressions
+     * as virDomainDefFormatInternalSetRootName implies _INACTIVE if 'def->id'
+     * is -1, thus VM is inactive. */
+    if (testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt,
                                    info->infile, info->outfile, true,
                                    info->parseFlags | VIR_DOMAIN_DEF_PARSE_INACTIVE,
                                    TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS) < 0) {
@@ -51,23 +46,6 @@ testXML2XMLActive(const void *opaque)
 }
 
 
-static int
-testXML2XMLInactive(const void *opaque)
-{
-    const testQemuInfo *info = opaque;
-
-    if (testXML2XMLCommon(info) < 0 ||
-        testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt,
-                                   info->infile, info->outfile, false,
-                                   info->parseFlags | VIR_DOMAIN_DEF_PARSE_INACTIVE,
-                                   TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS) < 0) {
-        return -1;
-    }
-
-    return 0;
-}
-
-
 static void
 testRun(const char *name,
         const char *suffix,
@@ -75,8 +53,7 @@ testRun(const char *name,
         int *ret,
         ...)
 {
-    g_autofree char *name_active = g_strdup_printf("QEMU XML-2-XML-active %s", name);
-    g_autofree char *name_inactive = g_strdup_printf("QEMU XML-2-XML-inactive %s", name);
+    g_autofree char *testname = g_strdup_printf("QEMU inactive-XML -> inactive-XML %s", name);
     g_autoptr(testQemuInfo) info = g_new0(testQemuInfo, 1);
     va_list ap;
 
@@ -92,8 +69,7 @@ testRun(const char *name,
     info->outfile = g_strdup_printf("%s/qemuxml2xmloutdata/%s%s.xml",
                                     abs_srcdir, info->name, suffix);
 
-    virTestRunLog(ret, name_inactive, testXML2XMLInactive, info);
-    virTestRunLog(ret, name_active, testXML2XMLActive, info);
+    virTestRunLog(ret, testname, testXML2XMLInactive, info);
 }