2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00
Commit Graph

1095 Commits

Author SHA1 Message Date
Pavel Emelyanov
320f57b0e5 dump: Cleanup regfiles fd generation
Move the preID generation from dump_one_fdinfo to make it look cleaner.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 16:41:43 +04:00
Pavel Emelyanov
f4968e2d05 dump: Do not forget to close drained fds
A bugfix. Drained fds should be closed after we are done with them.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 16:40:50 +04:00
Pavel Emelyanov
bac56b11c0 sockets: Remove statfs and 2nd stat from dump process
The statfs is not required, we now check for fd being a socket with S_IFSOCK.
The 2nd stat is just not needed, the caller provides stat info.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 16:40:10 +04:00
Pavel Emelyanov
250d0764d6 dump: Remove ID arg from dump_one_pipe
One can be read from fd_parms.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 16:38:59 +04:00
Pavel Emelyanov
64195c3458 dump: Move stat on fd_parms
This structure is actualy an fd parameter, so put it there. This will also
help with future patching.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 16:38:30 +04:00
Pavel Emelyanov
8ecb454bf7 dump: Rename try_dump_socket
Try meant that it might not be a socket, but with local fds we do know
it for sure.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 16:37:49 +04:00
Cyrill Gorcunov
ecc0b90992 dump: Use parasite file descriptors draining
Since we're able to simply drain file descriptors
we're interested in, just do that with parasite
help.

This changes the calling sequence a bit

 1) Collect file descriptors before parasite
    get intected the dumpee and remember them in
    local copy.

 2) Ask parasite to drain collected descriptrs
    into our space.

 3) Operate with file descriptors directly via fcntl
    calls and such.

Overall idea is to prepare ground for fowners
dumping which will be 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:30 +04:00
Cyrill Gorcunov
0ddcfbf265 parasite: Add interface for file descriptors draining
Just implemented but not yet used in dumping procedure,
this will be addressed in further patches.

Note the space for file descriptors is statically allocated
in 8K arguments area, not on stack.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 15:14:26 +04:00
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
5813cd0b55 util-net: Switch send_fd/recv_fd to use scm_fdset structure
To be able to use scm_fdset structure the two helpers
added scm_fdset_init_chunk and scm_fdset_init.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 15:14:19 +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
652363d7fc log: Specify logfile mode when creating one
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-28 00:48:13 +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
65db28eafc restore: Helper for vmas list remap and copy
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 18:42:12 +04:00
Pavel Emelyanov
7f0b083a00 restorer: Round size of area with self vmas up to page size
These chunks of memry, which transit into restorer code gets unmapped one-by-one and thus each of them
should be page-aligned.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 15:32:45 +04:00
Pavel Emelyanov
bbf17398a0 dump: Use O_DUMP flags for single image opening
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 15:20:38 +04:00
Pavel Emelyanov
ad1aed62a0 img: Fixup seeks
There's no need in seeking file on core dump.
Fix explicit sizeof(u32)-s in restore seeks.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 15:16:09 +04:00
Pavel Emelyanov
40a79dbc98 sockets: Show socket info in human-readable form
IOW, show family, type, state and proto as strings, not bare numbers.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 13:11:23 +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
98526bd240 files: Remove unused fd arg from open_fe_fd
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 12:10:11 +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
0c5dc42d6e dump: Don't forget to close fdset when task dump ends
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:58:22 +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
49cfa97954 show: Don't allocate fdset to show thread
Just use the open_image_ro for this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:56 +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
b77400fe24 dump: Allocate task fdset when needed
Move the fdset allocation inside dump_one_task and do it only for
non-zombies.

This makes sure we don't need to re-use an fdset, since we do allocate
it only when required.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:47 +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
Pavel Emelyanov
12147a0cbd show: Fix and clean cr_show_all
Don't allocate fdset to show sk queues and don't fail on pstree
fd opening :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:42 +04:00
Pavel Emelyanov
7eb3748637 dump: Make dump_task_core work on fd
This routine is used for dumping tasks, threads and zombies. For the
last two the whole fdset is not allocated thus it will be better to
use single fd in this case.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:31 +04:00
Pavel Emelyanov
dfe0f65ff6 parasite: Make parasite_prep_file work on fd
It doesn't need the whole fdset actually. Plus, this makes new
fdset implementation simpler.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:25 +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
90376f2286 repo: Add mailmap file
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 23:31:20 +04:00
Pavel Emelyanov
780ff64905 files: Move reg-file dumping routine into separate fn
This makes the code look cleaner and prepares the ground for better fmaps dumping

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 21:37:39 +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
ea045dac61 file-ids: Report whether a new id was generated
This will be required to determine whether we should dump the respective
file, or it was already dumped and we just re-use its id in fdinfo_entry.

For special fd-s the ID is always new.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 21:04:34 +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