[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 7/8] Given 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
 - VIR_DOMAIN_XML_UPDATE_CPU is not in fact handled by
   the domain_conf.c code at all - it must be dealt with
   by the driver code
 - 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.
---
 src/bhyve/bhyve_driver.c          |   9 +-
 src/conf/domain_conf.c            | 309 ++++++++++++++++++--------------------
 src/conf/domain_conf.h            |  70 ++++++---
 src/conf/snapshot_conf.c          |   6 +-
 src/esx/esx_driver.c              |  13 +-
 src/hyperv/hyperv_driver.c        |   3 +-
 src/libvirt_private.syms          |   1 +
 src/libxl/libxl_domain.c          |   2 +-
 src/libxl/libxl_driver.c          |  23 +--
 src/libxl/libxl_migration.c       |   6 +-
 src/lxc/lxc_driver.c              |  12 +-
 src/openvz/openvz_driver.c        |  13 +-
 src/phyp/phyp_driver.c            |   5 +-
 src/qemu/qemu_domain.c            |   8 +-
 src/qemu/qemu_driver.c            |  26 ++--
 src/qemu/qemu_migration.c         |   8 +-
 src/test/test_driver.c            |  18 ++-
 src/uml/uml_driver.c              |  10 +-
 src/vbox/vbox_common.c            |  14 +-
 src/vmware/vmware_driver.c        |   9 +-
 src/xen/xen_driver.c              |   9 +-
 src/xen/xend_internal.c           |   6 +-
 src/xen/xm_internal.c             |   4 +-
 src/xenapi/xenapi_driver.c        |   4 +-
 tests/domainsnapshotxml2xmltest.c |   2 +-
 tests/lxcxml2xmltest.c            |   4 +-
 tests/openvzutilstest.c           |   2 +-
 tests/qemuhotplugtest.c           |   6 +-
 tests/qemuxml2argvtest.c          |   2 +-
 tests/qemuxml2xmltest.c           |   9 +-
 tests/qemuxmlnstest.c             |   2 +-
 tests/vmx2xmltest.c               |   2 +-
 tests/xmconfigtest.c              |   4 +-
 tests/xml2sexprtest.c             |   2 +-
 tests/xml2vmxtest.c               |   2 +-
 35 files changed, 334 insertions(+), 291 deletions(-)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index f6d5d5e..a7312d0 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -476,7 +476,8 @@ bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
     if (virDomainGetXMLDescEnsureACL(domain->conn, vm->def, flags) < 0)
         goto cleanup;
 
-    ret = virDomainDefFormat(vm->def, flags);
+    ret = virDomainDefFormat(vm->def,
+                             virDomainDefFormatConvertXMLFlags(flags));
 
  cleanup:
     if (vm)
@@ -503,7 +504,7 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
 
     if ((def = virDomainDefParseString(xml, caps, privconn->xmlopt,
                                        1 << VIR_DOMAIN_VIRT_BHYVE,
-                                       VIR_DOMAIN_XML_INACTIVE)) == NULL)
+                                       VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
         goto cleanup;
 
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
@@ -690,7 +691,7 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
 
     if (!(def = virDomainDefParseString(xmlData, caps, privconn->xmlopt,
                                   1 << VIR_DOMAIN_VIRT_BHYVE,
-                                  VIR_DOMAIN_XML_INACTIVE)))
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (bhyveDomainAssignAddresses(def, NULL) < 0)
@@ -901,7 +902,7 @@ bhyveDomainCreateXML(virConnectPtr conn,
 
     if ((def = virDomainDefParseString(xml, caps, privconn->xmlopt,
                                        1 << VIR_DOMAIN_VIRT_BHYVE,
-                                       VIR_DOMAIN_XML_INACTIVE)) == NULL)
+                                       VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
         goto cleanup;
 
     if (virDomainCreateXMLEnsureACL(conn, def) < 0)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5f4b9f6..2dace76 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -85,39 +85,12 @@ struct _virDomainXMLOption {
 
     /* XML namespace callbacks */
     virDomainXMLNamespace ns;
- };
-
-
-/* Private flags used internally by virDomainSaveStatus and
- * virDomainLoadStatus, in addition to the public virDomainXMLFlags. */
-typedef enum {
-   /* dump internal domain status information */
-   VIR_DOMAIN_XML_INTERNAL_STATUS          = 1 << 16,
-   /* dump/parse <actual> element */
-   VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET      = 1 << 17,
-   /* dump/parse original states of host PCI device */
-   VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES = 1 << 18,
-   VIR_DOMAIN_XML_INTERNAL_ALLOW_ROM       = 1 << 19,
-   VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT      = 1 << 20,
-   VIR_DOMAIN_XML_INTERNAL_CLOCK_ADJUST    = 1 << 21,
-   /* parse only source half of <disk> */
-   VIR_DOMAIN_XML_INTERNAL_DISK_SOURCE     = 1 << 22,
-} virDomainXMLInternalFlags;
-
-#define DUMPXML_FLAGS                           \
-    (VIR_DOMAIN_XML_SECURE |                    \
-     VIR_DOMAIN_XML_INACTIVE |                  \
-     VIR_DOMAIN_XML_UPDATE_CPU |                \
-     VIR_DOMAIN_XML_MIGRATABLE)
-
-verify(((VIR_DOMAIN_XML_INTERNAL_STATUS |
-         VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET |
-         VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES |
-         VIR_DOMAIN_XML_INTERNAL_ALLOW_ROM |
-         VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT |
-         VIR_DOMAIN_XML_INTERNAL_CLOCK_ADJUST |
-         VIR_DOMAIN_XML_INTERNAL_DISK_SOURCE)
-        & DUMPXML_FLAGS) == 0);
+};
+
+#define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS             \
+    (VIR_DOMAIN_DEF_FORMAT_SECURE |                    \
+     VIR_DOMAIN_DEF_FORMAT_INACTIVE |                  \
+     VIR_DOMAIN_DEF_FORMAT_MIGRATABLE)
 
 VIR_ENUM_IMPL(virDomainTaint, VIR_DOMAIN_TAINT_LAST,
               "custom-argv",
@@ -792,9 +765,6 @@ VIR_ENUM_DECL(virDomainBlockJob)
 VIR_ENUM_IMPL(virDomainBlockJob, VIR_DOMAIN_BLOCK_JOB_TYPE_LAST,
               "", "", "copy", "", "active-commit")
 
-#define VIR_DOMAIN_XML_WRITE_FLAGS  VIR_DOMAIN_XML_SECURE
-#define VIR_DOMAIN_XML_READ_FLAGS   VIR_DOMAIN_XML_INACTIVE
-
 static virClassPtr virDomainObjClass;
 static virClassPtr virDomainObjListClass;
 static virClassPtr virDomainXMLOptionClass;
@@ -2650,11 +2620,11 @@ virDomainDeviceGetInfo(virDomainDeviceDefPtr device)
 }
 
 static bool
-virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info, unsigned int flags)
+virDomainDeviceInfoNeedsFormat(virDomainDeviceInfoPtr info, unsigned int flags)
 {
     if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
         return true;
-    if (info->alias && !(flags & VIR_DOMAIN_XML_INACTIVE))
+    if (info->alias && !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))
         return true;
     if (info->mastertype != VIR_DOMAIN_CONTROLLER_MASTER_NONE)
         return true;
@@ -3263,11 +3233,11 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
                           virDomainDeviceInfoPtr info,
                           unsigned int flags)
 {
-    if ((flags & VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) && info->bootIndex)
+    if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex)
         virBufferAsprintf(buf, "<boot order='%d'/>\n", info->bootIndex);
 
     if (info->alias &&
-        !(flags & VIR_DOMAIN_XML_INACTIVE)) {
+        !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
         virBufferAsprintf(buf, "<alias name='%s'/>\n", info->alias);
     }
 
@@ -3276,7 +3246,7 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
                           info->master.usb.startport);
     }
 
-    if ((flags & VIR_DOMAIN_XML_INTERNAL_ALLOW_ROM) &&
+    if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM) &&
         (info->rombar || info->romfile)) {
 
         virBufferAddLit(buf, "<rom");
@@ -3760,7 +3730,7 @@ virDomainDeviceInfoParseXML(xmlNodePtr node,
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
             if (alias == NULL &&
-                !(flags & VIR_DOMAIN_XML_INACTIVE) &&
+                !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
                 xmlStrEqual(cur->name, BAD_CAST "alias")) {
                 alias = cur;
             } else if (address == NULL &&
@@ -3770,11 +3740,11 @@ virDomainDeviceInfoParseXML(xmlNodePtr node,
                        xmlStrEqual(cur->name, BAD_CAST "master")) {
                 master = cur;
             } else if (boot == NULL &&
-                       (flags & VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) &&
+                       (flags & VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) &&
                        xmlStrEqual(cur->name, BAD_CAST "boot")) {
                 boot = cur;
             } else if (rom == NULL &&
-                       (flags & VIR_DOMAIN_XML_INTERNAL_ALLOW_ROM) &&
+                       (flags & VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) &&
                        xmlStrEqual(cur->name, BAD_CAST "rom")) {
                 rom = cur;
             }
@@ -4102,7 +4072,7 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node,
 
                 if (virDevicePCIAddressParseXML(cur, addr) < 0)
                     goto out;
-            } else if ((flags & VIR_DOMAIN_XML_INTERNAL_STATUS) &&
+            } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) &&
                        xmlStrEqual(cur->name, BAD_CAST "state")) {
                 /* Legacy back-compat. Don't add any more attributes here */
                 char *devaddr = virXMLPropString(cur, "devaddr");
@@ -4116,7 +4086,7 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node,
                     goto out;
                 }
                 def->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
