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

446 Commits

Author SHA1 Message Date
Andrew Vagin
a2eaa5cf44 ptrace: the task state is restored automatically
It's a feature of PTRACE_SEIZE.  So we need to do something, only
if we want to change the state.

[xemul: If task _was_ in stopped state before dump and we want them
 to stay alive after dump, the existing code queues one more STOP
 to it. This affects subsequent dump, as we seize a stopped task
 with STOP in queue.

 One more item in TODO list -- support stopped tasks with STOP in
 queue :)
]

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 20:36:12 +04:00
Andrey Vagin
800c4d09bb seize: add more detailed comment
Why we do several attempts to freeze tasks.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 16:41:14 +04:00
Andrey Vagin
bf67879062 crtools: rework freeze of processes (v2)
Before this patch crtools freezes processes and if something is changed,
it unfreezes all processes and starts again from the beginning.

If if are going to dump fork-bomb, this method doesn't work. Because a
big tree is always changed.

We don't need unfreeze processes, which have been frozen and this patch
does that.

This patch uses depth-first search (DFS) for traversing a process tree.

A root task is frozen at first turn, than a child is frozen, than a
child of child and so on.

When all children of one process are frozen, criu reads the list of
children again and check that nothing changed. This processes continues
until all of them will not be frozen. Afte that a new child can not be
appeared, because all children for children are frozen too.

v2: add comments in code
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:16:11 +04:00
Andrey Vagin
978badc196 dump: rework freeze of threads
When we try to freeze threads, some of them can exit
and a few new ones can be born. Currently we unfreeze process free
int this case, so we have the same chance to failed in the next case.

I suggest to not unfreeze frozen threads, just try to update thread list
and freeze unfrozen threads.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:16:10 +04:00
Pavel Emelyanov
a37cf7a407 seize: Add some comments about unseizing task
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-19 22:48:55 +04:00
Andrey Vagin
9cec289f74 dump: restore state correctly
Currently all task are restored as alive, but stopped tasks
must be restored as stopped.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-19 22:47:45 +04:00
Andrey Vagin
625ad48dfd dump: don't restore a state of threads
It is not needed, because stat is a property of task,
so we can restore a state of task and it should be enough.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-19 22:47:43 +04:00
Andrey Vagin
d7cf271ed4 crtools: preload libraries (v2)
Libraries (plugins) is going to be used for dumping and restoring
external dependencies (e.g. dbus, systemd journal sockets, charecter
devices, etc)

A plugin can have the cr_plugin_init() and cr_plugin_fini functions for
initialization and deinialization.

criu-plugin.h contains all things, which can be used in plugins.

v2: rename lib to plugin
v3: add a default value for a plugin path.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-19 21:48:33 +04:00
Pavel Emelyanov
5535e44dac crtools: Keep cr_dump_task's post-dump ret code
Broken by 09b7b57c.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-13 14:32:18 +04:00
Pavel Emelyanov
ae98ef6ae0 mount: Factor out mount tree build for NEWNS and non-NS cases
We anyway build the tree, in the NS case -- few calls later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 16:19:48 +04:00
Cyrill Gorcunov
cf1ce5f817 mount: Build mount tree on dump restore early, if needed
For paths resolution we will need mount tree to be parsed
and built, but it's not that simple -- the current code
implies that once parsed the tree must not be re-parsed
again, so we pass @parse argument from a caller: if a task
we're restoring do not use mount namespace, we should parse
mount tree early, otherwise defer this action until mount
tree is read from the image.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 16:05:19 +04:00
Andrey Vagin
4850fd94a8 crtools: move cr_options in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:17:52 +04:00
Andrey Vagin
1300cf4915 crtools: move all stuff about fdset in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 15:24:48 +04:00
Andrey Vagin
0d1dfc2e08 crtools: move all stuff about vma together
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 12:43:49 +04:00
Andrey Vagin
824403a009 crtools: create new header for servicefd stuff (v2)
v2: generate patch relative to the official git.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 12:43:02 +04:00
Andrey Vagin
a6edbcf669 crtools: don't include restorer.h in proc_parse.h
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 12:37:55 +04:00
Cyrill Gorcunov
fcfa58026c dump: Don't forget to cleanup link remap if needed
In case if checkpoint is failed or -R option passed
we need to remove link remap files created during
dump procedure.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-01 13:36:07 +04:00
Cyrill Gorcunov
7fe6220883 dump: Unlock network if -R option passed
It's been found that if -R (leave task running after checkpoint)
option passed we don't unlock network, nether we clean service
files (such as link remaps).

After a long discussion we choose the following path: if -R option
is passed, it means a user is quite confident in what he is doing
and consistency of the resources (file system) is achieved by
a user himself with help of post-dump script. Also a user knows
that the network will be unlocked and accept such case.

So here we check of -R being passed in command line and once
checkpoint complete we unlock the network.

Cleaning up of link remaps is addressed in another patch.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-01 13:35:48 +04:00
Jamie Liu
71e1a99523 pre-dump: do not disconnect from page server before writing to it
Signed-off-by: Jamie Liu <jamieliu@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-10 22:56:33 +04:00
Pavel Emelyanov
00ae0d330a dump: Add comment how we dump zombies in pidns case
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-10 15:28:29 +04:00
Pavel Emelyanov
20d64b4326 dump: Install target ns' proc fd as service fd
Don't carry it around in a static global variable. Would
be useful for pidns leaks (processes entered one) scan.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-10 15:07:01 +04:00
Pavel Emelyanov
6bf63b3f01 security: Push full creds info into may_xxx checks
It's not enough to check only uids on dump and restore -- we need to
check e-ids and s-ids now (and caps in the future).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 15:48:44 +04:00
Ruslan Kuprieiev
9907302823 dump: initilize vmas in the very beginning
When dump/pre-dump failed before initializing vmas, free_mappings(&vmas)
is called and this cause segfault. Lets initialize vmas in the very
beginning of dump.

