[libvirt] [PATCH 05/21] util: introduce virXMLNamespace

Ján Tomko posted 21 patches 6 years, 5 months ago
[libvirt] [PATCH 05/21] util: introduce virXMLNamespace
Posted by Ján Tomko 6 years, 5 months ago
For various XMLs, we allow a custom namespace for passing unsupported
configurations.

Introduce a single structure to hold all the driver-specific functions
to remove duplication.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/util/virxml.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/util/virxml.h b/src/util/virxml.h
index 6208977dd1..5b209bb040 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -246,3 +246,17 @@ VIR_DEFINE_AUTOCLEAN_FUNC(virXPathContextNodeSave, virXPathContextNodeRestore);
 
 VIR_DEFINE_AUTOPTR_FUNC(xmlDoc, xmlFreeDoc);
 VIR_DEFINE_AUTOPTR_FUNC(xmlXPathContext, xmlXPathFreeContext);
+
+typedef int (*virXMLNamespaceParse)(xmlXPathContextPtr, void **);
+typedef void (*virXMLNamespaceFree)(void *);
+typedef int (*virXMLNamespaceFormat)(virBufferPtr, void *);
+typedef const char *(*virXMLNamespaceHref)(void);
+
+struct _virXMLNamespace {
+    virXMLNamespaceParse parse;
+    virXMLNamespaceFree free;
+    virXMLNamespaceFormat format;
+    virXMLNamespaceHref href;
+};
+typedef struct _virXMLNamespace virXMLNamespace;
+typedef virXMLNamespace *virXMLNamespacePtr;
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 05/21] util: introduce virXMLNamespace
Posted by Jiri Denemark 6 years, 5 months ago
On Wed, Aug 21, 2019 at 01:15:27 +0200, Ján Tomko wrote:
> For various XMLs, we allow a custom namespace for passing unsupported
> configurations.
> 
> Introduce a single structure to hold all the driver-specific functions
> to remove duplication.
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  src/util/virxml.h | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/src/util/virxml.h b/src/util/virxml.h
> index 6208977dd1..5b209bb040 100644
> --- a/src/util/virxml.h
> +++ b/src/util/virxml.h
> @@ -246,3 +246,17 @@ VIR_DEFINE_AUTOCLEAN_FUNC(virXPathContextNodeSave, virXPathContextNodeRestore);
>  
>  VIR_DEFINE_AUTOPTR_FUNC(xmlDoc, xmlFreeDoc);
>  VIR_DEFINE_AUTOPTR_FUNC(xmlXPathContext, xmlXPathFreeContext);
> +
> +typedef int (*virXMLNamespaceParse)(xmlXPathContextPtr, void **);
> +typedef void (*virXMLNamespaceFree)(void *);
> +typedef int (*virXMLNamespaceFormat)(virBufferPtr, void *);
> +typedef const char *(*virXMLNamespaceHref)(void);

I know you copied it, but I'd prefer to see the parameter names here
rather than just their types.

> +
> +struct _virXMLNamespace {
> +    virXMLNamespaceParse parse;
> +    virXMLNamespaceFree free;
> +    virXMLNamespaceFormat format;
> +    virXMLNamespaceHref href;
> +};
> +typedef struct _virXMLNamespace virXMLNamespace;
> +typedef virXMLNamespace *virXMLNamespacePtr;

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list