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

679 Commits

Author SHA1 Message Date
Pavel Emelyanov
4c8e1c9927 rst: Close vmas image earlier
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-11 20:42:55 +04:00
Pavel Emelyanov
e93566c791 rst: Write comment about why we need two calls to restore_pgid
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-11 20:23:18 +04:00
Pavel Emelyanov
4c83c432d6 rst: Minor formatting fix
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-11 20:16:24 +04:00
Pavel Emelyanov
ede980c077 restore: Move kids (and session) restore into a helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-11 20:15:43 +04:00
Pavel Emelyanov
26aa61a344 rst: Rename read_vmas into prepare_vmas
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-11 20:10:44 +04:00
Pavel Emelyanov
e2a0258de3 util: Use open_detahc_mount helper for proc service fd creation
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-11 20:00:28 +04:00
Andrey Vagin
1f9da83048 mm: do check on shared pages only if a vma is inherited (v2)
v2: restore page contents directly into memory
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-14 11:18:48 +04:00
Pavel Emelyanov
e99576f655 rst: Collect stats about checked-vs-cowed pages
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>
2013-08-11 13:36:24 +04:00
Pavel Emelyanov
6ac4870181 stats: Prepare for collecting restore stats
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>
2013-08-11 13:00:45 +04:00
Andrew Vagin
53aae95796 restore: unset dumpable flag for zombies (v2)
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>
2013-08-07 13:51:35 +04:00
Pavel Emelyanov
7405f88c8f rst: Add some comments to VMAs inheritance procedure
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-25 18:29:03 +04:00
Pavel Emelyanov
fa66d9267f rst: Rename parent vmas list variable to reflect what it is
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-25 18:25:51 +04:00
Andrey Vagin
81e11b44de restore: unlock network before disabling repair mode on sockets (v2)
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>
2013-07-15 18:47:41 +04:00
Andrey Vagin
64c37b72ff restore: add __restore_switch_stage, which just switches stages
It never returns errors.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-15 18:47:32 +04:00
Andrey Vagin
6da52216ce restore: set the zero limit for RLIMIT_CORE
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>
2013-07-12 18:14:23 +04:00
Cyrill Gorcunov
a18f28d61e restore: Set up zombie name on restore
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>
2013-07-12 18:12:12 +04:00
Pavel Emelyanov
34f4e2d05c rst: Compile fix for rst mem API usage in rlims
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-09 13:48:59 +04:00
Cyrill Gorcunov
73a8b996c5 restorer: Use rst memory allocator for rlimits restore
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>
2013-07-09 00:21:31 +04:00
Pavel Emelyanov
bd58fce18f core: Sanitize check_core return evaluation
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-08 19:10:11 +04:00
Pavel Emelyanov
1133ed73bd rst: Create rst-mem pages _after_ local smaps parse
This memory is unmapped by handr, so no need in polluting
self-smaps with it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-05 16:39:43 +04:00
Pavel Emelyanov
402707107f rst: Simplify before/after remap API
Actually after remap the rst-mem is still visible in the crtools,
although at another address.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-05 16:27:03 +04:00
Pavel Emelyanov
2652962bd4 rst: Unmap restorer dyn-args memory at the end
Reported-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-05 16:22:51 +04:00
Pavel Emelyanov
79dfbe6cc2 tcp: Switch to use rst memory allocator on repair off
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-05 15:04:57 +04:00
Pavel Emelyanov
e458d20c4d siginfos: Switch to use rst memory allocator
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-05 15:02:46 +04:00
Pavel Emelyanov
4171d5bf58 posix-timers: Switch to use rst memory allocator
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-05 15:00:08 +04:00
Pavel Emelyanov
df51773b06 rst: Introduce memory allocator for rst blob
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>
2013-07-05 14:56:45 +04:00
Pavel Emelyanov
2030f2dfb1 timers: Unmap posix timers info mem after restoring them
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-01 20:11:22 +04:00
Pavel Tikhomirov
5c8db84fa2 posix-timer: Add reading image and put it to shared memory
Signed-off-by: Pavel Tikhomirov <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-01 16:19:32 +04:00
Pavel Tikhomirov
2940109a24 posix-timer: Restore and fix one timer
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>
2013-07-01 16:19:31 +04:00
Pavel Tikhomirov
2f98253c26 posix-timer: Add protobuf message and rename to protobuf/timer.proto
Signed-off-by: Pavel Tikhomirov <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-01 16:19:23 +04:00
Andrey Vagin
de71bc6917 restore: add action scripts setup-namespaces (v2)
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>
2013-05-31 19:01:31 +04:00
Pavel Emelyanov
6bf22f8c75 crtools: Get rid of on-stack cr_options
We have global instance of them, that's enough.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-28 21:11:13 +04:00
Andrey Vagin
22396f7690 restore: construct sigframe in crtools
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>
2013-05-24 17:39:52 +04:00
Andrey Vagin
5978380bef restore: use a concrete object for constructing sigframe
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>
2013-05-24 17:32:47 +04:00
Cyrill Gorcunov
b051c66fb6 vdso: Remap runtime vdso copy to safe place
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>
2013-05-24 13:27:16 +04:00
Cyrill Gorcunov
e44b3dbe84 vdso: Initialize vdso data on startup
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>
2013-05-24 13:27:15 +04:00
Andrey Vagin
653053b40c proc: use vma flags for determing vmas with MAP_GROWSDOWN
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>
2013-05-21 19:03:57 +04:00
Pavel Emelyanov
ec50a07727 ns: Add c/r for /proc/$pid/ns/$ids references
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>
2013-05-18 04:00:05 +04:00
Pavel Emelyanov
e75148dc03 util: Move user-per-sec constant into util.h header
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 13:50:09 +04:00
Kir Kolyshkin
3e8b82d367 Change crtools to criu in comments
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-10 11:02:27 +04:00
Kir Kolyshkin
c19e62f87c Change crtools to criu in criu messages
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-10 11:02:20 +04:00
Kir Kolyshkin
00ab805b74 cr-restore.c: fix a typo in a comment
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-10 11:02:08 +04:00
Kir Kolyshkin
43ce038e6e criu dump: don't require -t
and warn if it is used.

