- try:
- vserverimpl.setsched(self.ctx,fillrate,interval,tokens,tokensmin,tokensmax,cpuguaranteed)
- except OSError, ex:
- if ex.errno == 22:
- print "kernel does not support vserver scheduler"
- else:
- raise ex
+ def set_sched_config(self, cpu_share, sched_flags):
+
+ """ Write current CPU scheduler parameters to the vserver
+ configuration file. This method does not modify the kernel CPU
+ scheduling parameters for this context. """
+
+ if cpu_share == int(self.config.get("CPULIMIT", -1)):
+ return
+ cpu_guaranteed = sched_flags & SCHED_CPU_GUARANTEED
+ cpu_config = { "CPULIMIT": cpu_share, "CPUGUARANTEED": cpu_guaranteed }
+ self.update_resources(cpu_config)
+ if self.vm_running:
+ self.set_sched(cpu_share, sched_flags)
+
+ def set_sched(self, cpu_share, sched_flags = 0):
+
+ """ Update kernel CPU scheduling parameters for this context. """
+
+ vserverimpl.setsched(self.ctx, cpu_share, sched_flags)