2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00
Commit Graph

5765 Commits

Author SHA1 Message Date
Ruslan Kuprieiev
9adbbcce7f libcriu: criu_restore_child: don't forget to set errno
Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-31 15:41:53 +03:00
Cédric Bosdonnat
4c5b23e52c Fix criu.pc version
Use CRTOOLSVERSION instead of GITID to write criu.pc version. With
GITID, criu.pc had version '0' when built from tarballs.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-30 19:11:45 +03:00
Cyrill Gorcunov
cab42bca65 x86: sigframe -- Don't forget to copy ss
Make sure we don't pass any trash value here, because
the kernel does copy it explicitly. We allocate the
memory for frame as zero filled but stack segment
is special and zero is not acceptable (we've had
a discussion on LKML if we need a special handling
for zero ss but end up that new kernels need new CRIU
version, upon which all agreed). Finally in
commit 296bbf7e3 I managed to hit exactly
this problem :)

Reported-by: Andrey Wagin <avagin@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrey Wagin <avagin@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-30 16:35:48 +03:00
Cyrill Gorcunov
3e0b09b1b5 sk-unix: protobuf -- Use string type instead of bytestream
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-30 16:35:16 +03:00
Cyrill Gorcunov
48dbef3ecc sk-unix: unix_process_name -- Defer lookup until required
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-30 16:35:10 +03:00
Christopher Covington
bb9f7cffa9 pie: Formatting and typo fixes
Also remove the cast of a pointer-to-void variable to the type
it already is.

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-29 17:58:24 +03:00
Cyrill Gorcunov
f377dade94 proc: Align data in parse_mnt_flags and parse_sb_opt
Make it more readable.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-29 17:57:53 +03:00
Artem Kuzmitskiy
d50cd344d0 Add test for dumping\restoring unnamed unix sockets.
* Added test for dumping\restoring of unnamed unix sockets.
  Also test added to test/Makefile. Use make run for launch.

* Cleanup env after call run.sh in test/libcriu.

Signed-off-by: Artem Kuzmitskiy <artem.kuzmitskiy@lge.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-29 17:53:39 +03:00
Artem Kuzmitskiy
b790b586eb Add restoring of unnamed unix sockets.
Added functionality for restoring unnamed unix sockets
using already implemented feature - inherit fd and using same command line
option.
Usage example:
criu restore -d -D images -o restore.log --pidfile restore.pid -v4 \
     -x --inherit-fd fd[3]:socket:[9677263]

Signed-off-by: Artem Kuzmitskiy <artem.kuzmitskiy@lge.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-29 17:53:36 +03:00
Artem Kuzmitskiy
79fd764ae6 Add dumping of unnamed unix sockets.
* Added functionality for dumping unnamed unix sockets.
  When we call CRIU with dump option, for unnamed socket we
  should pass it inode into --ext-unix-sk. Details about this problem
  described in http://criu.org/External_UNIX_socket#What_to_do_with_socketpair.28.29-s.3F.
  Usage example:
    criu dump -D images -o dump.log -v4 --ext-unix-sk=4529709 -t 13506

* fix typo error in log output

Signed-off-by: Artem Kuzmitskiy <artem.kuzmitskiy@lge.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-29 17:51:51 +03:00
Cyrill Gorcunov
b925971218 test: Add testing of a unix socket with relative name
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-29 17:44:10 +03:00
Cyrill Gorcunov
8788054e33 sk-unix: Add trivial name resolver for sockets with relative names
Unix sockets may be created with non-absolute (relative) path
(when kernel creates one it always use AT_FDCWD for name resolving),
So when we collect sockets we see them as having names without leading
slash.

In common cases for such sockets application doesn't change own
working directory after that but this is not always the true.
So we need to invent some name resolver. The good candidate is
IRMAP cache but after a number of testings I found that it might
slow down performance very dramatically. Thus we need some more
intelligent way here.

For a while, for common applications such as postfix, fetching
dumpee working directory and root is enough. So here what we do

 - when socket get collected from diag interface we remember
   its relative name parameters (device and inode) but postprone
   name resolving to not bring perf penalty until really needed

 - when we meet a socket to dump with relative name assigned we
   try to use $cwd/name and $root/name for this socket to check
   if it has been created in those directories. On success we
   simply remember the directory in image and when restore such
   socket call for chdir helper to change working dir and generate
   relative name

