Activate cgroups for users
Sapan Bhatia [Tue, 9 Oct 2012 17:23:50 +0000 (13:23 -0400)]
lxcsu

diff --git a/lxcsu b/lxcsu
index 36cc5a5..6bcf2e3 100644 (file)
--- a/lxcsu
+++ b/lxcsu
@@ -60,6 +60,14 @@ if (not slice_spec or not pid):
     print "Not started: %s"%slice_name
     exit(1)
 
+# Enter cgroups
+try:
+    for subsystem in ['cpuset','memory','fs','blkio']:
+        open('/sys/fs/cgroup/%s/libvirt/tasks'%subsystem,'w').write(pid)
+except:
+    print "Error assigning resources: %s"%slice_name
+    exit(1)
+
 r1 = setns.chcontext('/proc/%s/ns/utc'%pid)
 r2 = setns.chcontext('/proc/%s/ns/ipc'%pid)
 path = '/proc/%s/ns/net'%pid
@@ -68,6 +76,8 @@ r3 = setns.chcontext(path)
 open('/proc/lxcsu','w').write(pid)
 open('/proc/pidsu','w').write(pid)
 
+
+
 pid = os.fork()
 
 cap_args = map(lambda c:'--drop='+c, drop_capabilities)