[libvirt PATCH v2 43/51] domain_conf: Use virXMLPropTristateXXX in virDomainLoaderDefParseXML

Tim Wiederhake twiederh at redhat.com
Fri Mar 19 13:40:57 UTC 2021


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

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 83fc12c41b..6c4595fd20 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18713,14 +18713,12 @@ virDomainLoaderDefParseXML(xmlNodePtr node,
                            virDomainLoaderDefPtr loader,
                            bool fwAutoSelect)
 {
-    g_autofree char *readonly_str = NULL;
-    g_autofree char *secure_str = NULL;
     g_autofree char *type_str = NULL;
 
-    secure_str = virXMLPropString(node, "secure");
-
     if (!fwAutoSelect) {
-        readonly_str = virXMLPropString(node, "readonly");
+        if (virXMLPropTristateBool(node, "readonly", false, &loader->readonly) < 0)
+            return -1;
+
         type_str = virXMLPropString(node, "type");
         if (!(loader->path = virXMLNodeContentString(node)))
             return -1;
@@ -18729,19 +18727,8 @@ virDomainLoaderDefParseXML(xmlNodePtr node,
             VIR_FREE(loader->path);
     }
 
-    if (readonly_str &&
-        (loader->readonly = virTristateBoolTypeFromString(readonly_str)) <= 0) {
-        virReportError(VIR_ERR_XML_DETAIL,
-                       _("unknown readonly value: %s"), readonly_str);
+    if (virXMLPropTristateBool(node, "secure", false, &loader->secure) < 0)
         return -1;
-    }
-
-    if (secure_str &&
-        (loader->secure = virTristateBoolTypeFromString(secure_str)) <= 0) {
-        virReportError(VIR_ERR_XML_DETAIL,
-                       _("unknown secure value: %s"), secure_str);
-        return -1;
-    }
 
     if (type_str) {
         int type;
-- 
2.26.2




More information about the libvir-list mailing list