On 5/11/21 11:01 AM, Tim Wiederhake wrote:
Signed-off-by: Tim Wiederhake <twiederh(a)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;
(Not about *this* patch, but rather the absence of a related patch) The
other "Use virXMLProp*" patches have a companion patch that makes
"nodes" a g_autofree, but you haven't included that patch for this
function.
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;
}