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

1696 Commits

Author SHA1 Message Date
Cyrill Gorcunov
401b4b89f1 util: Add read_fd_link helper
To fetch name of file opened from procfs.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-21 00:45:44 +04:00
Andrey Vagin
bce89dba4b restore: reserve the service descriptor for a control tty
I'm really lucky.

prepare_ctl_tty:
	e->fd           = get_service_fd(CTL_TTY_OFF); // -1 as fd is not set

send_fd_to_self:
if (dup2(fd, dfd) != dfd) { // tries to install sfd, but -1 == -1

tty_restore_ctl_terminal:
	if (!is_service_fd(fd, CTL_TTY_OFF))
		return fd == get_service_fd(type); // -1 = -1

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-18 23:04:09 +04:00
Andrey Vagin
5f5306eda9 crtools: remove declaration of rt_sigset_t
Actually rt_sigset_t and k_rtsigset_t are the same

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-15 19:11:25 +04:00
Pavel Emelyanov
39402af71a page-xfer: Simplify one page-pipe dumping
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-15 18:23:19 +04:00
Pavel Emelyanov
d36480ed05 mem: Raise the page images IDs base for page server
Currently shmem generates page images in parallel
with page server and IDs may intersect. Fix this by
making page server create larger IDs.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:28:38 +04:00
Pavel Emelyanov
213faeae6d mem: Introduce page server
The page server is a process, that is about to get pages over
the network and put them into pagemap- + pages- images. Right
now what it does is simply get the data and puts it into the
image files. When we have dirty set tracking in the kernel the
page server will have to collect "page changes" and properly
integrate them into images.

Running crtools with page server is like this:

dst_node# crtools page-server --port <port> -D dump/ ...
src_node# crtools dump -t <pid> --page-server --address <dst_node> --port <port> -D dump/ ...

After this images from dst_node/dump/ and src_node/dump/ should
be put into one place and tasks can be restored out of it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:16:44 +04:00
Pavel Emelyanov
02fc86958e mem: Abstraction layer for putting pages into image
We'll send them over network soon, so prepare abstraction layer for
this. Shmem is not on this scheme yet.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:16:43 +04:00
Pavel Emelyanov
8801f59615 mem: Protobuf format for page dumps
Since now we drain pages out of parasite, we can invent any format for
page dumps. Let is be ... prorobuf one! :)

Another thing to keep in mind, is that we're about to use splices and
implement iterative migration, so it's better to have actual pages be
page-aligned in the image.

And -- backward compatibility. That said the new format is:

1. pagemap-... file which contains a header (currently with a ID of
   the image with pages, see below) and an array of <nr_pages:vaddr>
   pairs. The first value means "how many pages to take from the
   file with pages (see below)" and the second -- where in the task
   address space to put them. Simple.

2. pages-... file which containes only pages one by one (thus aligned
   as we want).

This patch breaks backward compatibility (old images with pages wil
be restored and then crash). Need to do it before v0.5 release.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:16:41 +04:00
Cyrill Gorcunov
8a8c38b6a3 image: Move magic numbers to magic.h
This allows to reuse magic numbers outside of crtools code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-06 00:29:29 +04:00
Cyrill Gorcunov
8cbe560da3 image: Drop leftover macros
Unused

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-06 00:29:01 +04:00
Pavel Emelyanov
cf01381cbd mem: Drain memory from parasite before dumping it into file
Currently we dump pages directly from parasite into image files. This
is bad for several reasons:

1. We cannot use any more-or-less custom format for pages easily, since
   parasite code cannot be linked with any libraries;
2. We will not be able to optimize migration with preliminary memory
   migration (a.k.a. iterative migration) with it -- if we send pages
   from parasite over network we are not able to let the task we dump
   continue running.

That said, what is done is -- pages from target task are put into a
page-pipe in one go, then (not in this patch) parasite can be released
and we can do with pages whatever we want. For now pages are just
spliced from pipe into image file.

Some numbers:
In order to drain 1Gb of memory from task we need 1.5M of shared map
in args (for iovecs) and 4 pipes (8 descriptors) each referencing 128Mb
of pages, which int turn requires 4 x 640K chunks of sequential kernel
memory (for pipe_buffer). Not that big I guess.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-01 20:13:11 +04:00
Pavel Emelyanov
960694e96f page-pipe: Introduce object to collect pages within
The page-pipe is an object, that can accumulate pages inside it. It
consists of list of page-pipe-bufs, which in turn has a pipa, an
array of iovecs that describe the pages' locations and some stats.

