mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-27 07:22:07 +03:00
virxml: Fix schema validation of individual nodes
xmlDocSetRootElement removes the node from its previous document tree, effectively removing the "<cpu>" node from "<domain>" in virCPUDefParseXML. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
6e91cbfdad
commit
baaf79ac0e
@ -355,8 +355,7 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
|
||||
PKGDATADIR "/schemas")))
|
||||
return -1;
|
||||
|
||||
if (virXMLValidateNodeAgainstSchema(schemafile, ctxt->doc,
|
||||
ctxt->node) < 0)
|
||||
if (virXMLValidateNodeAgainstSchema(schemafile, ctxt->node) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1551,16 +1551,15 @@ virXMLValidateAgainstSchema(const char *schemafile,
|
||||
|
||||
|
||||
int
|
||||
virXMLValidateNodeAgainstSchema(const char *schemafile,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr node)
|
||||
virXMLValidateNodeAgainstSchema(const char *schemafile, xmlNodePtr node)
|
||||
{
|
||||
xmlNodePtr root;
|
||||
int ret;
|
||||
xmlDocPtr copy = xmlNewDoc(NULL);
|
||||
|
||||
root = xmlDocSetRootElement(doc, node);
|
||||
ret = virXMLValidateAgainstSchema(schemafile, doc);
|
||||
xmlDocSetRootElement(doc, root);
|
||||
xmlDocSetRootElement(copy, xmlCopyNode(node, true));
|
||||
ret = virXMLValidateAgainstSchema(schemafile, copy);
|
||||
|
||||
xmlFreeDoc(copy);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,6 @@ virXMLValidateAgainstSchema(const char *schemafile,
|
||||
|
||||
int
|
||||
virXMLValidateNodeAgainstSchema(const char *schemafile,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr node);
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user