[RFC 1/1] virxml: Accept 'default' for virTristate* properties

Andrea Bolognani abologna at redhat.com
Wed Mar 23 18:04:20 UTC 2022

The _ABSENT value of each enumeration has 'default' as string
representation, and when that's been formatted to XML we should
parse it back successfully, so we can't just treat encountering
it as an error.

Callers of virXMLPropTristate*() can of course still pass
VIR_XML_PROP_NONZERO explicitly to the helpers if the current
behavior is the one they want.

After this change, libvirtd no longer logs

  error : virXMLPropEnumInternal:516 : XML error: Invalid value
  for attribute 'value' in element 'allowReboot': 'default'.

when it gets restarted while there are running guests.

Fixes: 8861d96c880d25c940456c5997a2ac93fc073c78
Fixes: c8726ede83ac117cb18c0b0a1fbfeeac8b80384b
Signed-off-by: Andrea Bolognani <abologna at redhat.com>
 src/util/virxml.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/src/util/virxml.c b/src/util/virxml.c
index 8ff59e7cda..db5212de20 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -545,8 +545,6 @@ virXMLPropTristateBool(xmlNodePtr node,
                        virXMLPropFlags flags,
                        virTristateBool *result)
-    flags |= VIR_XML_PROP_NONZERO;
     return virXMLPropEnumInternal(node, name, virTristateBoolTypeFromString,
                                   flags, result, VIR_TRISTATE_BOOL_ABSENT);
@@ -573,8 +571,6 @@ virXMLPropTristateSwitch(xmlNodePtr node,
                          virXMLPropFlags flags,
                          virTristateSwitch *result)
-    flags |= VIR_XML_PROP_NONZERO;
     return virXMLPropEnumInternal(node, name, virTristateSwitchTypeFromString,
                                   flags, result, VIR_TRISTATE_SWITCH_ABSENT);

More information about the libvir-list mailing list