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

289 Commits

Author SHA1 Message Date
Pavel Emelyanov
f83ad9c46d dump: Log fd flags when dumping fds
For debugging

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-21 20:28:26 +04:00
Pavel Emelyanov
ed397e3a33 fds: Optimize fds draning (mem + cpu)
* Don't dumplicate array when sending to parasite
* Allocate necessary space in cr-dump for local fds/flags

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-21 19:59:07 +04:00
Pavel Emelyanov
969ca6d9bf shmem: Get rid of static array of dumped shmem areas
These are used by single process, no need in keeping them in
such a strange way. Plus, turn this array into a hash table
for better search.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-17 00:20:58 +04:00
Andrey Vagin
d0476ea93b sockets: fail if an unsupported socket is in a dumped netns
If netns is dumped, crtools fails if it collects unsupported sockets.

If netns isn't dumped, crtools will fail only
if an unsupported socket should be dumped.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-14 12:49:21 +04:00
Pavel Emelyanov
51133437c9 fd: Remove per-filetype make_gen_id abstraction
It doesn't makemuch sense in pulling this further. The generic genid generation seems to
be enough for eny file type.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-11 22:41:29 +04:00
Pavel Emelyanov
64149b40f2 code: A little but more checkpatch fixes over code
There are more in test/ (and checkpatch.pl crashes in the middle =),
but seem to be all.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-11 22:19:34 +04:00
Pavel Emelyanov
5c9cc71fea log: Replace perror-s with pr_perror-s over code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-11 21:57:42 +04:00
Andrey Vagin
796d4ceb95 socket: switch netns for collecting sockets
All sockets should be collected in a target net name-space when the -n net
is specified.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-11 13:12:43 +04:00
Cyrill Gorcunov
097d73a101 dump: Add futex robust list dumping v3
This patch introduces ThreadCoreEntry protobuf structure which is to carry
thread-specific arch-independent information.

