mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00: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")))
|
PKGDATADIR "/schemas")))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virXMLValidateNodeAgainstSchema(schemafile, ctxt->doc,
|
if (virXMLValidateNodeAgainstSchema(schemafile, ctxt->node) < 0)
|
||||||
ctxt->node) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1551,16 +1551,15 @@ virXMLValidateAgainstSchema(const char *schemafile,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virXMLValidateNodeAgainstSchema(const char *schemafile,
|
virXMLValidateNodeAgainstSchema(const char *schemafile, xmlNodePtr node)
|
||||||
xmlDocPtr doc,
|
|
||||||
xmlNodePtr node)
|
|
||||||
{
|
{
|
||||||
xmlNodePtr root;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
xmlDocPtr copy = xmlNewDoc(NULL);
|
||||||
|
|
||||||
root = xmlDocSetRootElement(doc, node);
|
xmlDocSetRootElement(copy, xmlCopyNode(node, true));
|
||||||
ret = virXMLValidateAgainstSchema(schemafile, doc);
|
ret = virXMLValidateAgainstSchema(schemafile, copy);
|
||||||
xmlDocSetRootElement(doc, root);
|
|
||||||
|
xmlFreeDoc(copy);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +296,6 @@ virXMLValidateAgainstSchema(const char *schemafile,
|
|||||||
|
|
||||||
int
|
int
|
||||||
virXMLValidateNodeAgainstSchema(const char *schemafile,
|
virXMLValidateNodeAgainstSchema(const char *schemafile,
|
||||||
xmlDocPtr doc,
|
|
||||||
xmlNodePtr node);
|
xmlNodePtr node);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user