2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 01:51:51 +00:00

275 Commits

Author SHA1 Message Date
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
Pavel Emelyanov
fc830ddca9 anoninode: Report error when dumping unknown anon file
It will fall through all the other checks, but let's do it
explicitly for better code understanding.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 16:13:50 +04:00
Pavel Emelyanov
6a55c1c596 dump: Move per-type dump opts into respective .c files
No functional changes, just a code move.

TODO:

* need to write personal make_gen_id implementations for special
files (device and pos is const for them effectively)
* need to merge dump ops with restore ones (file_desc_ops)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 15:34:55 +04:00
Pavel Emelyanov
2cea6414e6 fdpsrms: Remove now unused type field
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 15:28:28 +04:00
Pavel Emelyanov
f509fcf03f dump: Introduce file dumping operations
Now all the fds dump look very similar and we can reimplement
it via indirect calls.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 15:25:25 +04:00
Pavel Emelyanov
37a3ed86f4 dump: Split dumping reg file and pipes
Reg files are those obtained by open() syscall on restore.

Pipes should be checked to belong to pipefs (fifos are not supported
yet).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 15:06:20 +04:00
Cyrill Gorcunov
bff52ba952 inotify: Add checkpoint/restore v2
v2:
 - open_mount is cleaned up
 - byte-stream hex conversion remains untouched since
   strtol is flipping numbers to LE manner

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 14:00:45 +04:00
Cyrill Gorcunov
b38777dff4 eventpoll: Add checkpoint/restore v2
v2:
 - Move everything into eventpoll.[ch]
 - Use rst_file_params

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 14:00:05 +04:00
Cyrill Gorcunov
889795da5d eventfd: Add checkpoint/restore support v2
v2:
 - Pass initial counter value to eventfd call
   (can't pass flags here since they are obtained
    with fcntl and must be restored same way or
    restore will fail)
 - Use rst_file_params for flags and owner restore
 - Use eventfd.[ch] instead of eventfs.[ch]
 - Move show funcs to eventfd.c

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 13:59:51 +04:00
Pavel Emelyanov
26a53837f9 shmem: Move shmem dumping code to shmem.c
This is also a code move plus two changes:

* shmems renamed to dump_shmems
* shmem area size is shared with restorer (it's one page for both for now)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-03 18:07:01 +04:00
Pavel Emelyanov
fa8a928e9f pipes: Move dumping code to pipes.c
Just a codemove, no real changed.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-03 17:36:00 +04:00
Pavel Emelyanov
52242be32c dump: Stop using mincore and switch to /proc/pid/pagemap
We use mincore to check which pages we should take with us into
the image. The anonymour present or swapped should go, file present
but not cow-ed should not.

The mincore syscall wasn't very helpful with this -- it didn't detect
swap, but did detect some non present pages (pagecache). Plus it
didn't know anything about cow-ing filemaps.

Andrey Morton suggested to use the pagemap file in proc, but it lacked
the importaint stuff -- the cow filemap bit. Now it's there and we
can switch to using it.

The mincore usage for shared memory is still there, as for _that_ case
it's correct.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-03 16:10:04 +04:00
Pavel Emelyanov
675b4698ce tcp: Put connection locking management over the code
When dump finished with error we should unlock all locked
previously connections.

When restoring we should collect connctions and unlock them
all at the end.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-28 17:59:21 +04:00
Pavel Emelyanov
8cd64c5ae7 unix: Cleanup ext socket check
Rename the fn and fix indentation.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-26 15:30:30 +04:00
Konstantin Khlebnikov
bef7092834 Replace printf format "0x%x" with "%#x"
printf() has standard flag for adding "0x" prefix before hexadecimal integer.

MOD='[-+]\?[0-9]*.\?[0-9]*[lL]*'
git grep -l "0x%${MOD}x" | xargs -n1 sed -e "s/0x%\(${MOD}\)x/%#\1x/g" -i

Signed-off-by:    Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-24 15:20:24 +04:00