[libvirt PATCH 04/38] domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainKeyWrapCipherDefParseXML

Tim Wiederhake twiederh at redhat.com
Thu Mar 18 08:00:43 UTC 2021


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 src/conf/domain_conf.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 47756ff0be..b6e505b384 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1441,10 +1441,9 @@ static int
 virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr keywrap,
                                   xmlNodePtr node)
 {
-    int state_type;
+    virTristateSwitch state_type = VIR_TRISTATE_SWITCH_ABSENT;
     int name_type;
     g_autofree char *name = NULL;
-    g_autofree char *state = NULL;
 
     if (!(name = virXMLPropString(node, "name"))) {
         virReportError(VIR_ERR_CONF_SYNTAX, "%s",
@@ -1458,15 +1457,11 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr keywrap,
         return -1;
     }
 
-    if (!(state = virXMLPropString(node, "state"))) {
-        virReportError(VIR_ERR_CONF_SYNTAX,
-                       _("missing state for cipher named %s"), name);
+    if (virXMLPropOnOff(node, "state", &state_type) < 0)
         return -1;
-    }
-
-    if ((state_type = virTristateSwitchTypeFromString(state)) < 0) {
+    if (state_type == VIR_TRISTATE_SWITCH_ABSENT) {
         virReportError(VIR_ERR_CONF_SYNTAX,
-                       _("%s is not a supported cipher state"), state);
+                       _("missing state for cipher named %s"), name);
         return -1;
     }
 
-- 
2.26.2




More information about the libvir-list mailing list