Signed-off-by: Ruslan Kuprieiev <kurpuser@gmail.com>

seqfault.patch
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-02 13:27:32 +04:00
Pavel Emelyanov
e8f4840049 dump: Add some comments to tasks collecting code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 06:28:33 +04:00
Pavel Emelyanov
91389f8782 security: Introduce (rather basic) security restrictions for C/R
Right now we have an ability to launch the C/R service from root
and execure dump requests from unpriviledged users. Not to be bad
guys, we deny dumping tasks belonging to user, that cannot be
"watched" (traced, read /proc, etc.) by the dumper.

In the future we will use this "engine" when launched with suid
bit, and (probably) will have more sophisticated policy.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 06:16:17 +04:00
Andrey Vagin
07930a8df4 ns: replace pid on id in per-namespace files
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:17:04 +04:00
Andrey Vagin
79d47a939d crtoools: add support of stopped tasks (v2)
Currently we catch processes on the exit point from sigreturn.
If a task must be restored in the stopped state, we can send SIGSTOP
before detaching from it.

v2: add more descriptive comment about skipping SIGSTOP in ptrace.c
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 11:21:34 +04:00
Pavel Emelyanov
2169020bea dump: Add comment saying why we dump zombies separately from alive tasks
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 11:17:28 +04:00
Andrey Vagin
ca3a23ec9c dump: transfer pstree_item in dump_task_core_all
Currently we take pid and core from it and we are going to take state.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 11:14:44 +04:00
Andrey Vagin
dbd41b522f proc: allow parse_thread to use an existent buffer
parse_thread allocated a buffer for threads and then it initialized read
pid for each thread.

Now we want to use it on restore and in this moment we already have
a buffer with initialized virt pid-s, so we need to initialize read
pid-s only.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:04 +04:00
Andrey Vagin
3e5ad587f4 parse_proc: move parse_threads from cr-dump.c
It will be used in cr-restore.c for stopping threads on the exit from
sigreturn.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:03 +04:00
Ruslan Kuprieiev
4c504f5ddd dump: Don't dump if children's uids are not equal to client's uid
This is for security -- service is run from root, but serves requests from non-root
processes. Thus, we shouldn't allow for anyone to dump suid programs that a run from
under unpriviledged processes.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-13 15:53:42 +04:00
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
cdce5d216d util: Make set_proc_fd report success/error only
Returning the new proc fd value is useless.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-11 19:51:02 +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
Andrey Vagin
d5540a2de5 page-server: check that all data have been accepted
Currently criu sends data to the page server, but it doesn't get any
feedback, so it can't be sure that all data have been accepted.

This patch adds a flush command, which requires an answer from the page
server. This command is sent before disconnecting.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-09 15:39:37 +04:00
Cyrill Gorcunov
73c5a0f965 dump: Introduce "post-dump" script action
This is usefull if one needs to do some final action before checkpoint
is complete. For example in case of online migration one may provide
a script which would check the restore procedure on remote note
ended without errors, thus the script returns zero code and criu
simply kills running instance of application.

In turn, if migration failed, the script can return nonzero code
and criu won't kill the application but continue its execution
instead.

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

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-22 19:35:28 +04:00
Pavel Emelyanov
0dc835ac02 dump: Move signals dumping into a helper
... fixing erroneous goto on error path :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-16 20:40:06 +04:00
Pavel Emelyanov
cd0075abbd dump: Don't push parasite-ctl into fns needing pid only
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-16 20:35:53 +04:00
Pavel Emelyanov
d20089fb32 dump: Merge thread and task parasite-core info dumping
There are parts dumping which is common to thread and task,
and this stuff is represented by parasite_dump_thread structure.

Merge this into parasite_dump_misc and facror out dumping code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-16 19:47:52 +04:00
Andrey Vagin
c2c44d5261 signals: dump alternate stack as misc parameters
The initilization stage is not good for that, because it can fail.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-16 17:24:16 +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
Andrey Vagin
5336bc13c6 dump: dump tid_addr_clear for thread leaders
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-10 18:05:27 +04:00
Pavel Emelyanov
5762076dbb dump: Factor out thread_core dumping
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-10 16:09:23 +04:00
Pavel Emelyanov
a04ccc22a0 dump: Remove unused arg from dump_task_core_all
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-10 16:06:08 +04:00
Pavel Emelyanov
ae25daf007 dump: Move dump_task_mm out of dump_task_core
Mm used to be in code, so the call was left in that place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-10 16:05:29 +04:00
Pavel Tikhomirov
9a9424ee10 posix-timer: Add dump functionality
Signed-off-by: Pavel Tikhomirov <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-01 16:19:28 +04:00
Andrey Vagin
75a3932be6 dump: Return signal mask from parasite on initialization
This mask should be put into sigframe (used by parasite, coming
soon) thus we have to pull one from dumpee early.

Plus, check that signals are blocked for each thread separately

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 20:26:34 +04:00
Andrey Vagin
64ecb2746c dump: save registers when the task is already infected
Otherwise a task can start to handle a signal and registers can be
changed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 19:28:34 +04:00
Andrey Vagin
9b656a47d0 dump: dumping signals when a task is stopped
Currently it's always stopped, but it will be changed, when a parasite
will be executed as a daemon.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 18:55:33 +04:00