Commit graph

6532 commits

Author SHA1 Message Date
Andrew Vagin
5cfd96c46f restore: add missing break-s
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:16 +03:00
Dmitry Safonov
b3283a6996 pie/util-vdso: split parse_elf_symbols from vdso_fill_symtable
Impact: no functional changes, cleanup.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:15 +03:00
Dmitry Safonov
69b163ebdb pie/util-vdso: split parse_elf_dynamic from vdso_fill_symtable
Impact: no functional changes, cleanup.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:15 +03:00
Dmitry Safonov
9eb043b44a pie/util-vdso: split parse_elf_phdr from vdso_fill_symtable
Impact: no functional changes, cleanup

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:15 +03:00
Dmitry Safonov
4c69339cd2 string.h/pie: use builtin strncmp instead of strcmp
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:15 +03:00
Dmitry Safonov
86cc00fb5f pie/util-vdso: check elf structure end oob
Add checks that structure end is inside memory area [mem, mem + size]
before dereferencing structures.
Otherwise, for example, vdso_fill_symtable will try to dereference
ehdr members even with vma size 0.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:15 +03:00
Dmitry Safonov
7ec96efe3c pie/vdso: convert (char *mem) to (uintptr_t mem)
Impact: drop additional casts all around. Cleanup.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:15 +03:00
Dmitry Safonov
3bf85ce939 pie/util-vdso: separate has_elf_identity
Impact: refactor

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:15 +03:00
Dmitry Safonov
f7f1c24073 pie/util-vdso: down with UB in __ptr_oob
As I am here to fix some things, I would like to remove UB-based
pointer compare (6.5.8.5). We have -fno-strict-aliasing in pie
CFLAGS, but it even looks nicer and more readable with uintptr_t.

Impact: refactoring

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:15 +03:00
Dmitry Safonov
46d197eb94 pie: make util-vdso a little less 64-specific
Add Elf32 types and wrap them with Elf64 into some more generic types.
This is for parsing vDSO from image file.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:15 +03:00
Pavel Emelyanov
a356a2fd87 tcp: Get TCP_INFO once per socket
Right now we get SOL_TCP.TCP_INFO option twice, but one time
is enough.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:15 +03:00
Pavel Emelyanov
e34fcc70ba tcp: Move refresh routine into dump one
This is prerequisite for the next patch and, actually, for the libsoccr :)

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:15 +03:00
Dmitry Safonov
35f209ff76 fault: add dump pages fault for parasite_dump_pages_seized
Parasite should cleanup after fauilure and remove read-protection
from VMAs. Check it with maps00 test & fault injection.

Tested on travis with some addition:
python test/zdtm.py run -t zdtm/static/maps00 --fault 3 --keep-going --report report -f h || false
https://travis-ci.org/0x7f454c46/criu/jobs/119252291

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:15 +03:00
Pavel Emelyanov
058808007b pstree: Move the ids reading into separate function
It's just a cleanup to get rid of in-function {<code>} block.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:14 +03:00
Pavel Emelyanov
070d420be6 test: Check nomemfd parasite injection
By default criu tries to create parasite mem with memfd syscall,
which is present in many systems. Let's check also the legacy way.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:14 +03:00
Pavel Emelyanov
5c17b30236 zdtm: Nicer flavs removal
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:14 +03:00
Pavel Emelyanov
362784f032 pipe/fifo: Collect data via cinfo engine
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:14 +03:00
Pavel Emelyanov
f674cbd60f unix: Collect packets via cinfo engine
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:14 +03:00
Pavel Emelyanov
508cb93374 collect: Add img argument to cinfo
The plan is to allow ->collect callbacks to read more
stuff from image files.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:14 +03:00
Pavel Emelyanov
347d670f29 tty: Setup tty slavery via post_cb engine
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:14 +03:00
Pavel Emelyanov
92eb5ff594 pipe: Run master resolve via post_cb engine
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:14 +03:00
Pavel Emelyanov
3b288ca392 unix: Run peer resolving via post_cb engine
With autofs patches we've merged a small engine that allows
to queue random routine for post-prepare execution. Re-use
this for unix sockets' interconneting routine.

