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

91 Commits

Author SHA1 Message Date
Pavel Emelyanov
9b91bf390d files: Split fs restore into prepare and restore
The prepare one will become more complicated soon.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-07-04 15:09:03 +04:00
Pavel Emelyanov
b8d01d1b7a files: Rename prepare_fs into restore_fs
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-07-04 15:09:02 +04:00
Andrey Vagin
87b1f5408c files: save mnt_id on fd_param
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-04-21 22:39:18 +04:00
Pavel Emelyanov
dc7abdfb92 vma: Don't lookup file_desc for vma twice
We do it first -- on collect, second -- on restore. The
2nd lookup is excessive, we can put fd pointer on vm_area
at lookup and reuse one later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-07 13:51:29 +04:00
Pavel Emelyanov
3de41b8070 files: Rework select_ps_list fdsec ops callback
For unlinked opened and mmaped files we'd need to
care about remaps, for this the callback with both
file_desc and fdinfo_list_entry will be required.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-05 16:17:59 +04:00
Pavel Emelyanov
751856c8b8 files: Pre-dump file descriptors
We will generate some info about file-descriptors at that
stage. For now these pre-dumped ones would be fsnotifies,
so the pre-dump of a single fd is written as simple as
possible, but enough for that type of FDs pre-dump.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-30 16:20:15 +04:00
Pavel Emelyanov
52dec20a17 files: Save fstype on fd_parms
We will need to special-care NFS silly-rename files, thus
we need to know which FS a file belongs to.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-27 21:14:09 +04:00
Andrey Vagin
6bbdec26f3 files: add ability to set callbacks for files (v7)
Here is nothing interecting. If a file can't be dumped by criu,
plugins are called. If one of plugins knows how to dump the file,
the file entry is marked as need_callback. On restore if we see
this mark, we execute plugins for restoring the file.

v2: Callbacks are called for all files, which are not supported by CRIU.
v3: Call plugins for a file instead of file descriptor. A few file
descriptors can be associated with one file.
v4: A file descriptor is opened in a callback. It's required for
    restoring anon vmas.
v5: Add a separate type for unsupported files
v6: define FD_TYPES__UNSUPP
v7: s/unsupp/ext (external)

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 16:07:38 +04:00
Cyrill Gorcunov
291aa3f6d6 headers: Add extern specificator to functions
We really have a mess of extern/non-extern declaration
of functions in our headers. Always use extern for
unification purpose.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-15 17:00:58 +04:00
Cyrill Gorcunov
8f64a14a03 headers: Move fcntl related data to include/fcntl.h
fcntl data is arch independent, so move it out of include/asm/type.h

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-14 22:13:10 +04:00
Andrey Vagin
a434e7f075 crtools: move pid_rst_prio to pid.h
crtools.h is too heavy to be included in many sources

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:18:12 +04:00
Pavel Emelyanov
b4c09afd43 files: Add more comments about shared files dump/restore
This is not trivial codeflow, let's document it till we
remember what and why it does.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-10 12:13:36 +04:00
Pavel Emelyanov
7a16734ed5 rst: Formalize the shared resource restore order
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-29 08:07:15 +04:00
Andrew Vagin
5bf25d36c0 files: declare fd_params->pos as off_t
Currently pos has type unsigned long, so its size depends on
architecture. pos is saved as 64-bit value in the image file and it
isn't restored, if it is equal to -1. Due to convertation on 32-bit
platforms -1 is converted into UINT_MAX and we get error on restore.

$ zdtm.sh ns/static/tun
...
(00.398513)      5: Error (files-reg.c:534): Can't restore file pos: Illegal seek
(00.398888)      5: Error (files-reg.c:489): Can't open file /dev/net/tun: Illegal seek
...
id: 0x15 flags: 0x2 pos: 0x000000ffffffff fown: { uid: 0 euid: 0 signum: 0 pid_type: 0 pid: 0 }  name: "/dev/net/tun"

crtools is compiled with _FILE_OFFSET_BITS=64, so off_t is always 64-bit.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-29 14:55:37 +04:00
Pavel Emelyanov
9917c4fe34 rst: Compact file-descs collects a bit
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 01:06:58 +04:00
Pavel Emelyanov
f61eb82f8b files: Convert fdescs hash from list-s into hlist-s
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-10 16:41:18 +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
Cyrill Gorcunov
4531f0ac7d files: Add ability to use read link in dump_one_reg_file
To be able to dump procfs namespace entries we will need to
analyze the link name first and then figure out if the file
referred indeed a procfs entry or it's plain regular file.

This means we read link early, and to escape double reading
of same link, once we read it we remember it in fd_parms
structure which we pass to dump_one_reg_file.

Still the dump_one_reg_file is not solely used from inside
of dump_one_file, but from a number of other places (fifo,
special files) where fd_parms is filled only partially
and fill_fd_params is not even called. Thus dump_one_reg_file
must be ready for such scenario and read the link name by own
if the caller has not provided one.

To achieve all this we do

 - extend fd_parms structure to have a reference on a new
   fd_link structure, thus if caller already read the link
   name it might assign the reference and call for dump_one_reg_file

 - tune up dump_one_reg_file to fill own copy of fd_link
   structure if the caller has not provied one

  [ xemul: Added const to fill_fdlink arg ]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 03:36:54 +04:00
Cyrill Gorcunov
19ce784db5 dump: Add missing FD_PARMS_INIT assignments
struct fd_parms is reused for two calls, so don't
forget to initialize it before dump_one_reg_file
call.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 03:36:01 +04:00
Pavel Emelyanov
f34d63bfb1 fd: Comment file_desc_ops
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-16 14:47:10 +04:00
Cyrill Gorcunov
fdfef4b485 headers: Change "../protobuf/" to "protobuf/"
No need to walk up the directories if we need
to include protobuf file. This was always a bad
use of ability to walk the filesystem from other
headers.

Same time we don't need -I$(SRC_DIR)/protobuf/
in general makefile anymore.

[xemul: Small fixlet in head Makefile, since patch
 it out-of-order]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-15 17:33:06 +04:00
Pavel Emelyanov
2cdbeb4a11 files: Move dump_task_files into files.c
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-08 02:54:24 +04:00
Pavel Emelyanov
10b338c5db fdt: Move shared-fdt structure preparation into separate fn
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-19 00:30:42 +04:00
Andrey Vagin
d50c786c7e files: dump fdinfo per files_id instead of pid
A few processes can share one fdtable.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:44 +04:00
Andrey Vagin
bb25ed38c8 files: close_old_fds before forking children (v2)
A few processes can share one fd table. Each process has own set of
service file descriptors and a process knows nothing about servic fds
of another processes. So if two process share one fd table,
close_old_fds will close servic descriptors of another process.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:42 +04:00
Andrey Vagin
0fc129a121 files: pass a file descriptor on an fdinfo image instead of cr_fdset
Currently fdinfo dumps for each task, so CR_FD_FDINFO is in cr_fdset.
A few tasks can share one fd table and the set of descriptors will be
dumped once and a image name will contain files_id instead of pid.
In this case CR_FD_FDINFO will go away from cr_fdset.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-11 14:47:09 +04:00
Alexander Kartashov
6f61488f21 x86: moved x86-specific files into the directory arch/x86.
* The following files goes into the directory arch/x86/include/asm unmodified:
  - include/atomic.h,
  - include/linkage.h,
  - include/memcpy_64.h,
  - include/types.h,
  - include/bitops.h,
  - pie/parasite-head-x86-64.S,
  - include/processor-flags.h,
  - include/syscall-x86-64.def.

* Changed include directives in the source files that include the headers
  listed above.

* Modified build scripts to reflect the source moves.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:02:47 +04:00
Cyrill Gorcunov
830d92b0f0 headers: Unify include guards (in comments) and a few fixes
- fix names in comments
 - add empty lines where needed
 - fix rbtree.h
 - fix syscall-types.h

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-25 22:40:24 +04:00
Pavel Emelyanov
b4c2160449 hdrs: Fixup reinclusion preprocessor constants
Make them look like __CR_<smth>_H__ with

sed -e '1,2s/#\(ifndef\|define\) _\?_\?\(CR_\)\?/#\1 __CR_/' -e '1,2s/_H_\?_\?.*$/_H__/'

on every header file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-24 15:36:14 +04:00
Cyrill Gorcunov
2b816a593a dump: Make struct fd_parms to carry @parasite_ctl pointer
Some file-type specific parameters can be fetched with
parasite code only, so lets carry parasite control block
pointer in struct fd_parms.

