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

449 Commits

Author SHA1 Message Date
Andrey Vagin
14e42bb704 pipe: fix error code and message
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 18:24:40 +04:00
Andrey Vagin
9129d4e2a1 restore: don't use char in image struct-s
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 18:24:35 +04:00
Andrey Vagin
d6a1cd0fbc restore: Learn to work with shared struct file-s
Some process can share one struct file-s, we may find them by "object IDs".
A file descriptor is opened in one process and send to other via unix socket.

The procedure of restoring files contains four stages.
* Collect data about all file's descriptors
  On this stage we find process which will restore a file descriptor and
  create a list of processes, who should get this descriptor.

* Create datagrams unix sockets
  If a file descriptor should be received, a unix socket is created
  instead of it.

* Open file descriptors
  A process with the least pid opens a file and sends this file
  descriptors to all one who wait it.

* Receive file descriptors.

When we were thinking up this algoritm, we wanted to minimize a number
of context switches. A number of context switches is proportional of a
number of processes.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 16:01:44 +04:00
Pavel Emelyanov
b5cc5fc3e1 crtools: Sanitize parasite_ctl pass to parasite_cure_seized
Remove excessive checks and keep it a pointer.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 14:00:06 +04:00
Pavel Emelyanov
a49e30722a crtools: Kill constant arg from parasite_infect_seized
The mmap hint is always NULL.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 13:59:54 +04:00
Pavel Emelyanov
73633d5505 crtools: Kill constant arg from parasite_dump_pages_seized
The last one is always CR_FD_PAGES.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 13:59:41 +04:00
Pavel Emelyanov
0ca9ccc3e4 crtools: Sanitize the tasklist states switch
Introduce a helper for walking the list and sending signals.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-11 13:59:15 +04:00
Andrey Vagin
7fde5f061b restore: move file-related stuff to a separate file
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 18:39:39 +04:00
Andrey Vagin
d6a1d20690 zdtm: add test cases for shared sturct file-s
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 18:37:13 +04:00
Cyrill Gorcunov
37782e6e00 test: Update unix sockets
To include dgram bound && connected sockets, for example

CR_FD_UNIXSK: /home/cyrill/crtools/unixsk-2813.img
----------------------------------------
fd    3 type  1 state  1 namelen    0 backlog    0 id  19505 peer  19506
fd    4 type  1 state  1 namelen    0 backlog    0 id  19506 peer  19505
fd    5 type  2 state  7 namelen    0 backlog    0 id  19507 peer      0
fd    6 type  2 state  7 namelen   18 backlog   18 id  19508 peer      0 --> test-socket-bound
fd    7 type  2 state  7 namelen    0 backlog    0 id  19509 peer  19510
fd    8 type  2 state  7 namelen   17 backlog   17 id  19510 peer      0 --> test-socket-conn
fd    9 type  2 state  7 namelen   23 backlog   23 id  19511 peer  19511 --> test-socket-bound-conn
----------------------------------------

The last one is bound and connected.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:38:59 +04:00
Cyrill Gorcunov
dffaab578d sockets: Restore dgram sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-10 17:38:55 +04:00
Cyrill Gorcunov
930432f161 sockets: Make socket name printing similar to vmas
Use same format as we do for VMA names.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:51 +04:00
Cyrill Gorcunov
1a1979cc88 sockets: Show backlog length in "show" procedure
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:51 +04:00
Cyrill Gorcunov
196ce521a8 sockets: unix -- Retrieve backlog length for stream sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:51 +04:00
Cyrill Gorcunov
34b2ba0c06 sockets: Update unix_diag.h
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:50 +04:00
Cyrill Gorcunov
942355c166 sockets: Nitpick for dgram dumping
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:50 +04:00
Cyrill Gorcunov
054bf4ada2 sockets: Allow to dump dgram sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:50 +04:00
Cyrill Gorcunov
04ec43a5d5 sockets: Split open_unix_sk to stream and dgram versions
And add some comments.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:50 +04:00
Cyrill Gorcunov
cc15c01832 test: Rewrite sockets test
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:50 +04:00
Andrey Vagin
eac52b6090 util: reopen_fd_as to return an error if destination descritor is busy
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 16:55:02 +04:00
Andrey Vagin
f274f16081 log: close unused descriptor
This code opens a log file and duplicates the descriptor to logfd,
but forgets to close the first one.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 16:43:31 +04:00
Cyrill Gorcunov
5d5e8b801c retore: Fix up shared anonymous memory restore procedure
Restorer does really restore shared memory (including page
contents restore) only on master process, while all other
processes do open such memory area via map_files/ procfs entry
so that we might have a situation when shared VMA is present
in some particular core-%d.img file but it's not listed in
collected shmems array and find_shmem_by_pid will return NULL.
This is perfectly fine, be ready for that.

Another issue is that shared memory might look like

CR_FD_SHMEM: /home/cyrill/projects/kernel/crtools/shmem-2641.img
----------------------------------------
0x7f2200775000-0x7f2200776000 id 19664
0x7f2200776000-0x7f2200777000 id 19663
----------------------------------------

So vma area is [x;y) range and we should distinguish two
shmem lookup cases

 - one when we search for page in shmem area
 - second when we lookup shmem area in collected ranges

