2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 12:57:57 +00:00

542 Commits

Author SHA1 Message Date
Pavel Emelyanov
84737e2796 build: Generate most of the pb-desc automatically
These contain linkage between number, data type and routines
for pb messages we write/read to/from image files. Most of them
have simple number-type-routines mapping, so introduce a generating
script for that.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-23 21:47:31 +04:00
Pavel Emelyanov
1ac6d76cbd tun: Restore tun files and tun links
This thing is pretty straightforward -- on netns creation
populate it with tun-s, after this collect tun files, open
and attach them with regular fd-s engine.

One tricky thing -- when populating namespace with tun links
make them all persistent and drop this flag (if required)
later, when the first alive opened appears.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-23 19:10:15 +04:00
Pavel Emelyanov
60e6d38868 collect: Shorten common images collecting code
Now we have a set of cinfo-s, it's possible to collect all
this stuff in a plan for-loop.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 03:52:18 +04:00
Andrey Vagin
ef3ca3a104 restore: do not kill processes if not-all of them have been created
If processes are restored without pidns, criu knows pidtheir -s from images,
but part of those task may have not yet forked, and thus the pids can not
exist or (!) be used by other processes.

To address that we abort stages RESTORE_NS and FORKING without killing tasks,
but with task_entries->start futex by writing STATE_FAIL into it and making
the tasks to check that. Since during RESTORE_NS and FORKING stages tasks can
only block on the mentioned futes, we can safely do it.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-20 15:17:30 +04:00
Andrey Vagin
f824d8c3e9 restore: remove restore_one_fake, which duplicates the code
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-16 18:55:26 +04:00
Pavel Emelyanov
01f113ecd3 rst: Remove threads restore serialization
This thing was introduced by 01f8f8f4 to help not mixing
per-thread error messages in log files. Now messages are
not mixed by other means, so this thing is useless.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-12 09:17:02 +04:00
Pavel Emelyanov
0a6da43db9 rst: Check core near the place read it from image
Doing it several steps further is less clean.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-12 09:04:56 +04:00
Pavel Emelyanov
e0b8f91493 rst: Make clean error path for root task restore
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-12 06:33:21 +04:00
Pavel Emelyanov
44a85ee08d rst: Switch-and-wait creds restore stage with existing helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-12 06:23:11 +04:00
Pavel Emelyanov
e5534e8e3a rstore: Invert switch_restore_stage logic
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>
2013-08-12 06:17:04 +04:00
Pavel Emelyanov
9b45833b81 stats: Account total time to restore
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-11 21:25:42 +04:00
Pavel Emelyanov
2df39a4b47 stats: Account for time to fork tasks on restore
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-11 21:22:40 +04:00
Pavel Emelyanov
ebd826c97b rst: Reuse vma_list.priv_size for premapped area size calculation
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-11 20:46:00 +04:00
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