'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@xxxxxxxxxx> --- src/conf/domain_conf.c | 2 ++ tests/qemuxml2xmltest.c | 42 +++++++++-------------------------------- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index be57a1981e..4442a1df4b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27721,6 +27721,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; diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 896091f2f9..d1012636b5 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -20,8 +20,10 @@ 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); } -- 2.43.0 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx