Convenience function to return the value of a yes / no / optional XML
attribute.
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
---
src/libvirt_private.syms | 1 +
src/util/virxml.c | 28 ++++++++++++++++++++++++++++
src/util/virxml.h | 7 +++++++
3 files changed, 36 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index da60c965dd..3c9d4a4b04 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3720,6 +3720,7 @@ virXMLPropEnum;
virXMLPropEnumDefault;
virXMLPropInt;
virXMLPropLongLong;
+virXMLPropQuadstateOption;
virXMLPropString;
virXMLPropStringRequired;
virXMLPropTristateBool;
diff --git a/src/util/virxml.c b/src/util/virxml.c
index 0c1eae8c3c..d0f554fab5 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -475,6 +475,34 @@ virXMLPropTristateSwitch(xmlNodePtr node,
}
+/**
+ * virXMLPropQuadstateOption:
+ * @node: XML dom node pointer
+ * @name: Name of the property (attribute) to get
+ * @flags: Bitwise-OR of virXMLPropFlags
+ * @result: The returned value
+ *
+ * Convenience function to return value of a yes / no / optional attribute.
+ * In case when the property is missing @result is initialized to
+ * VIR_QUADSTATE_OPTION_ABSENT.
+ *
+ * Returns 1 in case of success in which case @result is set,
+ * or 0 if the attribute is not present,
+ * or -1 and reports an error on failure.
+ */
+int
+virXMLPropQuadstateOption(xmlNodePtr node,
+ const char *name,
+ virXMLPropFlags flags,
+ virQuadstateOption *result)
+{
+ flags |= VIR_XML_PROP_NONZERO;
+
+ return virXMLPropEnumInternal(node, name, virQuadstateOptionTypeFromString,
+ flags, result, VIR_QUADSTATE_OPTION_ABSENT);
+}
+
+
/**
* virXMLPropInt:
* @node: XML dom node pointer
diff --git a/src/util/virxml.h b/src/util/virxml.h
index 7af47437bd..901c82e6e3 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -120,6 +120,13 @@ virXMLPropTristateSwitch(xmlNodePtr node,
virTristateSwitch *result)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
+int
+virXMLPropQuadstateOption(xmlNodePtr node,
+ const char *name,
+ virXMLPropFlags flags,
+ virQuadstateOption *result)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
+
int
virXMLPropInt(xmlNodePtr node,
const char *name,
--
2.41.0