Now put there the c/r futex robust lists.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-10 20:28:59 +04:00
Pavel Emelyanov
2398c55e41 pb: Rewrite object writing to use pb-descs
The pb_write thing is no longer a macros.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:21:59 +04:00
Pavel Emelyanov
f345fc8f10 parasite: Don't pull opts through the stack
Revert and tune 9eda83b7. Andrey reminded me that we have
global instance of cr_options.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 16:25:52 +04:00
Pavel Emelyanov
da409cc641 signalfd: Dumping and restoring
Only the fact of the fd presence, its flags and fown and the sigmask.
The sigpending state is tightly coupled with the task's sigpending
state which is not yet supported.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 12:26:35 +04:00
Pavel Emelyanov
9eda83b74a parasite: Pull cr_options down (or up) to transport sock creation
We'll need to check whether the socket is to be created in a net
namespace (since we can't detect this automatically yet). Thus the
namespaces flags are required there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:53:02 +04:00
Andrey Vagin
c69be631e1 mntns: crtools: stat pathes relatively of a mntns root
If we dump tasks with mntns, we should look at pathes from point of a mntns root.

Now we support a situation when a root of an init task has the same root as the
mntns root, because we have not another way to get a root of mntns.

A path to an unix socket is copied, because the origin copy will be gone
out from the function, where it was created.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-01 07:00:48 +04:00
Cyrill Gorcunov
9d918c5964 protobuf: Convert core_entry to PB format v5
This requires some exlanations

 - Since we use protobuf data in restorer
   code we need to carry a copy of appropriate
   PB entities in resident memory. For this
   sake task_restore_core_args and thread_restore_args
   were significantly reworked. In short -- the caller
   code fills PB structures into task arguments space.

v3:
 - Combine everything arch related to thread_info field,
   and make it optional
 - Drop "version" field from message, we check version in
   another specific message
 - Don't forget to call core_entry__free_unpacked where needed
 - We continue dumping FPU state, still it's not yet restored

v4:
 - Don't carry task_core_entry and task_kobs_ids_entry for
   threads, and yield error if present in image.

v5:
 - Allocate core_entry depending on type of task being dumped

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-20 14:06:42 +04:00
Pavel Emelyanov
64967eef21 crtools: Kill the ability to work on individual process
We haven't tested it for several monthes and there's no evidence
it is required at all. For dumping a single task -t option works
just fine.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 17:55:34 +04:00
Pavel Emelyanov
9f2168a4f0 images: Introduce the top-level file -- inventory
Currently we store the images version in the core file. This is
bad, since core file describes a single process (or thread) and
says nothing about the images set as a whole (let alone the fact
that it's being parsed too late).

Thus introduce the inventory image file which describes the image
set the way we need (want). For now the only entry in it is the
images version. In the future it can be extended.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 17:37:25 +04:00
Cyrill Gorcunov
4806e1395f protobuf: Convert vma_entry to PB format v3
v2:
 - Use regular uint types in message proto
 - Use PB engine for "show"
v3:
 - drop usage of temp. variable in prepare_shmem_pid

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 12:43:36 +04:00
Pavel Emelyanov
ffd40996ea pb: Switch creds to protobuf format
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 12:35:25 +04:00
Cyrill Gorcunov
043cfc99b1 dump: Drop FD_DESC_INVALID redundant assignment
It's assigned by FD_PARMS_INIT already.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 09:40:13 +04:00
Cyrill Gorcunov
0468355c12 protobuf: Drop fown_t type
We are ready to use FownEntry everywhere,
so drop fown_t type and clean up source code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 09:39:00 +04:00
Cyrill Gorcunov
808b8f2f06 protobuf: Convert mm_entry to PB format
Because the MmEntry has a "repeated" field, we
copy aux vector explicitly and reserve space for
it in task args.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 07:25:05 +04:00
Pavel Emelyanov
b75d66e7df itimers: Don't write itimer_entry from parasite
Same as with previous patch -- we have to pull image-independent entry out of the victim
task to be able to use protobuf library for encoding.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-18 07:23:05 +04:00
Cyrill Gorcunov
b02158c14c protobuf: Convert struct fs_entry to PB engine
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-17 07:28:38 +04:00
Cyrill Gorcunov
a1fe3caf04 protobuf: Start switching our image entries to Google's protobuf
A short story -- there were a long conversation on which format should
be used to keep checkpointed data on disk image. We ended up in using
Google's Protocol Buffers (see https://developers.google.com/protocol-buffers/
for detailed description). Thus image entries should be convered to PB.

This patch converts fdinfo_entry to PB "message fdinfo_entry".

Build note: one should have protobuf and protobuf-c installed to be able
to build crtools.

 - http://code.google.com/p/protobuf/
 - http://code.google.com/p/protobuf-c/

Inspired-by: Pavel Emelianov <xemul@parallels.com>
Inspired-by: Kinsbursky Stanislav <skinsbursky@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-17 07:10:41 +04:00
Cyrill Gorcunov
ea1ce8e472 fifo: Add checkpoint restore for fifos v4
Checkpoint and restore of fifo is similar to
pipes c/r except the pipe end-points are named
file.

Because the fifo has a name we use regular files
facility for fifo path c/r.

Still there is a trick used to "open" fifo:
the opening procedure migh sleep if a fifo's peer
is not yet opened, so before doing a real open
we yield a fake open procedure (with O_RDWR flag)
which prevents us from sleeping even if peer
is not yet ready. Also we need writable fifo
end to restore data queued.

v2:
 - add open/priv members to reg_file_info
 - make open_fifo_fd to use open_fe_fd
 - comment on pipe_id
 - make sure the fifo data is not restored twice

v3:
 - drop useless fixme comment and add sane one
v4:
 - Use restore_data flag to escape data restore duplication
 - Use S_ISREG for file contents copying

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-01 17:15:48 +04:00
Andrey Vagin
49c1d43645 pstree: move all code about pstree in a separate file
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Looks-cool-to: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-27 21:07:30 +04:00
Andrey Vagin
325ff7b4ab dump: don't check xids
Now crtools can restore sid in all cases.
A restore of pgid will be added soon and now it will fail on restore.

It's prevent testing of restoring SIDs.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:14:35 +04:00
Andrey Vagin
9b8a206729 restore: restore sid of task which isn't leaders and isn't a child of init (v4)
It's sign, that a parent has been changed sid after forking a child.
We should know a sid with which a process was born, because in a processes
chain, more then one process might change SID.

v2: fix names of variables
v3: prevent rewriting of born_sid
v4: Abort the restorer with error message if a born_sid can't be determing.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:13:58 +04:00
Andrey Vagin
8075dc60a5 pstree: rename fields in struct pid
s/pid/virt/
s/real_pid/real/

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:09:44 +04:00
Andrey Vagin
9b3b059bdc crtools: add "pid" to the --namespaces cmdline option arguments (v3)
to require dumping pid namespace. Dump and restore will be failed if
a tress doesn't contain a process init.

pid namespace will be created implicitly if a process init in the tree.

v2: fix comments from Pavel
v3: Restore of pidns should be approved by user

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 12:08:57 +04:00
Cyrill Gorcunov
4140c9e4ec files: Move regular files handling code to files-reg
Instead of spreading regular files handling code over
files.c and cr-dump.c move it to files-reg.c.

This allows to extend regular file handling code in
future without disturbing other source files and
make code logically coupled, where files.c is mostly
a place for general file handling code unrelated to
file type specifics.

While mostly it was code tossing there is some change
I have to notice -- the structure ghost_file was previously
declared in two paces cr-dump.c and files.c, in cr-dump.c
it was used for dumping while in files.c it was used
for restore. The structure had different members.

So to resolve this conflict the ghost_file structure
was renamed to ghost_file_dumpee.

Nothing else is changed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 12:10:13 +04:00
Pavel Emelyanov
49da2834a5 fd: Cleanup in dump_one_file
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-20 19:24:48 +04:00
Pavel Emelyanov
9ca95b5d3a fd: Remove ID from fd_parm
It's only required for making pipe_id, but making it is better to
be done in place and using the st_ino only.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-20 19:24:46 +04:00
Andrey Vagin
0ee0b197bd dump: split real_pid and pid in struct pid (v2)
Now pid is dumped from pid ns, it's gotted from parasite.

v2: fail if a zombie is in PIDNS

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:17:07 +04:00
Andrey Vagin
634dd10b32 namespaces: dump_namespaces get a struct pid as argument
It uses pid for create image file and real_pid for dumping ns-s.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:16:54 +04:00
Andrey Vagin
c48bcbdb60 dump: move check_xids to dump_pstree
because in collect_pstree we don't know pid-s of processes inside pidns

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:16:44 +04:00
Andrey Vagin
20d2c780ce cr-dump: dump pstree after tasks
because a pid in a target pid ns is got from parasite.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:16:33 +04:00
Andrey Vagin
83e6d14efd cr-dump: split collect_dump_pstree to collect and dump
When we dump pid ns, dump_pstree is called after dump_tasks

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:16:10 +04:00
Andrey Vagin
772edd462c parasite: add ability to get pid and tid
If we try to dump a process from another pid ns,
we have not another way to get its pid.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:16:01 +04:00
Andrey Vagin
4b48849c32 ctrools: prepare to dump pid namespace
Add struct pid and use it everywhere. This struct contains
two fields: pid and real_pid.

real_pid is a pid outside of the target pid namespace.
pid is in the target pid namespace

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 22:13:52 +04:00
Cyrill Gorcunov
ac52abd83e pipes: Make pipes_with_data being static
There is no need to make it xmalloc'ed, it's
global for all processes dumped.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:27:10 +04:00
Cyrill Gorcunov
24c98006dd dump: Don't dump file params with on-stack values in dump_task_fs
Ad addition to commit 63000f5bb20e12ced2bc9662482775d163c97c5a,
this place was missed to fix.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-04 12:50:57 +04:00
Andrey Vagin
dfdf54d96b pstree: allocate restore data as a tail of pstree_item (v2)
v2: Synchronize the argument type of __alloc_pstree_item and the
values you put into it. I.e. int-int or bool-bool, not bool-int.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-31 15:41:05 +04:00
Andrey Vagin
cf63c1d9e8 crtools: link pstree_item-s in a tree (v3)
because they describes a process TREE.

It's usefull, when we dump tasks from another pid namespace,
because a real pid is got from parasite. In previous version
we need to update pid in two places one is in a pstree_item and
one is in a children array.

A process tree will be necessery to restore sid and pgid,
because we should add fake tasks in a tree. For example if
a sesion leader is absent.

v2: fix rollback actions
v3: fix comments from Pavel Emelyanov
    * add macros for_each_pstree_item
    * and a few bugs

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-31 15:41:02 +04:00
Stanislav Kinsbursky
41195598cf parasite: remove excessive header deps from parasite.h and friends
The task is not complete - this is just a part of what have to be done. I.e.
looks like a lot of excessive deps can be fixed.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-30 12:50:18 +04:00
Cyrill Gorcunov
63000f5bb2 dump: Don't dump file params with on-stack values
Otherwise I see output like

 | Dumping path for 1536412160 fd via self 27 [/usr/bin/screen]

where fd is taken from stack and what is worse -- we work
with root privilegues, thus dumping _anything_ from stack
is very bad idea.

With explicitly cleared stack data and FD_DESC_INVALID the
log file will have an entry like

 | Dumping path for -3 fd via self 27 [/usr/bin/screen]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-30 12:36:17 +04:00
Cyrill Gorcunov
9b2546576c dump: Use switch in dump_chrdev
This will allow to implement tty dumping
in future.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-30 12:30:53 +04:00
Andrey Vagin
066ec066a0 crtools: remove unused variables (v3)
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-18 19:01:21 +04:00
Cyrill Gorcunov
62ee701c89 Use /proc/pid/smaps for VMA parsing v2
This allows us to detect nonlinear mappings.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-11 17:41:05 +04:00