-            } else if ((flags & VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES) &&
+            } else if ((flags & VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES) &&
                        xmlStrEqual(cur->name, BAD_CAST "origstates")) {
                 virDomainHostdevOrigStatesPtr states = &def->origstates;
                 if (virDomainHostdevSubsysPCIOrigStatesDefParseXML(cur, states) < 0)
@@ -4914,7 +4884,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
      * present. Hence, return now. */
 
     if (STREQ_NULLABLE(seclabel->model, "none")) {
-        if (flags & VIR_DOMAIN_XML_INACTIVE) {
+        if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) {
             /* Fix older configurations */
             seclabel->type = VIR_DOMAIN_SECLABEL_NONE;
             seclabel->relabel = false;
@@ -4935,7 +4905,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
      * if the 'live' VM XML is requested
      */
     if (seclabel->type == VIR_DOMAIN_SECLABEL_STATIC ||
-        (!(flags & VIR_DOMAIN_XML_INACTIVE) &&
+        (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
          seclabel->type != VIR_DOMAIN_SECLABEL_NONE)) {
         p = virXPathStringLimit("string(./label[1])",
                                 VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
@@ -4951,7 +4921,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
 
     /* Only parse imagelabel, if requested live XML with relabeling */
     if (seclabel->relabel &&
-        (!(flags & VIR_DOMAIN_XML_INACTIVE) &&
+        (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
          seclabel->type != VIR_DOMAIN_SECLABEL_NONE)) {
         p = virXPathStringLimit("string(./imagelabel[1])",
                                 VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
@@ -5042,7 +5012,7 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def,
         if (def->seclabels[0]->type == VIR_DOMAIN_SECLABEL_NONE ||
             (def->seclabels[0]->type == VIR_DOMAIN_SECLABEL_DYNAMIC &&
              !def->seclabels[0]->baselabel &&
-             (flags & VIR_DOMAIN_XML_INACTIVE))) {
+             (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))) {
             /* Copy model from host. */
             VIR_DEBUG("Found seclabel without a model, using '%s'",
                       host->secModels[0].model);
@@ -5050,7 +5020,7 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def,
                 goto error;
 
             if (STREQ(def->seclabels[0]->model, "none") &&
-                flags & VIR_DOMAIN_XML_INACTIVE) {
+                flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) {
                 /* Fix older configurations */
                 def->seclabels[0]->type = VIR_DOMAIN_SECLABEL_NONE;
                 def->seclabels[0]->relabel = false;
@@ -5158,7 +5128,7 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDefPtr **seclabels_rtn,
         /* labelskip is only parsed on live images */
         labelskip = virXMLPropString(list[i], "labelskip");
         seclabels[i]->labelskip = false;
-        if (labelskip && !(flags & VIR_DOMAIN_XML_INACTIVE))
+        if (labelskip && !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
             seclabels[i]->labelskip = STREQ(labelskip, "yes");
         VIR_FREE(labelskip);
 
@@ -5653,7 +5623,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
                 driverIOThread = virXMLPropString(cur, "iothread");
             } else if (!def->mirror &&
                        xmlStrEqual(cur->name, BAD_CAST "mirror") &&
-                       !(flags & VIR_DOMAIN_XML_INACTIVE)) {
+                       !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) {
                 char *ready;
                 char *blockJob;
 
@@ -5905,7 +5875,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
                 def->src->shared = true;
             } else if (xmlStrEqual(cur->name, BAD_CAST "transient")) {
                 def->transient = true;
-            } else if ((flags & VIR_DOMAIN_XML_INTERNAL_STATUS) &&
+            } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) &&
                        xmlStrEqual(cur->name, BAD_CAST "state")) {
                 /* Legacy back-compat. Don't add any more attributes here */
                 devaddr = virXMLPropString(cur, "devaddr");
@@ -5984,7 +5954,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
      * that are not attached to a physical device presently */
     if (source == NULL && def->src->hosts == NULL && !def->src->srcpool &&
         (def->device == VIR_DOMAIN_DISK_DEVICE_DISK ||
-         (flags & VIR_DOMAIN_XML_INTERNAL_DISK_SOURCE))) {
+         (flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE))) {
         virReportError(VIR_ERR_NO_SOURCE,
                        target ? "%s" : NULL, target);
         goto error;
@@ -6004,7 +5974,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
         ctxt->node = saved_node;
     }
 
-    if (!target && !(flags & VIR_DOMAIN_XML_INTERNAL_DISK_SOURCE)) {
+    if (!target && !(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) {
         if (def->src->srcpool) {
             char *tmp;
             if (virAsprintf(&tmp, "pool = '%s', volume = '%s'",
@@ -6019,7 +5989,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
         goto error;
     }
 
-    if (!(flags & VIR_DOMAIN_XML_INTERNAL_DISK_SOURCE)) {
+    if (!(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) {
         if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
             !STRPREFIX(target, "fd")) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -6090,7 +6060,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
     } else {
         if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
             def->bus = VIR_DOMAIN_DISK_BUS_FDC;
-        } else if (!(flags & VIR_DOMAIN_XML_INTERNAL_DISK_SOURCE)) {
+        } else if (!(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) {
             if (STRPREFIX(target, "hd"))
                 def->bus = VIR_DOMAIN_DISK_BUS_IDE;
             else if (STRPREFIX(target, "sd"))
@@ -6264,7 +6234,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
         def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
     } else {
         if (virDomainDeviceInfoParseXML(node, bootHash, &def->info,
-                                        flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0)
+                                        flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) < 0)
             goto error;
     }
 
@@ -6324,7 +6294,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
         }
     }
 
-    if (!(flags & VIR_DOMAIN_XML_INTERNAL_DISK_SOURCE)) {
+    if (!(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) {
         if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE
             && virDomainDiskDefAssignAddress(xmlopt, def) < 0)
             goto error;
@@ -7215,7 +7185,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
                        xmlStrEqual(cur->name, BAD_CAST "target")) {
                 ifname = virXMLPropString(cur, "dev");
                 if (ifname &&
-                    (flags & VIR_DOMAIN_XML_INACTIVE) &&
+                    (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
                     STRPREFIX(ifname, VIR_NET_GENERATED_PREFIX)) {
                     /* An auto-generated target name, blank it out */
                     VIR_FREE(ifname);
@@ -7248,14 +7218,14 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
                 filter = virXMLPropString(cur, "filter");
                 virNWFilterHashTableFree(filterparams);
                 filterparams = virNWFilterParseParamAttributes(cur);
-            } else if ((flags & VIR_DOMAIN_XML_INTERNAL_STATUS) &&
+            } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) &&
                        xmlStrEqual(cur->name, BAD_CAST "state")) {
                 /* Legacy back-compat. Don't add any more attributes here */
                 devaddr = virXMLPropString(cur, "devaddr");
             } else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
                 /* boot is parsed as part of virDomainDeviceInfoParseXML */
             } else if (!actual &&
-                       (flags & VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET) &&
+                       (flags & VIR_DOMAIN_DEF_PARSE_ACTUAL_NET) &&
                        def->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
                        xmlStrEqual(cur->name, BAD_CAST "actual")) {
                 if (virDomainActualNetDefParseXML(cur, ctxt, def,
@@ -7312,8 +7282,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
         def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
     } else {
         if (virDomainDeviceInfoParseXML(node, bootHash, &def->info,
-                                        flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT
-                                        | VIR_DOMAIN_XML_INTERNAL_ALLOW_ROM) < 0)
+                                        flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT
+                                        | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) < 0)
             goto error;
     }
 
@@ -7494,7 +7464,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
         def->data.direct.linkdev = dev;
         dev = NULL;
 
-        if (flags & VIR_DOMAIN_XML_INACTIVE)
+        if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
             VIR_FREE(ifname);
 
         break;
@@ -7995,7 +7965,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
                     /* PTY path is only parsed from live xml.  */
                     if (!path  &&
                         (def->type != VIR_DOMAIN_CHR_TYPE_PTY ||
-                         !(flags & VIR_DOMAIN_XML_INACTIVE)))
+                         !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)))
                         path = virXMLPropString(cur, "path");
 
                     break;
@@ -8973,7 +8943,7 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
     if (address && address[0] &&
         (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
          (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
-          !(flags & VIR_DOMAIN_XML_INACTIVE)))) {
+          !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)))) {
         def->address = address;
         address = NULL;
     }
@@ -8991,7 +8961,7 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
     }
 
     if (fromConfig &&
-        flags & VIR_DOMAIN_XML_INTERNAL_STATUS) {
+        flags & VIR_DOMAIN_DEF_PARSE_STATUS) {
         if (virStrToLong_i(fromConfig, NULL, 10, &tmp) < 0) {
             virReportError(VIR_ERR_XML_ERROR,
                            _("Invalid fromConfig value: %s"),
@@ -9130,7 +9100,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
             VIR_FREE(port);
             /* Legacy compat syntax, used -1 for auto-port */
             if (def->data.vnc.port == -1) {
-                if (flags & VIR_DOMAIN_XML_INACTIVE)
+                if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
                     def->data.vnc.port = 0;
                 def->data.vnc.autoport = true;
             }
@@ -9141,7 +9111,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
 
         if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
             if (STREQ(autoport, "yes")) {
-                if (flags & VIR_DOMAIN_XML_INACTIVE)
+                if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
                     def->data.vnc.port = 0;
                 def->data.vnc.autoport = true;
             }
@@ -9231,7 +9201,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
             VIR_FREE(autoport);
         }
 
-        if (def->data.rdp.autoport && (flags & VIR_DOMAIN_XML_INACTIVE))
+        if (def->data.rdp.autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
             def->data.rdp.port = 0;
 
         if ((replaceUser = virXMLPropString(node, "replaceUser")) != NULL) {
@@ -9324,7 +9294,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
             def->data.spice.autoport = true;
         }
 
-        if (def->data.spice.autoport && (flags & VIR_DOMAIN_XML_INACTIVE)) {
+        if (def->data.spice.autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) {
             def->data.spice.port = 0;
             def->data.spice.tlsPort = 0;
         }
@@ -10351,8 +10321,8 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt,
 
     if (def->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
         if (virDomainDeviceInfoParseXML(node, bootHash, def->info,
-                                        flags  | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT
-                                        | VIR_DOMAIN_XML_INTERNAL_ALLOW_ROM) < 0)
+                                        flags  | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT
+                                        | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) < 0)
             goto error;
     }
 
@@ -10446,7 +10416,7 @@ virDomainRedirdevDefParseXML(xmlNodePtr node,
         def->source.chr.data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_USBREDIR;
 
     if (virDomainDeviceInfoParseXML(node, bootHash, &def->info,
-                                    flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0)
+                                    flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) < 0)
         goto error;
 
     if (def->bus == VIR_DOMAIN_REDIRDEV_BUS_USB &&
@@ -10877,7 +10847,7 @@ virDomainDiskDefSourceParse(const char *xmlStr,
         goto cleanup;
     }
 
-    flags |= VIR_DOMAIN_XML_INTERNAL_DISK_SOURCE;
+    flags |= VIR_DOMAIN_DEF_PARSE_DISK_SOURCE;
     if (!(disk = virDomainDiskDefParseXML(xmlopt, node, ctxt,
                                           NULL, def->seclabels,
                                           def->nseclabels,
@@ -12177,6 +12147,7 @@ virDomainLoaderDefParseXML(xmlNodePtr node,
     return ret;
 }
 
+
 static virDomainDefPtr
 virDomainDefParseXML(xmlDocPtr xml,
                      xmlNodePtr root,
@@ -12203,7 +12174,7 @@ virDomainDefParseXML(xmlDocPtr xml,
     if (VIR_ALLOC(def) < 0)
         return NULL;
 
-    if (!(flags & VIR_DOMAIN_XML_INACTIVE))
+    if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
         if (virXPathLong("string(./@id)", ctxt, &id) < 0)
             id = -1;
     def->id = (int)id;
@@ -15939,7 +15910,7 @@ virSecurityDeviceLabelDefFormat(virBufferPtr buf,
 {
     /* For offline output, skip elements that allow labels but have no
      * label specified (possible if labelskip was ignored on input).  */
-    if ((flags & VIR_DOMAIN_XML_INACTIVE) && !def->label && def->relabel)
+    if ((flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) && !def->label && def->relabel)
         return;
 
     virBufferAddLit(buf, "<seclabel");
@@ -16346,7 +16317,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
 
     /* Don't format backingStore to inactive XMLs until the code for
      * persistent storage of backing chains is ready. */
-    if (!(flags & VIR_DOMAIN_XML_INACTIVE) &&
+    if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
         virDomainDiskBackingStoreFormat(buf, def->src->backingStore,
                                         def->src->backingStoreRaw, 1) < 0)
         return -1;
@@ -16360,7 +16331,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
      * the new style similar to backingStore, but for back-compat on
      * blockcopy files we also have to output old style attributes.
      * The parser accepts either style across libvirtd upgrades. */
-    if (def->mirror && !(flags & VIR_DOMAIN_XML_INACTIVE)) {
+    if (def->mirror && !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
         const char *formatStr = NULL;
 
         if (def->mirror->format)
@@ -16503,7 +16474,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
         virStorageEncryptionFormat(buf, def->src->encryption) < 0)
         return -1;
     if (virDomainDeviceInfoFormat(buf, &def->info,
-                                  flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0)
+                                  flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) < 0)
         return -1;
 
     virBufferAdjustIndent(buf, -2);
@@ -16579,7 +16550,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
     }
 
     if (def->queues || def->cmd_per_lun || def->max_sectors ||
-        virDomainDeviceInfoIsSet(&def->info, flags) || pcihole64) {
+        virDomainDeviceInfoNeedsFormat(&def->info, flags) || pcihole64) {
         virBufferAddLit(buf, ">\n");
         virBufferAdjustIndent(buf, 2);
         if (def->queues)
@@ -16591,7 +16562,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
         if (def->max_sectors)
             virBufferAsprintf(buf, "<driver max_sectors='%u'/>\n", def->max_sectors);
 
-        if (virDomainDeviceInfoIsSet(&def->info, flags) &&
+        if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
             virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
             return -1;
 
@@ -16749,10 +16720,10 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
             policy = virDomainStartupPolicyTypeToString(def->startupPolicy);
             virBufferAsprintf(buf, " startupPolicy='%s'", policy);
         }
-        if (usbsrc->autoAddress && (flags & VIR_DOMAIN_XML_MIGRATABLE))
+        if (usbsrc->autoAddress && (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))
             virBufferAddLit(buf, " autoAddress='yes'");
 
-        if (def->missing && !(flags & VIR_DOMAIN_XML_INACTIVE))
+        if (def->missing && !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))
             virBufferAddLit(buf, " missing='yes'");
     }
 
@@ -16786,7 +16757,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("PCI address Formatting failed"));
 
-        if ((flags & VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES) &&
+        if ((flags & VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES) &&
             (def->origstates.states.pci.unbind_from_stub ||
              def->origstates.states.pci.remove_slot ||
              def->origstates.states.pci.reprobe)) {
@@ -17107,7 +17078,7 @@ virDomainNetDefFormat(virBufferPtr buf,
     unsigned int actualType = virDomainNetGetActualType(def);
     bool publicActual
        = (def->type == VIR_DOMAIN_NET_TYPE_NETWORK && def->data.network.actual &&
-          !(flags & (VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET)));
+          !(flags & (VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET)));
     const char *typeStr;
     virDomainHostdevDefPtr hostdef = NULL;
     char macstr[VIR_MAC_STRING_BUFLEN];
@@ -17172,7 +17143,7 @@ virDomainNetDefFormat(virBufferPtr buf,
              * as a subelement of <interface> so that no persistent config
              * data is overwritten.
              */
-            if ((flags & VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET) &&
+            if ((flags & VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET) &&
                 (virDomainActualNetDefFormat(buf, def, flags) < 0))
                 return -1;
             break;
@@ -17254,7 +17225,7 @@ virDomainNetDefFormat(virBufferPtr buf,
     virBufferEscapeString(buf, "<script path='%s'/>\n",
                           def->script);
     if (def->ifname &&
-        !((flags & VIR_DOMAIN_XML_INACTIVE) &&
+        !((flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
           (STRPREFIX(def->ifname, VIR_NET_GENERATED_PREFIX)))) {
         /* Skip auto-generated target names for inactive config. */
         virBufferEscapeString(buf, "<target dev='%s'/>\n", def->ifname);
@@ -17331,8 +17302,8 @@ virDomainNetDefFormat(virBufferPtr buf,
                           virDomainNetInterfaceLinkStateTypeToString(def->linkstate));
     }
     if (virDomainDeviceInfoFormat(buf, &def->info,
-                                  flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT
-                                  | VIR_DOMAIN_XML_INTERNAL_ALLOW_ROM) < 0)
+                                  flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT
+                                  | VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM) < 0)
         return -1;
 
     virBufferAdjustIndent(buf, -2);
@@ -17388,7 +17359,7 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
     case VIR_DOMAIN_CHR_TYPE_PIPE:
         if (def->type != VIR_DOMAIN_CHR_TYPE_PTY ||
             (def->data.file.path &&
-             !(flags & VIR_DOMAIN_XML_INACTIVE))) {
+             !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))) {
             virBufferEscapeString(buf, "<source path='%s'",
                                   def->data.file.path);
             virDomainSourceDefFormatSeclabel(buf, nseclabels, seclabels, flags);
@@ -17486,7 +17457,7 @@ virDomainChrDefFormat(virBufferPtr buf,
     tty_compat = (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
                   def->target.port == 0 &&
                   def->source.type == VIR_DOMAIN_CHR_TYPE_PTY &&
-                  !(flags & VIR_DOMAIN_XML_INACTIVE) &&
+                  !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
                   def->source.data.file.path);
     if (virDomainChrSourceDefFormat(buf, def, &def->source, tty_compat, flags) < 0)
         return -1;
@@ -17554,7 +17525,7 @@ virDomainChrDefFormat(virBufferPtr buf,
         break;
     }
 
-    if (virDomainDeviceInfoIsSet(&def->info, flags)) {
+    if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
         if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
             return -1;
     }
@@ -17583,7 +17554,7 @@ virDomainSmartcardDefFormat(virBufferPtr buf,
     virBufferAdjustIndent(buf, 2);
     switch (def->type) {
     case VIR_DOMAIN_SMARTCARD_TYPE_HOST:
-        if (!virDomainDeviceInfoIsSet(&def->info, flags)) {
+        if (!virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
             virBufferAdjustIndent(buf, -2);
             virBufferAddLit(buf, "/>\n");
             return 0;
@@ -17659,7 +17630,7 @@ virDomainTPMDefFormat(virBufferPtr buf,
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</backend>\n");
 
-    if (virDomainDeviceInfoIsSet(&def->info, flags)) {
+    if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
         if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
             return -1;
     }
@@ -17697,7 +17668,7 @@ virDomainSoundDefFormat(virBufferPtr buf,
         virDomainSoundCodecDefFormat(buf, def->codecs[i]);
     }
 
-    if (virDomainDeviceInfoIsSet(&def->info, flags)) {
+    if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
         if (!children) {
             virBufferAddLit(buf, ">\n");
             virBufferAdjustIndent(buf, 2);
@@ -17735,7 +17706,7 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
     virBufferAsprintf(buf, "<memballoon model='%s'", model);
     virBufferAdjustIndent(buf, 2);
 
-    if (virDomainDeviceInfoIsSet(&def->info, flags)) {
+    if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
         virBufferAddLit(buf, ">\n");
         if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
             return -1;
@@ -17765,7 +17736,7 @@ virDomainNVRAMDefFormat(virBufferPtr buf,
 {
     virBufferAddLit(buf, "<nvram>\n");
     virBufferAdjustIndent(buf, 2);
-    if (virDomainDeviceInfoIsSet(&def->info, flags) &&
+    if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
         virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
         return -1;
 
@@ -17799,7 +17770,7 @@ virDomainWatchdogDefFormat(virBufferPtr buf,
     virBufferAsprintf(buf, "<watchdog model='%s' action='%s'",
                       model, action);
 
-    if (virDomainDeviceInfoIsSet(&def->info, flags)) {
+    if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
         virBufferAddLit(buf, ">\n");
         virBufferAdjustIndent(buf, 2);
         if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
@@ -17836,7 +17807,7 @@ virDomainShmemDefFormat(virBufferPtr buf,
     if (!def->size &&
         !def->server.enabled &&
         !def->msi.enabled &&
-        !virDomainDeviceInfoIsSet(&def->info, flags)) {
+        !virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
         virBufferAddLit(buf, "/>\n");
         return 0;
     } else {
@@ -17908,7 +17879,7 @@ virDomainRNGDefFormat(virBufferPtr buf,
         break;
     }
 
-    if (virDomainDeviceInfoIsSet(&def->info, flags)) {
+    if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
         if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
             return -1;
     }
@@ -18016,7 +17987,7 @@ virDomainInputDefFormat(virBufferPtr buf,
     virBufferAsprintf(buf, "<input type='%s' bus='%s'",
                       type, bus);
 
-    if (virDomainDeviceInfoIsSet(&def->info, flags)) {
+    if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
         virBufferAddLit(buf, ">\n");
         virBufferAdjustIndent(buf, 2);
         if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
@@ -18123,7 +18094,7 @@ virDomainGraphicsAuthDefFormatAttr(virBufferPtr buf,
     if (!def->passwd)
         return;
 
-    if (flags & VIR_DOMAIN_XML_SECURE)
+    if (flags & VIR_DOMAIN_DEF_FORMAT_SECURE)
         virBufferEscapeString(buf, " passwd='%s'",
                               def->passwd);
 
@@ -18148,7 +18119,7 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf,
 {
     /* If generating migratable XML, skip listen address
      * dragged in from config file */
-    if ((flags & VIR_DOMAIN_XML_MIGRATABLE) && def->fromConfig)
+    if ((flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) && def->fromConfig)
         return;
 
     virBufferAddLit(buf, "<listen");
@@ -18160,7 +18131,7 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf,
     if (def->address &&
         (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
          (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
-          !(flags & VIR_DOMAIN_XML_INACTIVE)))) {
+          !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)))) {
         /* address may also be set to show current status when type='network',
          * but we don't want to print that if INACTIVE data is requested. */
         virBufferAsprintf(buf, " address='%s'", def->address);
@@ -18171,7 +18142,7 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf,
         virBufferEscapeString(buf, " network='%s'", def->network);
     }
 
-    if (flags & VIR_DOMAIN_XML_INTERNAL_STATUS)
+    if (flags & VIR_DOMAIN_DEF_FORMAT_STATUS)
         virBufferAsprintf(buf, " fromConfig='%d'", def->fromConfig);
 
     virBufferAddLit(buf, "/>\n");
@@ -18200,7 +18171,7 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
     for (i = 0; i < def->nListens; i++) {
         if (virDomainGraphicsListenGetType(def, i)
             == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) {
-            if (flags & VIR_DOMAIN_XML_MIGRATABLE &&
+            if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
                 def->listens[i].fromConfig)
                 continue;
             listenAddr = virDomainGraphicsListenGetAddress(def, i);
@@ -18218,7 +18189,7 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
                                   def->data.vnc.socket);
         } else {
             if (def->data.vnc.port &&
-                (!def->data.vnc.autoport || !(flags & VIR_DOMAIN_XML_INACTIVE)))
+                (!def->data.vnc.autoport || !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)))
                 virBufferAsprintf(buf, " port='%d'",
                                   def->data.vnc.port);
             else if (def->data.vnc.autoport)
@@ -18322,7 +18293,7 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
         if (virDomainGraphicsListenGetType(def, i)
             == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE)
             continue;
-        if (flags & VIR_DOMAIN_XML_MIGRATABLE &&
+        if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
             def->listens[i].fromConfig)
             continue;
         if (!children) {
@@ -18471,8 +18442,8 @@ virDomainHostdevDefFormat(virBufferPtr buf,
         virBufferAddLit(buf, "<shareable/>\n");
 
     if (virDomainDeviceInfoFormat(buf, def->info,
-                                  flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT
-                                  | VIR_DOMAIN_XML_INTERNAL_ALLOW_ROM) < 0)
+                                  flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT
+                                  | VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM) < 0)
         return -1;
 
     virBufferAdjustIndent(buf, -2);
@@ -18495,7 +18466,7 @@ virDomainRedirdevDefFormat(virBufferPtr buf,
     if (virDomainChrSourceDefFormat(buf, NULL, &def->source.chr, false, flags) < 0)
         return -1;
     if (virDomainDeviceInfoFormat(buf, &def->info,
-                                  flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0)
+                                  flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) < 0)
         return -1;
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</redirdev>\n");
@@ -18552,7 +18523,7 @@ virDomainHubDefFormat(virBufferPtr buf,
 
     virBufferAsprintf(buf, "<hub type='%s'", type);
 
-    if (virDomainDeviceInfoIsSet(&def->info, flags)) {
+    if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
         virBufferAddLit(buf, ">\n");
         virBufferAdjustIndent(buf, 2);
         if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
@@ -18690,8 +18661,7 @@ virDomainDefHasCapabilitiesFeatures(virDomainDefPtr def)
     return false;
 }
 
-/* This internal version can accept VIR_DOMAIN_XML_INTERNAL_*,
- * whereas the public version cannot.  Also, it appends to an existing
+/* This internal version  appends to an existing
  * buffer (possibly with auto-indent), rather than flattening to string.
  * Return -1 on failure.  */
 int
@@ -18707,11 +18677,11 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     bool blkio = false;
     bool cputune = false;
 
-    virCheckFlags(DUMPXML_FLAGS |
-                  VIR_DOMAIN_XML_INTERNAL_STATUS |
-                  VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET |
-                  VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES |
-                  VIR_DOMAIN_XML_INTERNAL_CLOCK_ADJUST,
+    virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS |
+                  VIR_DOMAIN_DEF_FORMAT_STATUS |
+                  VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET |
+                  VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES |
+                  VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST,
                   -1);
 
     if (!(type = virDomainVirtTypeToString(def->virtType))) {
@@ -18721,10 +18691,10 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     }
 
     if (def->id == -1)
-        flags |= VIR_DOMAIN_XML_INACTIVE;
+        flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;
 
     virBufferAsprintf(buf, "<domain type='%s'", type);
-    if (!(flags & VIR_DOMAIN_XML_INACTIVE))
+    if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))
         virBufferAsprintf(buf, " id='%d'", def->id);
     if (def->namespaceData && def->ns.href)
         virBufferAsprintf(buf, " %s", (def->ns.href)());
@@ -19279,7 +19249,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
         virBufferAsprintf(buf, " adjustment='%lld' basis='%s'",
                           def->clock.data.variable.adjustment,
                           virDomainClockBasisTypeToString(def->clock.data.variable.basis));
-        if (flags & VIR_DOMAIN_XML_INTERNAL_CLOCK_ADJUST) {
+        if (flags & VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST) {
             if (def->clock.data.variable.adjustment0)
                 virBufferAsprintf(buf, " adjustment0='%lld'",
                                   def->clock.data.variable.adjustment0);
@@ -19429,7 +19399,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
             if (virDomainInputDefFormat(buf, &autoInput, flags) < 0)
                 goto error;
 
-            if (!(flags & VIR_DOMAIN_XML_MIGRATABLE)) {
+            if (!(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE)) {
                 autoInput.type = VIR_DOMAIN_INPUT_TYPE_KBD;
                 if (virDomainInputDefFormat(buf, &autoInput, flags) < 0)
                     goto error;
@@ -19517,12 +19487,31 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     return -1;
 }
 
+int virDomainDefFormatConvertXMLFlags(unsigned int flags)
+{
+    int formatFlags = 0;
+
+    if (flags & VIR_DOMAIN_XML_SECURE)
+        formatFlags |= VIR_DOMAIN_DEF_FORMAT_SECURE;
+    if (flags & VIR_DOMAIN_XML_INACTIVE)
+        formatFlags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;
+    if (flags & VIR_DOMAIN_XML_MIGRATABLE)
+        formatFlags |= VIR_DOMAIN_DEF_FORMAT_MIGRATABLE;
+
+    /* VIR_DOMAIN_XML_UPDATE_CPU is not handled at the
+       XML formatting level. The driver code must take
+       care of it, so we don't include it here */
+
+    return formatFlags;
+}
+
+
 char *
 virDomainDefFormat(virDomainDefPtr def, unsigned int flags)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
-    virCheckFlags(DUMPXML_FLAGS, NULL);
+    virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS, NULL);
     if (virDomainDefFormatInternal(def, flags, &buf) < 0)
         return NULL;
 
@@ -19699,7 +19688,7 @@ virDomainSaveConfig(const char *configDir,
     int ret = -1;
     char *xml;
 
-    if (!(xml = virDomainDefFormat(def, VIR_DOMAIN_XML_WRITE_FLAGS)))
+    if (!(xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_SECURE)))
         goto cleanup;
 
     if (virDomainSaveXML(configDir, def, xml))
@@ -19716,11 +19705,11 @@ virDomainSaveStatus(virDomainXMLOptionPtr xmlopt,
                     const char *statusDir,
                     virDomainObjPtr obj)
 {
-    unsigned int flags = (VIR_DOMAIN_XML_SECURE |
-                          VIR_DOMAIN_XML_INTERNAL_STATUS |
-                          VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET |
-                          VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES |
-                          VIR_DOMAIN_XML_INTERNAL_CLOCK_ADJUST);
+    unsigned int flags = (VIR_DOMAIN_DEF_FORMAT_SECURE |
+                          VIR_DOMAIN_DEF_FORMAT_STATUS |
+                          VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET |
+                          VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES |
+                          VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST);
 
     int ret = -1;
     char *xml;
@@ -19759,7 +19748,7 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms,
         goto error;
     if (!(def = virDomainDefParseFile(configFile, caps, xmlopt,
                                       expectedVirtTypes,
-                                      VIR_DOMAIN_XML_INACTIVE)))
+                                      VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto error;
 
     if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL)
@@ -19806,10 +19795,10 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms,
         goto error;
 
     if (!(obj = virDomainObjParseFile(statusFile, caps, xmlopt, expectedVirtTypes,
-                                      VIR_DOMAIN_XML_INTERNAL_STATUS |
-                                      VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET |
-                                      VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES |
-                                      VIR_DOMAIN_XML_INTERNAL_CLOCK_ADJUST)))
+                                      VIR_DOMAIN_DEF_PARSE_STATUS |
+                                      VIR_DOMAIN_DEF_PARSE_ACTUAL_NET |
+                                      VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES |
+                                      VIR_DOMAIN_DEF_PARSE_CLOCK_ADJUST)))
         goto error;
 
     virUUIDFormat(obj->def->uuid, uuidstr);
@@ -20332,17 +20321,17 @@ virDomainDefCopy(virDomainDefPtr src,
 {
     char *xml;
     virDomainDefPtr ret;
-    unsigned int write_flags = VIR_DOMAIN_XML_WRITE_FLAGS;
-    unsigned int read_flags = VIR_DOMAIN_XML_READ_FLAGS;
+    unsigned int format_flags = VIR_DOMAIN_DEF_FORMAT_SECURE;
+    unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
 
     if (migratable)
-        write_flags |= VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_MIGRATABLE;
+        format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_MIGRATABLE;
 
     /* Easiest to clone via a round-trip through XML.  */
-    if (!(xml = virDomainDefFormat(src, write_flags)))
+    if (!(xml = virDomainDefFormat(src, format_flags)))
         return NULL;
 
-    ret = virDomainDefParseString(xml, caps, xmlopt, -1, read_flags);
+    ret = virDomainDefParseString(xml, caps, xmlopt, -1, parse_flags);
 
     VIR_FREE(xml);
     return ret;
@@ -20796,7 +20785,7 @@ virDomainNetFind(virDomainDefPtr def, const char *device)
  * @src: source to be copied
  *
  * virDomainDeviceDefCopy does a deep copy of only the parts of a
- * DeviceDef that are valid when just the flag VIR_DOMAIN_XML_INACTIVE is
+ * DeviceDef that are valid when just the flag VIR_DOMAIN_DEF_PARSE_INACTIVE is
  * set. This means that any part of the device xml that is conditionally
  * parsed/formatted based on some other flag being set (or on the INACTIVE
  * flag being reset) *will not* be copied to the destination. Caveat emptor.
@@ -20811,55 +20800,54 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
 {
     virDomainDeviceDefPtr ret = NULL;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
-    int flags = VIR_DOMAIN_XML_INACTIVE;
     char *xmlStr = NULL;
     int rc = -1;
 
     switch ((virDomainDeviceType) src->type) {
     case VIR_DOMAIN_DEVICE_DISK:
-        rc = virDomainDiskDefFormat(&buf, src->data.disk, flags);
+        rc = virDomainDiskDefFormat(&buf, src->data.disk, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_LEASE:
         rc = virDomainLeaseDefFormat(&buf, src->data.lease);
         break;
     case VIR_DOMAIN_DEVICE_FS:
-        rc = virDomainFSDefFormat(&buf, src->data.fs, flags);
+        rc = virDomainFSDefFormat(&buf, src->data.fs, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_NET:
-        rc = virDomainNetDefFormat(&buf, src->data.net, flags);
+        rc = virDomainNetDefFormat(&buf, src->data.net, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_INPUT:
-        rc = virDomainInputDefFormat(&buf, src->data.input, flags);
+        rc = virDomainInputDefFormat(&buf, src->data.input, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_SOUND:
-        rc = virDomainSoundDefFormat(&buf, src->data.sound, flags);
+        rc = virDomainSoundDefFormat(&buf, src->data.sound, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_VIDEO:
-        rc = virDomainVideoDefFormat(&buf, src->data.video, flags);
+        rc = virDomainVideoDefFormat(&buf, src->data.video, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_HOSTDEV:
-        rc = virDomainHostdevDefFormat(&buf, src->data.hostdev, flags);
+        rc = virDomainHostdevDefFormat(&buf, src->data.hostdev, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_WATCHDOG:
-        rc = virDomainWatchdogDefFormat(&buf, src->data.watchdog, flags);
+        rc = virDomainWatchdogDefFormat(&buf, src->data.watchdog, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_CONTROLLER:
-        rc = virDomainControllerDefFormat(&buf, src->data.controller, flags);
+        rc = virDomainControllerDefFormat(&buf, src->data.controller, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_GRAPHICS:
-        rc = virDomainGraphicsDefFormat(&buf, src->data.graphics, flags);
+        rc = virDomainGraphicsDefFormat(&buf, src->data.graphics, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_HUB:
-        rc = virDomainHubDefFormat(&buf, src->data.hub, flags);
+        rc = virDomainHubDefFormat(&buf, src->data.hub, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_REDIRDEV:
-        rc = virDomainRedirdevDefFormat(&buf, src->data.redirdev, flags);
+        rc = virDomainRedirdevDefFormat(&buf, src->data.redirdev, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_RNG:
-        rc = virDomainRNGDefFormat(&buf, src->data.rng, flags);
+        rc = virDomainRNGDefFormat(&buf, src->data.rng, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_CHR:
-        rc = virDomainChrDefFormat(&buf, src->data.chr, flags);
+        rc = virDomainChrDefFormat(&buf, src->data.chr, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
         break;
     case VIR_DOMAIN_DEVICE_NONE:
     case VIR_DOMAIN_DEVICE_SMARTCARD:
@@ -20878,7 +20866,8 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
         goto cleanup;
 
     xmlStr = virBufferContentAndReset(&buf);
-    ret = virDomainDeviceDefParse(xmlStr, def, caps, xmlopt, flags);
+    ret = virDomainDeviceDefParse(xmlStr, def, caps, xmlopt,
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
 
  cleanup:
     VIR_FREE(xmlStr);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 530a3ca..98497d6 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2389,42 +2389,74 @@ void virDomainObjListRemove(virDomainObjListPtr doms,
 void virDomainObjListRemoveLocked(virDomainObjListPtr doms,
                                   virDomainObjPtr dom);
 
+typedef enum {
+    /* parse internal domain status information */
+    VIR_DOMAIN_DEF_PARSE_STATUS          = 1 << 0,
+    VIR_DOMAIN_DEF_PARSE_INACTIVE        = 1 << 2,
+    /* parse <actual> element */
+    VIR_DOMAIN_DEF_PARSE_ACTUAL_NET      = 1 << 3,
+    /* parse original states of host PCI device */
+    VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES = 1 << 4,
+    VIR_DOMAIN_DEF_PARSE_ALLOW_ROM       = 1 << 5,
+    VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT      = 1 << 6,
+    VIR_DOMAIN_DEF_PARSE_CLOCK_ADJUST    = 1 << 7,
+    /* parse only source half of <disk> */
+    VIR_DOMAIN_DEF_PARSE_DISK_SOURCE     = 1 << 8,
+} virDomainDefParseFlags;
+
+typedef enum {
+    VIR_DOMAIN_DEF_FORMAT_SECURE          = 1 << 0,
+    VIR_DOMAIN_DEF_FORMAT_INACTIVE        = 1 << 1,
+    VIR_DOMAIN_DEF_FORMAT_MIGRATABLE      = 1 << 2,
+    /* format internal domain status information */
+    VIR_DOMAIN_DEF_FORMAT_STATUS          = 1 << 3,
+    /* format <actual> element */
+    VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET      = 1 << 4,
+    /* format original states of host PCI device */
+    VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES = 1 << 5,
+    VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM       = 1 << 6,
+    VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT      = 1 << 7,
+    VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST    = 1 << 8,
+} virDomainDefFormatFlags;
+
 virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
                                               const virDomainDef *def,
                                               virCapsPtr caps,
                                               virDomainXMLOptionPtr xmlopt,
                                               unsigned int flags);
 virStorageSourcePtr virDomainDiskDefSourceParse(const char *xmlStr,
-                                                const virDomainDef *def,
-                                                virDomainXMLOptionPtr xmlopt,
-                                                unsigned int flags);
+                                                 const virDomainDef *def,
+                                                 virDomainXMLOptionPtr xmlopt,
+                                                 unsigned int flags);
 virDomainDefPtr virDomainDefParseString(const char *xmlStr,
-                                        virCapsPtr caps,
-                                        virDomainXMLOptionPtr xmlopt,
-                                        unsigned int expectedVirtTypes,
-                                        unsigned int flags);
+                                         virCapsPtr caps,
+                                         virDomainXMLOptionPtr xmlopt,
+                                         unsigned int expectedVirtTypes,
+                                         unsigned int flags);
 virDomainDefPtr virDomainDefParseFile(const char *filename,
-                                      virCapsPtr caps,
-                                      virDomainXMLOptionPtr xmlopt,
-                                      unsigned int expectedVirtTypes,
-                                      unsigned int flags);
+                                       virCapsPtr caps,
+                                       virDomainXMLOptionPtr xmlopt,
+                                       unsigned int expectedVirtTypes,
+                                       unsigned int flags);
 virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc,
-                                      xmlNodePtr root,
-                                      virCapsPtr caps,
-                                      virDomainXMLOptionPtr xmlopt,
-                                      unsigned int expectedVirtTypes,
-                                      unsigned int flags);
+                                       xmlNodePtr root,
+                                       virCapsPtr caps,
+                                       virDomainXMLOptionPtr xmlopt,
+                                       unsigned int expectedVirtTypes,
+                                       unsigned int flags);
 
 bool virDomainDefCheckABIStability(virDomainDefPtr src,
                                    virDomainDefPtr dst);
 
 int virDomainDefAddImplicitControllers(virDomainDefPtr def);
 
+int virDomainDefFormatConvertXMLFlags(unsigned int flags);
+
 char *virDomainDefFormat(virDomainDefPtr def,
-                         unsigned int flags);
+                          unsigned int flags);
 int virDomainDefFormatInternal(virDomainDefPtr def,
-                               unsigned int flags,
-                               virBufferPtr buf);
+                                unsigned int flags,
+                                virBufferPtr buf);
 
 int virDomainDiskSourceFormat(virBufferPtr buf,
                               virStorageSourcePtr src,
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index a72ded7..602db3e 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -286,7 +286,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
             def->dom = virDomainDefParseNode(ctxt->node->doc, domainNode,
                                              caps, xmlopt,
                                              expectedVirtTypes,
-                                             VIR_DOMAIN_XML_INACTIVE);
+                                             VIR_DOMAIN_DEF_PARSE_INACTIVE);
             if (!def->dom)
                 goto cleanup;
         } else {
@@ -675,9 +675,9 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     size_t i;
 
-    virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
+    virCheckFlags(VIR_DOMAIN_DEF_FORMAT_SECURE, NULL);
 
-    flags |= VIR_DOMAIN_XML_INACTIVE;
+    flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;
 
     virBufferAddLit(&buf, "<domainsnapshot>\n");
     virBufferAdjustIndent(&buf, 2);
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 248bb92..aa3ae5c 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2751,7 +2751,8 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
         if (powerState != esxVI_VirtualMachinePowerState_PoweredOff)
             def->id = id;
 
-        xml = virDomainDefFormat(def, flags);
+        xml = virDomainDefFormat(def,
+                                 virDomainDefFormatConvertXMLFlags(flags));
     }
 
  cleanup:
@@ -2805,7 +2806,7 @@ esxConnectDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
     def = virVMXParseConfig(&ctx, priv->xmlopt, nativeConfig);
 
     if (def)
-        xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
+        xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
 
     virDomainDefFree(def);
 
@@ -2844,7 +2845,7 @@ esxConnectDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
 
     def = virDomainDefParseString(domainXml, priv->caps, priv->xmlopt,
                                   1 << VIR_DOMAIN_VIRT_VMWARE,
-                                  VIR_DOMAIN_XML_INACTIVE);
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
 
     if (!def)
         return NULL;
@@ -3055,7 +3056,7 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
     /* Parse domain XML */
     def = virDomainDefParseString(xml, priv->caps, priv->xmlopt,
                                   1 << VIR_DOMAIN_VIRT_VMWARE,
-                                  VIR_DOMAIN_XML_INACTIVE);
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
 
     if (!def)
         return NULL;
@@ -4301,7 +4302,9 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
 
     virUUIDFormat(snapshot->domain->uuid, uuid_string);
 
-    xml = virDomainSnapshotDefFormat(uuid_string, &def, flags, 0);
+    xml = virDomainSnapshotDefFormat(uuid_string, &def,
+                                     virDomainDefFormatConvertXMLFlags(flags),
+                                     0);
 
  cleanup:
     esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotList);
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index ece943e..ca214f2 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -887,7 +887,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
 
     /* FIXME: devices section is totally missing */
 
-    xml = virDomainDefFormat(def, flags);
+    xml = virDomainDefFormat(def,
+                             virDomainDefFormatConvertXMLFlags(flags));
 
  cleanup:
     virDomainDefFree(def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b48dde4..8165bfd 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -192,6 +192,7 @@ virDomainDefCompatibleDevice;
 virDomainDefCopy;
 virDomainDefFindDevice;
 virDomainDefFormat;
+virDomainDefFormatConvertXMLFlags;
 virDomainDefFormatInternal;
 virDomainDefFree;
 virDomainDefGetDefaultEmulator;
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 9c62291..9185117 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -880,7 +880,7 @@ libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver,
 
     if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_XEN,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto error;
 
     VIR_FREE(xml);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 9b049db..8a1a11f 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -643,7 +643,7 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml,
 
     if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_XEN,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (virDomainCreateXMLEnsureACL(conn, def) < 0)
@@ -2189,7 +2189,8 @@ libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
     if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;
 
-    ret = virDomainDefFormat(vm->def, flags);
+    ret = virDomainDefFormat(vm->def,
+                              virDomainDefFormatConvertXMLFlags(flags));
 
  cleanup:
     if (vm)
@@ -2241,7 +2242,7 @@ libxlConnectDomainXMLFromNative(virConnectPtr conn,
         goto cleanup;
     }
 
-    xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
+    xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
 
  cleanup:
     virDomainDefFree(def);
@@ -2278,7 +2279,7 @@ libxlConnectDomainXMLToNative(virConnectPtr conn, const char * nativeFormat,
     if (!(def = virDomainDefParseString(domainXml,
                                         cfg->caps, driver->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_XEN,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (!(conf = xenFormatXM(conn, def, cfg->verInfo->xen_version_major)))
@@ -2381,7 +2382,7 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
 
     if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_XEN,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
@@ -3273,7 +3274,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
     if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
         if (!(dev = virDomainDeviceDefParse(xml, vm->def,
                                             cfg->caps, driver->xmlopt,
-                                            VIR_DOMAIN_XML_INACTIVE)))
+                                            VIR_DOMAIN_DEF_PARSE_INACTIVE)))
             goto endjob;
 
         /* Make a copy for updated domain. */
@@ -3290,7 +3291,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
         virDomainDeviceDefFree(dev);
         if (!(dev = virDomainDeviceDefParse(xml, vm->def,
                                             cfg->caps, driver->xmlopt,
-                                            VIR_DOMAIN_XML_INACTIVE)))
+                                            VIR_DOMAIN_DEF_PARSE_INACTIVE)))
             goto endjob;
 
         if (libxlDomainAttachDeviceLive(driver, priv, vm, dev) < 0)
@@ -3384,7 +3385,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
     if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
         if (!(dev = virDomainDeviceDefParse(xml, vm->def,
                                             cfg->caps, driver->xmlopt,
-                                            VIR_DOMAIN_XML_INACTIVE)))
+                                            VIR_DOMAIN_DEF_PARSE_INACTIVE)))
             goto endjob;
 
         /* Make a copy for updated domain. */
@@ -3401,7 +3402,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
         virDomainDeviceDefFree(dev);
         if (!(dev = virDomainDeviceDefParse(xml, vm->def,
                                             cfg->caps, driver->xmlopt,
-                                            VIR_DOMAIN_XML_INACTIVE)))
+                                            VIR_DOMAIN_DEF_PARSE_INACTIVE)))
             goto endjob;
 
         if (libxlDomainDetachDeviceLive(driver, priv, vm, dev) < 0)
@@ -3492,7 +3493,7 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
     if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
         if (!(dev = virDomainDeviceDefParse(xml, vm->def,
                                             cfg->caps, driver->xmlopt,
-                                            VIR_DOMAIN_XML_INACTIVE)))
+                                            VIR_DOMAIN_DEF_PARSE_INACTIVE)))
             goto cleanup;
 
         /* Make a copy for updated domain. */
@@ -3511,7 +3512,7 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
         virDomainDeviceDefFree(dev);
         if (!(dev = virDomainDeviceDefParse(xml, vm->def,
                                             cfg->caps, driver->xmlopt,
-                                            VIR_DOMAIN_XML_INACTIVE)))
+                                            VIR_DOMAIN_DEF_PARSE_INACTIVE)))
             goto cleanup;
 
         if ((ret = libxlDomainUpdateDeviceLive(priv, vm, dev)) < 0)
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 0b562f7..ac42a70 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -199,7 +199,7 @@ libxlDomainMigrationBegin(virConnectPtr conn,
         if (!(tmpdef = virDomainDefParseString(xmlin, cfg->caps,
                                                driver->xmlopt,
                                                1 << VIR_DOMAIN_VIRT_XEN,
-                                               VIR_DOMAIN_XML_INACTIVE)))
+                                               VIR_DOMAIN_DEF_PARSE_INACTIVE)))
             goto endjob;
 
         if (!libxlDomainDefCheckABIStability(driver, vm->def, tmpdef))
@@ -213,7 +213,7 @@ libxlDomainMigrationBegin(virConnectPtr conn,
     if (!libxlDomainMigrationIsAllowed(def))
         goto endjob;
 
-    xml = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE);
+    xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_SECURE);
 
  endjob:
     if (!libxlDomainObjEndJob(driver, vm))
@@ -245,7 +245,7 @@ libxlDomainMigrationPrepareDef(libxlDriverPrivatePtr driver,
 
     if (!(def = virDomainDefParseString(dom_xml, cfg->caps, driver->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_XEN,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (dname) {
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index a9a34b5..54e9fef 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -462,7 +462,7 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
 
     if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_LXC,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
@@ -1038,7 +1038,7 @@ static char *lxcDomainGetXMLDesc(virDomainPtr dom,
 
     ret = virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) &&
                              vm->newDef ? vm->newDef : vm->def,
-                             flags);
+                             virDomainDefFormatConvertXMLFlags(flags));
 
  cleanup:
     if (vm)
@@ -1204,7 +1204,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
 
     if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_LXC,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (virDomainCreateXMLWithFilesEnsureACL(conn, def) < 0)
@@ -5004,7 +5004,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
 
     dev = dev_copy = virDomainDeviceDefParse(xml, vm->def,
                                              caps, driver->xmlopt,
-                                             VIR_DOMAIN_XML_INACTIVE);
+                                             VIR_DOMAIN_DEF_PARSE_INACTIVE);
     if (dev == NULL)
         goto cleanup;
 
@@ -5133,7 +5133,7 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
 
     dev = dev_copy = virDomainDeviceDefParse(xml, vm->def,
                                              caps, driver->xmlopt,
-                                             VIR_DOMAIN_XML_INACTIVE);
+                                             VIR_DOMAIN_DEF_PARSE_INACTIVE);
     if (dev == NULL)
         goto cleanup;
 
@@ -5246,7 +5246,7 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom,
 
     dev = dev_copy = virDomainDeviceDefParse(xml, vm->def,
                                              caps, driver->xmlopt,
-                                             VIR_DOMAIN_XML_INACTIVE);
+                                             VIR_DOMAIN_DEF_PARSE_INACTIVE);
     if (dev == NULL)
         goto cleanup;
 
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 69bb38c..e2a6b9e 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -566,7 +566,8 @@ static char *openvzDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
         goto cleanup;
     }
 
-    ret = virDomainDefFormat(vm->def, flags);
+    ret = virDomainDefFormat(vm->def,
+                             virDomainDefFormatConvertXMLFlags(flags));
 
  cleanup:
     if (vm)
@@ -981,7 +982,7 @@ openvzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
     openvzDriverLock(driver);
     if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
                                          1 << VIR_DOMAIN_VIRT_OPENVZ,
-                                         VIR_DOMAIN_XML_INACTIVE)) == NULL)
+                                         VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
         goto cleanup;
 
     vm = virDomainObjListFindByName(driver->domains, vmdef->name);
@@ -1073,7 +1074,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
     openvzDriverLock(driver);
     if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
                                          1 << VIR_DOMAIN_VIRT_OPENVZ,
-                                         VIR_DOMAIN_XML_INACTIVE)) == NULL)
+                                         VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
         goto cleanup;
 
     vm = virDomainObjListFindByName(driver->domains, vmdef->name);
@@ -2105,7 +2106,7 @@ openvzDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
         goto cleanup;
 
     dev = virDomainDeviceDefParse(xml, vmdef, driver->caps, driver->xmlopt,
-                                  VIR_DOMAIN_XML_INACTIVE);
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
     if (!dev)
         goto cleanup;
 
@@ -2260,7 +2261,7 @@ openvzDomainMigrateBegin3Params(virDomainPtr domain,
         goto cleanup;
     }
 
-    xml = virDomainDefFormat(vm->def, VIR_DOMAIN_XML_SECURE);
+    xml = virDomainDefFormat(vm->def, VIR_DOMAIN_DEF_FORMAT_SECURE);
 
  cleanup:
     if (vm)
@@ -2308,7 +2309,7 @@ openvzDomainMigratePrepare3Params(virConnectPtr dconn,
 
     if (!(def = virDomainDefParseString(dom_xml, driver->caps, driver->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_OPENVZ,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto error;
 
     if (!(vm = virDomainObjListAdd(driver->domains, def,
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 71db7bd..7d2c849 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1720,7 +1720,7 @@ phypDomainAttachDevice(virDomainPtr domain, const char *xml)
         goto cleanup;
 
     dev = virDomainDeviceDefParse(xml, def, phyp_driver->caps, NULL,
-                                  VIR_DOMAIN_XML_INACTIVE);
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
     if (!dev)
         goto cleanup;
 
@@ -3291,7 +3291,8 @@ phypDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
         goto err;
     }
 
-    return virDomainDefFormat(&def, flags);
+    return virDomainDefFormat(&def,
+                              virDomainDefFormatConvertXMLFlags(flags));
 
  err:
     return NULL;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 00fbb2f..98386f3 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1708,7 +1708,7 @@ qemuDomainDefCopy(virQEMUDriverPtr driver,
 
     if (!(ret = virDomainDefParseString(xml, caps, driver->xmlopt,
                                         QEMU_EXPECTED_VIRT_TYPES,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
  cleanup:
@@ -1818,7 +1818,9 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
 
     }
 
-    ret = virDomainDefFormatInternal(def, flags, buf);
+    ret = virDomainDefFormatInternal(def,
+                                     virDomainDefFormatConvertXMLFlags(flags),
+                                     buf);
 
  cleanup:
     def->cpu = def_cpu;
@@ -2171,7 +2173,7 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
 
     virUUIDFormat(vm->def->uuid, uuidstr);
     newxml = virDomainSnapshotDefFormat(uuidstr, snapshot->def,
-                                        VIR_DOMAIN_XML_SECURE, 1);
+                                        VIR_DOMAIN_DEF_FORMAT_SECURE, 1);
     if (newxml == NULL)
         return -1;
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 654fa2e..6ccf940 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1705,7 +1705,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
 
     if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt,
                                         QEMU_EXPECTED_VIRT_TYPES,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (virDomainCreateXMLEnsureACL(conn, def) < 0)
@@ -3220,7 +3220,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
 
         if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlopt,
                                             QEMU_EXPECTED_VIRT_TYPES,
-                                            VIR_DOMAIN_XML_INACTIVE))) {
+                                            VIR_DOMAIN_DEF_PARSE_INACTIVE))) {
             goto endjob;
         }
         if (!qemuDomainDefCheckABIStability(driver, vm->def, def)) {
@@ -5577,7 +5577,7 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver,
 
     if (!(newdef = virDomainDefParseString(newxml, caps, driver->xmlopt,
                                            QEMU_EXPECTED_VIRT_TYPES,
-                                           VIR_DOMAIN_XML_INACTIVE)))
+                                           VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (!(newdef_migr = qemuDomainDefCopy(driver,
@@ -5733,7 +5733,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
     /* Create a domain from this XML */
     if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt,
                                         QEMU_EXPECTED_VIRT_TYPES,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto error;
 
     if (xmlout)
@@ -6319,7 +6319,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
 
     def = virDomainDefParseString(xmlData, caps, driver->xmlopt,
                                   QEMU_EXPECTED_VIRT_TYPES,
-                                  VIR_DOMAIN_XML_INACTIVE);
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
     if (!def)
         goto cleanup;
 
@@ -6672,7 +6672,7 @@ static virDomainPtr qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml
 
     if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt,
                                         QEMU_EXPECTED_VIRT_TYPES,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
@@ -7493,7 +7493,7 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
     virDomainDefPtr vmdef = NULL;
     virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
     int ret = -1;
-    unsigned int affect, parse_flags = VIR_DOMAIN_XML_INACTIVE;
+    unsigned int affect, parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
     virQEMUCapsPtr qemuCaps = NULL;
     qemuDomainObjPrivatePtr priv;
     virQEMUDriverConfigPtr cfg = NULL;
@@ -7694,7 +7694,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
 
     dev = dev_copy = virDomainDeviceDefParse(xml, vm->def,
                                              caps, driver->xmlopt,
-                                             VIR_DOMAIN_XML_INACTIVE);
+                                             VIR_DOMAIN_DEF_PARSE_INACTIVE);
     if (dev == NULL)
         goto endjob;
 
@@ -7832,7 +7832,7 @@ static int qemuDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
 
     if ((flags & VIR_DOMAIN_AFFECT_CONFIG) &&
         !(flags & VIR_DOMAIN_AFFECT_LIVE))
-        parse_flags |= VIR_DOMAIN_XML_INACTIVE;
+        parse_flags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
 
     dev = dev_copy = virDomainDeviceDefParse(xml, vm->def,
                                              caps, driver->xmlopt,
@@ -13954,7 +13954,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
         if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)) ||
             !(def->dom = virDomainDefParseString(xml, caps, driver->xmlopt,
                                                  QEMU_EXPECTED_VIRT_TYPES,
-                                                 VIR_DOMAIN_XML_INACTIVE)))
+                                                 VIR_DOMAIN_DEF_PARSE_INACTIVE)))
             goto endjob;
 
         if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) {
@@ -14393,7 +14393,9 @@ qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
 
     virUUIDFormat(snapshot->domain->uuid, uuidstr);
 
-    xml = virDomainSnapshotDefFormat(uuidstr, snap->def, flags, 0);
+    xml = virDomainSnapshotDefFormat(uuidstr, snap->def,
+                                     virDomainDefFormatConvertXMLFlags(flags),
+                                     0);
 
  cleanup:
     virObjectUnlock(vm);
@@ -16181,7 +16183,7 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
     }
 
     if (!(dest = virDomainDiskDefSourceParse(destxml, vm->def, driver->xmlopt,
-                                             VIR_DOMAIN_XML_INACTIVE)))
+                                             VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     ret = qemuDomainBlockCopyCommon(vm, dom->conn, disk, dest,
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 100600e..9d53987 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1108,7 +1108,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
         }
         mig->persistent = virDomainDefParseNode(doc, nodes[0],
                                                 caps, driver->xmlopt,
-                                                -1, VIR_DOMAIN_XML_INACTIVE);
+                                                -1, VIR_DOMAIN_DEF_PARSE_INACTIVE);
         if (!mig->persistent) {
             /* virDomainDefParseNode already reported
              * an error for us */
@@ -2386,7 +2386,7 @@ static char
     if (xmlin) {
         if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlopt,
                                             QEMU_EXPECTED_VIRT_TYPES,
-                                            VIR_DOMAIN_XML_INACTIVE)))
+                                            VIR_DOMAIN_DEF_PARSE_INACTIVE)))
             goto cleanup;
 
         if (!qemuDomainDefCheckABIStability(driver, vm->def, def))
@@ -2598,7 +2598,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
                 VIR_DEBUG("Using hook-filtered domain XML: %s", xmlout);
                 newdef = virDomainDefParseString(xmlout, caps, driver->xmlopt,
                                                  QEMU_EXPECTED_VIRT_TYPES,
-                                                 VIR_DOMAIN_XML_INACTIVE);
+                                                 VIR_DOMAIN_DEF_PARSE_INACTIVE);
                 if (!newdef)
                     goto cleanup;
 
@@ -3078,7 +3078,7 @@ qemuMigrationPrepareDef(virQEMUDriverPtr driver,
 
     if (!(def = virDomainDefParseString(dom_xml, caps, driver->xmlopt,
                                         QEMU_EXPECTED_VIRT_TYPES,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (dname) {
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 4469ad5..a71ed7b 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -758,7 +758,7 @@ testOpenDefault(virConnectPtr conn)
                                            privconn->caps,
                                            privconn->xmlopt,
                                            1 << VIR_DOMAIN_VIRT_TEST,
-                                           VIR_DOMAIN_XML_INACTIVE)))
+                                           VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto error;
 
     if (testDomainGenerateIfnames(domdef) < 0)
@@ -1082,7 +1082,7 @@ testParseDomains(testConnPtr privconn,
         def = virDomainDefParseNode(ctxt->doc, node,
                                     privconn->caps, privconn->xmlopt,
                                     1 << VIR_DOMAIN_VIRT_TEST,
-                                    VIR_DOMAIN_XML_INACTIVE);
+                                    VIR_DOMAIN_DEF_PARSE_INACTIVE);
         if (!def)
             goto error;
 
@@ -1749,7 +1749,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
     testDriverLock(privconn);
     if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt,
                                        1 << VIR_DOMAIN_VIRT_TEST,
-                                       VIR_DOMAIN_XML_INACTIVE)) == NULL)
+                                       VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
         goto cleanup;
 
     if (testDomainGenerateIfnames(def) < 0)
@@ -2218,7 +2218,7 @@ testDomainSaveFlags(virDomainPtr domain, const char *path,
     }
 
     xml = virDomainDefFormat(privdom->def,
-                             VIR_DOMAIN_XML_SECURE);
+                             VIR_DOMAIN_DEF_FORMAT_SECURE);
 
     if (xml == NULL) {
         virReportSystemError(errno,
@@ -2362,7 +2362,7 @@ testDomainRestoreFlags(virConnectPtr conn,
 
     def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt,
                                   1 << VIR_DOMAIN_VIRT_TEST,
-                                  VIR_DOMAIN_XML_INACTIVE);
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
     if (!def)
         goto cleanup;
 
@@ -2890,7 +2890,7 @@ static char *testDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
         privdom->newDef ? privdom->newDef : privdom->def;
 
     ret = virDomainDefFormat(def,
-                             flags);
+                             virDomainDefFormatConvertXMLFlags(flags));
 
  cleanup:
     if (privdom)
@@ -2943,7 +2943,7 @@ static virDomainPtr testDomainDefineXMLFlags(virConnectPtr conn,
     testDriverLock(privconn);
     if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt,
                                        1 << VIR_DOMAIN_VIRT_TEST,
-                                       VIR_DOMAIN_XML_INACTIVE)) == NULL)
+                                       VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
         goto cleanup;
 
     if (testDomainGenerateIfnames(def) < 0)
@@ -6784,7 +6784,9 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
 
     virUUIDFormat(snapshot->domain->uuid, uuidstr);
 
-    xml = virDomainSnapshotDefFormat(uuidstr, snap->def, flags, 0);
+    xml = virDomainSnapshotDefFormat(uuidstr, snap->def,
+                                     virDomainDefFormatConvertXMLFlags(flags),
+                                     0);
 
  cleanup:
     if (vm)
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index d15b55a..5684df0 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1612,7 +1612,7 @@ static virDomainPtr umlDomainCreateXML(virConnectPtr conn, const char *xml,
     umlDriverLock(driver);
     if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_UML,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (virDomainCreateXMLEnsureACL(conn, def) < 0)
@@ -1988,7 +1988,7 @@ static char *umlDomainGetXMLDesc(virDomainPtr dom,
 
     ret = virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ?
                              vm->newDef : vm->def,
-                             flags);
+                             virDomainDefFormatConvertXMLFlags(flags));
 
  cleanup:
     if (vm)
@@ -2088,7 +2088,7 @@ umlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
     umlDriverLock(driver);
     if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_UML,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
@@ -2252,7 +2252,7 @@ static int umlDomainAttachDevice(virDomainPtr dom, const char *xml)
     }
 
     dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlopt,
-                                  VIR_DOMAIN_XML_INACTIVE);
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
 
     if (dev == NULL)
         goto cleanup;
@@ -2372,7 +2372,7 @@ static int umlDomainDetachDevice(virDomainPtr dom, const char *xml)
     }
 
     dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlopt,
-                                  VIR_DOMAIN_XML_INACTIVE);
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
     if (dev == NULL)
         goto cleanup;
 
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 322353f..18d05c5 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -1851,7 +1851,7 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags
     VBOX_IID_INITIALIZE(&mchiid);
     if (!(def = virDomainDefParseString(xml, data->caps, data->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_VBOX,
-                                        VIR_DOMAIN_XML_INACTIVE))) {
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE))) {
         goto cleanup;
     }
 
@@ -3967,7 +3967,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
     /* dump USB devices/filters if active */
     vboxHostDeviceGetXMLDesc(data, def, machine);
 
-    ret = virDomainDefFormat(def, flags);
+    ret = virDomainDefFormat(def, virDomainDefFormatConvertXMLFlags(flags));
 
  cleanup:
     VBOX_RELEASE(machine);
@@ -4106,7 +4106,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
         goto cleanup;
 
     dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt,
-                                  VIR_DOMAIN_XML_INACTIVE);
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
     if (dev == NULL)
         goto cleanup;
 
@@ -4238,7 +4238,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml)
         goto cleanup;
 
     dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt,
