2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-24 19:08:11 +00:00

124 Commits

Author SHA1 Message Date
Andrey Vagin
aabb56bd66 crtools: write a pid of a root task in a specified file
When we restore a pid namespace the root task will get some unknown pid
in the original (i.e. -- the ns crtools a launched from) one. To find
this pid out one can use this option -- it will make the pid obtained by
the new init to be written into a pid file.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-14 12:54:00 +04:00
Andrey Vagin
ba0d5fb226 dump: handle overmounted devices (v2)
"init" in LXC opens /dev/null and then mounts devtmpfs in /dev,
so crtools can not resolve the path to the origin /dev/null.

crtools with the option --evasive-devices will check the origin
device and a new device are the same and if it's true, crtools will
dump a new path.

v2: add a description for the option

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:33:49 +04:00
Pavel Emelyanov
9e84bd1083 pb: Introduce pb message types and cr-descriptors
The protobuf-c generate plain routines for entries manipulations, but
we want to have some "generic" way of working with messages. Collect them
all in an array of descriptors (similar to image files descriptions) and
do full typechecking while this.

Such thing will allow to simplfy code later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:21:58 +04:00
Cyrill Gorcunov
25b35f13b6 help: Add mnt and net options into the list
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-06 18:29:53 +04:00
Andrey Vagin
420325dca6 restore: add an option for changing a root file system (v2)
The option is -r|--pivot-root and an argument is a path to new root.
A root task will make pivot_root. LXC CT does that, so we need that
for restoring.

v2: s/pivot-root/root/

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 16:07:43 +04:00
Pavel Emelyanov
0a827aa96c net: Basic netns dump/restore skeleton
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 08:06:29 +04:00
Kinsbursky Stanislav
6243e9c0cb crtools: remove references to absent '-p' option
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-28 09:09:52 +04:00
Kinsbursky Stanislav
2249fb3c91 crtools: check optind is valid before parsing command argument
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-28 09:08:46 +04:00
Cyrill Gorcunov
f34cd5fd94 help: Drop -p option
We don't have it anymore

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-23 07:09:22 +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
76e7f12cb8 log: Fix loglevel assignment
For some reason the optind was misused (maybe I broke it with prev patch)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 17:25:04 +04:00
Pavel Emelyanov
0b76ba375e crtools: Add version constans and cmdline option
Set it to 0.0 since we haven't done any releases yet.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 16:51:58 +04:00
Pavel Emelyanov
dd16fec48c crtools: Sanitize options parsing
Do not presume that the argv[1] is action. Use the optind index at the end
of parsing instead. This allows to specify --help option properly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 16:50:04 +04:00
Pavel Emelyanov
2c978d84d3 crtools: Celan crtools.c from unneeded headers
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-28 03:15:01 +04:00
Pavel Emelyanov
611b97248b img: Move all the img files management code to image.c
And clean util.c and crtools.c from image manupulation code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-28 03:12:08 +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
Pavel Emelyanov
db297a0f97 mnt: Preparations for mountpoints dumping
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-12 03:30:10 +04:00
Pavel Emelyanov
3d64f9d140 crtools: Remove explicit FMT_FNAME_ macros
Just put names right into desc template array. Nobody uses
these individually.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-12 03:17:48 +04:00
Pavel Emelyanov
21075911cc image: Shorted fdset template description
Introduce a helper, that will declare one tmpl entry
with one line.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-12 03:12:12 +04:00
Pavel Emelyanov
5cfa8a6de1 crtools: Remove unused flags arg from parse_ns_string
Opts are now global and flags are just assigned on it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-12 02:34:22 +04:00
Andrey Vagin
fc7bedc50a crtools: make to be able to split messages by pid
If the option --log-pid is set, each process will have an own log file.
Otherwise PID is added to each log message.

