[libvirt PATCH 08/10] virDomainGraphicsListenDefParseXML: 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 | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2103aae2a3..1acd692720 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12439,12 +12439,9 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDef *def,
 {
     int ret = -1;
     const char *graphicsType = virDomainGraphicsTypeToString(graphics->type);
-    int tmp, typeVal;
-    g_autofree char *type = virXMLPropString(node, "type");
     g_autofree char *address = virXMLPropString(node, "address");
     g_autofree char *network = virXMLPropString(node, "network");
     g_autofree char *socketPath = virXMLPropString(node, "socket");
-    g_autofree char *fromConfig = virXMLPropString(node, "fromConfig");
     g_autofree char *autoGenerated = virXMLPropString(node, "autoGenerated");
     g_autofree char *addressCompat = NULL;
     g_autofree char *socketCompat = NULL;
@@ -12454,18 +12451,9 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDef *def,
         socketCompat = virXMLPropString(parent, "socket");
     }
 
-    if (!type) {
-        virReportError(VIR_ERR_XML_ERROR, "%s",
-                       _("graphics listen type must be specified"));
-        goto error;
-    }
-
-    if ((typeVal = virDomainGraphicsListenTypeFromString(type)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown graphics listen type '%s'"), type);
+    if (virXMLPropEnum(node, "type", virDomainGraphicsListenTypeFromString,
+                       VIR_XML_PROP_REQUIRED, &def->type) < 0)
         goto error;
-    }
-    def->type = typeVal;
 
     switch (def->type) {
     case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
@@ -12545,14 +12533,10 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDef *def,
         def->socket = g_steal_pointer(&socketPath);
     }
 
-    if (fromConfig &&
-        flags & VIR_DOMAIN_DEF_PARSE_STATUS) {
-        if (virStrToLong_i(fromConfig, NULL, 10, &tmp) < 0) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Invalid fromConfig value: %s"),
-                           fromConfig);
-            goto error;
-        }
+    if (flags & VIR_DOMAIN_DEF_PARSE_STATUS) {
+        int tmp;
+        if (virXMLPropInt(node, "fromConfig", 10, VIR_XML_PROP_NONE, &tmp) < 0)
+            return -1;
         def->fromConfig = tmp != 0;
     }
 
-- 
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