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
Pavel Emelyanov
6ed9f87269 proc: Make small stat parsing read pgid and sid
They are just two next in this file, so extend. This is
required for pgid/sid early read, see next patches for
details.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:09:12 +04:00
Pavel Emelyanov
2a0c526b6d dump: Save pstree_item's parent on item, not ppid
This is trivial change, but is required to check for pgid/sid
are in 'restorable' state, see for respective patch/code for
details.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:07:47 +04:00
Pavel Emelyanov
b17c49aa99 rst: Wait till everyone completes forking on restore
New stage CR_STATE_FORKING. This is required to restore pgids
properly -- we need to make sure a task with pid whose pgid we
are about to enter is alive. And this task is not necesserily
our parent, thus wait for everyone to appear.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:06:36 +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
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
30224abcb6 util-net: Make send/recv fds carry fd flags in message
The flags are only one bit in the kernel (close-on-exec, all the rest are not per-fd, but per-file),
but for simplicity I save it in a char field.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:36:13 +04:00
Pavel Emelyanov
e8cdf57f40 syscall: Add fcntl syscall and F_GETFD cmd
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:35:54 +04:00
Pavel Emelyanov
6af08c3326 fd: Sanitize fd_parms fd_name field
It used to be ulong, but it can be int now (no mapping addresses there). And the
name fd is better than fd_name (reason is the same).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 17:49:39 +04:00
Pavel Emelyanov
8b80a1e30c files: Remove obsolete fmap_fd structure
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 19:09:50 +04:00
Pavel Emelyanov
1d6578bbd5 kcmp: Dump task's objects shared with CLONE_ flags
Just dump their IDs and check they are not shared. For future.
IO and SEMUNDO is not there since tasks may have NO such objects
and currently we cannot detect whether they have them equal or
both don't have.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 18:02:00 +04:00
Pavel Emelyanov
3386535491 kcmp: Introduce generic object ID generator
Just move the patched code from file-ids.c to kcmp-ids.c and
make the former one be client for the latter.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 18:01:18 +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
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
fe70efad29 mm: Split mm parts from task core image
The mm_xxx bits are per-mm_struct, not per-task_struct in kernel.
Thus, when we support CLONE_VM we'd better have these bits in a
separate image file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 14:51:37 +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
28a1474779 usk: The INFLIGHT flag is no longer used
It was required before we switched to socketpair restore
scheme. Now it's not required, sockets just connect to
the peer they want to.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:43:19 +04:00
Pavel Emelyanov
705bf5aba6 img: Hide image dir fd into util.c
No image copy occurs since 2b175282, so this
fd can be hidden. Thus fixind the FIXME near it :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:39:10 +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
96be8be2d1 pipe: save all pipe data in a separate file
A pipe buffer has 16 slots. A slot is page, offset and size.
When we use splice and data is not aligned, splice connects
a page from file cache and set offset. For this reason we loose
a part of buffer.

If a data size is more than 15 pages, data will be aligned in a image.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:23:57 +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
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
Andrey Vagin
bdb3932be5 pipe: all pipes are saved in one file (v2)
Information about pipe's file structs saved in one global file and
fdinfo_entry is saved for each descriptor

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 21:17:24 +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
Cyrill Gorcunov
aca2c976c0 proc: Add missing includes into proc_parse.h
Since proc_parse.h declares functions which have
list_head as arguments, it should include list.h
and basic types.

Otherwise if included into the files without list support
the compilation might fail as
 |
 | In file included from cr-check.c:5:
 | ./include/proc_parse.h:83: error: expected declaration specifiers or ‘...’ before ‘bool’

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 16:39:15 +04:00
Pavel Emelyanov
056f41fb46 img: Remove unused open_image_ro_nocheck
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 15:43:50 +04:00
Pavel Emelyanov
a541fa8df3 rst: Remove unused pstree_pid
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 14:23:21 +04:00
Cyrill Gorcunov
d7961998bd lock: Restore ability to abort on futex waiting
In commit 71cc2733a79efba65d3466f784b19d17805cf50d
I occasionally dropped the ability to abort on waiting
(because we used signed -1 value to inform waiters that
something is wrong and waiting should be aborted, but
the type was changed to unsigned one and as result
this condition never triggers).

So to resolve it futex_abort_and_wake() is added and
should be used explicitly where appropriate instead
if signess hack.

Reported-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 14:07:39 +04:00
Pavel Emelyanov
2a33c4d5dc mem: Remove zero page from the end of mem image files
This was required when pages were stored in elf files for
exec. Now we can stop reading it on eof.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 14:07:31 +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
54c1979c84 unix: Collect unix sockets early on restore
Same as prev 2 patches now for the unix sockets. They are still in per-pid image files, but
this is going to change soon (I hope).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-03 00:58:41 +04:00
Pavel Emelyanov
94a11df0a1 inet: Collect inet sockets early on restore
Same as previous patch -- pull inet sockets in and store in the hash for the same reasons.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-03 00:54:52 +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
e437e616af parasite, restorer: Cleanup ld scripts
There is no need for specific parasite or restorer
head sections, a general "head" one is enough.

Also .stack section is dropped since it's never used.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-02 22:43:22 +04:00
Cyrill Gorcunov
c859dbcc29 parasite: Drop unused PARASITE_COMPLETE_ADDR helper
It has been used when debuggin without PTRACE_SEIZE,
not needed anymore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-02 22:40:08 +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
66771c8fbc sockets: Dump socket queus without parasite
Since now we have local copies of a remove FDs we can dump socket queus without entering
a parasite code. This makes the code MUCH simpler.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 16:44:15 +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
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
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