From 797f41e8aabe111c295f1fc1919da57711ca75f2 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Mon, 28 Dec 2020 20:51:27 +0300 Subject: [PATCH] test/zdtm_ct: Run zdtm.py in the host time namespace Before the 5.11 kernel, there is a known issue. start_time in /proc/pid/stat is printed in the host time namespace, but /proc/uptime is shown in a current namespace, but criu compares them to detect when a new task has reused one of old pids. Fixes: #1266 Signed-off-by: Andrei Vagin --- test/zdtm_ct.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/zdtm_ct.c b/test/zdtm_ct.c index 5495d61eb..d9823da3f 100644 --- a/test/zdtm_ct.c +++ b/test/zdtm_ct.c @@ -9,6 +9,7 @@ #include #include #include +#include #ifndef CLONE_NEWTIME #define CLONE_NEWTIME 0x00000080 /* New time namespace */ @@ -42,7 +43,28 @@ static inline int _settime(clockid_t clk_id, time_t offset) static int create_timens() { - int fd; + struct utsname buf; + unsigned major, minor; + int fd, ret; + + /* + * Before the 5.11 kernel, there is a known issue. + * start_time in /proc/pid/stat is printed in the host time + * namespace, but /proc/uptime is shown in the current time + * namespace, so criu can't compare them to detect tasks that + * reuse old pids. + */ + ret = uname(&buf); + if (ret) + return -1; + + if (sscanf(buf.release, "%u.%u", &major, &minor) != 2) + return -1; + + if (major == 5 && minor < 11) { + fprintf(stderr, "timens isn't supported on %s\n", buf.release); + return 0; + } if (unshare(CLONE_NEWTIME)) { if (errno == EINVAL) {