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

83 Commits

Author SHA1 Message Date
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
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
Pavel Emelyanov
b978c6f873 util: Introduce buffer size for carrying /proc/self/fd/N path
There's ... a number of places where we want to do something
with /proc/self/fd/%d path. Each time we guess buffer size
that is enough for this. Make standard constant for this and
save some space on stack and drop args for some functions.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-15 13:59:59 +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
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
Pavel Emelyanov
64e7d2435a collect: Reduce amount of args to collect_image call
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 03:27:06 +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
72ec39f10c util: Rename pie's util-net.c into util.c
Will put more things there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-29 12:43:30 +04:00
Pavel Emelyanov
d020ebb36d files: Compact the code by removing per-file dump helpers
Since *all* of them just call do_dump_gen_file with proper ops,
just call one directly. Compacts the code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-06-14 00:11:08 +04:00
Pavel Emelyanov
5cae819d8c img: Get rid of open_image_ro helper
O_RSTR flag should be used instead for regular open_image

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-09 19:22:21 +04:00
Andrey Vagin
3736fcf9f1 pipes: fix error handling
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-19 23:54:41 +04:00
Andrey Vagin
f2664d6524 pipe: don't reopen pipes via /proc, if it's not required
The system call open can add O_LARGEFILE.

A point is reopend for unsharing a file descriptor. So here are two
types of points. One is returned by pipe() and all other ones are
got via opening /proc/PID/fd.

Currently I know only one difference between these types, it's
O_LARGEFILE.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Tested-by: Alexander Kartashov <alekskartashov@parallels.com
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-19 23:00:59 +04:00
Andrey Vagin
31ce074b55 pipe: prevent dumping pipes in the packetized mode
This mode was introduced less than year ago:

commit 9883035ae7edef3ec62ad215611cb8e17d6a1a5d
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Apr 29 13:12:42 2012 -0700

    pipes: add a "packetized pipe" mode for writing

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 22:34:06 +04:00
Alexander Kartashov
3bb6d9f4fb cr: use the length modifier %z to print an integer of the type size_t
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:38 +04:00
Pavel Emelyanov
a82cb23f98 pipe: Dump and restore pipe size
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-11 17:45:54 +04:00
Pavel Emelyanov
42d7bc07cb pipe: Make pipe-data entry always be present in the image
It contains info about the pipe itself, not jut one of its
ends. Thus if we want to add more (e.g. -- its size) we'll
have to put it there and thus have it always present.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-11 17:45:52 +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
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
a0560c4298 pipes: Fix wrong pipe info check on master selection
The currently observed list entry should be examined, not
the original one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 22:02: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
9efd12f2c7 code: Remove trailing whitespaces over .c and .h files
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-11 21:34:35 +04:00
Pavel Emelyanov
b91445701b img: Introduce generic routine for collecting image entries
On restore we typically read an image and put the entries into
some hash/list/whatever to work on them later. It's handy to have
a generic routine for doing so.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-09 13:16:46 +04:00
Pavel Emelyanov
b1b0a39a58 pb: Rewrite object reading to use pb-descs
The pb_read thing is no longer a macros. This will allow to
factor out objects collecting on restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:22:00 +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
9fc1d6bbeb fdinfo: Make fdinfo.type be an enum
This types specifies a strict set of what is hidden behind
the fd. Thus these numbers should be in the description of
the fdinfo message.

Plus protobuf makes shure nothing else will be there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 10:18:37 +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
7861d32de0 protobuf: Convert struct pipe_data_entry to PB engine
Note, at moment we don't use "data" from proto declaration,
it's reserved to implement later (simply because it's easier
to use current code for a while).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-17 14:50:23 +04:00
Cyrill Gorcunov
baa30914b5 protobuf: Convert pipe_entry to PB engine
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-17 07:29:57 +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
6c2807e512 pipes: Use pipe_entry as a reference in pipe_info
Need it for PB transition.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-13 11:56:41 +04:00
Pavel Emelyanov
237ef3c809 pipe: Rework pipe data restore to use vmsplice
This serves two things -- kills annoying data offset management
which makes protobuf switch too ugly. And removes the need to
seek the pipe data image, which in turn is the prerequisity for
streaming migration.

Memory usage is still optimal, since we still use splice on dump
path and on restore stage we F_GIFT pipe buffers to the kernel.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-12 06:57:20 +04:00
Pavel Emelyanov
ab59e7d3a5 pipes: Plug memory leak on pipd data image EOF
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-11 14:44:00 +04:00
Cyrill Gorcunov
906f08133b pipes: Use pde as a reference in pipe_data_rst
Need it for PB transition.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-11 14:41:03 +04:00
Pavel Emelyanov
f965ead8b8 pipe: Shorten array for self link path
To open /proc/self/fd/%d PATH_MAX array is too long :) We can use shorter.
Plus fix the snprintf size argument.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-11 12:57:19 +04:00
Pavel Emelyanov
d271850694 pipe: Add helper for getting pipe_id from fdparms
Just to explicitly state that a pipe ID is its inode number.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-11 11:57:28 +04:00
Pavel Emelyanov
7ea40df4db pipe/fifo: Remove unused members from rst structures
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-01 08:56:20 +04:00
Pavel Emelyanov
d448a75ec7 pipe/fifo: Fix and cleanup data restore
Make it in two stages.

First -- collect pipe data into hash without checking for pipe/fifo existance.
Next -- when pipe/fifo gets restored walk the hash and search where the pipe data
is.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-01 08:55:16 +04:00
Pavel Emelyanov
3aa01f649f pipe: Don't intermix pipe and fifo data when dumping
The existing code checks for ID to be already dumped. But pipe and fifo may have the same ID
since they reside on different filesystems.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-01 08:21:54 +04:00
Pavel Emelyanov
499cc6789b pipe: Remove ID arg from pipe data dump fn
This routine checks for pipe data being dumped based on pipe ID, but the arg in questoin
is the pipe's end ID which makes code reading confusing.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-01 07:50:39 +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
Pavel Emelyanov
b1919be8bb pipes: Cleanup pipe data collecting code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-28 13:32:59 +04:00
Cyrill Gorcunov
d16d4baa8d pipes: Make dump_one_pipe_data/restore_pipe_data being non-static
To reuse with fifo data restore.

v2:
 - use image type in functions arguments instead of forcing
   calling side to provide file descriptor

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-01 17:13:11 +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
Cyrill Gorcunov
2adbbcba89 pipes: Don't forget to init pipe_info::create
Otherwise its value might be taken from heap (it's xmalloc'ed).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:45:18 +04:00
Cyrill Gorcunov
70b65c9a50 pipes: Don't call for restore_fown if open failed
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:33:09 +04:00
Cyrill Gorcunov
6b06c744db pipes: Style tune up for pipe_info members
- align members
 - comment with empty line

No func changes.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:32:14 +04:00
Cyrill Gorcunov
f973fcabb9 pipes: Shrink pipe_should_open_transport to want_transport
It's static function near the file_desc_ops,
no need for a long name.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:30:36 +04:00
Cyrill Gorcunov
61e289f184 pipes: Reorder functions
Checkpoint and restore do use fdtype_ops
and file_desc_ops intensively so reorder
pipes functions, this allow us to make
them static and drop additional declarations.

No func changes.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:30:03 +04:00
Cyrill Gorcunov
f3c93470e1 pipes: Get rid of dangling line in dump_pipe
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:29:24 +04:00
Cyrill Gorcunov
28cd2a7633 pipes: Add missing void into func arguments
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-19 15:28:53 +04:00