[libvirt PATCH 13/14] virInterfaceDefParseXML: Simplify and cleanup

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

 



Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/conf/interface_conf.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index 8f8e8871cb..7c2a0f162c 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -573,26 +573,14 @@ static virInterfaceDef *
 virInterfaceDefParseXML(xmlXPathContextPtr ctxt,
                         int parentIfType)
 {
-    g_autoptr(virInterfaceDef) def = NULL;
-    int type;
-    g_autofree char *tmp = NULL;
     VIR_XPATH_NODE_AUTORESTORE(ctxt)
+    g_autoptr(virInterfaceDef) def = NULL;
+    virInterfaceType type;
     xmlNodePtr lnk;
 
-
-    /* check @type */
-    tmp = virXPathString("string(./@type)", ctxt);
-    if (tmp == NULL) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       "%s", _("interface misses the type attribute"));
+    if (virXMLPropEnum(ctxt->node, "type", virInterfaceTypeFromString,
+                       VIR_XML_PROP_REQUIRED, &type) < 0)
         return NULL;
-    }
-    type = virInterfaceTypeFromString(tmp);
-    if (type == -1) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown interface type %s"), tmp);
-        return NULL;
-    }
 
     def = g_new0(virInterfaceDef, 1);
 
@@ -680,7 +668,8 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt,
                 return NULL;
             break;
         }
-
+        case VIR_INTERFACE_TYPE_LAST:
+            return NULL;
     }
 
     return g_steal_pointer(&def);
-- 
2.31.1




[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