Users of it are supposed to vmsplice pages into pipes to accumulate
then for later use, and vmsplice them from pipes when required.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-01 20:12:58 +04:00
Pavel Emelyanov
4d0b24b52a vma: Keep track of lonest vma in list and sum of its lengths
I will have to push some sort of map of pages to dump into parasite.
For this, I need to have estimation of how much memory I'd need for
than in parasite args. These two values will help with it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-01 20:12:33 +04:00
Pavel Emelyanov
8fdc707084 vma: Helper, that checks whether vma is dumped via parasite
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-01 20:12:02 +04:00
Pavel Emelyanov
b71f9e80be vma: Introduce list-of-vmas object
Right now when we collect list of vmas we need to know the
number of elements in it. In the future I will need to know
more, so it makes sense to create a vmas-list object for it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-01 20:11:51 +04:00
Pavel Emelyanov
7a7506f615 fd: Dynamically allocate args for the array of fds to drain
Just make use of previous patch. The creds dumping args are tuned to
fit one page (minimal static args size).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-01 20:11:38 +04:00
Pavel Emelyanov
b8d0d5e779 parasite: Make parasite arguments variable size
Sometimes we don't know the exact amount of data we would want
to send to parasite via args area (e.g. -- while draining fds).

Fix this, by moving the args area behind the parasite blob and
mmap-ing it with the run-time calculated size.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-01 20:11:28 +04:00
Cyrill Gorcunov
bdf8c565d9 lock: Include bug.h instead of big util.h
This makes it suitable to use in PIE code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-27 15:43:33 +04:00
Cyrill Gorcunov
19cc8a5eb2 Move BUG_ONs to include/bug.h
We will need futexes to use in PIE code but futex.h
uses BUG_ON helper, so to diet inclusions move BUG_ONs
code to include/bug.h.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-27 15:43:31 +04:00
Cyrill Gorcunov
94ef03947a pstree: Add general core_entry_free helper
This facrots out common core members freeing into pstree.c
helper. Per-arch freeing helpers are now symmetrical to the
allocating ones.

This is a merge of two Cyrill's patches.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-22 15:41:27 +04:00
Cyrill Gorcunov
03b95b5717 fpu: Move definitions to asm/fpu.h
The FPU data is quite CPU-type oriented,
thus move it to asm/fpu.h.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-18 18:42:08 +04:00
Cyrill Gorcunov
fcb9a9bfb1 cpu: Make cpu routines being per-acrh
They are really depends on CPU we're running on.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-18 18:42:08 +04:00
Cyrill Gorcunov
2f9f03a36b lock: Move inline attribute before function type
That's correct syntax.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-18 18:42:08 +04:00
Cyrill Gorcunov
75e1fb5c3a include/compiler.h: Cleanup
- Drop parasite \Space in NORETURN definition
- Align likely/unlikely

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-15 17:34:38 +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
Andrey Vagin
ef4783a646 check: Check for ability to get tcp timestamp
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-14 20:27:55 +04:00
Cyrill Gorcunov
b752e05e41 dump: Make sure we're dumping task not running in compat mode
It's been reported that we do not test if the tracee is 32bit
task running kn 64bit kernel. This patch adds such test.

https://bugzilla.openvz.org/show_bug.cgi?id=2505

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-14 20:26:29 +04:00
Cyrill Gorcunov
90fbbabb34 make: Generate crtools version from Makefile definition
This allows us to have a unique place where version lives
and what is more important other subsystems (such as docs
generation) may reuse version definitions.

At moment EXTRA (which corresponds kernels -rc tag) and
NAME is not yet used, but I desided to put them in place
for future needs.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-11 19:24:06 +04:00
Pavel Emelyanov
c77e52992b locks: Move dump_task_file_locks into file-locks.c
Make all locks code be in one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-08 02:58:10 +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
Andrey Vagin
ea767143f1 tty: require stdin to be a terminal only if shell_job is set
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-22 22:45:31 +04:00
Pavel Emelyanov
475bb1e775 rst: Evaluate per-task clone mask early
When we've read all pstree-items and their ids we
can get the desired clone-flags early and avoid all
these dances with flag calculations in fork_with_pid
and company.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-19 01:16:19 +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
Pavel Emelyanov
ac845bd1d8 cr: Obsolete the --namespaces option
It's no longer required to use this option -- two currently
supported cases (tasks on host and tasks in containers) can
be detected automatically. Keep this option for future.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:16 +04:00
Pavel Emelyanov
a46831aee9 cr: Detect namespaces presence automatically
Introduce the current_ns_mask variable, that collects info about
which namespaces tasks being dumped and to be restored live in.

