[libvirt PATCH 10/10] virDomainGraphicsDefParseXMLVNC: Use virXMLProp*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 59 ++++++++++--------------------------------
 1 file changed, 13 insertions(+), 46 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1acd692720..b752ccd70b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12645,11 +12645,8 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDef *def,
                                 unsigned int flags)
 {
     g_autofree char *port = virXMLPropString(node, "port");
-    g_autofree char *websocket = virXMLPropString(node, "websocket");
     g_autofree char *websocketGenerated = virXMLPropString(node, "websocketGenerated");
-    g_autofree char *sharePolicy = virXMLPropString(node, "sharePolicy");
     g_autofree char *autoport = virXMLPropString(node, "autoport");
-    g_autofree char *powerControl = virXMLPropString(node, "powerControl");
     xmlNodePtr audioNode;
     VIR_XPATH_NODE_AUTORESTORE(ctxt)
 
@@ -12680,62 +12677,32 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDef *def,
             def->data.vnc.port = 0;
     }
 
-    if (websocket) {
-        if (virStrToLong_i(websocket,
-                           NULL, 10,
-                           &def->data.vnc.websocket) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("cannot parse vnc WebSocket port %s"), websocket);
-            return -1;
-        }
-    }
+    if (virXMLPropInt(node, "websocket", 10, VIR_XML_PROP_NONE,
+                      &def->data.vnc.websocket) < 0)
+        return -1;
 
     if (websocketGenerated)
         ignore_value(virStringParseYesNo(websocketGenerated,
                      &def->data.vnc.websocketGenerated));
 
-    if (sharePolicy) {
-        int policy =
-           virDomainGraphicsVNCSharePolicyTypeFromString(sharePolicy);
-
-        if (policy < 0) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("unknown vnc display sharing policy '%s'"),
-                           sharePolicy);
-            return -1;
-        } else {
-            def->data.vnc.sharePolicy = policy;
-        }
-    }
+    if (virXMLPropEnum(node, "sharePolicy",
+                       virDomainGraphicsVNCSharePolicyTypeFromString,
+                       VIR_XML_PROP_NONE, &def->data.vnc.sharePolicy) < 0)
+        return -1;
 
-    if (powerControl) {
-        int powerControlVal = virTristateBoolTypeFromString(powerControl);
-        if (powerControlVal < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("cannot parse vnc power control '%s'"), powerControl);
-            return -1;
-        }
-        def->data.vnc.powerControl = powerControlVal;
-    }
+    if ((virXMLPropTristateBool(node, "powerControl", VIR_XML_PROP_NONE,
+                                &def->data.vnc.powerControl)) < 0)
+        return -1;
 
     def->data.vnc.keymap = virXMLPropString(node, "keymap");
 
     ctxt->node = node;
     audioNode = virXPathNode("./audio", ctxt);
     if (audioNode) {
-        g_autofree char *tmp = NULL;
-        tmp = virXMLPropString(audioNode, "id");
-        if (!tmp) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("missing audio 'id' attribute"));
-            return -1;
-        }
-        if (virStrToLong_ui(tmp, NULL, 10, &def->data.vnc.audioId) < 0 ||
-            def->data.vnc.audioId == 0) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Invalid audio 'id' value '%s'"), tmp);
+        if (virXMLPropUInt(audioNode, "id", 10,
+                           VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO,
+                           &def->data.vnc.audioId) < 0)
             return -1;
-        }
     }
 
     if (virDomainGraphicsAuthDefParseXML(node, &def->data.vnc.auth,
-- 
2.26.3




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux