2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

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 <avagin@gmail.com>
This commit is contained in:
Andrei Vagin
2020-12-28 20:51:27 +03:00
parent f736b8750e
commit 797f41e8aa

View File

@@ -9,6 +9,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/utsname.h>
#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) {