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

6308 Commits

Author SHA1 Message Date
Andrew Vagin
e25c625131 util: call va_end() after va_copy() (v2)
CID 157804 (#1 of 1): Missing varargs init or cleanup (VARARGS)
16. missing_va_end: va_end was not called for tmp.

v2: typo fix

Reported-by: Mr Coverity
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-06 20:47:11 +03:00
Andrew Vagin
ced5eeeee3 crtools: terminate the case for value 1071
CID 157800 (#1 of 1): Missing break in switch (MISSING_BREAK)
unterminated_case: The case for value 1071 is not terminated by a 'break' statement.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-06 20:46:51 +03:00
Andrew Vagin
672f97ad4a vdso: don't call close() for a negative value
CID 157801 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
19. negative_returns: fd is passed to a parameter that cannot be negative.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-06 20:46:51 +03:00
Andrei Vagin
a28c4a9979 test: add --force-irmap for static/inotify_irmap
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-06 20:44:53 +03:00
Laurent Dufour
8ceab588a5 crtools: no more linked with builtin syscall
crtools binary is linked with the C library and could rely on all the
services this library is providing, including system calls.

Thus it doesn't need to be linked with the builtin system calls code
made for the parasite/restorer binaries.

This patch does:
 - remove the inclusion of syscall.h
 - replace all call to sys_<syscall>() by C library <syscall>()
 - replace unwrapped system calls by syscall(SYS_<syscall>,...)
 - fix the generated compiler's issues.

There should not be any functional changes. The only 'code' changes is
appearing in locks.h when futex is called through the C library, the
errno value is fetched from errno variable instead of the return
value.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-06 20:42:03 +03:00
Laurent Dufour
34faa89bcf namespace: move definition of CLONE_SUBNS
The CRIU internal define of CLONE_SUBNS should not be put in
syscall-types.h since this define is not part of a system call.

This move is required to prepare the removal of syscall.h from the
component of crtools binary.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-06 20:42:01 +03:00
Laurent Dufour
62194b1548 build: conditional define of struct prctl_mm_map
The file include/prctl.h should define the struct prctl_mm_map only if
it is not already defined in the system include file linux/prctl.h.

The definition should be part of the '#ifndef PR_SET_MM_MAP' block
since this structure is not defined in that case.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-06 20:41:59 +03:00
Cyrill Gorcunov
e9aed2ed38 plugin: Add PRE_DUMP stage into plugins
It is missged in first place and may cause
problem on exiting via alarm hanling.

Reported-by: Igor Sukhih <igor@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-05 13:24:11 +03:00
Tycho Andersen
7fc8ecc5e1 tests: remember to clean up in some failure cases of cgroup01
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-05 12:38:50 +03:00
Andrew Vagin
e68008a80a zdtm_ct: don't create a new session
All processes should exit if an user presses ctrl-c.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-05 12:38:14 +03:00
Kirill Tkhai
fe078a0f52 zdtm: Disable unlink_regular00 by default
Skip it till remap-links are supported.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-05 12:37:25 +03:00
Kirill Tkhai
afe361f053 zdtm: Add unlink_regular00 test
Test checks that a deleted file content in a deleted parent directory
restores right. Initially directory is created in a separate mount,
to check the ghost file is created in right mount and link() in
rfi_remap() is working.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-03 16:27:49 +03:00
Kirill Tkhai
e62f1aea52 files-reg: Recreate deleted parent directories during restore of ghost file
This patch makes ghost files to restore with the right path.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-03 16:27:48 +03:00
Kirill Tkhai
6345b6aa6a files-reg: Create ghost files in first existing parent directory
Since a deleted file may belong to a deleted directory
(which, in turn, may belong to another deleted, etc),
it's necessary to recreate all missing dentries in the path.

Doing this in mkreg_ghost() is not a good idea, because
another ghost file may need some of the dentries in the path,
and this requires to do refcouting of recreated directories.

To avoid this, we restore a ghost file in the first existing
parent directory of the patch. This guarantees, the ghost file
will be in the same mount with target file (rfi_remap() needs
that, because it uses link()).

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-03 16:27:47 +03:00
Laurent Dufour
685953e484 test/arm: Fix building on armv7l architecture
The issue here is that ARCH is not overwritten if the caller Makefile
already define it, and the upper Makefile is not overwriting the ARCH
define to "arm", when it is "armv7l" for instance, so the SRCARCH is
set to "armv7l" which is wrong.

With this patch, SRCARCH is using the inherinted define if called from
the top level Makefile.

This is required to build test on armv7l architecture (qemu).

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-03 16:26:05 +03:00
Tycho Andersen
ca7841601e tests: prevent zdtm_mount_cgroups from failing w/ EBUSY
Sometimes I get:

sudo ./zdtm.py run -t zdtm/live/static/cgroup03
umount: /home/tycho/packages/criu/test/zdtm.qPwsoO: target is busy
        (In some cases useful info about processes that
         use the device is found by lsof(8) or fuser(1).)
Traceback (most recent call last):
  File "./zdtm.py", line 1401, in <module>
    tst.available()
  File "./zdtm.py", line 435, in available
    subprocess.check_call(["flock", "zdtm_mount_cgroups", "./zdtm_mount_cgroups"])
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['flock', 'zdtm_mount_cgroups', './zdtm_mount_cgroups']' returned non-zero exit status 1

let's use a lazy unmount so we avoid this.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-03 16:25:28 +03:00
Tycho Andersen
ee2b893969 cgroup: drop cgroup.sane_behavior from global properties
cgroup.sane_behavior is read only (and in fact, the value is always 0), so
we don't need to c/r this value.

Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-03 16:25:15 +03:00
Pavel Tikhomirov
33adc6d7c1 mount: separate private remount conditions for external and non-external
We have two separate cases 1) mount is external - has mi->external set,
2) mount is internal - mi->external == 0. For those two cases we need
separate decesions on making moutn private.