Also this is a tiny optimization -- when we don't have unix
sockets to interconnect we don't make extra list walk.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:14 +03:00
Pavel Emelyanov
46408840a4 rst: Mark post_prepare_cbs static
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:14 +03:00
Tycho Andersen
03e13d475d restore: zombies should collect their children
Consider when there is a double fork of helpers or zombies, e.g. when a
zombie has a session id which doesn't match its pid. If the child dies and
exits before the grandchild, the grandchild reparents to init, and when the
task dies init doesn't have it in the helper list, so init dies as well,
viz. the log below.

(00.118789) Add a helper 293 for restoring SID 293
(00.118792) Attach 294 to the temporary task 293
...
(01.394403)    294: Restoring zombie with 0 code
...
pie: Task 294  exited, status= 0
(01.434279) Error (cr-restore.c:1308): 12097 killed by signal 19
(01.434420) Error (cr-restore.c:1308): 12097 killed by signal 19
(01.450258) Switching to new ns to clean ghosts
(01.450324) Error (cr-restore.c:2138): Restoring FAILED.

Let's have the helpers reap their children before they exit to avoid this.

v2: block SIGCHLD when waiting on helpers so that it doesn't race with the
    SICGHLD handler
v3: * only helpers should collect their children, zombies can't have kids
    * don't double decrement nr_tasks in zombie case

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:10:14 +03:00
Pavel Emelyanov
a6c6ec89ad Remove bogus add_ns_shared_cb extern declaration
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:01:55 +03:00
Mike Rapoport
366c9131ff autofs: fix build on Fedora 22
The following error happens when building CRIU on Fedora 22:

  CC       autofs.o
autofs.c: In function ‘autofs_mount’:
autofs.c:892:9: error: implicit declaration of function ‘add_post_prepare_cb’ [-Werror=implicit-function-declaration]
   ret = add_post_prepare_cb(autofs_add_mount_info, mi);
         ^
cc1: all warnings being treated as errors

Adding forward declaration of add_post_prepare_cb resolves the issue.

Signed-off-by: Mike Rapoport <rapoport@il.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:01:53 +03:00
Stanislav Kinsburskiy
d6b97ad536 cr-restore: move add_ns_shared_cb declaration to include/namespaces.h
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:01:41 +03:00
Stanislav Kinsburskiy
7d7373a429 cr-restore: new list of ns shared objects introduced
Autofs restore needs to create some shared data structures to be able to pass
data to actual autofs master.
But on mount restore stage shared data is not configured yet.
This list of objects and their actors is processed after all mounts and shared
data are restored to let autofs to create the objects.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-04 17:01:10 +03:00
Tycho Andersen
84a89b46ad restore: correctly restore cgroup mounts inside a container
Before the nsroot= mount option, we were just getting lucky because the
cgroup superblocks "matched" when inspecting them from userspace, so we
were actually getting a bind mount from the host when migrating from within
cgroup namespaces.

Instead, let's actually do a new (i.e. not a bind mount) for cgroup
namespaces. For this, we need two things:

1. to prepare the cgroup namespace (and thus the cgroups) before the mount
   ns, so when the mount() occurrs it is relative to the right cgroup path.

2. not reject cgroup filesystems with no root. A cgroup ns mount looks
   like:

	 223 222 0:22 /lxc/unpriv /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd,nsroot=/lxc/unpriv

   i.e. it has /lxc/unpriv as its root, and thus doesn't look rooted to CRIU.
   We use the fstype->parse hook to rewrite this root to /, since it
   is handled by the cgroup ns infrastructure.

v2: add new fstype->munge hook, allowing fstypes to munge their parsed
    mountinfo entries if they want to. this allows us to get rid of the
    ugly hacks with FSTYPE__CGROUP everywhere in teh patch.
