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

289 Commits

Author SHA1 Message Date
Pavel Emelyanov
fc830ddca9 anoninode: Report error when dumping unknown anon file
It will fall through all the other checks, but let's do it
explicitly for better code understanding.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 16:13:50 +04:00
Pavel Emelyanov
6a55c1c596 dump: Move per-type dump opts into respective .c files
No functional changes, just a code move.

TODO:

* need to write personal make_gen_id implementations for special
files (device and pos is const for them effectively)
* need to merge dump ops with restore ones (file_desc_ops)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 15:34:55 +04:00
Pavel Emelyanov
2cea6414e6 fdpsrms: Remove now unused type field
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 15:28:28 +04:00
Pavel Emelyanov
f509fcf03f dump: Introduce file dumping operations
Now all the fds dump look very similar and we can reimplement
it via indirect calls.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 15:25:25 +04:00
Pavel Emelyanov
37a3ed86f4 dump: Split dumping reg file and pipes
Reg files are those obtained by open() syscall on restore.

Pipes should be checked to belong to pipefs (fifos are not supported
yet).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 15:06:20 +04:00
Cyrill Gorcunov
bff52ba952 inotify: Add checkpoint/restore v2
v2:
 - open_mount is cleaned up
 - byte-stream hex conversion remains untouched since
   strtol is flipping numbers to LE manner

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 14:00:45 +04:00
Cyrill Gorcunov
b38777dff4 eventpoll: Add checkpoint/restore v2
v2:
 - Move everything into eventpoll.[ch]
 - Use rst_file_params

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 14:00:05 +04:00
Cyrill Gorcunov
889795da5d eventfd: Add checkpoint/restore support v2
v2:
 - Pass initial counter value to eventfd call
   (can't pass flags here since they are obtained
    with fcntl and must be restored same way or
    restore will fail)
 - Use rst_file_params for flags and owner restore
 - Use eventfd.[ch] instead of eventfs.[ch]
 - Move show funcs to eventfd.c

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 13:59:51 +04:00
Pavel Emelyanov
26a53837f9 shmem: Move shmem dumping code to shmem.c
This is also a code move plus two changes:

* shmems renamed to dump_shmems
* shmem area size is shared with restorer (it's one page for both for now)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-03 18:07:01 +04:00
Pavel Emelyanov
fa8a928e9f pipes: Move dumping code to pipes.c
Just a codemove, no real changed.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-03 17:36:00 +04:00
Pavel Emelyanov
52242be32c dump: Stop using mincore and switch to /proc/pid/pagemap
We use mincore to check which pages we should take with us into
the image. The anonymour present or swapped should go, file present
but not cow-ed should not.

The mincore syscall wasn't very helpful with this -- it didn't detect
swap, but did detect some non present pages (pagecache). Plus it
didn't know anything about cow-ing filemaps.

Andrey Morton suggested to use the pagemap file in proc, but it lacked
the importaint stuff -- the cow filemap bit. Now it's there and we
can switch to using it.

The mincore usage for shared memory is still there, as for _that_ case
it's correct.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-03 16:10:04 +04:00
Pavel Emelyanov
675b4698ce tcp: Put connection locking management over the code
When dump finished with error we should unlock all locked
previously connections.

When restoring we should collect connctions and unlock them
all at the end.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-28 17:59:21 +04:00
Pavel Emelyanov
8cd64c5ae7 unix: Cleanup ext socket check
Rename the fn and fix indentation.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-26 15:30:30 +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
Cyrill Gorcunov
19c1de828b sockets: Restore unconnected dgram sockets v7
In case if dgram socket peer is not connected back
we can try to resolve peer by name.

For security reason this happens only if '-x' option
is passed at checkpoint and restore time.

In particular this is needed for programs which do
use dgram socket to send messages to /dev/log.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-19 12:04:58 +04:00
Pavel Emelyanov
fd85b194ab dump: Init mmap's file pos
It's unused, but makes show command show 0, not trash.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-19 01:14:00 +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
ccdca9e3d1 dump: Add missing new lines
Otherwise output looks like

Dumping core (pid: 16953)
----------------------------------------
Dumping GP/FPU registers ... OK
Obtainting personality ... OK
Obtainting task auvx ... Dumping path for 1 fd via self 19 [/home/crtools/test/legacy/test-inotify]
Dumping header ... ----------------------------------------

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 15:22:06 +04:00
Cyrill Gorcunov
44492851e1 fowners: Add regular files/pipes owners dumping
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:28:34 +04:00
Pavel Emelyanov
814bd5d321 xids: Dump and restore tasks' pgid and sid
This is preriquisity for terminals handling and just a good
practice to save and restore everything we can :)

Not all combinations are supported. All the problems we still
have come from the inability to attach to group/session with
ID no tasks own as its PID.

This can be workarounded by fork()-ing this pid temporarily,
but we'd rather think in the direction of modifying the kernel
to give us direct syscall for this (oh my...)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:11:41 +04:00
Pavel Emelyanov
6f67bb8fc3 xids: Save pgid and sid on pstree_Item and pstree_entry
I store them on _entry since sids can only be inherited or
set to current's pid. Thus the best we can do it restore sids
at fork time, thus save them in the image we use to fork.

Maybe when we submit patches that will give us ability to set
arbitrary pgid and sid we'll change this, but this is in the
future.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:10:09 +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
1e6d32276a parasite: Cure task in case any dump failed while infected
Wile the task is infected we cannot just detach from it and go away. The victim will die after this.
So, call the parasite_cure_seized on any error handing between infect and cure.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 15:25:03 +04:00
Pavel Emelyanov
1e9ccd2bbd dump: Don't kill tasks after failed dump
This is not very good practice :) Just leave them in the state they've been to before
dumping. Plz note, that tasks segfault for some reason after unseizeing, but this is
another story.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 15:17:26 +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
f999b8cfb5 dump: Rename fd dumping functions
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:17:26 +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
9a39482875 dump: Remove unused brk on-stack var from dump_task_core_all
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 15:43:13 +04:00
Pavel Emelyanov
38ea98aa8b dump: Toss code withing dump_task_core_all
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 15:41:16 +04:00
Pavel Emelyanov
a9930c7fdc dump: Move dump-personality logs into dumper fn
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 15:39:21 +04:00
Pavel Emelyanov
d71e5e44f1 dump: Factor out dump-regs logging
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 15:38:33 +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
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
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
Andrey Vagin
32b5aa76e0 dump: return a negative value in case of error
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 10:28:01 +04:00
Pavel Emelyanov
7d3a89970e dump: Check for regfile path being accessible
A file pointed by an fd should be not unlinked
and be open-able with the provided path (overmounts
and/or renames coupled with links can screw it up).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-07 00:32:03 +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
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
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
Cyrill Gorcunov
adc161a108 dump: Simplify cr_dump_tasks message printing
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-02 22:35:40 +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
3b0397dbae dump: Cleanup chrdevs dumping
We have two checks for fd being a chrdev:

One to skip stdio-s that are termilans and
The other one for any fd being a /dev/null or other special device.

Clean this a little bit.

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