v2: fix help text as well

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-08 13:41:42 +04:00
Cyrill Gorcunov
921dbf23de Don't use \Newline in pr_perror
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-02 22:44:24 +04:00
Andrey Vagin
15b64d12ca restore: use a correct object core for restoring fpu
tcore (per thread core) should be used here

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-29 18:40:39 +04:00
Andrey Vagin
ae729638ef restore: fix restoring signal blocking mask on arm
RT_SIGFRAME_UC(sigframe).uc_sigmask.sig = args->blk_sigset;

blk_sigset is u64, but uc_sigmask.sig has type ulong [2], so
only a part of mask is restore here.

This patch reworks restoring of blocking masks symmetrically to dumping
these masks.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Tested-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-29 16:36:04 +04:00
Andrey Vagin
a724acf571 restore: handle errors of setting credentials (v2)
v2: handle errors from setXids and securebits manipulations
    handle errors of restoring creds after finishing CR_STATE_RESTORE_CREDS,
    because a sigchild handler is already restored in this moment.
    Only the current process is killed in a error case.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-29 16:32:24 +04:00
Andrey Vagin
a34057c192 restore: add a synchronisation point after restoring credentials
For security reason processes can be resumed only when all
credentials are restored. Otherwise someone can attach to a
process, which are not restored credentials yet and execute
some code.

https://bugzilla.openvz.org/show_bug.cgi?id=2561

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-19 15:58:50 +04:00
Kir Kolyshkin
41c7ca8218 Fix typos in comments
This is less useful than fixing typos in output messages, but anyway.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 12:46:46 +04:00
Kir Kolyshkin
d90d4b1b88 Fix typos in log messages
Someone has to do it, right?..

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 12:46:25 +04:00