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

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

 



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

diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index 1ce31e9234..a2893fec6f 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -468,28 +468,14 @@ int
 virInterfaceLinkParseXML(xmlNodePtr node,
                          virNetDevIfLink *lnk)
 {
-    int state;
-
-    g_autofree char *stateStr = virXMLPropString(node, "state");
-    g_autofree char *speedStr = virXMLPropString(node, "speed");
-
-    if (stateStr) {
-        if ((state = virNetDevIfStateTypeFromString(stateStr)) < 0) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("unknown link state: %s"),
-                           stateStr);
-            return -1;
-        }
-        lnk->state = state;
-    }
+    if (virXMLPropEnum(node, "state", virNetDevIfStateTypeFromString,
+                       VIR_XML_PROP_OPTIONAL, &lnk->state) < 0)
+        return -1;
 
-    if (speedStr &&
-        virStrToLong_ui(speedStr, NULL, 10, &lnk->speed) < 0) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("Unable to parse link speed: %s"),
-                       speedStr);
+    if (virXMLPropUInt(node, "speed", 10, VIR_XML_PROP_OPTIONAL,
+                       &lnk->speed) < 0)
         return -1;
-    }
+
     return 0;
 }
 
-- 
2.26.2




[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