[libvirt PATCH v3 30/51] domain_conf: Use virXMLPropTristateXXX in virDomainGraphicsDefParseXMLSDL

Tim Wiederhake twiederh at redhat.com
Fri Mar 19 15:57:27 UTC 2021


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

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 35320fe1e5..4684496522 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13139,10 +13139,8 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
                                 xmlXPathContextPtr ctxt)
 {
     VIR_XPATH_NODE_AUTORESTORE(ctxt)
-    int enableVal;
     xmlNodePtr glNode;
     g_autofree char *fullscreen = virXMLPropString(node, "fullscreen");
-    g_autofree char *enable = NULL;
 
     ctxt->node = node;
 
@@ -13161,20 +13159,14 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
 
     glNode = virXPathNode("./gl", ctxt);
     if (glNode) {
-        enable = virXMLPropString(glNode, "enable");
-        if (!enable) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("sdl gl element missing enable"));
+        if (virXMLPropTristateBool(glNode, "enable", false, &def->data.sdl.gl) < 0)
             return -1;
-        }
 
-        enableVal = virTristateBoolTypeFromString(enable);
-        if (enableVal < 0) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("unknown enable value '%s'"), enable);
+        if (def->data.sdl.gl == VIR_TRISTATE_BOOL_ABSENT) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("sdl gl element missing enable"));
             return -1;
         }
-        def->data.sdl.gl = enableVal;
     }
 
     return 0;
-- 
2.26.2




More information about the libvir-list mailing list