They both have a different lookup conditions so single
find_shmem splitted into two helpers find_shmem and
find_shmem_page as appropriate.

This patch finally fixes the three process asynchronious
shared memory updates test-case.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 18:31:48 +04:00
Cyrill Gorcunov
1b21a27b0c restore: Simplify shmem_wait_and_open
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:41:05 +04:00
Cyrill Gorcunov
d0a6e9a101 restore: Pass shmems_fd as argument as well
We might be needing to close the shmems file descriptor.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:40:54 +04:00
Cyrill Gorcunov
4416c649c8 syscalls: Add sys_msync helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:40:35 +04:00
Cyrill Gorcunov
e0e934aa4b restore: shmems -- Use cr_wait_init helper
Just in a sake of consistency

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:40:24 +04:00
Cyrill Gorcunov
86d114438e lock: Add cr_wait_init helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:40:13 +04:00
Cyrill Gorcunov
793f3aa947 restore: shmem_remap arguments resort
Style tuning, no func change

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:39:58 +04:00
Cyrill Gorcunov
5b47af26f5 restore: No need to check if vma_entry->fd == -1
Dumping procedure does check for VMA_ANON_SHARED
so the same should be done at restore time.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:39:44 +04:00
Cyrill Gorcunov
1238d2dd72 restore: Signal waiters on shmem being read only when pages data is restored
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:39:29 +04:00
Cyrill Gorcunov
e189efc176 restore: shmems -- Fix /proc path
The remapping of /proc path to shmem should be
done with pid of process which did mmap() call
initially.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:39:08 +04:00
Cyrill Gorcunov
58ad088870 restore: Fix typo in shmem_wait_and_open
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:38:44 +04:00
Cyrill Gorcunov
80492c78e6 restore: More detailed log on shmem restore
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:38:18 +04:00
Cyrill Gorcunov
a03e3622f2 restore: Add log message that restore via sigreturn is started
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:38:04 +04:00
Cyrill Gorcunov
3afb83299c restore: Gather setting agrument for sigreturn code in one place
Also add a few more comments.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:37:41 +04:00
Cyrill Gorcunov
ee0f17b0a7 restore: Fix typo in shmem size assignment
And use SHMEMS_SIZE constant as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:37:12 +04:00
Cyrill Gorcunov
a14ceb4950 util: Fix parse_maps to handle anonymous shared mappings
In commit 99eb3d09c5c42200b230783e793b778882ce8dd6
we started to use self-contained shared memory
region but it revealed the problem that anonymous
sgared mappings might be parsed by parse_maps incorrectly,
so fix it and be ready to get anon-shared mappings.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-04 16:36:56 +04:00
Cyrill Gorcunov
f3ed69a339 sockets: Print socket id as well
Also make output a bit more fancy, as

CR_FD_UNIXSK: unixsk-2440.img
----------------------------------------
fd    3 type  1 state  1 namelen    0 id  19406 peer  19407
fd    4 type  1 state  1 namelen    0 id  19407 peer  19406
fd    5 type  2 state  7 namelen    7 id  19408 peer      0	---> [tst-sk]
fd    6 type  2 state  7 namelen    0 id  19409 peer      0
fd    7 type  2 state  7 namelen    0 id  19410 peer  19411
fd    8 type  2 state  7 namelen    8 id  19411 peer      0	---> [tst-sk1]
----------------------------------------

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-30 18:24:55 +04:00
Pavel Emelyanov
5f7d677fad crtools: Sanitize collect_mappings path buffers usage
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-30 16:25:42 +04:00
Cyrill Gorcunov
2967bb9c37 sockets: Use reopen_fd_as helper
It also tests for possible dup() call error.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-30 15:34:05 +04:00
Pavel Emelyanov
96f92ee612 crtools: Cleanup open_image_ro
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-29 19:56:34 +04:00
Pavel Emelyanov
7b0b203b34 crtools: Use open_image_ro where appropriate
Several places just need to open an image, thus the helper is OK to use.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 21:38:00 +04:00
Pavel Emelyanov
329d8aa662 The pid == 0 is enough.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 21:16:02 +04:00
Pavel Emelyanov
d4fd91046f crtools: Remove duplicate show_single_file boolean
It duplicates the show_dump_file pointer.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 21:15:55 +04:00
Pavel Emelyanov
a76922ebc0 crtools: Fix lost magic arg from print
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 21:15:21 +04:00
Cyrill Gorcunov
935c8e75f0 net: sockets -- Use read_ptr_safe for magic number test
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 12:17:02 +04:00
Cyrill Gorcunov
4432c6447e net: sockets -- A few style tuneups
To follow rest of code

 - use !x for xalloc result tests
 - structure members are tab aligned
 - multiline assignments over structure members are aligned as well

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 12:16:51 +04:00
Cyrill Gorcunov
bc3370fc47 net: sockets -- Dont use multiline for() without braces
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 12:16:36 +04:00
Cyrill Gorcunov
269fb0b777 net: libnetlink -- Drop trailing whitespaces
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 12:16:11 +04:00
Cyrill Gorcunov
c53408d6b7 net: sockets -- Make sure ue->namelen < UNIX_PATH_MAX
UNIX_PATH_MAX is a size of path, so max length
should never be equal to such size.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 23:32:17 +04:00