mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-21 19:02:25 +00:00
domain_conf: replace validation with variables passed to virXMLParse()
virXMLParse() now allows to validate xml against schema directly, eliminating the need to do it individually. Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
323a1318a3
commit
e6c730c865
@ -19515,7 +19515,7 @@ virDomainDefControllersParse(virDomainDef *def,
|
||||
}
|
||||
|
||||
static virDomainDef *
|
||||
virDomainDefParseXML(xmlDocPtr xml,
|
||||
virDomainDefParseXML(xmlDocPtr xml G_GNUC_UNUSED,
|
||||
xmlXPathContextPtr ctxt,
|
||||
virDomainXMLOption *xmlopt,
|
||||
unsigned int flags)
|
||||
@ -19529,18 +19529,6 @@ virDomainDefParseXML(xmlDocPtr xml,
|
||||
g_autofree xmlNodePtr *nodes = NULL;
|
||||
g_autofree char *tmp = NULL;
|
||||
|
||||
if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) {
|
||||
g_autofree char *schema = NULL;
|
||||
|
||||
schema = virFileFindResource("domain.rng",
|
||||
abs_top_srcdir "/docs/schemas",
|
||||
PKGDATADIR "/schemas");
|
||||
if (!schema)
|
||||
return NULL;
|
||||
if (virXMLValidateAgainstSchema(schema, xml) < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(def = virDomainDefNew()))
|
||||
return NULL;
|
||||
|
||||
@ -20400,7 +20388,8 @@ virDomainDefParse(const char *xmlStr,
|
||||
virDomainDef *def = NULL;
|
||||
int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
||||
xmlNodePtr root;
|
||||
if (!(xml = virXMLParse(filename, xmlStr, _("(domain_definition)"), NULL, false)))
|
||||
if (!(xml = virXMLParse(filename, xmlStr, _("(domain_definition)"), "domain.rng",
|
||||
flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA)))
|
||||
goto cleanup;
|
||||
|
||||
root = xmlDocGetRootElement(xml);
|
||||
|
Loading…
x
Reference in New Issue
Block a user