In both cases we need private remount if:
a)mount does not have master_id and shared_id
or
b)if mount has different shared_id from bind source.

But do not private remount if has master_id or it will be lost. As after
setting private the mount is alone in its shared group so setting master
will silently fail as kernel can not find any for our mount.
(see do_make_slave)

https://jira.sw.ru/browse/PSBM-42829

v2: rework patches 2/4 and 4/4 together and no need then in 3/4
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-03 15:57:51 +03:00
Stanislav Kinsburskiy
2f70a79eac pipes: move struct pipe_info declaration to pipes.h
AutoFS will need to create write pipe end file descriptor, if it was closed.
Thus, pipe_info structure have to be exported.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 17:32:19 +03:00
Stanislav Kinsburskiy
cae94b76f1 cr-restore: restore root sid before mount namespace
This is a precursor patch for AutoFS mount restore.
To restore AutoFS indirect mount points, we have to create mount point dentries.
This can do only the process with pgrp, configured to mount. Process, which
does AutoFS mount call (init) at that moment is not.
Restoring actual pgrp before sid breaks sid restoring.
Thus, restoring of sid is required to make process group leader.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 17:29:17 +03:00
Kirill Tkhai
5ff22ad29b files-reg: Move applying ghost file metadata from create_ghost() to separate function
This cleanup makes create_ghost() smaller.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:58:16 +03:00
Kirill Tkhai
dbb9d5ebd7 files-reg: Make try_clean_ghost() use struct ghost_file ptr
This cleanup will be used in next patch.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:51:50 +03:00
Kirill Tkhai
78a0f8db3f files-reg: Refactor create_ghost()
In the most cases, file descriptor is not need in this function.
It's need in the case of creating a regular file only. So we can
use chown() instead of fchown(), and operate with a path directly.

The patch moves copying content of a regular file to new function
mkreg_ghost(). This will be used in next patches. Also, parameter
gf will be used.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:50:47 +03:00
Cyrill Gorcunov
da7f3ffc73 cg: Add debug printing on subset mismatch
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:49:37 +03:00
Tycho Andersen
ffcdeb7d0a docs: add a note about the default mode
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:45:32 +03:00
Tycho Andersen
c30c6e38fe tests: add a test for cgroup perms/global props
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:45:30 +03:00
Tycho Andersen
c6e5e33414 cgroups: restore perms on tasks and cgroup.procs files
Although we don't want to restore the values on these files, we definitely
do want to restore the permissions, as certain container engines (lxc) make
use of this.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:45:27 +03:00
Tycho Andersen
fa433b7552 cgroup: restore perms on cgroup dirs as well
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:45:24 +03:00
Tycho Andersen
142f2c8e1c cgroup: dump some global properties as well
These are present in every cgroup, so let's dump them.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:45:22 +03:00
Tycho Andersen
cbe8ef4fe7 cgroup: restore cgroup property perms as well
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:45:20 +03:00
Andrew Vagin
3c18439ebd dump: save master_id for the root mount
The root mount is always external and master_id is external too.
It's required to validate mounts. We already do this on restore,
but we need to do this on dump too. Otherwise we will get the error:

Mount %d %s (master_id: %d shared_id: %d) has unreachable sharing. Try --enable-external-masters.

