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
d360133fa6 util-net: Itroduce send_fds/recv_fds routines
We will need these helpers to transfer file
descriptors from dumpee to our space.

Also make send_fd/recv_fd to be a wrappers over
send_fds/revc_fds to not duplicate the code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 15:14:23 +04:00
Cyrill Gorcunov
333ce8fce2 util-net: Add declaration of scm_fdset structure
This structure will serve for multiple fds transmission/receive.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 15:14:15 +04:00
Cyrill Gorcunov
ee82f0cf0e types: Add SCM limits
We will need them in file descriptors transfer addressed in further patches.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 15:14:10 +04:00
Cyrill Gorcunov
998cb619fe Add builtin_memcpy helper
We will need it in parasite code where we can't use libc functions.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 15:14:06 +04:00
Cyrill Gorcunov
2c11239159 rb: Drop rb_attach_node
It's unused and wrong.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-28 20:28:29 +04:00
Pavel Emelyanov
2b175282fb restore: Don't write to vma image on restore
This is not good to update images while restoring.

Thus, read vma_entry-es once into a list, put opened (when required) fds
in there and make restorer walk the entries in mem, not those read from
the image file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 18:42:18 +04:00
Pavel Emelyanov
9b2617353b inet: Rework inet sk dumping on new fdinfo scheme
Now every inetsk fd dump results in a new entry in the fdinfo.img file. Sockets itself are
dumped into inetsk.img global image file. On restore the generic fdinfo redistribution algo
is used and inet sockets are opened only when required.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 12:42:59 +04:00
Pavel Emelyanov
34b047a585 files: Search fdinfo_descs by id and type
Currently only type is taken into account, but further we will need to distinguish
types as well.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 12:42:20 +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
Cyrill Gorcunov
71cc2733a7 lock: Add own type and helpers for mutexes
To be consistent. Mutexes are futex based but have
own semantics so better to be able to distinguish
the types.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 11:37:50 +04:00
Cyrill Gorcunov
dc848fae7a lock: Introduce futex_t and appropriate helpers
Instead of open-coded u32 variables poking lets use
futex_t type and appropriate helpers where needed.

This should increase readability.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 11:37:27 +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
44a6dd4ff5 fdset: Reorder CR_FD_ types
Move pstree and sk-queues below, they are not per-task/-ns and
will be global soon.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:57:02 +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
f1429be087 dump: Don't include sk-queues fd in task set
This fd is global, so make it such. It will stop being just a global
variable soon.

Plus, remove the pid arg from format.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:44 +04:00
Stanislav Kinsbursky
b82edc9fdf crtools: dump pstree to image file without pid number
Pid number is redundant - this file is one for the whole tree.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 15:46:07 +04:00
Stanislav Kinsbursky
f659f64247 crtools: make pid parameter optional for open_image_ro()
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 15:43:44 +04:00
Pavel Emelyanov
6b79601ccb files: Split regfiles info into separate file
Since now on the fdinfo image only contains plain fdinfo_entry-es.
The tpye == FDINFO_REG files are described by regfiles.img entries
and are matched by te ID in both.

At dump stage each new ID generated results in a new entry in the
regfiles.img. At restore stage open_fe_fd should open a regfile by
the fdinfo's ID. Now this is done in suboptimal way, need to improve.

Show shows both images separately.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 21:15:16 +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
0fb534a947 util: Fix open_image_ro definition
No colon at the end and handle empty ... set properly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 21:05:32 +04:00
Pavel Emelyanov
500468d4e7 files: Split fdinfo in two parts
Make fdinfo_entry carry only the minimal info describing a file
descriptor -- the fd value itself, the fd type (regular file, exe
link, cwd, filemap and it will be pipes, sockets, inotifies, etc.)
and the describing file ID.

The mentioned ID will identify the type-d object, e.g. for regfiles
this ID is already generated with file-ids.c code.

The other part of this structure describes a regfile (i.e. a file
opened with open syscall). I put this new entry at the end of the
fdinfo_entry just to make the patching simpler. Soon this entry
will be dumped into its own file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 21:03:26 +04:00
Pavel Emelyanov
159d3bdfd5 fdinfo: Sanitize types in fdinfo_entry
The namelen is u16, to cover the PATH_MAX u8 is not enough.
The pos is u64, since file offset is that long indeed.
The id is u32 as per previous patch.

