]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Fix the unprivileged tests cgroup management
authorStéphane Graber <stgraber@ubuntu.com>
Mon, 22 Sep 2014 22:08:49 +0000 (18:08 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 23 Sep 2014 14:17:54 +0000 (10:17 -0400)
To cover all the cases we have around, we need to:
 - Attempt to use cgm if present (preferred)
 - Attempt to use cgmanager directly over dbus otherwise
 - Fallback to cgroupfs

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/tests/lxc-test-unpriv
src/tests/lxc-test-usernic.in

index 59c264032744334f4fa72912f98ac95ce65210c6..6235901c7f9e96e394989d3537ca33e777b8377c 100755 (executable)
@@ -92,7 +92,11 @@ chown -R $TUSER: /run/user/$(id -u $TUSER)
 
 cd $HDIR
 
-if [ -e /sys/fs/cgroup/cgmanager/sock ]; then
+if which cgm >/dev/null 2>&1; then
+       cgm create all $TUSER
+       cgm chown all $TUSER $(id -u $TUSER) $(id -g $TUSER)
+       cgm movepid all $TUSER $$
+elif [ -e /sys/fs/cgroup/cgmanager/sock ]; then
        for d in $(cut -d : -f 2 /proc/self/cgroup); do
                dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \
                        --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Create \
index 7955d4f65a8b1208f0d2a2975523a681339b20eb..8d78fea59b38ee047db38b88603a75dcc82690b6 100755 (executable)
@@ -84,7 +84,11 @@ lxc.id_map = u 0 910000 10000
 lxc.id_map = g 0 910000 10000
 EOF
 
-if [ -e /sys/fs/cgroup/cgmanager/sock ]; then
+if which cgm >/dev/null 2>&1; then
+       cgm create all $TUSER
+       cgm chown all $TUSER $(id -u $TUSER) $(id -g $TUSER)
+       cgm movepid all $TUSER $$
+elif [ -e /sys/fs/cgroup/cgmanager/sock ]; then
        for d in $(cut -d : -f 2 /proc/self/cgroup); do
                dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \
                        --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Create \