]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix scheduler support check
authorMartin Kletzander <mkletzan@redhat.com>
Fri, 18 Nov 2016 07:12:12 +0000 (08:12 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Fri, 18 Nov 2016 15:08:52 +0000 (16:08 +0100)
Commit 94cc577807ba tried fixing build on systems that did not have
SCHED_BATCH or SCHED_IDLE defined.  But instead of changing it to
conditional support, it rather completely disabled the support for
setting any scheduler.  Since then, such old systems are not
supported, but rather than reverting that commit, let's change that to
the conditional support.  That way any addition to the list of
schedulers can follow the same style so that we're consistent in the
future.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/util/virprocess.c

index 718c4a2664e1e8f865eaf1a1572fcb358ce101c4..f2993493d2c29d355647234f073c41eca3494d7a 100644 (file)
@@ -1183,7 +1183,7 @@ virProcessExitWithStatus(int status)
     exit(value);
 }
 
-#if HAVE_SCHED_SETSCHEDULER && defined(SCHED_BATCH) && defined(SCHED_IDLE)
+#if HAVE_SCHED_SETSCHEDULER
 
 static int
 virProcessSchedTranslatePolicy(virProcessSchedPolicy policy)
@@ -1193,10 +1193,18 @@ virProcessSchedTranslatePolicy(virProcessSchedPolicy policy)
         return SCHED_OTHER;
 
     case VIR_PROC_POLICY_BATCH:
+# ifdef SCHED_BATCH
         return SCHED_BATCH;
+# else
+        return -1;
+# endif
 
     case VIR_PROC_POLICY_IDLE:
+# ifdef SCHED_IDLE
         return SCHED_IDLE;
+# else
+        return -1;
+# endif
 
     case VIR_PROC_POLICY_FIFO:
         return SCHED_FIFO;
@@ -1225,6 +1233,13 @@ virProcessSetScheduler(pid_t pid,
     if (!policy)
         return 0;
 
+    if (pol < 0) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Scheduler '%s' is not supported on this platform"),
+                       virProcessSchedPolicyTypeToString(policy));
+        return -1;
+    }
+
     if (pol == SCHED_FIFO || pol == SCHED_RR) {
         int min = 0;
         int max = 0;