A message can't be bigger than one page minus some bytes for pid.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 16:22:04 +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
1dc8527dea help: Reformat the help text
* Split dump/restore options from show ones
* Structure the former list
* Add the --tcp-established one

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-29 09:23:12 +04:00
Pavel Emelyanov
4debf589f6 tcp: Automate TCP stream c/r
This test is very basic :( Need more work on it.
One note about --close arg to crtools -- bash leaves all
fds open when laucnhing progams, and for restore this is
critical, as one of them can be busy. Iterating over all
the possibel fds and closing them is "do not want" thing.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-28 20:37:54 +04:00
Pavel Emelyanov
a53aa45be0 tcp: Initial image description
Introduce the image file for tcp info, its entry and the show method.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-28 17:59:21 +04:00
Pavel Emelyanov
051b0a1f02 tcp: Prepare sk-inet for dumping and restoring tcp connections
First of all -- to make crtools dump/restore established tcp sockets
you have to specify the --tcp-established options. By doing so you
inform crtools that

a) you know, that after dump there will be a netfilter rules blocking
   the dumped connections

b) you guarantee, that before restore this netfilter block is still
   there

What else this patch does is simple -- collects establised sockets and
calls the dump/restore tcp function (now empty) where appropriate.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-28 17:59:21 +04:00
Cyrill Gorcunov
19c1de828b sockets: Restore unconnected dgram sockets v7
In case if dgram socket peer is not connected back
we can try to resolve peer by name.

For security reason this happens only if '-x' option
is passed at checkpoint and restore time.

In particular this is needed for programs which do
use dgram socket to send messages to /dev/log.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-19 12:04:58 +04:00
Pavel Emelyanov
aec30b34db crtools: Add long options
By now equip all the short options with respective long one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 14:23:05 +04:00
Pavel Emelyanov
ed7586a7ad crtools: Rewrite options parsing via while
This avoids two duplicate lines.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 14:14:41 +04:00
Pavel Emelyanov
a1ccfb9297 files: Support dumping/restoring of completely unlinked files
Completely unlinked file is the one with n_link count being zero.
Such files only allow to read their contents and carry with us.

In order to dump this thing I introduce the "path remap" technology.
For reg file a remapping entry is dumped which describes, that at
restore stage before opening a regfile->path this path should be
linked to some other name and then (after open) unlinked.

For completely unlinked files the remap path would be a path to
a "ghost" file, i.e. a file which is created only at the time of
restore and which is removed completely at the end of it.

Partially unlinked files (i.e. those having n_link != 0, but a
path by which we see them in someone's fd is not accessible) should
be handled in another way.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 17:54:36 +04:00
Pavel Emelyanov
fe70efad29 mm: Split mm parts from task core image
The mm_xxx bits are per-mm_struct, not per-task_struct in kernel.
Thus, when we support CLONE_VM we'd better have these bits in a
separate image file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 14:51:37 +04:00
Pavel Emelyanov
e5e57e832b fs: Move info about cwd into separate file
Why? Because one day we'll support various CLONE_ flags and
for fdtable and fs info we'd like to have separate images (since
these objects are separate in kernel).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 13:41:05 +04:00
Andrey Vagin
96be8be2d1 pipe: save all pipe data in a separate file
A pipe buffer has 16 slots. A slot is page, offset and size.
When we use splice and data is not aligned, splice connects
a page from file cache and set offset. For this reason we loose
a part of buffer.

