Allow independent setting of CPU reservation and CPU share
[util-vserver-pl.git] / python / vserver.py
index 65d9c62..7937022 100644 (file)
@@ -17,7 +17,6 @@ import resource
 import vserverimpl
 import cpulimit, bwlimit
 
 import vserverimpl
 import cpulimit, bwlimit
 
-from vserverimpl import VS_SCHED_CPU_GUARANTEED as SCHED_CPU_GUARANTEED
 from vserverimpl import DLIMIT_INF
 from vserverimpl import VC_LIM_KEEP
 from vserverimpl import VLIMIT_NSOCK
 from vserverimpl import DLIMIT_INF
 from vserverimpl import VC_LIM_KEEP
 from vserverimpl import VLIMIT_NSOCK
@@ -325,25 +324,23 @@ class VServer:
 
         return block_limit
 
 
         return block_limit
 
-    def set_sched_config(self, cpu_share, sched_flags):
+    def set_sched_config(self, cpu_min, cpu_share):
 
         """ Write current CPU scheduler parameters to the vserver
         configuration file. This method does not modify the kernel CPU
         scheduling parameters for this context. """
 
 
         """ Write current CPU scheduler parameters to the vserver
         configuration file. This method does not modify the kernel CPU
         scheduling parameters for this context. """
 
-        if sched_flags & SCHED_CPU_GUARANTEED:
-            cpu_guaranteed = cpu_share
-        else:
-            cpu_guaranteed = 0
+        self.config.update('sched/fill-rate', cpu_min)
         self.config.update('sched/fill-rate2', cpu_share)
         self.config.update('sched/fill-rate2', cpu_share)
-        self.config.update('sched/fill-rate', cpu_guaranteed)
-
+        if cpu_share == 0:
+            self.config.unset('sched/idle-time')
+        
         if self.vm_running:
         if self.vm_running:
-            self.set_sched(cpu_share, sched_flags)
+            self.set_sched(cpu_min, cpu_share)
 
 
-    def set_sched(self, cpu_share, sched_flags = 0):
+    def set_sched(self, cpu_min, cpu_share):
         """ Update kernel CPU scheduling parameters for this context. """
         """ Update kernel CPU scheduling parameters for this context. """
-        vserverimpl.setsched(self.ctx, cpu_share, sched_flags)
+        vserverimpl.setsched(self.ctx, cpu_min, cpu_share)
 
     def get_sched(self):
         # have no way of querying scheduler right now on a per vserver basis
 
     def get_sched(self):
         # have no way of querying scheduler right now on a per vserver basis