xmlDocSetRootElement removes the node from its previous document tree,
effectively removing the "<cpu>" node from "<domain>" in
virCPUDefParseXML.
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/util/virxml.c | 13 ++++++-------
src/util/virxml.h | 1 -
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/util/virxml.c b/src/util/virxml.c
index 117f50f2bf..d816a8e08d 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -1285,16 +1285,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;
}
diff --git a/src/util/virxml.h b/src/util/virxml.h
index de171dce12..8a8ec2a6df 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -213,7 +213,6 @@ virXMLValidateAgainstSchema(const char *schemafile,
int
virXMLValidateNodeAgainstSchema(const char *schemafile,
- xmlDocPtr doc,
xmlNodePtr node);
void
--
2.26.2