[libvirt PATCH 04/10] virDomainNumaDefNodeDistanceParseXML: Use virXMLProp*

Tim Wiederhake twiederh at redhat.com
Tue May 11 15:01:51 UTC 2021


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

diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
index 531bdc6eba..e631bfa341 100644
--- a/src/conf/numa_conf.c
+++ b/src/conf/numa_conf.c
@@ -743,7 +743,6 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *def,
 {
     int ret = -1;
     int sibling;
-    char *tmp = NULL;
     xmlNodePtr *nodes = NULL;
     size_t i, ndistances = def->nmem_nodes;
 
@@ -765,24 +764,9 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *def,
         virDomainNumaDistance *rdist;
         unsigned int sibling_id, sibling_value;
 
-        /* siblings are in order of parsing or explicitly numbered */
-        if (!(tmp = virXMLPropString(nodes[i], "id"))) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Missing 'id' attribute in NUMA "
-                             "distances under 'cell id %d'"),
-                           cur_cell);
-            goto cleanup;
-        }
-
-        /* The "id" needs to be applicable */
-        if (virStrToLong_uip(tmp, NULL, 10, &sibling_id) < 0) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Invalid 'id' attribute in NUMA "
-                             "distances for sibling: '%s'"),
-                           tmp);
+        if (virXMLPropUInt(nodes[i], "id", 10, VIR_XML_PROP_REQUIRED,
+                           &sibling_id) < 0)
             goto cleanup;
-        }
-        VIR_FREE(tmp);
 
         /* The "id" needs to be within numa/cell range */
         if (sibling_id >= ndistances) {
@@ -793,26 +777,9 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *def,
             goto cleanup;
         }
 
-        /* We need a locality value. Check and correct
-         * distance to local and distance to remote node.
-         */
-        if (!(tmp = virXMLPropString(nodes[i], "value"))) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Missing 'value' attribute in NUMA distances "
-                             "under 'cell id %d' for 'sibling id %d'"),
-                           cur_cell, sibling_id);
-            goto cleanup;
-        }
-
-        /* The "value" needs to be applicable */
-        if (virStrToLong_uip(tmp, NULL, 10, &sibling_value) < 0) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("'value %s' is invalid for "
-                             "'sibling id %d' under NUMA 'cell id %d'"),
-                           tmp, sibling_id, cur_cell);
+        if (virXMLPropUInt(nodes[i], "value", 10, VIR_XML_PROP_REQUIRED,
+                           &sibling_value) < 0)
             goto cleanup;
-        }
-        VIR_FREE(tmp);
 
         /* Assure LOCAL_DISTANCE <= "value" <= UNREACHABLE
          * and correct LOCAL_DISTANCE setting if such applies.
@@ -867,7 +834,6 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *def,
         def->mem_nodes[i].ndistances = 0;
     }
     VIR_FREE(nodes);
-    VIR_FREE(tmp);
 
     return ret;
 }
-- 
2.26.3




More information about the libvir-list mailing list