[PATCH 14/37] util: xml: Introduce virXMLPropStringRequired

Ján Tomko jtomko at redhat.com
Wed Sep 21 14:28:12 UTC 2022


On a Monday in 2022, Peter Krempa wrote:
>Similarly to virXMLPropString it extracts a string but reports an errori

s/errori/error/

>similar to the newer virXMLProp helpers if the attribute is not present.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/libvirt_private.syms |  1 +
> src/util/virxml.c        | 27 +++++++++++++++++++++++++++
> src/util/virxml.h        |  4 ++++
> 3 files changed, 32 insertions(+)
>
>diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
>index 1e852902ab..01bb349e05 100644
>--- a/src/libvirt_private.syms
>+++ b/src/libvirt_private.syms
>@@ -3683,6 +3683,7 @@ virXMLPropEnum;
> virXMLPropEnumDefault;
> virXMLPropInt;
> virXMLPropString;
>+virXMLPropStringRequired;
> virXMLPropTristateBool;
> virXMLPropTristateBoolAllowDefault;
> virXMLPropTristateSwitch;
>diff --git a/src/util/virxml.c b/src/util/virxml.c
>index eac2d0a73f..b94af9c7a3 100644
>--- a/src/util/virxml.c
>+++ b/src/util/virxml.c
>@@ -455,6 +455,33 @@ virXMLPropString(xmlNodePtr node,
> }
>
>
>+/**
>+ * virXMLPropStringRequired:
>+ * @node: XML dom node pointer
>+ * @name: Name of the property (attribute) to get
>+ *
>+ * Convenience function to return copy of an mandatoryu attribute value of a
>+ * XML node.

*an XML

>+ *
>+ * Returns the property (attribute) value as string or NULL and if the attribute
>+ * is not present (libvirt error reported).
>+ * The caller is responsible for freeing the returned buffer.
>+ */

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano


More information about the libvir-list mailing list