2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-09-04 00:05:26 +00:00
Commit Graph

6509 Commits

Author SHA1 Message Date
Andrew Vagin
bab4e9c98c netlink: Use nlattr instead of rtattr
because the kernel uses nlattr for these messages.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-25 23:28:10 +03:00
Laurent Dufour
cae683dc46 ppc64: Fix build regressions
The build on powerPC has been broken when doing some code cleanup
recently.

This patch fixes these regressions.

Fixes: f8a1a1d8d95e ("parasite-syscall: get rid of code_syscall{,size} globals")
Fixes: 69d88241584e ("sigframe: move setup_sas & make it inliner")
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Acked-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-23 13:10:45 +03:00
Cyrill Gorcunov
227068c8dc build: Drop @images
Autogenerated by @gen-built-in

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-23 13:10:45 +03:00
Cyrill Gorcunov
3ddf271a5b nmk: scritps/macro.mk -- Enhance gen-built-in
Add ability to specify prerequsites and phony targets.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-23 13:10:45 +03:00
Dmitry Safonov
c58cd75503 sigframe: move setup_sas & make it inliner
Impact: No functional changes, cleanup

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-23 13:10:45 +03:00
Dmitry Safonov
0b3901fb29 parasite-syscall: get rid of code_syscall{,size} globals
I think, we may safely remove this exports, as:
- code_syscall is used only in one function, which now will have
  it as a parameter;
- code_syscall_size must be equall to BUILTIN_SYSCALL_SIZE under
  BUILD_BUG_ON, so BUILTIN_SYSCALL_SIZE may be used instead.
  (see ptrace(2) - align restriction to PTRACE_PEEKUSER).

This will reduce arch-depended code coupling a little.