This is a bit ugly but requires less code to touch and
enough for now. In long terms we need some more generalized
routine/hooks which would depends on file type.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-15 23:42:50 +04:00
Pavel Emelyanov
1be08acc7c remap: Add cmdline option to allow linked remap
By default crtools shouldn't modify the environment, except for
killing the dumped tasks. The link remap does so and should sit
under explicit cmdline option.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:39:23 +04:00
Pavel Emelyanov
563b116096 files: Support opened-and-unlinked files with non zero link count
These are not ghost, as they are still on fs, so we cannot take
them with us in the image. Neither we can easily find the other name
of that file. Sad :(

To make it work we linkat() the new name to that file using the
AT_EMPTY_PATH flag to link directly to the opened fd. If we could
openat() the fd's parent we would better do it, but we can't and
thus have to create the link name by explicit absolute path :(

This modifies the fs we're dumping, so I'll introduce one more cmd
line option for that soon.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:22:52 +04:00
Pavel Emelyanov
8fc6dbfadd files: Formalize fd restore priorities
There are places when we have to select which fd to ->open
and which to ->receive. To avoid deadlocks we sort them in
an ascending order on { pid, fd } pair.

Make this idea more formal by introducing an explicit function
doing this check and call it where appropriate (pipe.c master
selection is also simplified to fit new ... API).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 22:09:22 +04:00
Pavel Emelyanov
62cf23b93a files: Hide pslist selection logic into file desc handlers
Don't do explicit switch by file type in files.c and don't export
intimate knowledge of pty being master/slave. Use a file desc op
for that.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 21:53:51 +04:00
Pavel Emelyanov
845f3ee973 fd: Indirect fd opening states engine
Put the states into in one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 00:34:37 +04:00
Cyrill Gorcunov
20d6762d93 tty: Add restoration of controlling terminal v4
The idea behind is pretty simple -- once we find
that there is a controlling terminal present we
do call ioctl on appropriate /dev/pts/N.

This is done in a bit unusuall manner. When we
find that there is a controling terminal present
we do create an additional FdinfoEntry for it
with object id taken from existing master peer.

The file engine stack this new FdinfoEntry on
fd_info_head head list. Thus we will have at
least two entries on this list. One for real
Fdinfo associated with master peer and one for
our new generated Fdfinfo entry, it depends on
pid which one become a file master.

Finally we do use post_open_fd hook in our
tty code which allows us to open controlling
terminal and yield proper ioctl on it.

v2:
 - restore control terminals via service fd,
   still need to speedup service fd retrieval.

v3:
 - use prepare_ctl_tty() helper to generate
   control terminal fdinfo entry

v4:
 - use post_open_fd

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:58 +04:00
Andrey Vagin
403dcb9de5 files: place the state POST_CREATE after the state RECV
It will be used for restoring epollfd.
Currently a transport fd may be added to epollfd.
epollfd should be populated, when all descriptors were already received.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 17:50:22 +04:00
Cyrill Gorcunov
1fd9913ffb files: Add a few comments on structures we use for files handling
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-05 19:58:30 +04:00
Cyrill Gorcunov
4ececa09ba files: Drop unused self_exe_fd declaration
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-27 23:21:44 +04:00
Andrey Vagin
61490ba985 files: add one more operation post_create
It will be used for restoring inet sockets. An inet socket is created with
the option REUSEADDR, because the restore logic requires this.
The origin value can be restored only when all sockets were restored.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-20 17:50:01 +04:00
Cyrill Gorcunov
19672e9cd1 files: Rename argument to sock
It's unclear why we've had two different names
for same argument. Moreover, "tsk" is definitely
misnamed feature.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-17 15:43:22 +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
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
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
7c44757683 files: Add pb_ helpers
To not spread opencoded copying of PB entries and image structures
we add a few pb_ helpers to be used until PB code completely merged.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-17 07:24:51 +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
2db18f5e16 files: Use fdinfo_entry * in fdinfo_list_entry structure
We will need to use pointer here (to PB object) anyway
so better to make it in a separate patch for bisectability sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-09 15:04:35 +04:00
Cyrill Gorcunov
3c18a9f47e Beautify files.h
- add argument names
 - align members
 - add extern kw
 - group struct decl. on top
 - make file_desc_ops::type being unsigned
   integer similar to fdtype_ops::type

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 17:03:13 +04:00
Cyrill Gorcunov
cb74aa3e48 files: Drop redundant declarations from files.h
These are declared in files-reg.h, so get rid of
them and add files-reg.h inclusion where needed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-22 17:02:23 +04:00
Pavel Emelyanov
a842cfe68f files: Don't lookup fdesc twice
In the open_fdinfo we need to get a file_desc associated with the given
fdinfo_list_entry. This is done by searching the hash of descs, but this
can be speeded up by saving the desc pointer on the fdinfo at the time
of collecting them.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-21 17:32:56 +04:00