2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 04:48:16 +00:00

289 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
fb6f22749e dump: Remove 2nd mappings free call
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 17:07:53 +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
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
Pavel Emelyanov
5f788993a5 dump: Remove dead find_vma_by_addr
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 21:01:02 +04:00
Pavel Emelyanov
1b5c403241 dump: Sanitize pstree dumping
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 20:51:47 +04:00
Stanislav Kinsbursky
3e8e358d82 dump: merge collect and dump stage for processes tree
This is a cleanup patch. This tree is merged only once. So it's image file can
be opened by opne_image() call and dumped right after collect stage.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-22 20:24:08 +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
Pavel Emelyanov
f212e6fe37 dump: Reformat vma dumping a little
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-21 11:33:54 +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
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
Pavel Emelyanov
2b9fd6ce17 dump: Formatting of regs dump fixup
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-17 01:02:55 +04:00
Stanislav Kinsbursky
8b7497a5ef dump: dump pstree outside tasks loop
No need in checking the pid in every task loop cycle, just dump it
at the beginning and that's it.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-16 15:40:40 +04:00
Cyrill Gorcunov
45b76a9a9a dump: Don't shadow the ret code with dump_namespaces
cr_dump_tasks does assign ret = -1 by default but
dump_namespaces does shadow this variable with own
error code so that if any subsequent calls will fail
we will not notice the error.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-15 20:19:46 +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
a544b6842c sockinfo call indentation fix
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-04 17:07:00 +04:00
Pavel Emelyanov
7b7f09e4f0 sanitize vma types parsing
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-04 17:06:36 +04:00
Pavel Emelyanov
fc225709b0 proc: Make parse_maps return the amount of them found
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 21:31:35 +04:00
Kinsbursky Stanislav
a26d524011 dump: rename st_buf to fd_stat
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 11:25:46 +04:00
Kinsbursky Stanislav
698fe036d0 dump: hide check for fifo
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 11:25:46 +04:00
Kinsbursky Stanislav
ba6ac0104e dump: remove else
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 11:25:46 +04:00
Kinsbursky Stanislav
81060211c5 dump: hide fd type into fd_params structure
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 11:25:46 +04:00
Kinsbursky Stanislav
42963b9450 dump: hide fd open in dump routine
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 11:25:46 +04:00
Cyrill Gorcunov
7aa8e4b6e2 log: log-engine slight redesign
The messages are filtered by their type

    LOG_MSG     - plain messages, they escape any (!) log level
                  filtration and go to stdout
    LOG_ERROR   - error messages
    LOG_WARN    - warning messages
    LOG_INFO    - informative messages
    LOG_DEBUG   - debug messages

By default the LOG_WARN log level is used, thus LOG_INFO
and LOG_DEBUG messages will not appear in output stream.

pr_panic helper was replaced with pr_err, pr_warning
shorthanded to pr_warn and old printk if rather pr_msg
now.

Because we share messages between "show" and "dump" actions,
before the "show" action proceed we need to tune up
log level and set it to LOG_INFO.

Also note that printing of VMA and siginfo now
became LOG_INFO messages, it was not that correct
to print them regardless the log level.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-02 01:05:43 +04:00
Pavel Emelyanov
1e98f53cca dump: Stop scanning at once if list is empty
Empty list on scan error means, that the very top task ran away from
us. There's no point in trying to catch one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-01 19:31:21 +04:00
Pavel Emelyanov
ae9f1bfdc4 dump: Restart seize in case reparent occurred
This can happen while dumping a pid-namespace (we can't do it now), thus
put this check not to forget one in the future.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-01 19:31:21 +04:00
Pavel Emelyanov
a1fe2c58a9 dump: Try to seize task tree several times on error
Tasks can fork or die while we try to seize them. It's much more simpler
and much more reliably to unseize what was seized and walk the tree again
in case of some tree check failed.

Yes, this makes it impossible to suspend a big tree which constantly forks :(
but I'd prefer fixing more urgent issues before.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-01 19:31:21 +04:00
Pavel Emelyanov
9e0b308af0 dump/restore: Rework final-state switch
Remove CR_TASK_XXX states, use the TASK_XXX ones (for image). This is
required to unseize tasks properly in the next patches.

Plus, make sure that pstree_list and the seized set coincide (i.e.
handle error in collect_task).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-01 19:31:20 +04:00
Pavel Emelyanov
0afad031d5 dump: Check for process/threads tree not to change after seizeing
When we've seized all the tasks and threads found in /proc check for
the /proc contents be the same. Do it one-by-one as we descend the tree.
This is OK, since tasks cannot create kids for anyone but themselves or
their parents (reparent will be handled later).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-01 19:31:20 +04:00
Pavel Emelyanov
30a2b6f314 dump: Don't pass pid to children parser routine
It's in item already.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-01 19:31:20 +04:00