mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-19 01:26:22 +00:00
zdtm: reexec the mountpoints test in a target mntns
Otherwise it will have external files (from another namespace, which isn't dumped). Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
15a457bde8
commit
9ea2baa2db
3 changed files with 22 additions and 9 deletions
|
|
@ -161,6 +161,7 @@ tempfs
|
|||
maps007
|
||||
tempfs
|
||||
bind-mount
|
||||
mountpoints
|
||||
"
|
||||
|
||||
source $(readlink -f `dirname $0`/env.sh) || exit 1
|
||||
|
|
|
|||
|
|
@ -149,6 +149,9 @@ void test_init(int argc, char **argv)
|
|||
setup_outfile();
|
||||
redir_stdfds();
|
||||
|
||||
if (getenv("ZDTM_REEXEC"))
|
||||
goto skip_pid;
|
||||
|
||||
pidf = fopen(pidfile, "wx");
|
||||
if (!pidf) {
|
||||
err("Can't create pid file %s: %m\n", pidfile);
|
||||
|
|
@ -183,22 +186,23 @@ void test_init(int argc, char **argv)
|
|||
_exit(0);
|
||||
}
|
||||
|
||||
fclose(pidf);
|
||||
|
||||
if (setsid() < 0) {
|
||||
err("Can't become session group leader: %m\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
skip_pid:
|
||||
/* record the test pid to remember the ownership of the pidfile */
|
||||
master_pid = getpid();
|
||||
|
||||
fclose(pidf);
|
||||
|
||||
sa.sa_handler = SIG_DFL;
|
||||
if (sigaction(SIGCHLD, &sa, NULL)) {
|
||||
err("Can't reset SIGCHLD handler: %m\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (setsid() < 0) {
|
||||
err("Can't become session group leader: %m\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
srand48(time(NULL)); /* just in case we need it */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sched.h>
|
||||
#include <sys/wait.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zdtmtst.h"
|
||||
|
||||
|
|
@ -69,6 +70,13 @@ static int test_fn(int argc, char **argv)
|
|||
mode_t old_mask;
|
||||
pid_t pid;
|
||||
|
||||
if (!getenv("ZDTM_REEXEC")) {
|
||||
setenv("ZDTM_REEXEC", "1", 0);
|
||||
return execv(argv[0], argv);
|
||||
} else
|
||||
test_init(argc, argv);
|
||||
|
||||
close(0); /* /dev/null */
|
||||
again:
|
||||
fs_cnt = 0;
|
||||
f = fopen("/proc/self/mountinfo", "r");
|
||||
|
|
@ -254,8 +262,6 @@ done:
|
|||
mknod("/dev/null", 0777 | S_IFCHR, makedev(1, 3));
|
||||
umask(old_mask);
|
||||
|
||||
setup_outfile();
|
||||
|
||||
fd = open(MPTS_ROOT"/kernel/meminfo", O_RDONLY);
|
||||
if (fd == -1)
|
||||
return 1;
|
||||
|
|
@ -336,6 +342,8 @@ done:
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (getenv("ZDTM_REEXEC"))
|
||||
return test_fn(argc, argv);
|
||||
test_init_ns(argc, argv, CLONE_NEWNS, test_fn);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue