mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-09 01:50:35 +00:00
Fix the unprivileged tests cgroup management
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>
This commit is contained in:
parent
93c709b231
commit
42e5c9878f
@ -105,9 +105,32 @@ chown -R $TUSER: /run/user/$(id -u $TUSER)
|
|||||||
|
|
||||||
cd $HDIR
|
cd $HDIR
|
||||||
|
|
||||||
|
if which cgm >/dev/null 2>&1; then
|
||||||
cgm create all $TUSER
|
cgm create all $TUSER
|
||||||
cgm chown all $TUSER $(id -u $TUSER) $(id -g $TUSER)
|
cgm chown all $TUSER $(id -u $TUSER) $(id -g $TUSER)
|
||||||
cgm movepid all $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 \
|
||||||
|
string:$d string:$TUSER >/dev/null
|
||||||
|
|
||||||
|
dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \
|
||||||
|
--type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Chown \
|
||||||
|
string:$d string:$TUSER int32:$(id -u $TUSER) int32:$(id -g $TUSER) >/dev/null
|
||||||
|
|
||||||
|
dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \
|
||||||
|
--type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.MovePid \
|
||||||
|
string:$d string:$TUSER int32:$$ >/dev/null
|
||||||
|
done
|
||||||
|
else
|
||||||
|
for d in /sys/fs/cgroup/*; do
|
||||||
|
[ ! -d $d/lxctest ] && mkdir $d/lxctest
|
||||||
|
chown -R $TUSER: $d/lxctest
|
||||||
|
echo $$ > $d/lxctest/tasks
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
run_cmd mkdir -p $HDIR/.cache/lxc
|
run_cmd mkdir -p $HDIR/.cache/lxc
|
||||||
[ -d /var/cache/lxc/download ] && \
|
[ -d /var/cache/lxc/download ] && \
|
||||||
|
@ -92,7 +92,11 @@ chown -R $TUSER: /run/user/$(id -u $TUSER)
|
|||||||
|
|
||||||
cd $HDIR
|
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
|
for d in $(cut -d : -f 2 /proc/self/cgroup); do
|
||||||
dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \
|
dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \
|
||||||
--type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Create \
|
--type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Create \
|
||||||
|
@ -84,7 +84,11 @@ lxc.id_map = u 0 910000 10000
|
|||||||
lxc.id_map = g 0 910000 10000
|
lxc.id_map = g 0 910000 10000
|
||||||
EOF
|
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
|
for d in $(cut -d : -f 2 /proc/self/cgroup); do
|
||||||
dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \
|
dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \
|
||||||
--type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Create \
|
--type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Create \
|
||||||
|
Loading…
Reference in New Issue
Block a user