diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6211d2a51b..50e3847ddc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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; diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index a1355b7b92..7020b3ab1b 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); }