Currentl it waits for previous stage to complete and starts the
next one. Now it starts the next one and waits for it to complete.
The latter way fits better into both -- the code and the head.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
On restore we compare pages' contents with memcmp to check which
of them can remain shared. Report this info in restore stats.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Restore stats are difficult -- we have to collect them from several
tasks and thus existing plain variables would not work. We'll need
shared memory with stats, so prepre for allocating one.
Other than this -- put call to write_stats() where appropriate for
restore.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
We have already tried to prevent generating core files for zombies:
commit 6da52216ce8e47fed0ded1c5a451968ef7c177a2
Author: Andrey Vagin <avagin@openvz.org>
Date: Fri Jul 12 18:14:23 2013 +0400
restore: set the zero limit for RLIMIT_CORE
But it doesn't work if a core file is sent into a pipe.
This functionality is used by the abrt daemon for example.
This patch uses more direct way, it unsets the dumpable flag with help
of PR_SET_DUMPABLE.
v2: remove the previous hack
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Window probe is sent during disabling repair mode on a socket, so
network must be unlocked in this moment.
https://bugzilla.openvz.org/show_bug.cgi?id=2670
v2: don't fail after unlocking network
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This should be done to prevent generating core files, if a process was
killed by SIGSEGV, SIGBUS, etc
https://bugzilla.openvz.org/show_bug.cgi?id=2655
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Otherwise we lost 1:1 mapping between names being
dumped and what user sees after restore.
| 1455 pts/0 T 0:00 \_ ./crtools restore -t 1448
| 1448 ? Ss 0:00 | \_ ./zombie00 --pidfile=zombie00.pid --outfile=zombie00.out
| 1449 ? Z 0:00 | \_ [zombie00] <defunct>
| 1450 ? Z 0:00 | \_ [zombie00] <defunct>
| 1451 ? Z 0:00 | \_ [zombie00] <defunct>
| 1452 ? Z 0:00 | \_ [zombie00] <defunct>
https://bugzilla.openvz.org/show_bug.cgi?id=2635
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Number of rlimits may vary depending on system version
criu is compiled against. So we use rst-allocator to
carry all limits read from file.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The memory in question is allocated and then remaped into
restorer with one call to mremap. Thus, to use the mem we
need to provide to users API for
* alloc memory
* get current allocation pointer
* convert current pointer into remapped one
* the remap itself
This would help combinding lots of small allocations such
as tcp sockets to unrepair, siginfos and posix timers.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This also add function to check if time represented by two numbers is
valid. I.e. for timespec(sec, nsec), sec and nsec must be > 0 and nsec
must be less when NSEC_PER_SEC.
Signed-off-by: Pavel Tikhomirov <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
After creating namespaces we may need to apply some configuration.
For example uid and gid maps should be applied in this moment.
This script should be executed from crtools, but namespaces are created
in a root process, so we need to add a new stage for synchronizing.
v2: use a separate stage instead of socketpair.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Before this patch sigframes were constructed in restorer. We are going
to construct sigframes for parasites. Both parasite and restorer should
be as thing as posible.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
struct thread_restore_args contains many pointers on different objects,
only a few of them are really required.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Runtime vdso need to be kept in some safe place when all
self-vmas are unmapped. So we reserve space for it in restorer
blob area and then remap it into. It's quite important to do
a remap here rather than data copy because otherwise pfn
of vdso disappear and in future we won't be able to detect
vdso are on dumping stage.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
During criu startup we need to fill symbol table of own
run-time vdso provided by the kernel. We will need this
data for vdso proxy.
Because this functions are not used in restorer code,
we move them out of PIE (since PIE code must remain
as small as possible).
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
When a kernel didn't show vma flags, we set MAP_GROWSDOWN for stack
vmas, but it's not reliable. E.g. thread stacks are mapped without
MAP_GROWSDOWN.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Based on work done by Cyrill Corcunov (many thanks for that).
In this commit we implement c/r for files which have opened
/proc/$pid/ns/$ids entries.
The idea is rather simple one
Checkpoint
==========
- Check if the file name is the one of known to be ns ref
- If match then write protobuf entry
Restore
=======
- Read all ns entries from the image
- When criu tries to open one we lookup over process
tree to figure out which PID should be used in path
and then just open it
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>