---
src/libvirt_private.syms | 1 +
src/util/virxml.c | 33 +++++++++++++++++++++++++++++++++
src/util/virxml.h | 2 ++
3 files changed, 36 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0631941..18e9a4b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2091,6 +2091,7 @@ virUUIDParse;
# util/virxml.h
virXMLChildElementCount;
+virXMLNodeDump;
virXMLParseHelper;
virXMLPickShellSafeComment;
virXMLPropString;
diff --git a/src/util/virxml.c b/src/util/virxml.c
index f652ee0..44d6f27 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -895,3 +895,36 @@ virXMLChildElementCount(xmlNodePtr node)
}
return ret;
}
+
+
+/**
+ * virXMLNodeDump: convert a XML node ptr to a XML string
+ *
+ * Returns the XML string of the document or NULL on error.
+ * The caller has to free the string.
+ */
+char *
+virXMLNodeDump(xmlDocPtr doc,
+ xmlNodePtr node)
+{
+ xmlBufferPtr xmlbuf = NULL;
+ char *ret = NULL;
+
+ if (!(xmlbuf = xmlBufferCreate())) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ if (xmlNodeDump(xmlbuf, doc, node, 0, 1) == 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("failed to dump XML node tree"));
+ goto cleanup;
+ }
+
+ ignore_value(VIR_STRDUP(ret, (const char *)xmlBufferContent(xmlbuf)));
+
+cleanup:
+ xmlBufferFree(xmlbuf);
+
+ return ret;
+}
diff --git a/src/util/virxml.h b/src/util/virxml.h
index 364288d..9165cb1 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -163,4 +163,6 @@ int virXMLSaveFile(const char *path,
const char *warnCommand,
const char *xml);
+char *virXMLNodeDump(xmlDocPtr doc, xmlNodePtr node);
+
#endif /* __VIR_XML_H__ */
--
1.8.3.2