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

Tim Wiederhake twiederh at redhat.com
Wed Apr 21 15:51:33 UTC 2021


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

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 113f4123d7..c53ed60bae 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -20047,36 +20047,16 @@ virDomainMemorytuneDefParseMemory(xmlXPathContextPtr ctxt,
     VIR_XPATH_NODE_AUTORESTORE(ctxt)
     unsigned int id;
     unsigned int bandwidth;
-    g_autofree char *tmp = NULL;
 
     ctxt->node = node;
 
-    tmp = virXMLPropString(node, "id");
-    if (!tmp) {
-        virReportError(VIR_ERR_XML_ERROR, "%s",
-                       _("Missing memorytune attribute 'id'"));
+    if (virXMLPropUInt(node, "id", 10, VIR_XML_PROP_REQUIRED, &id) < 0)
         return -1;
-    }
-    if (virStrToLong_uip(tmp, NULL, 10, &id) < 0) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("Invalid memorytune attribute 'id' value '%s'"),
-                       tmp);
-        return -1;
-    }
-    VIR_FREE(tmp);
 
-    tmp = virXMLPropString(node, "bandwidth");
-    if (!tmp) {
-        virReportError(VIR_ERR_XML_ERROR, "%s",
-                       _("Missing memorytune attribute 'bandwidth'"));
+    if (virXMLPropUInt(node, "bandwidth", 10, VIR_XML_PROP_REQUIRED,
+                       &bandwidth) < 0)
         return -1;
-    }
-    if (virStrToLong_uip(tmp, NULL, 10, &bandwidth) < 0) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("Invalid memorytune attribute 'bandwidth' value '%s'"),
-                       tmp);
-        return -1;
-    }
+
     if (virResctrlAllocSetMemoryBandwidth(alloc, id, bandwidth) < 0)
         return -1;
 
-- 
2.26.3




More information about the libvir-list mailing list