From: Martin Kletzander Date: Fri, 18 Nov 2016 07:12:12 +0000 (+0100) Subject: Fix scheduler support check X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=f2bf5fbb04494a0635cbc690c083b844876aa4a6;p=libvirt.git Fix scheduler support check 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 --- diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 718c4a2664..f2993493d2 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -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;