2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-23 02:17:22 +00:00

73 Commits

Author SHA1 Message Date
Pavel Emelyanov
14e5cdcb04 files: Remove dead desc opening code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 15:59:27 +04:00
Pavel Emelyanov
f560ddea55 files: Use open_reg_by_id helper where appropriate
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 15:57:05 +04:00
Pavel Emelyanov
447f369ba9 fd: Remove fs_is_special
It's no longer required. All the previously special fds are
now scattered over other images.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 15:54:28 +04:00
Pavel Emelyanov
b984eeff9c mm: Move exe file id on mm_entry
This is mm_struct entity, so save one there. Also gets rid
of special FDINFO-s.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 15:52:00 +04:00
Pavel Emelyanov
de66a5d04b fs: Reserve place for task's root dumping
Do not restore it yet -- the logic we're about to apply to
resolve tasks' paths relative to dumper/restorer is not yet
clear to me and it should better be hidden into a couple of
calls (dump_one_reg_file/open_fe_fd). But since we can't
chroot to fd we're about to expose the logic outside of the
open_fe_fd, which is not desirable ATM.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 13:52:42 +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
Pavel Emelyanov
69b3ebd002 vma: Remove FDINFO_MAP fd type
The regfile's ID of a VMA is stored in its shmid field. And the
file itself if sumped into regfiles.img image with 'special'-ly
generated ID (i.e. -- just allocate a new unique one).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 12:57:38 +04:00
Pavel Emelyanov
76c2818b95 files: Factor sending fd to peer via temp unix sk
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:20:28 +04:00
Pavel Emelyanov
b16293414b files: Generalize file open, get rid of explicit types switch
Introduce and use generic file_desc ops for this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 20:39:48 +04:00
Pavel Emelyanov
3c174a885d files: Generalize fd restore, make file_desc common hash
No need in per-type hash tables and search routines. We can
handle it via generic file_desc structure. Some more thoughts
on unixsk and pipe lists are still required :(

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 20:30:48 +04:00
Pavel Emelyanov
527b67b91f files: Generalize fd restore, introduce file_desc
The struct replaces bare list_head on all of the _info-s we've
introduced recently.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 20:08:48 +04:00
Pavel Emelyanov
b386751697 sockets: Rework unix sockets onto fdinfo scheme
This is a big change, yes. Dump unix sockets in the same manner
as all the other files are done now. A few notes however.

1. We explicitly drop names for connected stream sockets. This is
   done to avoid conflicts with names -- accepted sockets share their
   names with the listening parent. This can be done later by binding
   a socket to a name, them renaming it to some temporary uniq one
   and at the very very end renaming some back to original.

2. Interconnected sockets are restored via socketpair() call. This is
   correct, but names are dropped. Need to bind() sockets after this
   (yes, this can be done), but for this we need to implement the trick
   with renames described before.

3. FD for socket queues is constantly re-opened not to resolve fd
   conflicts. Need to use service fds engine for this later.

4. Some code cleanup is still required, yes (will follow shortly).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 19:27:08 +04:00
Andrey Vagin
7b10ef0761 pipes: add functions to restore pipes
[xemul: This check in open_transport_fd should go away once we
        implement opening files with peers. ]

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:23:48 +04:00
Andrey Vagin
373a93248f files: some types of objects want to open transport for masters
For example it's pipe.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:22:42 +04:00
Andrey Vagin
4f2bd37704 pipes: add functions for collecting pipes
pipe_entry is encapsulated in pipe_info.
All pipe_info-s connects in the list pipes.
All pipe_info-s with the same piep_id connects to pipe_list,
it a circular list without a defined head.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:22:16 +04:00
Andrey Vagin
216233d104 files: add some function in files.h
They will be used to restore pipes

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:18:02 +04:00
Pavel Emelyanov
6e562b0c9c files: Remove unused fn
It was used in old code, now it can be dropped

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 20:43:40 +04:00
Pavel Emelyanov
12316c4994 files: Ease the fd collecting
No need in separate per-type fn for doing this. We can just
find the respective fd list and do sorting in the generic code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 16:54:10 +04:00
Pavel Emelyanov
b4edfa7891 files: Dup local files on open, not receive
This will be needed for pipes, since we can't keep the pipe's
other end till that for dup.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 12:50:33 +04:00
Pavel Emelyanov
b9f13599a9 files: Simpler regfiles and sockets open
The list_head ptr passed into it can be converted into
the respective _info with container_of, rather than search.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 12:49:34 +04:00
Pavel Emelyanov
d1c9f0d71c files: Show collected regfiles fd tree
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 12:48:57 +04:00
Pavel Emelyanov
eee874e465 files: Rework the way fdinfos are collected
Now fdinfos are collected independently from reg files and
sockets. During tihs collect we effectively create the mirroring
list of both by checking which type-IDs are added first.

Fix this by removing the fdinfo_desc and attaching fds directly
to collected reg files and sockets. Pipes and unix sockets will
be reworked in the same manner soon.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 12:45:30 +04:00
Pavel Emelyanov
84678526ac files: Read regfiles image in early on restore
Instread of re-reading this image again and again on every fd restore, pull the
reg-files.img in early and store the entries in a hash. This will simplify the
further fd restoring fixes and will allow for dump/restore via a stream (socket).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-03 00:50:50 +04:00
Cyrill Gorcunov
e857977bb6 files: Add case::default in open_fd
Otherwise I'm getting error
 |
 | files.c: In function ‘prepare_fds’:
 | files.c:329:23: error: ‘tmp’ may be used uninitialized in this function [-Werror=uninitialized]
 | files.c:309:6: note: ‘tmp’ was declared here

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-02 22:36:38 +04:00
Pavel Emelyanov
68a793a05c files: Users counter is not required on file desc
It's used only to check whether we should do file re-send and verify we've served
all the cliens. This can be replaced with proper list manipulations.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-02 21:58:34 +04:00
Pavel Emelyanov
89492de3ef files: Real pid on fdinfo_desc is unused
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-02 21:55:47 +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
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
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
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
af57e42e03 files: Sanitize fd logging
Don't print namelen (it's useless) and type (the code being patched
works with FDINFO_REG only).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-25 20:59:11 +04:00
Pavel Emelyanov
5b44cbd890 restore: Restore cwd with fchdir
Use the open_fe_fd everywhere to obtain an fd from image.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-24 19:56:13 +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
Pavel Emelyanov
7a98cd2bf4 files: Sanitize fd restore state machine again
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-23 12:19:35 +04:00
Pavel Emelyanov
ebc1ac8bc5 files: Factor out transport name generation
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-23 12:19:24 +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
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
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
Cyrill Gorcunov
2acc741a3a files: Use sys_kcmp to find file descriptor duplicates v4
We switch generic-object-id concept with sys_kcmp approach,
which implies changes of image format a bit (and since it's
early time for project overall, we're allowed to).

In short -- previously every file descriptor had an ID
generated by a kernel and exported via procfs. If the
appropriate file descriptors were the same objects in
kernel memory -- the IDs did match up to bit. It allows
us to figure out which files were actually the identical
ones and should be restored in a special way.

Once sys_kcmp system call was merged into the kernel,
we've got a new opprotunity -- to use this syscall instead.
The syscall basically compares kernel objects and returns
ordered results suitable for objects sorting in a userspace.

For us it means -- we treat every file descriptor as a combination
of 'genid' and 'subid'. While 'genid' serves for fast comparison
between fds, the 'subid' is kind of a second key, which guarantees
uniqueness of genid+subid tuple over all file descritors found
in a process (or group of processes).

To be able to find and dump file descriptors in a single pass we
collect every fd into a global rbtree, where (!) each node might
become a root for a subtree as well.

The main tree carries only non-equal genid. If we find genid which
is already in tree, we need to make sure that it's either indeed
a duplicate or not. For this we use sys_kcmp syscall and if we
find that file descriptors are different -- we simply put new
fd into a subtree.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-28 19:13:47 +04:00
Cyrill Gorcunov
8b187454b4 files: Rename prepare_fdinfo_global to prepare_shared_fdinfo
This function simply allocates shared memory. Name it so
and move it closer to the variables it referes on.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-28 19:13:47 +04:00
Cyrill Gorcunov
4d3b3e8166 files: Rename pop_fmap_fd to pull_fmap_fd
The function has nothing to do with "pop" operation,
it rather "pull"s descriptor out of list. Name it so.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-28 19:13:47 +04:00
Cyrill Gorcunov
69fefa4d65 files: Move structures and enums into the header
Having them in the header file will allow to share these
structures with other callers. Moreover, this is a good
practice to have definition(s) in header file until otherwise
really needed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-28 19:13:47 +04:00
Kir Kolyshkin
b5a377ca7d files.c: fix error message
Use perror since read() set errno.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-11 11:58:06 +04:00
Cyrill Gorcunov
76a249282e restore: Add checkpoint/restore for /proc/pid/exe symlink
This patch adds ability to checkpoint/restore
/proc/pid/exe symlink, so if a process we've just
checkpointed has been say /path/to/exe, then at restore
time we bring this path back.

There some restiction from kernel side: if
existing /proc/pid/exe already mapped more than
once, the kernel will refuse to change the symlink,
so we need to restore it lately when mmaps of crtools
itself already unmapped (ie via late call in
restorer.c).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-07 20:08:01 +04:00
Pavel Emelyanov
75cb79973e files.c: Use RW API
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:18:25 +04:00
Pavel Emelyanov
a038cbd9b8 files: Fix memory overflow checks for shared files.
Otherwise we skip shared segment
overflow on big scales and tests sporadically fail.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-02 01:34:40 +04:00
Andrey Vagin
1465fade3b util: move recv_fd and send_fd in a separate file
It will be used in the parasite

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-01 19:26:41 +04:00