-                                  VIR_DOMAIN_XML_INACTIVE);
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
     if (dev == NULL)
         goto cleanup;
 
@@ -5198,7 +5198,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
         VIR_FREE(currentSnapshotXmlFilePath);
         if (virAsprintf(&currentSnapshotXmlFilePath, "%s%s.xml", machineLocationPath, snapshotMachineDesc->currentSnapshot) < 0)
             goto cleanup;
-        char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, VIR_DOMAIN_XML_SECURE, 0);
+        char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, VIR_DOMAIN_DEF_FORMAT_SECURE, 0);
         if (snapshotContent == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("Unable to get snapshot content"));
@@ -6118,7 +6118,9 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
 
     virUUIDFormat(dom->uuid, uuidstr);
     memcpy(def->dom->uuid, dom->uuid, VIR_UUID_BUFLEN);
-    ret = virDomainSnapshotDefFormat(uuidstr, def, flags, 0);
+    ret = virDomainSnapshotDefFormat(uuidstr, def,
+                                      virDomainDefFormatConvertXMLFlags(flags),
+                                      0);
 
  cleanup:
     virDomainSnapshotDefFree(def);
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 4ee9526..8c87a1b 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -378,7 +378,7 @@ vmwareDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
     vmwareDriverLock(driver);
     if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
                                          1 << VIR_DOMAIN_VIRT_VMWARE,