(and I also interested in this because of I need __parasite_execute_syscall
to execute 32-bit syscall code on x86_64, which I prefer to leave without
some CONFIG_X86_64 as it's generic code)

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-23 13:10:45 +03:00
Saied Kazemi
5f51cd4de2 netfilter: add -n to iptables and ip6tables calls
To preload netfilter modules, criu runs "iptables -L" and "ip6tables -L"
before starting to dump or restore a process tree.

On systems with many entries, the above commands without the -n option
take a long time because of lengthy DNS lookups.

Signed-off-by: Saied Kazemi <saied@google.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-23 13:10:45 +03:00
Cyrill Gorcunov
ef4dbebe47 criu: seize -- Don't left dangling @processes_to_wait_pids pointer
If an error occured during freezer_wait_processes we are
freeing processes_to_wait_pids array but same time
take freezer_detach on error path to execute, which
lead in nil dereference in best case.

Simply zap dangling pointer and make sure it exist
in freezer_detach.

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-21 10:15:32 +03:00
Dmitry Safonov
2d938397a6 x86/restorer: drop unused struct pt_regs
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-21 10:15:32 +03:00
Dmitry Safonov
a833ead951 pie/restorer: remove unused parameter frm restore_thread_common
Since commit 22396f7690 ("restore: construct sigframe in crtools")
sigframe is unused in restore_thread_common, as restore gpregs/fpu regs
now does construct_sigframe.

Impact: cleanup

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-21 10:15:32 +03:00
Pavel Emelyanov
b1b9eb7b32 zdtm: Wait for transition test to run for some time after, start
These tests do some work while being C/R-ed, so it make sense to
let them do some progress before doing so.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
2016-03-21 10:15:31 +03:00
Cyrill Gorcunov
6fe502dc80 build: docs -- Use autogenerated footer
We can generate footer dynamically and
provide criu.8 version the same as
the program has.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-21 10:15:31 +03:00
Cyrill Gorcunov
1fc5c0244b criu: pstree_switch_state -- Fix nil deref on error path
We may enter with @root_item = NULL in case of error
handling, so simply bail out.

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-21 10:15:31 +03:00
Pavel Emelyanov
66ccd9a932 types: Remove setns override with sys_setns
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-21 10:15:31 +03:00
Laurent Dufour
046a1fc8cc cr-check: fix kcmp check
The commit 16e673c2f6a0 ("cr-check: Inspect errno on syscall
failures") reverts the way the returned the error returned by kcmp is
checked. As a consequence 'criu check' is always failing with the
following message:

Error (cr-check.c:165): System call kcmp is not supported: No such process

This patch ensure is reported only if syscall(SYS_kcmp) returns
ENOSYS.

Fixes: 16e673c2f6a0 ("cr-check: Inspect errno on syscall failures")
Looks-good-to: Filipe Brandenburger <filbranden@google.com>
Cc: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-21 10:15:31 +03:00
Cyrill Gorcunov
d693a53fec criu: arm -- Use conditional syscalls where needed
We're using general syscall-codes.h in criu itself
so make sure the headers we include do not override
system headers definitions.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-18 17:18:57 +03:00
Cyrill Gorcunov
e085251fc4 criu: arm -- Guard __ARM_NR_ definitions
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-18 17:18:51 +03:00
Andrew Vagin
717d6a512a cr-dump: getpriority() can return a negative value
Since getpriority() can legitimately return the value -1, it is necessary
to clear the external variable errno prior to the call, then check
it afterward to determine if -1 is an error or a legitimate value.

Cc: Filipe Brandenburger <filbranden@google.com>
Fixes: 16e673c2f6a0 ("cr-check: Inspect errno on syscall failures")
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:09 +03:00
Pavel Emelyanov
9f5c378ff1 check: Call sbrk to get current brk
According to man, glibc brk reports 0 on success, but we need current brk

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Saied Kazemi <saied@google.com>
2016-03-16 16:16:09 +03:00
Laurent Dufour
8c6062e877 git: ignore scripts/build/qemu-user-static/*
Cc: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:09 +03:00
Cyrill Gorcunov
fa3c34c361 criu: Use __NR_memfd_create for testing memfd presence
We define own SYS_memfd_create in case if it's missing
in libc, but we need it for user-namespace restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:09 +03:00
Laurent Dufour
74a265e74a build: Conditionally defined SYS_* constants
This patch changes the way the per architecture syscall-codes.h is
generated to define __NR* and SYS_* constants only if there are not
already defined.

This way this file could be included in the C files calling syscall()
to ensure the SYS_* constant is defined even if the C library is too
old.

The file syscall-codes.h should be included after the C library header
files.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:09 +03:00
Cyrill Gorcunov
12ae750bc2 build: criu -- Don't link with syscalls library
We don't need it since we use syscall() libc wrapper.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:09 +03:00
Filipe Brandenburger
e7ba90955c cr-check: Inspect errno on syscall failures
After replacing sys_kcmp with syscall() and sys_prctl with prctl(), the
API is changed to return -1 and set errno on failure (instead of
returning the negative value of the error code directly on return.)

Commit 8ceab588a5 ("crtools: no more linked with builtin syscall")
replaced calls to sys_kcmp and sys_prctl, but did not update the checks
for ret to check for -1 and errno, so update them here.

Also make the comparisons for the return value explicit checks for a
negative value (expected -1) instead of just failing on a non-zero value
with the implicit comparison.

Add %m to report what errno was set to on failed syscalls, to make it
easier to troubleshoot a check failure.

Tested that now `criu check --ms` stopped reporting the misleading:
  prctl: One needs CAP_SYS_RESOURCE capability to perform testing.
Instead, now it reports:
  Error (cr-check.c:165): System call kcmp is not supported: No such process
  Warn  (cr-check.c:195): Skipping unssuported PR_SET_MM_MAP: Invalid argument
  prctl: PR_SET_MM is not supported: Invalid argument
And those messages include the error message that explains why the
syscall failed.

Reported-by: Saied Kazemi <saied@google.com>
Fixes: 8ceab588a5 ("crtools: no more linked with builtin syscall")
Cc: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:09 +03:00
Ivan Shapovalov
a1b94a3d3e zdtm: zdtm.py: write "meta" checkskip/hook scripts for group tests
Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Ivan Shapovalov
8fa1d7114a zdtm: zdtm.py: allow deliberately generating test groups of size 1
Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Ivan Shapovalov
0fd53e07a5 zdtm: zdtm.py: reset $PATH to canonical in ns tests
This is to deal with distros like Arch which take /usr merge to the
extreme and set their $PATH to something like /usr/local/bin:/usr/bin
(no /usr/sbin, no /{s,}bin), which breaks our rather inflexible nsroot
population logic.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Andrew Vagin
9892355192 zdtm/mountpoints: clean up
Now, we execute this test in a test mount namespace, which contains only
test mounts.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Andrew Vagin
3006ada21d jenkins: add a script to execute tests on overlayfs
Here are all tests which pass now

And I created an issue to investigate fails of other tests:
https://github.com/xemul/criu/issues/136

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Andrew Vagin
d2499d974e mounts: handle device numbers in different formats properly
We have two formats for devices and we had to use proper
helpers for them and compare values of a one format.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Andrew Vagin
f8ea08bb46 irmap: don't try to dereference a null pointer
irmap_revalidate() sets a cursor to the next element or null,
then we try to dereference cursor->next in the for statemant.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Tycho Andersen
70afb3bde2 build: clean up various other bits
.gitid, and some of the build directories from setup.py need to be cleaned
on 'clean'.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Cyrill Gorcunov
3d0fcc0715 build: Add verbose message on packages needed for CRIU building
From issue #135

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Cyrill Gorcunov
029650bfed build: Unify phony forms usage
Explicit .PHONY is preferred for style unification sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Tycho Andersen
b8df05e6ce cgroup: don't leak old paths when rewriting
Remember to set tmp2 when allocating the new path so that we can free it
later. Also, don't leak tmp2 in the error case.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Evgenii Shatokhin
c4cf5f0b76 dump: check for conflicts with the dead processes
It may happen that a process has completed but its files in /proc/PID/
are still open by another process (see remap_dead_pid test from zdtm
suite, for example).

If the PID number has been given to some newer thread since then, this
can be problematic. If that thread is the main thread of some process,
it seems to be handled OK on restore. However, if it is a secondary
thread, restore fails with an error like:

  pie: Error (pie/restorer.c:439): Thread pid mismatch 4404/4403

This is because open_remap_dead_process() adds a helper with PID 4403 to
restore /proc/4403/* and that clashes with the thread's PID.

It seems reasonable to detect such things at the checkpoint stage and
refuse to dump, rather than to fail during restore.

v.3:
* Loop over dead_pids[] first: the array is likely to be empty.
  Note that it is still needed to iterate over the threads explicitly
  because pstree contains no items for the threads at that point.

v.2:
* Check for conflicts after all tasks have been dumped. One cannot rely
  on any particular order of tasks being dumped.

Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Andrew Vagin
e12ccb95b0 mount: don't use a shared mount to get a clean mount
When we bind-mount something into a shared mount,
a new mount will be shared too.

By default /tmp is a shared mount, so when we get a "clean mount",
it will be always shared. On restore we don't need this side effect,
so let's do bind-mount in a private mount.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:08 +03:00
Andrew Vagin
e22aaf7f6c mount: master_id should be 0 for new mounts
v2: add a comment before calling BUG_ON(mi->master_id)
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:07 +03:00
Andrew Vagin
cfc267a2a2 mount: restore a shared group for propagated mounts
When a mount is propagated, the result mount is always shared.
If we want to get a private mount, we need to convert it.

Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:07 +03:00
Andrew Vagin
5287540ea1 irmap: use kdev everywere
Currently we kdev and odev together and try to compare them without
converting to the one type.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:07 +03:00
Andrei Vagin
a2a41df96a pre-dump: don't waste time in error cases
In error cases we need to exit immediatly

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:07 +03:00
Andrei Vagin
d67397a3c5 dump: pre-dump should never kill processes
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:07 +03:00
Andrei Vagin
615465498f gcov: mount criu sources into a test mount tree
CRIU processes save *.gcda and *.gcno files near source files,
so when we restore tests into another mount namespace,
we need to have access to sources from this namespace.

Cc: Sergey Bronnikov <sergeyb@openvz.org>
Reported-by: Sergey Bronnikov <sergeyb@openvz.org>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:07 +03:00
Andrew Vagin
aa40501d95 test/ext-tty: return an error if a child isn't killed by SIGHUP
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-16 16:16:07 +03:00
Cyrill Gorcunov
d55a1fdd31 make: Improve tar generation
By default it generates archive name same
as a tag name, but Pavel requested to match
old scheme and strip off "v" prefix.

Reported-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-09 13:06:33 +03:00
Tycho Andersen
fc2c3c94b8 tests: add --dry-run to zdtm.py
v2: print test name + flavor info for each test too.
v3: pass dry_run via CR_CT_TEST_INFO

Output looks like this now:

=== Run 1/242 ----------------
Skipping zdtm/transition/thread-bomb (manual run only)
Skipping zdtm/transition/file_aio (manual run only)

======================= Run zdtm/transition/maps007 in h =======================

====================== Run zdtm/transition/maps007 in ns =======================

====================== Run zdtm/transition/maps007 in uns ======================
=== Run 4/242 ----------------
Skipping zdtm/transition/epoll (manual run only)

==================== Run zdtm/transition/pipe_shared00 in h ====================

=================== Run zdtm/transition/pipe_shared00 in ns ====================

=================== Run zdtm/transition/pipe_shared00 in uns ===================
=== Run 6/242 ----------------

======================== Run zdtm/transition/fork in h =========================

======================== Run zdtm/transition/fork in ns ========================

======================= Run zdtm/transition/fork in uns ========================
=== Run 7/242 ----------------
Skipping zdtm/transition/ptrace (manual run only)
Skipping zdtm/transition/socket_loop00 (manual run only)

======================== Run zdtm/transition/ipc in ns =========================
=== Run 10/242 ----------------
Skipping zdtm/transition/netlink00 (manual run only)

===================== Run zdtm/transition/socket-tcp6 in h =====================
=== Run 12/242 ----------------
...

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-09 13:00:38 +03:00
Andrew Vagin
ab8fdf82b3 zdtm: Check a private mount in a shared mount
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-09 12:56:02 +03:00
Pavel Emelyanov
fbdc00391d zdtm: Relax on-stack args for ns creation
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-09 12:49:57 +03:00
Pavel Emelyanov
c88d40991a zdtm: Factor out pidfiles creation
After the pidfile manipulation is sanitized, we can have
a helper for pidfile wrting.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-09 12:49:55 +03:00
Pavel Emelyanov
8abf6d2d1b zdtm: Get dir of init.pid file
For the caller there should be only one pidfile -- the one
that should be fired with TERM signal on stop. All the other
stuff is test's internal business.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-09 12:49:52 +03:00