]> xenbits.xensource.com Git - libvirt.git/commitdiff
virDomainSchedulerParseCommonAttrs: Use virXMLProp*
authorTim Wiederhake <twiederh@redhat.com>
Tue, 4 May 2021 14:02:31 +0000 (16:02 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 6 May 2021 11:54:38 +0000 (13:54 +0200)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c

index a534aa77ad9edb1f2f8725b62a1546eab29a9ba8..7714cfec523347adf698c0aabb9e62eec709d97e 100644 (file)
@@ -17870,37 +17870,15 @@ virDomainSchedulerParseCommonAttrs(xmlNodePtr node,
                                    virProcessSchedPolicy *policy,
                                    int *priority)
 {
-    int pol = 0;
-    g_autofree char *tmp = NULL;
-
-    if (!(tmp = virXMLPropString(node, "scheduler"))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Missing scheduler attribute"));
-        return -1;
-    }
-
-    if ((pol = virProcessSchedPolicyTypeFromString(tmp)) <= 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Invalid scheduler attribute: '%s'"), tmp);
+    if (virXMLPropEnum(node, "scheduler", virProcessSchedPolicyTypeFromString,
+                       VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO,
+                       policy) < 0)
         return -1;
-    }
-    *policy = pol;
 
-    VIR_FREE(tmp);
-
-    if (pol == VIR_PROC_POLICY_FIFO ||
-        pol == VIR_PROC_POLICY_RR) {
-        if (!(tmp = virXMLPropString(node, "priority"))) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("Missing scheduler priority"));
-            return -1;
-        }
-
-        if (virStrToLong_i(tmp, NULL, 10, priority) < 0) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("Invalid value for element priority"));
+    if (*policy == VIR_PROC_POLICY_FIFO || *policy == VIR_PROC_POLICY_RR) {
+        if (virXMLPropInt(node, "priority", 10, VIR_XML_PROP_REQUIRED,
+                          priority) < 0)
             return -1;
-        }
     }
 
     return 0;