v2:

 - Use new unlink_stale to remove sockets we're to restore
 - Use *at() helpers once we're changed working dir in bind_unix_sk
 - Add more debug ouput

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-29 17:44:08 +03:00
Cyrill Gorcunov
a6543f8d33 sk-unix: Move name handling into separate routine
It gonna be extende to support relative names.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 15:02:53 +03:00
Cyrill Gorcunov
350b8f2107 sk-unix: Defile log prefix
For grepability sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 15:01:53 +03:00
Cyrill Gorcunov
e559f26909 sockets: unix -- Drop redundant empty lines
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 15:01:52 +03:00
Tycho Andersen
83f1f7e588 rst: only restore dgram socket queue once
In the case where there were multiple clients for a dgram socket, we were
restoring the queue for each client. Instead, we should pick one client and
she should restore the queue while the rest skip it.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 13:53:11 +03:00
Tycho Andersen
03c2a0a632 test: add a test for dgram queue error
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 13:53:09 +03:00
Christopher Covington
69d008d567 Use run-time page_size() for mremap
The old and new address parameters passed to the mremap system
call must be page size aligned. On AArch64, the page size can
only be correctly determined at run time. This fixes the following
errors for CRIU on AArch64 kernels with CONFIG_ARM64_64K_PAGES=y.

      call mremap(0x3ffb7d50000, 8192, 8192, MAYMOVE | FIXED, 0x2a000)
  Error (rst-malloc.c:201): Can't mremap rst mem: Invalid argument

      call mremap(0x3ffb7d90000, 8192, 8192, MAYMOVE | FIXED, 0x32000)
  Error (rst-malloc.c:201): Can't mremap rst mem: Invalid argument

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 13:38:30 +03:00
Christopher Covington
b61224bffe Use run-time page_size() in pie_size()
This fixes the following error for CRIU on AArch64 kernels with
CONFIG_ARM64_64K_PAGES=y.

  Error (cr-restore.c:2828): Can't mmap section for restore code

This occurred because the address being requested (0x16000 in
one case) was not page aligned.

Also change the capitalization of the pie_size() macro to make it
clear that the value is not necessarily a build-time constant.

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 13:38:20 +03:00
Cyrill Gorcunov
4ee50534a8 proc: Drop parse_cpuinfo_features helper
We use native cpuid, so this one is no longer used.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 13:37:03 +03:00
Laurent Dufour
ba74350954 ppc64: Add Altivec and VSX support
Add checkpoint and restore of the Altivec and VSX registers.

Currently we rely on the return value of ptrace to detect if the CPU is
supporting these features or not. In the future, we should rely on the
AT_HWCAP vector and check feature at restart time.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 13:35:20 +03:00
Cyrill Gorcunov
3b62aef741 fsnotify: Unify debug print formats
Use hex output for the whole module with proper 0x prefix.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 13:34:26 +03:00
Ruslan Kuprieiev
841f610a21 libcriu: don't include rpc.pb-c.h into criu.h, v2
Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 13:32:51 +03:00
Cyrill Gorcunov
296bbf7e33 x86: Add proper ifdefs into sigframe construction
This will help to support compat mode in the future.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 13:31:55 +03:00
Artem Kuzmitskiy
61a59fdd20 Added support linking libcriu into C++ source
This patch adds capability to using libcriu from C++ code.

Signed-off-by: Artem Kuzmitskiy <artem.kuzmitskiy@lge.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-28 13:30:52 +03:00
Andrey Vagin
ace699d763 travis: add libcap-dev for arm
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-24 18:57:35 +03:00
Andrey Vagin
518405cc04 arm: fix syscall numbers for waitid
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-24 18:22:35 +03:00
Tycho Andersen
5f729636b4 rst: don't hang when SIGCHLD is coalesced
When a TASK_HELPER would exit just before a zombie, sometimes the signal
would get coalesced, and we would miss the zombie exit, causing us to block
forever waiting for the zombie to complete. Let's use an entirely different
strategy for waiting on zombies: explicitly wait on them with waitid, and
use WNOWAIT to prevent their data from actually being reaped.

v2: don't decrement nr_{tasks,threads} in the loop

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-23 15:17:55 +03:00
Tycho Andersen
c91cbe3caa add the waitid syscall
We'll use this in the next patch for collecting the zombies without
actually waiting on them.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-23 15:17:54 +03:00
Tycho Andersen
1de38f344d crit: add a show option for human consumption
This saves some keystrokes and is equivalent to decode --pretty.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-23 15:15:27 +03:00
Andrey Vagin
430a9be90f zdtm: remove busy loops from seccomp_strict
Don't heat a planet! :)

Cc: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-23 15:14:38 +03:00
Cyrill Gorcunov
6c572bee8f cgroup: Set "soft" mode by default
In criu 1.6 if no --manage-cgroups option been specified
we still restore default (known) properties. But in commit
c7d646afb3 we've enhanced its semantics occasionally break
backward compatibility: if no --manage-cgroups passed at all
it's assumed that one asks to not touch cgroups at all on
restore. To restore old behaviour setup "soft" mode by
default.

Reported-by: Andrew Vagin <avagin@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-23 15:14:07 +03:00
Andrey Vagin
cb3c1bb7fe proc: show a string in a error message if we can't parse it
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-23 15:13:17 +03:00
Andrey Vagin
842a196159 travis: add libcap-dev
It's required for zdtm/live/static/different_creds

cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0  -iquote ../../lib/arch/x86/include -I../../lib  -c -o different_creds.o different_creds.c
different_creds.c:7:28: fatal error: sys/capability.h: No such file or directory

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-23 15:12:50 +03:00
Ruslan Kuprieiev
de17028a08 libcriu: criu_init_opts: don't leak on rpc and opts
Reported-by: Andrew Vagin <avagin@gmail.com>
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-21 16:47:25 +03:00
Cyrill Gorcunov
ba68d61f54 files: Adjust file position for /dev/kmsg
The kernel doesnt allow to call lseek on /dev/kmsg
if it has been opened with O_WRONLY mode so our
restore procedure fails.

Thus if we meet a file which fits the condition
above -- set it's position to predefined value
which tells criu to not call lseek on restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-21 16:46:42 +03:00
Andrey Vagin
337c73114f zdtm: add a new test to check escaped charecter in mountinfo
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-21 16:45:43 +03:00
Andrey Vagin
8360d9aa9a tar: use no-unquote and --no-wildcards
to be able to use any symbols in paths

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-21 16:45:33 +03:00
Andrey Vagin
5b767ffd49 mount: decode paths from mountinfo (v2)
mountinfo contains mangled paths. space, tab and back slash were
replaced with usual octal escape, so we need to replace these charecter
back.

v2: declare cure_path as static
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-21 16:44:55 +03:00
Andrey Vagin
34cb65ce5d mount: handle a case when a source argument is empty (v2)
For example:
mount -t tmpfs "" test

v2: don't leak memory

Reported-by: Ross Boucher <boucher@gmail.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-21 16:44:23 +03:00
Ruslan Kuprieiev
18034bb642 libcriu: allow user to specify service fd, v2
Currently, libcriu is connecting to CRIU service
by itself, just asking user for a path to socket.
But in some cases users need to provide fd instead
path. For example, sometimes task has no access to
criu socket because of strict security mesures, but
is able to inherit fd from a parent that has access
to criu socket.

v2, use union for addr and fd

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-16 23:09:43 +03:00
Ruslan Kuprieiev
5551bbb301 test: libcriu: include protobuf dir
We only need a rpc.pb-c.h header.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-16 14:30:02 +03:00
Ruslan Kuprieiev
9e0ff7af4f libcriu: use criu_opts structure to keep all the options
criu_opts contains rpc options and notify callback,
so we can keep all options in just one structure.
This will allow us to easily extend libcriu functionality
and yet keep all options in one place.

We're also not hiding rpc opts structure anymore, so
it is pretty clear where power-user should put his own
CriuOpts instance if he would like to do that.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-16 14:29:47 +03:00
Tycho Andersen
7b20f42f78 rst: move lsm memory allocations before rst_mem_lock()
8ffbe754bd moved the rst_mem_lock() call, but didn't move the
corresponding LSM allocations, so we do that here.

One unfortunate thing is that we have to split this into two steps: first
we have to read the creds to figure out exactly how much memory to
allocate for the lsm string. Since prepare_creds() wants to write directly
to the task_restore_args struct and that can't be allocated until after we
lock the restore memory, we break it up into two steps.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-16 14:26:44 +03:00
Tycho Andersen
3122529fc8 unix: wait for listen() as well as bind()
We need to wait for listen() as well as bind() for internal unix sockets, or we
can race like this:

(00.135950)      1: Opening standalone socket (id 0xb ino 0x9422f peer 0)
(00.135974)    353: Error (sk-unix.c:701): Can't connect 0x947c4 socket: Connection refused
(00.136390)      1: Error (cr-restore.c:1228): 353 exited, status=1
(00.136407)      1:  Putting 0x9422f into listen state

(where 0x9422f is the peer for 0x947c4)

This race was pretty rare for me, but I've run 1000 tests and it didn't
happen so hopefully this patch fixes it :)

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-16 14:25:39 +03:00
Andrey Vagin
445dbd9d09 log: don't forget LF for pr_err()
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-16 14:24:13 +03:00
Cyrill Gorcunov
0162665c8c cgroup: rpc -- Fix @manage_cgroups option parsing
In commit c7d646afb3 we introduced cgroup resotre
modes but when option passed via RPC code it simply
either true or false which erroniously maps to
CG_MODE_PROPS or CG_MODE_IGNORE modes.

Lets map @true to CG_MODE_SOFT to preserve backward
compatibility and enhance this option in future via
separate option.

Reported-by: Ross Boucher <rboucher@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-16 14:23:48 +03:00
Andrey Vagin
de70936ec7 util: don't ignore standard descriptors
It's rudiment. close_old_fds() closes all extra descriptors.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-15 17:36:18 +03:00
Andrey Vagin
686467832f test/pipes: execute two test cases
* reopen a pipe descriptor via /proc/self/fd/X
* give another end of a pipe to "criu restore"

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-15 17:36:11 +03:00
Andrey Vagin
bea8903d38 test/pipes: check that file status flags are restored
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-07-15 17:36:05 +03:00