[PATCH] conf: Enforce scheduler name when parsing XML

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

 



We require the scheduler name attribute in the schemas but the code
would actually be fine when it was omitted. Make it mandatory.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1234729
---
 src/conf/domain_conf.c | 49 ++++++++++++++++++++++++++-----------------------
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e592adf..183e66c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14153,32 +14153,35 @@ virDomainThreadSchedParse(xmlNodePtr node,
     }
     VIR_FREE(tmp);

-    tmp = virXMLPropString(node, "scheduler");
-    if (tmp) {
-        if ((pol = virProcessSchedPolicyTypeFromString(tmp)) <= 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Invalid scheduler attribute: '%s'"),
-                           tmp);
+    if (!(tmp = virXMLPropString(node, "scheduler"))) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Missing scheduler attribute"));
+        goto error;
+    }
+
+    if ((pol = virProcessSchedPolicyTypeFromString(tmp)) <= 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Invalid scheduler attribute: '%s'"),
+                       tmp);
+        goto error;
+    }
+    sp->policy = pol;
+
+    VIR_FREE(tmp);
+    if (sp->policy == VIR_PROC_POLICY_FIFO ||
+        sp->policy == VIR_PROC_POLICY_RR) {
+        tmp = virXMLPropString(node, "priority");
+        if (!tmp) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("Missing scheduler priority"));
             goto error;
         }
-        sp->policy = pol;
-
-        VIR_FREE(tmp);
-        if (sp->policy == VIR_PROC_POLICY_FIFO ||
-            sp->policy == VIR_PROC_POLICY_RR) {
-            tmp = virXMLPropString(node, "priority");
-            if (!tmp) {
-                virReportError(VIR_ERR_XML_ERROR, "%s",
-                               _("Missing scheduler priority"));
-                goto error;
-            }
-            if (virStrToLong_i(tmp, NULL, 10, &sp->priority) < 0) {
-                virReportError(VIR_ERR_XML_ERROR, "%s",
-                               _("Invalid value for element priority"));
-                goto error;
-            }
-            VIR_FREE(tmp);
+        if (virStrToLong_i(tmp, NULL, 10, &sp->priority) < 0) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("Invalid value for element priority"));
+            goto error;
         }
+        VIR_FREE(tmp);
     }

     return 0;
-- 
2.4.1

--
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]