For simlicity all tasks are supposed to live in one set of spaces.
This should be fixed eventually.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:10 +04:00
Pavel Emelyanov
15999f6b2f ids: Split routine that dumps task's IDs
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:24:55 +04:00
Pavel Emelyanov
2105e18eee core: Save tasks' namespaces IDs in the ids image
The recent kernels allow to get namespaces IDs by reading proc-ns links.
Use this to generate IDs for tasks' namespaces (I do generate them, since
IDs provided by kernel look ugly :( ).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:18:33 +04:00
Alexander Kartashov
2d70f89664 protobuf: cast the result of the macro pb_repeated_size to size_t
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:43 +04:00
Andrey Vagin
ce4c8c1d31 crtools: don't prevent to dump memory mappings on /dev/zero (v2)
Oracle has such mappings.

v2: add check, that a file is a character device

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:46:33 +04:00
Qiang Huang
4bf96b6680 crtools: restore flock&posix file locks
According to the file lock information from the image, we recall
flock or fcntl with proper parameters, so we can rehold the file
locks as we were dumped.
We only support flock and posix file locks so far.

Changelog since the initial version:
a. Use prepare_file_locks instead of restore function directly.
b. Fix some bugs.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:43 +04:00
Qiang Huang
95801808aa crtools: dump flock&posix file locks
Dump file locks' necessary entries to the image, we only support flock and
posix file lock right now.

Changelog since the initial version:
We got file lock info from global list, so the dump_task_file_locks
can be much simpler.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:41 +04:00
Qiang Huang
286801d4c1 crtools: collect and check file locks
We collect all file locks to a golbal list, so we can use them easily
in dump_one_task. For optimizaton, we only collect file locks hold by
tasks in the pstree.

Thanks to the ptrace-seize machanism, we can aviod the blocked file lock
issue, makes the work simpler.

Right now, the check handles only one situation:
-- Dumping tasks with file locks hold without the -l option.

This covers for the most part. But we still need some more work to make
it perfect robust in the future.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:07 +04:00
Qiang Huang
b08836cc51 pstree: add a function to check if a task is in pstree
Sometimes, when we parse some global info files, we can only care about
tasks which are taken into dump(such as file locks), which means their
pids are in the pstree.
So a function like this would be help.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:40:01 +04:00
Qiang Huang
de54cd4385 crtools: add image contents for filelocks
Some contents needed by filelock's image.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:40:00 +04:00
Qiang Huang
0de267ccdc crtools: add a callback to show filelocks-%d.img
Add a callback for filelock's image show.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:38:40 +04:00
Qiang Huang
c9797cfa27 protobuf: add a new description for saving file-lock
We need a new protobuf description for file-lock.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:38:11 +04:00
Qiang Huang
8f96ff85ff crtools: Add --file-locks option
Add --file-locks/-l option to support handling file locks, for safety,
only used for container.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:36:47 +04:00
Alexander Kartashov
7997f673be restorer: introduced the struct krlimit
The layout of the struct rlimit depends on the value
of the macro FILE_OFFSET_BITS. If FILE_OFFSET_BITS is 64
the userspace and kernel definitions becomes incoherent
on a 32-bit platform.

The struct krlimit representing the kernel version of
the struct rlimit is introduced to address the issue:
the function restore_rlims() is fixed to convert between
the userspace and kernel representations of the struct.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 19:15:40 +04:00
Alexander Kartashov
95bcaed4cb include/restorer.h: use the alias UserRegsEntry for UserX86RegsEntry
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 19:10:25 +04:00
Pavel Emelyanov
3a1c7d1d76 ns: Introduce ns descriptors
These are structs that (now) tie together ns string
and the CLONE_ flag. It's nice to have one (some code
becomes simpler) and will help us with auto-namespaces
detection.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-15 23:24:01 +04:00