"ANON": VLIMIT_ANON,
"SHMEM": VLIMIT_SHMEM}
+CPU_SHARE_MULT = 1024
+
# add in the platform supported rlimits
for entry in resource.__dict__.keys():
if entry.find("RLIMIT_")==0:
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. """
-
- self.config.update('sched/fill-rate', cpu_min)
- self.config.update('sched/fill-rate2', cpu_share)
- if cpu_share == 0:
- self.config.unset('sched/idle-time')
-
+ configuration file. Currently, 'cpu_min' is not supported. """
+ self.config.update('cgroup/cpu.shares', cpu_share * CPU_SHARE_MULT)
if self.is_running():
self.set_sched(cpu_min, cpu_share)
def set_sched(self, cpu_min, cpu_share):
- """ Update kernel CPU scheduling parameters for this context. """
- vserverimpl.setsched(self.ctx, cpu_min, cpu_share)
+ """ Update kernel CPU scheduling parameters for this context.
+ Currently, 'cpu_min' is not supported. """
+ try:
+ cgroup = open('/dev/cgroup/%s/cpu.shares' % name, 'w')
+ cgroup.write('%s' % (cpu_share * CPU_SHARE_MULT))
+ cgroup.close()
+ except:
+ pass
def get_sched(self):
- # have no way of querying scheduler right now on a per vserver basis
- return (-1, False)
+ try:
+ cpu_share = int(int(self.config.get('cgroup/cpu.shares')) / CPU_SHARE_MULT)
+ except:
+ cpu_share = False
+ return (-1, cpu_share)
def set_bwlimit(self, minrate = bwlimit.bwmin, maxrate = None,
exempt_min = None, exempt_max = None,