virDomainBackupDef *ret = NULL;
g_autoptr(xmlDoc) xml = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
+ bool validate = !(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL);
- if ((xml = virXMLParse(NULL, xmlStr, _("(domain_backup)"), "domainbackup.rng",
- !(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL)))) {
+ if ((xml = virXMLParse(NULL, xmlStr, _("(domain_backup)"),
+ NULL, NULL, "domainbackup.rng", validate))) {
xmlKeepBlanksDefault(keepBlanksDefault);
ret = virDomainBackupDefParseNode(xml, xmlDocGetRootElement(xml),
xmlopt, flags);
g_autoptr(xmlDoc) xml = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
- if ((xml = virXMLParse(NULL, xmlStr, _("(domain_checkpoint)"),
+ if ((xml = virXMLParse(NULL, xmlStr, _("(domain_checkpoint)"), NULL, NULL,
"domaincheckpoint.rng", true))) {
xmlKeepBlanksDefault(keepBlanksDefault);
ret = virDomainCheckpointDefParseNode(xml, xmlDocGetRootElement(xml),
virDomainDef *def = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
xmlNodePtr root;
- if (!(xml = virXMLParse(filename, xmlStr, _("(domain_definition)"), "domain.rng",
- flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA)))
+ bool validate = flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
+
+ if (!(xml = virXMLParse(filename, xmlStr, _("(domain_definition)"),
+ NULL, NULL, "domain.rng", validate)))
goto cleanup;
root = xmlDocGetRootElement(xml);
unsigned int flags)
{
g_autoptr(xmlDoc) xml = NULL;
+ bool validate = flags & VIR_INTERFACE_DEFINE_VALIDATE;
xml = virXMLParse(filename, xmlStr, _("(interface_definition)"),
- "interface.rng", flags & VIR_INTERFACE_DEFINE_VALIDATE);
+ NULL, NULL, "interface.rng", validate);
if (!xml)
return NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
if ((xml = virXMLParse(filename, xmlStr, _("(network_definition)"),
- "network.rng", validate)))
+ NULL, NULL, "network.rng", validate)))
def = virNetworkDefParseNode(xml, xmlDocGetRootElement(xml), xmlopt);
xmlKeepBlanksDefault(keepBlanksDefault);
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(virNodeDeviceDef) def = NULL;
- if (!(xml = virXMLParse(filename, str, _("(node_device_definition)"), NULL, false)) ||
+ if (!(xml = virXMLParse(filename, str, _("(node_device_definition)"),
+ NULL, NULL, NULL, false)) ||
!(def = virNodeDeviceDefParseNode(xml, xmlDocGetRootElement(xml),
create, virt_type)))
return NULL;
{
virNWFilterDef *def = NULL;
g_autoptr(xmlDoc) xml = NULL;
+ bool validate = flags & VIR_NWFILTER_DEFINE_VALIDATE;
- if ((xml = virXMLParse(filename, xmlStr, _("(nwfilter_definition)"), "nwfilter.rng",
- flags & VIR_NWFILTER_DEFINE_VALIDATE))) {
+ if ((xml = virXMLParse(filename, xmlStr, _("(nwfilter_definition)"),
+ NULL, NULL, "nwfilter.rng", validate))) {
def = virNWFilterDefParseNode(xml, xmlDocGetRootElement(xml));
}
{
g_autoptr(xmlDoc) xml = NULL;
virSecretDef *ret = NULL;
+ bool validate = flags & VIR_SECRET_DEFINE_VALIDATE;
- if ((xml = virXMLParse(filename, xmlStr, _("(definition_of_secret)"), "secret.rng",
- flags & VIR_SECRET_DEFINE_VALIDATE))) {
+ if ((xml = virXMLParse(filename, xmlStr, _("(definition_of_secret)"),
+ NULL, NULL, "secret.rng", validate))) {
ret = secretXMLParseNode(xml, xmlDocGetRootElement(xml));
}
virDomainSnapshotDef *ret = NULL;
g_autoptr(xmlDoc) xml = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
+ bool validate = flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE;
- if ((xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)"), "domainsnapshot.rng",
- flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE))) {
+ if ((xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)"),
+ NULL, NULL, "domainsnapshot.rng", validate))) {
xmlKeepBlanksDefault(keepBlanksDefault);
ret = virDomainSnapshotDefParseNode(xml, xmlDocGetRootElement(xml),
xmlopt, parseOpaque,
{
virStoragePoolDef *ret = NULL;
g_autoptr(xmlDoc) xml = NULL;
+ bool validate = flags & VIR_STORAGE_POOL_DEFINE_VALIDATE;
if ((xml = virXMLParse(filename, xmlStr, _("(storage_pool_definition)"),
- "storagepool.rng", flags & VIR_STORAGE_POOL_DEFINE_VALIDATE))) {
+ NULL, NULL, "storagepool.rng", validate))) {
ret = virStoragePoolDefParseNode(xml, xmlDocGetRootElement(xml));
}
virStorageVolDef *ret = NULL;
g_autoptr(xmlDoc) xml = NULL;
- if ((xml = virXMLParse(filename, xmlStr, _("(storage_volume_definition)"), NULL, false))) {
+ if ((xml = virXMLParse(filename, xmlStr, _("(storage_volume_definition)"),
+ NULL, NULL, NULL, false))) {
ret = virStorageVolDefParseNode(pool, xml, xmlDocGetRootElement(xml), flags);
}
{
virNetworkPortDef *def = NULL;
g_autoptr(xmlDoc) xml = NULL;
+ bool validate = flags & VIR_NETWORK_PORT_CREATE_VALIDATE;
if ((xml = virXMLParse(filename, xmlStr, _("(networkport_definition)"),
- "networkport.rng",
- flags & VIR_NETWORK_PORT_CREATE_VALIDATE))) {
+ NULL, NULL, "networkport.rng", validate))) {
def = virNetworkPortDefParseNode(xml, xmlDocGetRootElement(xml));
}
{
virNWFilterBindingDef *def = NULL;
g_autoptr(xmlDoc) xml = NULL;
+ bool validate = flags & VIR_NWFILTER_BINDING_CREATE_VALIDATE;
if ((xml = virXMLParse(filename, xmlStr, _("(nwfilterbinding_definition)"),
- "nwfilterbinding.rng",
- flags & VIR_NWFILTER_BINDING_CREATE_VALIDATE))) {
+ NULL, NULL, "nwfilterbinding.rng", validate))) {
def = virNWFilterBindingDefParseNode(xml, xmlDocGetRootElement(xml));
}
virNWFilterBindingObj *obj = NULL;
g_autoptr(xmlDoc) xml = NULL;
- if ((xml = virXMLParse(filename, xmlStr, _("(nwfilterbinding_status)"), NULL, false))) {
+ if ((xml = virXMLParse(filename, xmlStr, _("(nwfilterbinding_status)"),
+ NULL, NULL, NULL, false))) {
obj = virNWFilterBindingObjParseNode(xml, xmlDocGetRootElement(xml));
}
if ((relFile = virXMLPropString(node, "file"))) {
absFile = testBuildFilename(file, relFile);
- if (!(doc = virXMLParse(absFile, NULL, type, NULL, false)))
+ if (!(doc = virXMLParse(absFile, NULL, type, NULL, NULL, NULL, false)))
return NULL;
ret = xmlCopyNode(xmlDocGetRootElement(doc), 1);
* @filename: file to parse, or NULL for string parsing
* @xmlStr: if @filename is NULL, a string to parse
* @url: if @filename is NULL, an optional filename to attribute the parse to
+ * @rootelement: if non-NULL, validate that the root element name equals to this parameter
+ * @ctxt: if non-NULL, filled with a new XPath context including populating the root node
+ * @schemafile: name of the appropriate schema file for the parsed XML for validation (may be NULL)
+ * @validate: if true and @schemafile is non-NULL, validate the XML against @schemafile
*
* Parse xml from either a file or a string.
*
* Return the parsed document object, or NULL on failure.
*/
-#define virXMLParse(filename, xmlStr, url, schemafile, validate) \
- virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, NULL, NULL, schemafile, validate)
+#define virXMLParse(filename, xmlStr, url, rootelement, ctxt, schemafile, validate) \
+ virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, rootelement, ctxt, schemafile, validate)
/**
* virXMLParseString:
machineDescription = g_new0(virVBoxSnapshotConfMachine, 1);
- xml = virXMLParse(filePath, NULL, NULL, NULL, false);
+ xml = virXMLParse(filePath, NULL, NULL, NULL, NULL, NULL, false);
if (xml == NULL) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Unable to parse the xml"));
_("filePath is null"));
goto cleanup;
}
- xml = virXMLParse(filePath, NULL, NULL, NULL, false);
+ xml = virXMLParse(filePath, NULL, NULL, NULL, NULL, NULL, false);
if (xml == NULL) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Unable to parse the xml"));
_("filePath is null"));
goto cleanup;
}
- xml = virXMLParse(filePath, NULL, NULL, NULL, false);
+ xml = virXMLParse(filePath, NULL, NULL, NULL, NULL, NULL, false);
if (xml == NULL) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Unable to parse the xml"));
if (*treexml == '\0')
return snapshots;
- if (!(xml = virXMLParse(NULL, treexml, _("(snapshot_tree)"), NULL, false)))
+ if (!(xml = virXMLParse(NULL, treexml, _("(snapshot_tree)"),
+ NULL, NULL, NULL, false)))
goto cleanup;
root = xmlDocGetRootElement(xml);
if (testCheckExclusiveFlags(info->flags) < 0)
goto cleanup;
- if (!(xml = virXMLParse(info->infile, NULL, "(domain_definition)", NULL, false)))
+ if (!(xml = virXMLParse(info->infile, NULL, "(domain_definition)",
+ NULL, NULL, NULL, false)))
goto cleanup;
root = xmlDocGetRootElement(xml);