The virDomainDefParse* and virDomainDefFormat* methods both accept the VIR_DOMAIN_XML_* flags defined in the public API, along with a set of other VIR_DOMAIN_XML_INTERNAL_* flags defined in domain_conf.c. This is seriously confusing & error prone for a number of reasons: - VIR_DOMAIN_XML_SECURE, VIR_DOMAIN_XML_MIGRATABLE and VIR_DOMAIN_XML_UPDATE_CPU are only relevant for the formatting operation - Some of the VIR_DOMAIN_XML_INTERNAL_* flags only apply to parse or to format, but not both. This patch cleanly separates out the flags. There are two distint VIR_DOMAIN_DEF_PARSE_* and VIR_DOMAIN_DEF_FORMAT_* flags that are used by the corresponding methods. The VIR_DOMAIN_XML_* flags received via public API calls must be converted to the VIR_DOMAIN_DEF_FORMAT_* flags where needed. The various calls to virDomainDefParse which hardcoded the use of the VIR_DOMAIN_XML_INACTIVE flag change to use the VIR_DOMAIN_DEF_PARSE_INACTIVE flag. --- src/bhyve/bhyve_driver.c | 9 +- src/conf/domain_conf.c | 290 ++++++++++++++++++-------------------- src/conf/domain_conf.h | 33 +++++ src/conf/snapshot_conf.c | 8 +- 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/parallels/parallels_driver.c | 2 +- src/phyp/phyp_driver.c | 5 +- src/qemu/qemu_domain.c | 9 +- src/qemu/qemu_driver.c | 26 ++-- src/qemu/qemu_migration.c | 8 +- src/security/security_apparmor.c | 2 +- src/security/virt-aa-helper.c | 3 +- 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/bhyvexml2argvtest.c | 2 +- tests/bhyvexml2xmltest.c | 4 +- tests/domainsnapshotxml2xmltest.c | 2 +- tests/lxcxml2xmltest.c | 4 +- tests/openvzutilstest.c | 2 +- tests/qemuagenttest.c | 2 +- tests/qemuhotplugtest.c | 6 +- tests/qemuxml2argvtest.c | 2 +- tests/qemuxml2xmltest.c | 9 +- tests/qemuxmlnstest.c | 2 +- tests/vmx2xmltest.c | 2 +- tests/xlconfigtest.c | 7 +- tests/xmconfigtest.c | 4 +- tests/xml2sexprtest.c | 2 +- tests/xml2vmxtest.c | 2 +- 42 files changed, 320 insertions(+), 274 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 601ad71..a40956f 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 1e3bede..4361834 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -86,39 +86,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", @@ -800,9 +773,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; @@ -2724,11 +2694,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; @@ -3384,11 +3354,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); } @@ -3397,7 +3367,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"); @@ -3881,7 +3851,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 && @@ -3891,11 +3861,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; } @@ -4223,7 +4193,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"); @@ -4237,7 +4207,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) @@ -5191,7 +5161,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; @@ -5212,7 +5182,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); @@ -5228,7 +5198,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); @@ -5319,7 +5289,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); @@ -5327,7 +5297,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; @@ -5435,7 +5405,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); @@ -5941,7 +5911,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; @@ -6194,7 +6164,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"); @@ -6273,7 +6243,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; @@ -6293,7 +6263,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'", @@ -6308,7 +6278,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, @@ -6379,7 +6349,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")) @@ -6553,7 +6523,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; } @@ -6613,7 +6583,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; @@ -7564,7 +7534,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); @@ -7597,14 +7567,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, @@ -7661,8 +7631,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; } @@ -7835,7 +7805,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; @@ -8274,7 +8244,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def, case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: def->target.name = virXMLPropString(cur, "name"); - if (!(flags & VIR_DOMAIN_XML_INACTIVE) && + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && (stateStr = virXMLPropString(cur, "state"))) { int tmp; @@ -8363,7 +8333,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; @@ -9363,7 +9333,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; } @@ -9381,7 +9351,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"), @@ -9520,7 +9490,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; } @@ -9531,7 +9501,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; } @@ -9621,7 +9591,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) { @@ -9714,7 +9684,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; } @@ -10759,8 +10729,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; } @@ -10854,7 +10824,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 && @@ -11293,7 +11263,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, @@ -12652,6 +12622,7 @@ virDomainLoaderDefParseXML(xmlNodePtr node, return ret; } + static virDomainDefPtr virDomainDefParseXML(xmlDocPtr xml, xmlNodePtr root, @@ -12678,7 +12649,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; @@ -16469,7 +16440,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"); @@ -16884,7 +16855,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; @@ -16898,7 +16869,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) @@ -17041,7 +17012,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); @@ -17117,7 +17088,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) @@ -17129,7 +17100,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; @@ -17342,10 +17313,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'"); } @@ -17379,7 +17350,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)) { @@ -17717,9 +17688,9 @@ virDomainNetDefFormat(virBufferPtr buf, */ if (def->type == VIR_DOMAIN_NET_TYPE_NETWORK && def->data.network.actual && - !(flags & (VIR_DOMAIN_XML_INACTIVE | - VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET | - VIR_DOMAIN_XML_MIGRATABLE))) + !(flags & (VIR_DOMAIN_DEF_FORMAT_INACTIVE | + VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET | + VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))) publicActual = true; if (publicActual) { @@ -17782,7 +17753,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; @@ -17860,7 +17831,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); @@ -17937,8 +17908,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); @@ -17994,7 +17965,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); @@ -18092,7 +18063,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; @@ -18131,7 +18102,7 @@ virDomainChrDefFormat(virBufferPtr buf, virBufferEscapeString(buf, " name='%s'", def->target.name); if (def->state != VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT && - !(flags & VIR_DOMAIN_XML_INACTIVE)) { + !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { virBufferAsprintf(buf, " state='%s'", virDomainChrDeviceStateTypeToString(def->state)); } @@ -18165,7 +18136,7 @@ virDomainChrDefFormat(virBufferPtr buf, break; } - if (virDomainDeviceInfoIsSet(&def->info, flags)) { + if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) { if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) return -1; } @@ -18194,7 +18165,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; @@ -18270,7 +18241,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; } @@ -18308,7 +18279,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); @@ -18346,7 +18317,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; @@ -18376,7 +18347,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; @@ -18410,7 +18381,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) @@ -18447,7 +18418,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 { @@ -18519,7 +18490,7 @@ virDomainRNGDefFormat(virBufferPtr buf, break; } - if (virDomainDeviceInfoIsSet(&def->info, flags)) { + if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) { if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) return -1; } @@ -18629,7 +18600,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) @@ -18736,7 +18707,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); @@ -18761,7 +18732,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"); @@ -18773,7 +18744,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); @@ -18784,7 +18755,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"); @@ -18813,7 +18784,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); @@ -18831,7 +18802,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) @@ -18935,7 +18906,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) { @@ -19084,8 +19055,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); @@ -19108,7 +19079,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"); @@ -19165,7 +19136,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) @@ -19303,8 +19274,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 @@ -19320,11 +19290,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))) { @@ -19334,10 +19304,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)()); @@ -19878,7 +19848,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, } if (virCPUDefFormatBufFull(buf, def->cpu, - !!(flags & VIR_DOMAIN_XML_UPDATE_CPU)) < 0) + !!(flags & VIR_DOMAIN_DEF_FORMAT_UPDATE_CPU)) < 0) goto error; virBufferAsprintf(buf, "<clock offset='%s'", @@ -19893,7 +19863,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); @@ -20043,7 +20013,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; @@ -20131,12 +20101,29 @@ 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_UPDATE_CPU) + formatFlags |= VIR_DOMAIN_DEF_FORMAT_UPDATE_CPU; + if (flags & VIR_DOMAIN_XML_MIGRATABLE) + formatFlags |= VIR_DOMAIN_DEF_FORMAT_MIGRATABLE; + + 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; @@ -20313,7 +20300,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)) @@ -20330,11 +20317,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; @@ -20373,7 +20360,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) @@ -20420,10 +20407,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); @@ -20946,17 +20933,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; @@ -21422,7 +21409,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. @@ -21437,7 +21424,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, { virDomainDeviceDefPtr ret = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; - int flags = VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE; + int flags = VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_SECURE; char *xmlStr = NULL; int rc = -1; @@ -21510,7 +21497,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 ac1f4f8..00ebdf8 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2436,6 +2436,37 @@ 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 << 1, + /* parse <actual> element */ + VIR_DOMAIN_DEF_PARSE_ACTUAL_NET = 1 << 2, + /* parse original states of host PCI device */ + VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES = 1 << 3, + VIR_DOMAIN_DEF_PARSE_ALLOW_ROM = 1 << 4, + VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT = 1 << 5, + VIR_DOMAIN_DEF_PARSE_CLOCK_ADJUST = 1 << 6, + /* parse only source half of <disk> */ + VIR_DOMAIN_DEF_PARSE_DISK_SOURCE = 1 << 7, +} virDomainDefParseFlags; + +typedef enum { + VIR_DOMAIN_DEF_FORMAT_SECURE = 1 << 0, + VIR_DOMAIN_DEF_FORMAT_INACTIVE = 1 << 1, + VIR_DOMAIN_DEF_FORMAT_UPDATE_CPU = 1 << 2, + VIR_DOMAIN_DEF_FORMAT_MIGRATABLE = 1 << 3, + /* format internal domain status information */ + VIR_DOMAIN_DEF_FORMAT_STATUS = 1 << 4, + /* format <actual> element */ + VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET = 1 << 5, + /* format original states of host PCI device */ + VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES = 1 << 6, + VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM = 1 << 7, + VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT = 1 << 8, + VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST = 1 << 9, +} virDomainDefFormatFlags; + virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, const virDomainDef *def, virCapsPtr caps, @@ -2467,6 +2498,8 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, int virDomainDefAddImplicitControllers(virDomainDefPtr def); +int virDomainDefFormatConvertXMLFlags(unsigned int flags); + char *virDomainDefFormat(virDomainDefPtr def, unsigned int flags); int virDomainDefFormatInternal(virDomainDefPtr def, diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index d9339c3..a0667c2 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -287,7 +287,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 { @@ -677,10 +677,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid, virBuffer buf = VIR_BUFFER_INITIALIZER; size_t i; - virCheckFlags(VIR_DOMAIN_XML_SECURE | - VIR_DOMAIN_XML_UPDATE_CPU, NULL); + virCheckFlags(VIR_DOMAIN_DEF_FORMAT_SECURE | + VIR_DOMAIN_DEF_FORMAT_UPDATE_CPU, 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 9a47270..86996fc 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 ea9ba85..be379e9 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 a376e2d..7a2c585 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 3e0df84..c506e2a 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -645,7 +645,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) @@ -2191,7 +2191,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) @@ -2253,7 +2254,7 @@ libxlConnectDomainXMLFromNative(virConnectPtr conn, goto cleanup; } - xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE); + xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_INACTIVE); cleanup: virDomainDefFree(def); @@ -2284,7 +2285,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 (STREQ(nativeFormat, LIBXL_CONFIG_FORMAT_XL)) { @@ -2397,7 +2398,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) @@ -3289,7 +3290,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. */ @@ -3306,7 +3307,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) @@ -3400,7 +3401,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. */ @@ -3417,7 +3418,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) @@ -3508,7 +3509,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. */ @@ -3527,7 +3528,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 4db89b6..271390a 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -242,7 +242,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)) @@ -256,7 +256,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)) @@ -288,7 +288,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 70f0e53..04ad73e 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -463,7 +463,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) @@ -1039,7 +1039,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) @@ -1205,7 +1205,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) @@ -4988,7 +4988,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; @@ -5117,7 +5117,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; @@ -5230,7 +5230,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 b6ea7bb..bc5c929 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) @@ -986,7 +987,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); @@ -1078,7 +1079,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); @@ -2110,7 +2111,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; @@ -2265,7 +2266,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) @@ -2313,7 +2314,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/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 1731259..6e35e7f 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -670,7 +670,7 @@ parallelsDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int parallelsDriverLock(privconn); if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt, 1 << VIR_DOMAIN_VIRT_PARALLELS, - VIR_DOMAIN_XML_INACTIVE)) == NULL) + VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL) goto cleanup; olddom = virDomainObjListFindByUUID(privconn->domains, def->uuid); 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 3d4023c..c4a9508 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1699,7 +1699,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: @@ -1807,7 +1807,9 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver, } - ret = virDomainDefFormatInternal(def, flags, buf); + ret = virDomainDefFormatInternal(def, + virDomainDefFormatConvertXMLFlags(flags), + buf); cleanup: def->cpu = def_cpu; @@ -2160,7 +2162,8 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, virUUIDFormat(vm->def->uuid, uuidstr); newxml = virDomainSnapshotDefFormat(uuidstr, snapshot->def, - QEMU_DOMAIN_FORMAT_LIVE_FLAGS, 1); + VIR_DOMAIN_DEF_FORMAT_SECURE | + VIR_DOMAIN_DEF_FORMAT_UPDATE_CPU, 1); if (newxml == NULL) return -1; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index efaed81..5059269 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1690,7 +1690,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) @@ -3165,7 +3165,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)) { @@ -5582,7 +5582,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, @@ -5738,7 +5738,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) @@ -6317,7 +6317,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; @@ -6684,7 +6684,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) @@ -7529,7 +7529,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; @@ -7728,7 +7728,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; @@ -7864,7 +7864,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, @@ -13929,7 +13929,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) { @@ -14366,7 +14366,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: qemuDomObjEndAPI(&vm); @@ -16133,7 +16135,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, bandwidth, diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 77e0b35..a878652 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1249,7 +1249,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 */ @@ -2668,7 +2668,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)) @@ -2869,7 +2869,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; @@ -3345,7 +3345,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/security/security_apparmor.c b/src/security/security_apparmor.c index 3025284..4134a17 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -178,7 +178,7 @@ load_profile(virSecurityManagerPtr mgr, const char *probe = virSecurityManagerGetAllowDiskFormatProbing(mgr) ? "1" : "0"; - xml = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE); + xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_SECURE); if (!xml) goto cleanup; diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 869bf18..e53779e 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -740,7 +740,8 @@ get_definition(vahControl * ctl, const char *xmlStr) ctl->def = virDomainDefParseString(xmlStr, ctl->caps, ctl->xmlopt, - -1, VIR_DOMAIN_XML_INACTIVE); + -1, + VIR_DOMAIN_DEF_PARSE_INACTIVE); if (ctl->def == NULL) { vah_error(ctl, 0, _("could not parse XML")); goto exit; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 44288ce..d92e578 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 6b0cb0d..21f9e59 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 7b96321..371a5da 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1860,7 +1860,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; } @@ -3977,7 +3977,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); @@ -4116,7 +4116,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; @@ -4248,7 +4248,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; @@ -5208,7 +5208,7 @@ vboxSnapshotRedefine(virDomainPtr dom, VIR_FREE(currentSnapshotXmlFilePath); if (virAsprintf(¤tSnapshotXmlFilePath, "%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")); @@ -6128,7 +6128,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 933bc0a..c9183a7 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 49fb50f..e35986c 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 5f4363d..7bdaafb 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/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index cd3aea0..c5b0681 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -33,7 +33,7 @@ static int testCompareXMLToArgvFiles(const char *xml, if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt, 1 << VIR_DOMAIN_VIRT_BHYVE, - VIR_DOMAIN_XML_INACTIVE))) + VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto out; vm.def = vmdef; diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c index 81cba0f..a1a3701 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -28,10 +28,10 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml) if (!(def = virDomainDefParseString(inXmlData, driver.caps, driver.xmlopt, 1 << VIR_DOMAIN_VIRT_BHYVE, - VIR_DOMAIN_XML_INACTIVE))) + VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto fail; - if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE))) + if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_INACTIVE))) goto fail; if (STRNEQ(outXmlData, actual)) { 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 1065555..5f87359 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_FORMAT_INACTIVE); if (actual == NULL) { err = virGetLastError(); diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index eaf764f..54a45df 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -187,7 +187,7 @@ testQemuAgentGetFSInfo(const void *data) if (!(def = virDomainDefParseString(domain_xml, caps, xmlopt, QEMU_EXPECTED_VIRT_TYPES, - VIR_DOMAIN_XML_INACTIVE))) + VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; if (qemuMonitorTestAddAgentSyncResponse(test) < 0) 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 bce88a8..e5c9a3f 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 e1ec514..866a1fa 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_DEF_FORMAT_SECURE; + if (!live) + format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE; if (virtTestLoadFile(inxml, &inXmlData) < 0) goto fail; @@ -38,7 +41,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) goto fail; if (!(def = virDomainDefParseString(inXmlData, driver.caps, driver.xmlopt, - QEMU_EXPECTED_VIRT_TYPES, flags))) + QEMU_EXPECTED_VIRT_TYPES, parse_flags))) goto fail; if (!virDomainDefCheckABIStability(def, def)) { @@ -46,7 +49,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) goto fail; } - if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE | flags))) + if (!(actual = virDomainDefFormat(def, format_flags))) goto fail; if (STRNEQ(outXmlData, actual)) { 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/xlconfigtest.c b/tests/xlconfigtest.c index b966c15..086f739 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -70,7 +70,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)) { @@ -132,8 +132,9 @@ testCompareFormatXML(const char *xmcfg, const char *xml, int xendConfigVersion) if (!(def = xenParseXL(conf, caps, xendConfigVersion))) goto fail; - if (!(gotxml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE | - VIR_DOMAIN_XML_SECURE))) + if (!(gotxml = virDomainDefFormat(def, + VIR_DOMAIN_DEF_FORMAT_INACTIVE | + VIR_DOMAIN_DEF_FORMAT_SECURE))) goto fail; if (STRNEQ(xmlData, gotxml)) { diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index 8a49eb5..00a05ee 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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list