2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 09:58:09 +00:00

zdtm: use unique holder for cgroups

The idea that each zdtm.py should have own helder, so that two zdtm.py that are
running on the same host don't effect each other.

Fixes: #1774
Signed-off-by: Andrei Vagin <avagin@google.com>
This commit is contained in:
Andrei Vagin 2022-03-20 22:11:19 -07:00 committed by Andrei Vagin
parent 73a783ac17
commit ab6191ccd3
3 changed files with 11 additions and 5 deletions

View File

@ -27,6 +27,7 @@ import subprocess
import sys import sys
import tempfile import tempfile
import time import time
import uuid
from builtins import input, int, open, range, str, zip from builtins import input, int, open, range, str, zip
import yaml import yaml
@ -38,6 +39,7 @@ from zdtm.criu_config import criu_config
STREAMED_IMG_FILE_NAME = "img.criu" STREAMED_IMG_FILE_NAME = "img.criu"
prev_line = None prev_line = None
uuid = uuid.uuid4()
def alarm(*args): def alarm(*args):
@ -617,12 +619,12 @@ class zdtm_test:
if not os.access("zdtm/lib/libzdtmtst.a", os.F_OK): if not os.access("zdtm/lib/libzdtmtst.a", os.F_OK):
subprocess.check_call(["make", "-C", "zdtm/"]) subprocess.check_call(["make", "-C", "zdtm/"])
subprocess.check_call( subprocess.check_call(
["flock", "zdtm_mount_cgroups.lock", "./zdtm_mount_cgroups"]) ["flock", "zdtm_mount_cgroups.lock", "./zdtm_mount_cgroups", str(uuid)])
@staticmethod @staticmethod
def cleanup(): def cleanup():
subprocess.check_call( subprocess.check_call(
["flock", "zdtm_mount_cgroups.lock", "./zdtm_umount_cgroups"]) ["flock", "zdtm_mount_cgroups.lock", "./zdtm_umount_cgroups", str(uuid)])
def load_module_from_file(name, path): def load_module_from_file(name, path):

View File

@ -4,13 +4,15 @@
# Error (cgroup.c:768): cg: Set 3 is not subset of 2 # Error (cgroup.c:768): cg: Set 3 is not subset of 2
# so lets create all test controllers before executing tests. # so lets create all test controllers before executing tests.
uuid=$1
cat /proc/self/cgroup | grep -q zdtmtst.defaultroot && exit cat /proc/self/cgroup | grep -q zdtmtst.defaultroot && exit
tdir=`mktemp -d zdtm.XXXXXX` tdir=`mktemp -d zdtm.XXXXXX`
for i in "zdtmtst" "zdtmtst.defaultroot"; do for i in "zdtmtst" "zdtmtst.defaultroot"; do
mount -t cgroup -o none,name=$i zdtm $tdir && mount -t cgroup -o none,name=$i zdtm $tdir &&
# a fake group prevents destroying of a controller # a fake group prevents destroying of a controller
mkdir -p $tdir/holder && mkdir -p $tdir/holder.$uuid &&
umount -l $tdir || exit 1 umount -l $tdir || exit 1
done done
rmdir $tdir rmdir $tdir

View File

@ -4,12 +4,14 @@
cat /proc/self/cgroup | grep -q zdtmtst.defaultroot || exit 0 cat /proc/self/cgroup | grep -q zdtmtst.defaultroot || exit 0
uuid=$1
tdir=`mktemp -d zdtm.XXXXXX` tdir=`mktemp -d zdtm.XXXXXX`
for i in "zdtmtst" "zdtmtst.defaultroot"; do for i in "zdtmtst" "zdtmtst.defaultroot"; do
mount -t cgroup -o none,name=$i zdtm $tdir || { rmdir $tdir; exit 1; } mount -t cgroup -o none,name=$i zdtm $tdir || { rmdir $tdir; exit 1; }
# remove a fake group if exists # remove a fake group if exists
if [ -d "$tdir/holder" ]; then if [ -d "$tdir/holder.$uuid" ]; then
rmdir $tdir/holder || { umount -l $tdir && rmdir $tdir; exit 1; } rmdir $tdir/holder.$uuid || { umount -l $tdir && rmdir $tdir; exit 1; }
fi fi
umount -l $tdir || exit 1; umount -l $tdir || exit 1;
done done