We need it for a single scenario in which prop='default' has to
be treated as valid input.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/libvirt_private.syms | 1 +
src/util/virxml.c | 18 ++++++++++++++++++
src/util/virxml.h | 7 +++++++
3 files changed, 26 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8a3e5f7f7c..a9d7ed972f 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3647,6 +3647,7 @@ virXMLPropEnumDefault;
virXMLPropInt;
virXMLPropString;
virXMLPropTristateBool;
+virXMLPropTristateBoolAllowDefault;
virXMLPropTristateSwitch;
virXMLPropUInt;
virXMLPropULongLong;
diff --git a/src/util/virxml.c b/src/util/virxml.c
index 8ff59e7cda..e9ccb54c41 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -552,6 +552,24 @@ virXMLPropTristateBool(xmlNodePtr node,
}
+/* Same as virXMLPropTristateBoolAllowDefault, but will accept the
+ * value 'default' and convert it to VIR_TRISTATE_BOOL_ABSENT instead
+ * of rejecting it with an error. Should only be used for backwards
+ * compatibility reasons, and specifically to parse XML files where a
+ * property having value VIR_TRISTATE_BOOL_ABSENT has historically
+ * resulted in it being formatted with value 'default' instead of
+ * being omitted entirely */
+int
+virXMLPropTristateBoolAllowDefault(xmlNodePtr node,
+ const char* name,
+ virXMLPropFlags flags,
+ virTristateBool *result)
+{
+ return virXMLPropEnumInternal(node, name, virTristateBoolTypeFromString,
+ flags, result, VIR_TRISTATE_BOOL_ABSENT);
+}
+
+
/**
* virXMLPropTristateSwitch:
* @node: XML dom node pointer
diff --git a/src/util/virxml.h b/src/util/virxml.h
index c39eae6282..05016db577 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -103,6 +103,13 @@ virXMLPropTristateBool(xmlNodePtr node,
virTristateBool *result)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
+int
+virXMLPropTristateBoolAllowDefault(xmlNodePtr node,
+ const char *name,
+ virXMLPropFlags flags,
+ virTristateBool *result)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
+
int
virXMLPropTristateSwitch(xmlNodePtr node,
const char *name,
--
2.35.1