v3: s/fstype->munge/fstype->parse for FSTYPE__CGROUP

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:31 +03:00
Dmitry Safonov
870089d1ee Makefile: drop 'rebuild' from help message
The target has been broken for some time without complaints from users.
https://lists.openvz.org/pipermail/criu/2016-March/026525.html

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-04-01 18:06:31 +03:00
Cyrill Gorcunov
6094b643dc nmk: build.mk -- Add @libso-y helper
To link dynamic libs (libcompel for example).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:31 +03:00
Cyrill Gorcunov
4a19618ea2 nmk: build.mk -- Add @hostprogs-y mode
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:30 +03:00
Cyrill Gorcunov
e4e2f19d85 nmk: msg.mk -- Add host- messages
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:30 +03:00
Cyrill Gorcunov
1693e539d5 nmk: build.mk -- Shrink gen-cc-rules
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:30 +03:00
Cyrill Gorcunov
cfc37c119c nmk: build.mk -- Drop any-match rule
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:30 +03:00
Cyrill Gorcunov
cb32e353bb nmk: build.mk -- Fix deps for target mode
Don't forget to call objectify.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:30 +03:00
Cyrill Gorcunov
cd5f7df520 nmk: build.mk -- Squash gen-rule-x into gen-cc-rules
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:30 +03:00
Cyrill Gorcunov
0d1eac7ed4 nmk: Drop rules.mk
No much point in carrying it in a separate file.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:30 +03:00
Cyrill Gorcunov
580ca3dd68 nmk: rules.mk -- Fix AFLAGS typo
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:30 +03:00
Cyrill Gorcunov
afbc03ee15 tests: remap_dead_pid[_root] -- Run in namespace only
These tests check for file descriptor being assigned
to the pid which is freed already, so check them
in PID namespace only, otherwise the kernel may
give PID someone else and the check from
commit c4cf5f0b76
might trigger and stop testing procedure.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:30 +03:00
Dmitry Safonov
a8fb0b99be log: add gnu-styled output to stdout
Before this would open file named '-' as log:
./criu/criu dump -t 20526 -o -
But now it will print log into stdout. Charming.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:30 +03:00
Andrew Vagin
08ff91d966 jenkins: build a coverage report if GCOV is set (v2)
v2: set umask to 0000. It's required to generate gcda, gcno files
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:29 +03:00
Dmitry Safonov
790957ea33 criu: use strsignal to describe kill reason
Where it's possible to use glibc.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-04-01 18:06:29 +03:00
Andrei Vagin
89ba5489c4 rst-malloc: adjust free_bytes in rst_mem_align_cpos
We need to adjust free_bytes each time when we change free_bytes.

Fixes #140
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-25 23:39:22 +03:00
Sergey Bronnikov
12e85f1572 zdtm.py: updated logic for --keep-going option
- option --keep-going is not mandatory if we run a single testcase
- show warning when we use --keep-going with a custom set of testcases
- ignore --keep-going when we run a custom set of testcase (exit on 1st fail)

Signed-off-by: Sergey Bronnikov <sergeyb@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-25 23:39:22 +03:00
Cyrill Gorcunov
92c0e732d8 build: images -- Add missing cleanups
In commit 9469dae61c we've dropped implicit cleanups as
a pattern but in images dir we use additional custom
rules so simply drop files built.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-25 23:39:22 +03:00
Pavel Emelyanov
bd70812023 zdtm: Add ability to run tests from list
Sometimes when running tests manually it's tempting to
prepare the list of tests to run in advance and then
run only those. E.g. -- when testing a new feature
that affects only _some_ tests. This option allows it.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-25 23:39:22 +03:00
Cyrill Gorcunov
06cc12a275 nmk: build.mk -- Fix ar rule for external libs
A typo.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-25 23:39:22 +03:00
Cyrill Gorcunov
8994edebe1 nmk: build.mk -- Make process depend on Makefile itself
If makefile is changed itself we've been not detecting it.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-25 23:39:22 +03:00
Tycho Andersen
10eaabd175 namespaces: zero struct ns_id when allocating
Later (find_ext_ns_id, but probably others as well) we depend on the struct
being zeroed in order to figure out whether or not to collect info about
it. Let's make sure it is actually zeroed.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-03-25 23:39:22 +03:00