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

191 Commits

Author SHA1 Message Date
Pavel Emelyanov
92a088a04c files: Restore fdflags on proper fd
After reopen_fd_as the original fd is closed.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-28 17:59:20 +04:00
Pavel Emelyanov
3b0a8e7c81 file: Factor out fowners and flags restore
This is common, that opened fd fix its fowner and flags. Make
a cuntion for this. Those that obtain fd with open() don't need
to restore flags though.

A thought -- do we need yet another abstraction between fdinfo and
type-d files?

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-26 15:30:26 +04:00
Konstantin Khlebnikov
bef7092834 Replace printf format "0x%x" with "%#x"
printf() has standard flag for adding "0x" prefix before hexadecimal integer.

MOD='[-+]\?[0-9]*.\?[0-9]*[lL]*'
git grep -l "0x%${MOD}x" | xargs -n1 sed -e "s/0x%\(${MOD}\)x/%#\1x/g" -i

Signed-off-by:    Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-24 15:20:24 +04:00
Pavel Emelyanov
e2f745b920 files: Simplify fd-s restore
Don't re-read fdinfo image 4 times on restore, just use those collected
on me pstree_entry instance.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-18 16:27:46 +04:00
Pavel Emelyanov
a72d858652 files: Collect fdinfo-s on per-pstree_item list
Later we'll be able to restore them without re-reading the fdinfo file again.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-18 16:24:08 +04:00
Pavel Emelyanov
0e57ce29be files: Put fdinfo entry on fdinfo_list_entry
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-18 16:03:14 +04:00
Pavel Emelyanov
b96dd2c400 files: Named constant for fdinfo_list_entry pool size
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-18 15:59:21 +04:00
Pavel Emelyanov
04800b6ed1 files: Rename fdinfo_list_entry's list to desc_list
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-18 15:46:04 +04:00
Cyrill Gorcunov
90ae972b9a files: Sanitize message on fd restoring
The message "Got fd for %d" is non-informative,
change it to "Restoring fd %d" since that is
what function does.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 12:37:38 +04:00
Kinsbursky Stanislav
35eedb5f1f output: add "0x" to hex prints using sed
Command below was executed several times:

sed 's/\(pr_.*[^%,x,X]\)\(\%[0-9,l,L]*x\)/\10x\2/g' -i *.c

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 12:33:35 +04:00
Pavel Emelyanov
a1ccfb9297 files: Support dumping/restoring of completely unlinked files
Completely unlinked file is the one with n_link count being zero.
Such files only allow to read their contents and carry with us.

In order to dump this thing I introduce the "path remap" technology.
For reg file a remapping entry is dumped which describes, that at
restore stage before opening a regfile->path this path should be
linked to some other name and then (after open) unlinked.

For completely unlinked files the remap path would be a path to
a "ghost" file, i.e. a file which is created only at the time of
restore and which is removed completely at the end of it.

Partially unlinked files (i.e. those having n_link != 0, but a
path by which we see them in someone's fd is not accessible) should
be handled in another way.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 17:54:36 +04:00
Cyrill Gorcunov
318535db97 fowners: Restore for regular files and pipes
The base idea is trivial, once file descriptor
created the owner is read and set up.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:28:51 +04:00
Pavel Emelyanov
13ee53a098 sockets: Save and restore fd flags for sockets
For regfiles this is done at open() time, for pipes thit is done with fcntl. Use
the same fcntl approach for sockets.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 13:20:03 +04:00
Cyrill Gorcunov
827f1a2f0b files: Don't call for run_unix_connections if there error happened earlier
It doesn't make sense to try to connect sockets if error
happened previously.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:54:49 +04:00
Cyrill Gorcunov
611343a50c files: Print the state of files restoring transition
It's confusing to see the output like

 | Got fd for 3
 | Got fd for 3

Better to point what is going on

 | Got fd for 3 (state -> 0)
 | Got fd for 3 (state -> 1)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:54:29 +04:00
Cyrill Gorcunov
a83ad7b813 files: Drop redundant lseek in prepare_fds
No need to obtain MAGIC_OFFSET from current position,
the files have predefined structure.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:54:12 +04:00
Pavel Emelyanov
05e3c4d2c9 fd: Handle close-on-exec bits
This bit is not per-file, but per-fd, thus put it on the fdinfo_entry.
Draing these bits from parasite together with the fds themselves, save
into image and restore with fcntl F_SETFD cmd where applicable.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:36:59 +04:00
Pavel Emelyanov
43367e2545 fdinfo: Rename fdinfo_entry addr to fd
Now we store only real fdtable entries in this file, so it's
time to name the field properly and change type to u32.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 16:18:33 +04:00
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