[libvirt] [PATCH 14/21] util: introduce virXMLNamespaceFormatNS

Ján Tomko jtomko at redhat.com
Tue Aug 20 23:15:36 UTC 2019


A function to automatically format the xmlns:<prefix>='<uri>'
attribute for per-driver namespaces.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/util/virxml.c | 7 +++++++
 src/util/virxml.h | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/src/util/virxml.c b/src/util/virxml.c
index f55b9a362c..11b6031b09 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -1408,3 +1408,10 @@ virXPathContextNodeRestore(virXPathContextNodeSavePtr save)
 
     save->ctxt->node = save->node;
 }
+
+void
+virXMLNamespaceFormatNS(virBufferPtr buf,
+                        virXMLNamespace const *ns)
+{
+    virBufferAsprintf(buf, " xmlns:%s='%s'", ns->prefix, ns->href());
+}
diff --git a/src/util/virxml.h b/src/util/virxml.h
index ea0c3d3ab3..bcc10647b5 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -261,3 +261,7 @@ struct _virXMLNamespace {
 };
 typedef struct _virXMLNamespace virXMLNamespace;
 typedef virXMLNamespace *virXMLNamespacePtr;
+
+void
+virXMLNamespaceFormatNS(virBufferPtr buf,
+                        virXMLNamespace const *ns);
-- 
2.19.2




More information about the libvir-list mailing list