-                                         VIR_DOMAIN_XML_INACTIVE)) == NULL)
+                                         VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
         goto cleanup;
 
     /* generate vmx file */
@@ -665,7 +665,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml,
 
     if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
                                          1 << VIR_DOMAIN_VIRT_VMWARE,
-                                         VIR_DOMAIN_XML_INACTIVE)) == NULL)
+                                         VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
         goto cleanup;
 
     /* generate vmx file */
@@ -983,7 +983,8 @@ vmwareDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
         goto cleanup;
     }
 
-    ret = virDomainDefFormat(vm->def, flags);
+    ret = virDomainDefFormat(vm->def,
+                             virDomainDefFormatConvertXMLFlags(flags));
 
  cleanup:
     if (vm)
@@ -1014,7 +1015,7 @@ vmwareConnectDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
     def = virVMXParseConfig(&ctx, driver->xmlopt, nativeConfig);
 
     if (def != NULL)
-        xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
+        xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
 
     virDomainDefFree(def);
 
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 1897584..6a2e535 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -775,7 +775,7 @@ xenUnifiedDomainCreateXML(virConnectPtr conn,
 
     if (!(def = virDomainDefParseString(xml, priv->caps, priv->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_XEN,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (virDomainCreateXMLEnsureACL(conn, def) < 0)
@@ -1596,7 +1596,8 @@ xenUnifiedDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
     }
 
     if (def)
-        ret = virDomainDefFormat(def, flags);
+        ret = virDomainDefFormat(def,
+                                 virDomainDefFormatConvertXMLFlags(flags));
 
  cleanup:
     virDomainDefFree(def);
@@ -1686,7 +1687,7 @@ xenUnifiedConnectDomainXMLToNative(virConnectPtr conn,
 
     if (!(def = virDomainDefParseString(xmlData, priv->caps, priv->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_XEN,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (STREQ(format, XEN_CONFIG_FORMAT_XM)) {
@@ -1892,7 +1893,7 @@ xenUnifiedDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int
 
     if (!(def = virDomainDefParseString(xml, priv->caps, priv->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_XEN,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index b233b6b..a51cb20 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -2256,7 +2256,7 @@ xenDaemonAttachDeviceFlags(virConnectPtr conn,
         goto cleanup;
 
     if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlopt,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
 
@@ -2404,7 +2404,7 @@ xenDaemonUpdateDeviceFlags(virConnectPtr conn,
         goto cleanup;
 
     if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlopt,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
 
@@ -2506,7 +2506,7 @@ xenDaemonDetachDeviceFlags(virConnectPtr conn,
         goto cleanup;
 
     if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlopt,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     if (virDomainXMLDevID(conn, minidef, dev, class, ref, sizeof(ref)))
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 293b2ab..dc6f88a 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -1251,7 +1251,7 @@ xenXMDomainAttachDeviceFlags(virConnectPtr conn,
     if (!(dev = virDomainDeviceDefParse(xml, entry->def,
                                         priv->caps,
                                         priv->xmlopt,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     switch (dev->type) {
@@ -1338,7 +1338,7 @@ xenXMDomainDetachDeviceFlags(virConnectPtr conn,
     if (!(dev = virDomainDeviceDefParse(xml, entry->def,
                                         priv->caps,
                                         priv->xmlopt,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     switch (dev->type) {
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 656f923..405c129 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -554,7 +554,7 @@ xenapiDomainCreateXML(virConnectPtr conn,
     virDomainDefPtr defPtr = virDomainDefParseString(xmlDesc,
                                                      priv->caps, priv->xmlopt,
                                                      1 << VIR_DOMAIN_VIRT_XEN,
-                                                     VIR_DOMAIN_XML_INACTIVE);
+                                                     VIR_DOMAIN_DEF_PARSE_INACTIVE);
     createVMRecordFromXml(conn, defPtr, &record, &vm);
     virDomainDefFree(defPtr);
     if (record) {
@@ -1728,7 +1728,7 @@ xenapiDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
     virDomainDefPtr defPtr = virDomainDefParseString(xml,
                                                      priv->caps, priv->xmlopt,
                                                      1 << VIR_DOMAIN_VIRT_XEN,
-                                                     VIR_DOMAIN_XML_INACTIVE);
+                                                     VIR_DOMAIN_DEF_PARSE_INACTIVE);
     if (!defPtr)
         return NULL;
 
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
index 1b3a28f..845d52f 100644
--- a/tests/domainsnapshotxml2xmltest.c
+++ b/tests/domainsnapshotxml2xmltest.c
@@ -102,7 +102,7 @@ testCompareXMLToXMLFiles(const char *inxml,
         goto cleanup;
 
     if (!(actual = virDomainSnapshotDefFormat(uuid, def,
-                                              VIR_DOMAIN_XML_SECURE,
+                                              VIR_DOMAIN_DEF_FORMAT_SECURE,
                                               internal)))
         goto cleanup;
 
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
index 6dce070..e372dcd 100644
--- a/tests/lxcxml2xmltest.c
+++ b/tests/lxcxml2xmltest.c
@@ -38,7 +38,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
 
     if (!(def = virDomainDefParseString(inXmlData, caps, xmlopt,
                                         1 << VIR_DOMAIN_VIRT_LXC,
-                                        live ? 0 : VIR_DOMAIN_XML_INACTIVE)))
+                                        live ? 0 : VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto fail;
 
     if (!virDomainDefCheckABIStability(def, def)) {
@@ -46,7 +46,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
         goto fail;
     }
 
-    if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
+    if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_SECURE)))
         goto fail;
 
     if (STRNEQ(outXmlData, actual)) {
diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c
index f5a8d12..c57543f 100644
--- a/tests/openvzutilstest.c
+++ b/tests/openvzutilstest.c
@@ -115,7 +115,7 @@ testReadNetworkConf(const void *data ATTRIBUTE_UNUSED)
         goto cleanup;
     }
 
-    actual = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
+    actual = virDomainDefFormat(def, VIR_DOMAIN_DEF_PARSE_INACTIVE);
 
     if (actual == NULL) {
         err = virGetLastError();
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 9d39968..8bdd37f 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -67,7 +67,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
                                                driver.caps,
                                                driver.xmlopt,
                                                QEMU_EXPECTED_VIRT_TYPES,
-                                               VIR_DOMAIN_XML_INACTIVE)))
+                                               VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
     priv = (*vm)->privateData;
@@ -177,7 +177,7 @@ testQemuHotplugCheckResult(virDomainObjPtr vm,
     char *actual;
     int ret;
 
-    actual = virDomainDefFormat(vm->def, VIR_DOMAIN_XML_SECURE);
+    actual = virDomainDefFormat(vm->def, VIR_DOMAIN_DEF_FORMAT_SECURE);
     if (!actual)
         return -1;
 
@@ -246,7 +246,7 @@ testQemuHotplug(const void *data)
     }
 
     if (test->action == ATTACH)
-        device_parse_flags = VIR_DOMAIN_XML_INACTIVE;
+        device_parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
 
     if (!(dev = virDomainDeviceDefParse(device_xml, vm->def,
                                         caps, driver.xmlopt,
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b2e60e8..6357d28 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -287,7 +287,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
 
     if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,
                                         QEMU_EXPECTED_VIRT_TYPES,
-                                        VIR_DOMAIN_XML_INACTIVE))) {
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE))) {
         if (!virtTestOOMActive() &&
             (flags & FLAG_EXPECT_PARSE_ERROR))
             goto ok;
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index ca11e90..0cf7c99 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -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_XML_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)) {
diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c
index 2f37a26..947aa9c 100644
--- a/tests/qemuxmlnstest.c
+++ b/tests/qemuxmlnstest.c
@@ -56,7 +56,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
 
     if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,
                                         QEMU_EXPECTED_VIRT_TYPES,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto fail;
 
     if (!virDomainDefCheckABIStability(vmdef, vmdef)) {
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index 6b1e724..412be88 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -90,7 +90,7 @@ testCompareFiles(const char *vmx, const char *xml)
         goto cleanup;
     }
 
-    if (!(formatted = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
+    if (!(formatted = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_SECURE)))
         goto cleanup;
 
     if (STRNEQ(xmlData, formatted)) {
diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c
index 0c6f803..b3dfd97 100644
--- a/tests/xmconfigtest.c
+++ b/tests/xmconfigtest.c
@@ -74,7 +74,7 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
 
     if (!(def = virDomainDefParseString(xmlData, caps, xmlopt,
                                         1 << VIR_DOMAIN_VIRT_XEN,
-                                        VIR_DOMAIN_XML_INACTIVE)))
+                                        VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto fail;
 
     if (!virDomainDefCheckABIStability(def, def)) {
@@ -140,7 +140,7 @@ testCompareFormatXML(const char *xmcfg, const char *xml, int xendConfigVersion)
     if (!(def = xenParseXM(conf, priv.xendConfigVersion, priv.caps)))
         goto fail;
 
-    if (!(gotxml = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
+    if (!(gotxml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_SECURE)))
         goto fail;
 
     if (STRNEQ(xmlData, gotxml)) {
diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c
index 7d9e780..f65eaef 100644
--- a/tests/xml2sexprtest.c
+++ b/tests/xml2sexprtest.c
@@ -37,7 +37,7 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
 
   if (!(def = virDomainDefParseString(xmlData, caps, xmlopt,
                                       1 << VIR_DOMAIN_VIRT_XEN,
-                                      VIR_DOMAIN_XML_INACTIVE)))
+                                      VIR_DOMAIN_DEF_PARSE_INACTIVE)))
       goto fail;
 
   if (!virDomainDefCheckABIStability(def, def)) {
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index ca9445d..2d72407 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -86,7 +86,7 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
 
     def = virDomainDefParseString(xmlData, caps, xmlopt,
                                   1 << VIR_DOMAIN_VIRT_VMWARE,
-                                  VIR_DOMAIN_XML_INACTIVE);
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
 
     if (def == NULL)
         goto failure;
-- 
2.1.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]