If a data size is more than 15 pages, data will be aligned in a image.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:23:57 +04:00
Pavel Emelyanov
2a33c4d5dc mem: Remove zero page from the end of mem image files
This was required when pages were stored in elf files for
exec. Now we can stop reading it on eof.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 14:07:31 +04:00
Pavel Emelyanov
c58abfd03d show: Introduce ->show callback for fdset
Each fdset item now has the callback which will show a contents of a magic-described
image file. Per-task and global show code is reworked to walk the respective fdsets
and calling ->show on each file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 12:01:14 +04:00
Pavel Emelyanov
82b7c07ca9 show: Fix 'all' mode showing
After we removed the pid from pstree image file the -t or -p option for show
command no longer makes sense. Make 'show' mode rely on -D option to find out
where to find the root (i.e. pstree.img) file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 11:04:23 +04:00
Pavel Emelyanov
4a3861acb8 fdset: Introduce glbal fdset
This contains reg-files and sk-queues images, as they contain data
which is potentially generated by every task, so keep it open all
the time dump goes.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:57:07 +04:00
Pavel Emelyanov
1fb1d94186 fdset: Introduce new fdsets
Current fdsets are ugly, limited (bitmask will exhaust in several months) and
suffer from unknown problems with fdsets reuse :(

With new approach (this set) the images management is simple. The basic function
is open_image, which gives you an fd for an image. If you want to pre-open several
images at once instead of calling open_image every single time, you can use the
new fdsets.

Images CR_FD_ descriptors should be grouped like

_CR_FD_FOO_FROM,
CR_FD_FOO_ITEM1,
CR_FD_FOO_ITEM2,
..
CR_FD_FOO_ITEMN,
_CR_FD_FOO_TO,

After this you can call cr_fd_open() specifying ranges -- _FROM and _TO macros,
it will give you an cr_fdset object. Then the fdset_fd(set, type) will give you
the descriptor of the open "set" group corresponding to the "type" type.

3 groups are introduced in this set -- tasks, ns and global.

That's it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:57:04 +04:00
Pavel Emelyanov
3858ee4950 fdset: Introduce two fdsets -- task and ns
Write two helpers for opening an fdset for task and one for ns.

This probably can be done with some "generic" macro(s), but this
time it's simpler not to produce more code of that type.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:57:00 +04:00
Pavel Emelyanov
bcf9ee3d1c fdset: Helper for getting fd out of a set
This patch does

s/$fdset->fds[$nr]/fdset_fd($fdset, $nr)/

over the code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:59 +04:00
Pavel Emelyanov
7241b9291b fdset: Kill ability to re-use fdset
It's not required any longer. Now fdsets are allocated one-by-one only
when required and there's no need in adding new fds to existing sets.

Thus just remove the last arg from cr_fdset_open.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:51 +04:00
Pavel Emelyanov
95f957b837 image: New image file for regfiles
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 21:11:58 +04:00
Pavel Emelyanov
97a1d8bb1c mm: Dump vmas into separate image file
The core image now contains only core per-task stuff.
The new file resurrects Tula magic number removed earlier.

Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 18:17:12 +04:00
Andrey Vagin
e869c16df5 mm: rework of dumping shared memory
vma_entry contains shmid and all shared memory are dumped in own files.
The most interesting thing is restore.
A maping is restored by process with the smallest pid. The mamping
is created before executing restorer.
We map a full mapping and restore it's conten, then we open a file from
/proc/pid/map_files and store a descriptor in vma_info. The mapping is
unmaped. Now we can map any region of this mapping in the restorer.

We use this trick, because a target process may have this mapping in
some places and the restorer has not function to open proc files.

v2: fix error hangling
xemul: Fixed static-s and args for cr_dump_shmem

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 11:03:55 +04:00
Andrey Vagin
31feef8ab4 mm: s/PAGES_SHMEM/SHMEM_PAGES
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 10:57:23 +04:00
Andrey Vagin
5dda50468b mm: change offset of zero_page_entry to ~0LL
Because 0 is actually a valid value.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 10:57:14 +04:00
Andrey Vagin
5ca347889e crtools: support any format of image path (v3)
Now a name of an image file is hard coded ("smth-%d.img", pid),
but the images of namespaces, shared memery, etc belong to
not one task, so they may have other formats of names, which
will describe objects.

For example a image of shared memory content may have name like
this ("pages-shmem-%ld.img", shmid)

v2: fix comment
v3: rebase

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-19 15:45:12 +04:00
Pavel Emelyanov
ffacd0f17c image: Open images via openat
Using absolute paths for this is dangerous - while doing c/r we should
be extremely carefully and not change tasks' roots and mount namespaces
too early. Sometimes it will not work -- when restoring containers we'll
be unable to switch to new CT and still have the ability to open images.

Rework the images opening via openat and keep the image dir fd open all
the time as the service fd (introduced earlier).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-16 20:45:50 +04:00