https://jira.sw.ru/browse/PSBM-43260
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:42:46 +03:00
Andrew Vagin
c37324b6d0 crtools: describe the inherit-fd option
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:38:40 +03:00
Cyrill Gorcunov
79f430ba75 parasite: Don't left memfd opened inside dumpee
If for some reason ptrace_poke_area return error
we might left dumpee with memfd descriptor opened.

Later in code we remove out injected blob making
dumpee to look untouched but descriptor will hang there.

lsof from container output:

 | systemd-u   48       root    6u      REG                0,4        0  53855 /memfd:CRIUMFD (deleted)

Thus lets close it immediately.

https://jira.sw.ru/browse/PSBM-43199

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:35:40 +03:00
Pavel Emelyanov
e46594ae3e mount: Sanitize mounts_equal helper
* Split into two -- full/sb comparisons
* Code formatting (spaces)
* Arg names

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:34:31 +03:00
Pavel Emelyanov
70c3c92874 mount: Rework bool insert_roots argument
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:34:17 +03:00
Pavel Emelyanov
5ff440924b files: Remove unused args from dump_dead_process_remap
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-27 16:34:07 +03:00
Tycho Andersen
5dc64eb61f gitignore: ignore some more generated testcases
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-21 16:14:26 +03:00
Andrew Vagin
101775b158 seize: remove extra \n from the error message
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-21 16:12:50 +03:00
Andrew Vagin
4429a4c914 seize: don't detach from a task if a freezer cgroup is set
criu detaches from tasks in freezer_detach() in this case

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-21 16:12:48 +03:00
Andrew Vagin
15c9eb220e seize: detach from all processes before waiting the root task
We need to detach from all processes before waiting the root
task, because one of these processes may collect processes from a
target pid namespace. The pid namespace is destroyed only when all
processes have been killed and collected.

https://jira.sw.ru/browse/PSBM-43089
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-21 16:12:44 +03:00
Kirill Tkhai
2f80e54cd9 zdtm: Add suid flag to binfmt_misc test
This fixes the following test error:

    FAIL: binfmt_misc.c:111: mount failed (errno = 1 (Operation not permitted))

CRIU tests (./test/zdtm.py run -a) passed.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-20 15:33:25 +03:00
Pavel Emelyanov
a85aeb7fd0 ns: Remove __rst_new_ns_id
There's only one user of it, so better to reshuffle the arg set.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-20 11:11:06 +03:00
Pavel Emelyanov
b8a9122d89 fds: Remove unused arg from close_old_fds()
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-20 11:10:29 +03:00
Tycho Andersen
0420e09908 tmpfs: don't try to dump mountpoint at 0 fd
If we happen to get 0 as the fd for the mountpoint, there is an error:

(00.280617) Dumping task cwd id 0x2b root id 0x2b
(00.280697) mnt: Dumping mountpoints
(00.280702) mnt:        132: 34:/ @ ./run/lock
(00.280714) mnt: Path `/run/lock' resolved to `./run/lock' mountpoint
tar: /proc/self/fd/0: Cannot open: Not a directory
tar: Error is not recoverable: exiting now
(00.283581) Error (util.c:666): exited, status=2
(00.283598) Error (mount.c:1220): mnt: Can't dump tmpfs content

Instead, let's not ever use 0 as the mountpoint fd.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-20 11:09:30 +03:00
Igor Sukhih
eec66f3d30 criu [PATCH] post-setup-namespaces
Introduce post-setup-namespaces action script

It needed to have possibility to run cutom script after mount
namespace is configured

Signed-off-by: Igor Sukhih <igor@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-20 11:08:22 +03:00
Andrew Vagin
ef8d4cf285 service: add support for the --external option
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-20 11:07:31 +03:00
Tycho Andersen
751a4982a9 dump: add some stray newlines to pr_infos
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-20 11:06:01 +03:00
Kirill Tkhai
25b88d10d9 binfmt_misc: Make debug printed using pr_debug()
It's a debug message, and it shouldn't be printed with
pr_perror(). Also, we interested in debug in the both
cases: magic and extensions.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-20 11:05:09 +03:00
Kirill Tkhai
bd27328b7d zdtm: Add binfmt_misc test
Generate random binfmt_misc entries of different types
and check that they remain registered after the signal.

v2: pr_perror() in cleanup, .desc file and TST_DIR in Makefile

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-20 11:04:47 +03:00
Laurent Dufour
ef074d3ff4 ppc64: introduce CPU feature checking operations
This patch introduces basic CPU feature checking for PowerPC.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-01-18 21:11:36 +03:00