Give virDomainDef parser & formatter their own flags

The virDomainDefParse* and virDomainDefFormat* methods both
accept the VIR_DOMAIN_XML_* flags defined in the public API,
along with a set of other VIR_DOMAIN_XML_INTERNAL_* flags
defined in domain_conf.c.

This is seriously confusing & error prone for a number of
reasons:

 - VIR_DOMAIN_XML_SECURE, VIR_DOMAIN_XML_MIGRATABLE and
   VIR_DOMAIN_XML_UPDATE_CPU are only relevant for the
   formatting operation
 - Some of the VIR_DOMAIN_XML_INTERNAL_* flags only apply
   to parse or to format, but not both.

This patch cleanly separates out the flags. There are two
distint VIR_DOMAIN_DEF_PARSE_* and VIR_DOMAIN_DEF_FORMAT_*
flags that are used by the corresponding methods. The
VIR_DOMAIN_XML_* flags received via public API calls must
be converted to the VIR_DOMAIN_DEF_FORMAT_* flags where
needed.

The various calls to virDomainDefParse which hardcoded the
use of the VIR_DOMAIN_XML_INACTIVE flag change to use the
VIR_DOMAIN_DEF_PARSE_INACTIVE flag.
This commit is contained in:
Daniel P. Berrange
2014-11-18 16:44:00 +00:00
parent e34473c1da
commit 0ecd685109
41 changed files with 320 additions and 272 deletions

View File

@@ -30,7 +30,10 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
char *actual = NULL;
int ret = -1;
virDomainDefPtr def = NULL;
unsigned int flags = live ? 0 : VIR_DOMAIN_XML_INACTIVE;
unsigned int parse_flags = live ? 0 : VIR_DOMAIN_DEF_PARSE_INACTIVE;
unsigned int format_flags = VIR_DOMAIN_DEF_FORMAT_SECURE;
if (!live)
format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;
if (virtTestLoadFile(inxml, &inXmlData) < 0)
goto fail;
@@ -38,7 +41,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
goto fail;
if (!(def = virDomainDefParseString(inXmlData, driver.caps, driver.xmlopt,
QEMU_EXPECTED_VIRT_TYPES, flags)))
QEMU_EXPECTED_VIRT_TYPES, parse_flags)))
goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
@@ -46,7 +49,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
goto fail;
}
if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE | flags)))
if (!(actual = virDomainDefFormat(def, format_flags)))
goto fail;
if (STRNEQ(outXmlData, actual)) {