[PATCH v2 1/6] conf: Parse common scheduler attributes in separate function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This will become useful later when parsing emulatorsched parameters which don't
need the rest of the current function.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 70 +++++++++++++++++++++++++-----------------
 1 file changed, 41 insertions(+), 29 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b969a9f6e566..15838c2a23f5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18441,45 +18441,24 @@ virDomainLoaderDefParseXML(xmlNodePtr node,
 }
 
 
-static virBitmapPtr
-virDomainSchedulerParse(xmlNodePtr node,
-                        const char *name,
-                        virProcessSchedPolicy *policy,
-                        int *priority)
+static int
+virDomainSchedulerParseCommonAttrs(xmlNodePtr node,
+                                   virProcessSchedPolicy *policy,
+                                   int *priority)
 {
-    virBitmapPtr ret = NULL;
     int pol = 0;
     VIR_AUTOFREE(char *) tmp = NULL;
 
-    if (!(tmp = virXMLPropString(node, name))) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("Missing attribute '%s' in element '%sched'"),
-                       name, name);
-        goto error;
-    }
-
-    if (virBitmapParse(tmp, &ret, VIR_DOMAIN_CPUMASK_LEN) < 0)
-        goto error;
-
-    if (virBitmapIsAllClear(ret)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("'%s' scheduler bitmap '%s' is empty"),
-                       name, tmp);
-        goto error;
-    }
-
-    VIR_FREE(tmp);
-
     if (!(tmp = virXMLPropString(node, "scheduler"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing scheduler attribute"));
-        goto error;
+        return -1;
     }
 
     if ((pol = virProcessSchedPolicyTypeFromString(tmp)) <= 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Invalid scheduler attribute: '%s'"), tmp);
-        goto error;
+        return -1;
     }
     *policy = pol;
 
@@ -18490,16 +18469,49 @@ virDomainSchedulerParse(xmlNodePtr node,
         if (!(tmp = virXMLPropString(node, "priority"))) {
             virReportError(VIR_ERR_XML_ERROR, "%s",
                            _("Missing scheduler priority"));
-            goto error;
+            return -1;
         }
 
         if (virStrToLong_i(tmp, NULL, 10, priority) < 0) {
             virReportError(VIR_ERR_XML_ERROR, "%s",
                            _("Invalid value for element priority"));
-            goto error;
+            return -1;
         }
     }
 
+    return 0;
+}
+
+
+static virBitmapPtr
+virDomainSchedulerParse(xmlNodePtr node,
+                        const char *name,
+                        virProcessSchedPolicy *policy,
+                        int *priority)
+{
+    virBitmapPtr ret = NULL;
+    VIR_AUTOFREE(char *) tmp = NULL;
+
+    if (!(tmp = virXMLPropString(node, name))) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("Missing attribute '%s' in element '%sched'"),
+                       name, name);
+        goto error;
+    }
+
+    if (virBitmapParse(tmp, &ret, VIR_DOMAIN_CPUMASK_LEN) < 0)
+        goto error;
+
+    if (virBitmapIsAllClear(ret)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("'%s' scheduler bitmap '%s' is empty"),
+                       name, tmp);
+        goto error;
+    }
+
+    if (virDomainSchedulerParseCommonAttrs(node, policy, priority) < 0)
+        goto error;
+
     return ret;
 
  error:
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux