]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainMemorytuneDefParseMemory: Use virXMLProp*
authorTim Wiederhake <twiederh@redhat.com>
Wed, 21 Apr 2021 15:51:33 +0000 (17:51 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 22 Apr 2021 09:24:53 +0000 (11:24 +0200)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c

index c786a46890d904030528e9a34461ebce3e19cad4..720d56cf694c9596d64c5f2b8177263b0e880202 100644 (file)
@@ -20065,36 +20065,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;