Fix printf-s respectively.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 21:00:35 +04:00
Pavel Emelyanov
c92c9e234e file-ids: Enlighten ID generation and storage
The unique id is 32 bit and consists only of the subid value. This
is _really_ enough. The genid part is just a hint for the tree-search
algirythm to avoid unneeded sys_kcmp calls.

Plus, generate IDs for special files. This will make it easier to
move the regfiles into into separate files (see the respective patch
for details).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 20:58:19 +04:00
Pavel Emelyanov
308f6150c2 file-ids: Fix collect genid type
It is u32 and that is it :\

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 17:00:06 +04:00
Pavel Emelyanov
ed67491c45 file-ids: Show collected subtree at the end of dump
Just for debugging. Useful to know how the tree was built

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 16:52:09 +04:00
Pavel Emelyanov
7a451ff108 rst: Open exe link fd early
Open the exec link at fd restore stage as yet another service fd,
then pass it to restover via args and just call prctl on it.

This is good for several reasons -- the amount of code required for
this is less and opening files should better happen before we switch
to restorer (opening will be complex and it's MUCH easier to open all
we need in one place).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 15:30:20 +04:00
Stanislav Kinsbursky
12c5801749 dump: files tree - return id upon collect instead on inner structure
Hide the structure - it's not required.

[ xemul: Ranem long id into u32 id and adopt to current tree ]

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 00:40:52 +04:00
Stanislav Kinsbursky
b68b3d5dd5 dump: convert fd types into enum
This is a precursor patch. Macro for max possible fd type will be required.
And it's easier to use enum in this case.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 00:31:58 +04:00
Pavel Emelyanov
488790b677 util: Remove dead code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 21:17:44 +04:00
Pavel Emelyanov
6faac3a39e rst: Factor out vma fd fixup
Just make the fixup_vma_fds read and write vma images and
those called by it provide and fd for this.

Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 14:00:27 +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
c3051512f3 crtools: delete CORE_OUT
It's a rudiment from old times, when restore worked via ececve.
Now we modify the core file in place to fixup vma-s.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 11:06:10 +04:00
Andrey Vagin
650be3d2be mm: clean up parasite (v2)
Now it has only one descritor for dumping pages

v2: remove rudiments

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 11:04:17 +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
37a6c1fc88 mm: move shmid to vma_entry (v2)
It will be used to restore shared mappings

v2: clean up

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 10:56:31 +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
Cyrill Gorcunov
4b1f8d0840 parasite: Refactor code to follow calling convention
It happened some routines in parasite service code
were not following calling convention so I fixed the
callers and added a comment about adding new code here.

At the same time the 3 error code madness is dropped
as being requested by Pavel -- now we return one error
code only.

The PARASITE_ERR_ codes were dropped as well due to
become redundant.

The status of parasite service routine is set via
SET_PARASITE_RET helper. In case if there is no error --
just return 0. The calling code should not expect to
find anything sane in parasite_status_t because parasite
code might not touch it at all.

Same time, due to this convention the parasite's
dump_socket_queue is getting rid of third @err
member, because it's now returned as a regular
error code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-19 13:53:14 +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
Pavel Emelyanov
3dd8f2e659 fds: Introduce service fd-s
These are the fds that help us to do c/r. We want them not to intersect
with any "real-life" ones and thus store them close the the file rlimit
boundary. For now only the logfd one is such.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-16 20:45:42 +04:00
Cyrill Gorcunov
59890c3b28 parasite: Drop unneeded PARASITE_CMD_PINGME command
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-15 20:30:43 +04:00
Kinsbursky Stanislav
fe1cf26085 dump: add const qualifiers where possible
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-06 17:00:42 +04:00
Kinsbursky Stanislav
c1999ec58e dump: use fd_params->type for cwd and exe magic
This is a cleanup patch. Use file entry type variable for special files
instead of file entry addr variable.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-06 16:59:28 +04:00
Pavel Emelyanov
85f18ef02f restorer: Pass self-vmas via memory, not temp file
Reserve more mem for bootrstrap code and put all self vmas at its tail.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 21:31:35 +04:00
Pavel Emelyanov
bad126e7a5 sock: Add dst creds to socket structs
These are required for inet sockets, but were not added since listen
sockets do not have them.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00