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

11124 Commits

Author SHA1 Message Date
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 99eb3d09c5
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
Cyrill Gorcunov
2ae99d73b9 net: Define named constant for nlmsg_seq
For better readability.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 20:13:18 +04:00
Cyrill Gorcunov
25d048c02a test: Add usnix-socket test
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 20:01:47 +04:00
Cyrill Gorcunov
843747de55 net: A few changes in headres to follow c99
Since we're not system library

 - no underscopes in functions name until really needed
   and known to not clash with posix namespace
 - empty line between system headers and own headers
   for readability
 - extern for function prototypes

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 14:26:13 +04:00
Cyrill Gorcunov
f532e9fed2 net: sockets -- Use dprintk helper
Drop USK_DEBUG, we have dprintk which is active
if compiled with make DEBUG=1

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 14:26:02 +04:00
Cyrill Gorcunov
ccd5e2295f net: sockets -- Replace __u32 with u32
We provide such type in types.h.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 12:41:42 +04:00
Cyrill Gorcunov
00e14f0448 make: Add DEBUG=1 option
This allows to use pr_debug and dprintk helpers.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 02:28:12 +04:00
Cyrill Gorcunov
4c0fb12e11 util: Make pr_warning to report file and line as well
For easier debugging. We can zap it at release time.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 02:28:02 +04:00
Cyrill Gorcunov
e6a033fb05 net: libnetlink -- Add #ifdefs to escape system header conflict
Otherwise getting errors like

 | CC       libnetlink.o
 | In file included from libnetlink.c:4:0:
 | ./include/libnetlink.h:34:0: error: "NLMSG_LENGTH" redefined [-Werror]

And make macros a bit more readable.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 01:41:17 +04:00
Cyrill Gorcunov
2f85054ddf libnetlink: Drop tailing whitespaces
Cosmetic change.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 00:24:23 +04:00
Cyrill Gorcunov
4a015bba33 sockets: Use safe snprintf
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 00:17:24 +04:00
Andrey Vagin
aeb638f845 restore: shmem -- Don't poll, use wait helpers instead
Signed-off-by: Andrey Vagin <avagin@openvz.org>
[gorcunov: A few tuneups]
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 23:54:18 +04:00
Andrey Vagin
bd8b2b0f11 restore: shmems -- Remap shmems to use in restorer
Signed-off-by: Andrey Vagin <avagin@openvz.org>
[gorcunov: log error in restorer.c]
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 23:54:18 +04:00
Andrey Vagin
99eb3d09c5 restore: shmem - Add self-contained shem's memory region
The next patch will remap shmems region and will use it in restorer.
Actually this patch moves shmem_nr to struct shmems.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
[gorcunov: Various tuneups]
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 23:54:18 +04:00
Andrey Vagin
74a56b8c5a restore: pipes -- Don't poll, use wait-helpers instead
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 23:54:18 +04:00
Cyrill Gorcunov
fd7543e6e5 Gather futex helpers into lock.h
Based-on-patch-from: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrey Vagin <avagin@openvz.org>
2011-12-26 23:54:18 +04:00
Cyrill Gorcunov
e7ce6f7a3f net: unix-diag -- Drop double underscopes
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 23:25:13 +04:00
Pavel Emelyanov
c5eb61e866 Unix sockets initial support
Currently it can only work with stream sockets, which have no skbs in queues
(listening or established -- both work OK).

The cpt part uses the sock_diag engine that was merged to Dave recently to
collect sockets. Then it dumps sockets by checking the filesystem ID of a
failed-to-open through /proc/pid/fd descriptors (sockets do not allow for
such tricks with opens through proc) against SOCKFS_TYPE.

The rst part is more tricky. Listen sockets are just restored, this is simple.
Connected sockets are restored like this:

1. One end establishes a listening anon socket at the desired descriptor;
2. The other end just creates a socket at the desired descriptor;
3. All sockets, that are to be connect()-ed call connect. Unix sockets
   do not block connect() till the accept() time and thus we continue with...
4. ... all listening sockets call accept() and ... dup2 the new fd into the
   accepting end.

There's a problem with this approach -- socket names are not preserved, but
looking into our OpenVZ implementation I think this is OK for existing apps.

What should be done next is:

1. Need to merge the file IDs patches in our tree and make Andrey to
   support files sharing. This will solve the

	sk = socket();
	fork();

   case. Currently it simply doesn't work :(

2. Need to add support for DGRAM sockets -- I wrote comment how to do it
   in the can_dump_unix_sk()

3. Need to add support for in-flight connections

4. Implement support for UDP sockets (quite simple)

5. Implement support for listening TCP sockets (also not very complex)

6. Implement support for connected TCP scokets (hard one, Tejun's patches are not
   very good for this from my POV)

Cyrill, plz, apply this patch and put the above descriptions onto wiki docs (do we
have the plans page yet?).

Andrey, plz, take care of unix sockets tests in zdtm. Most likely it won't work till
you do the shared files support for sockets.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 23:25:04 +04:00
Pavel Emelyanov
bf7a74d47e Helper for moving image fd
When opening an fd at a position where the current image fd sits
the latter one should be moved.

Introduce a helper for this.

Signed-off-by; Pavel Emelyanov <xemul@parallels.com>

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 21:53:44 +04:00
Pavel Emelyanov
99cc87949f reopn_fd_as return code fixlet and cleanup
Nobody cares the returned fd, so just make it 0/-1 and clean up the callers.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 21:53:36 +04:00
Cyrill Gorcunov
d7ab5f2f7b restorer: Implement own BUG_ON_HANDLER
Due to code specifics (we're running without
glibc support) we need own one.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 15:54:27 +04:00
Cyrill Gorcunov
f5a87742a0 util: Add BUG_ON helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 15:54:03 +04:00
Cyrill Gorcunov
42c755b466 restorer: last_pid_ns should be written without eol
Otherwise -EINVAL returned

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 02:25:06 +04:00
Cyrill Gorcunov
4f797015e6 test: Enhance pthreads test to include fork calls
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 02:24:56 +04:00
Cyrill Gorcunov
3c929e540c dump: Adopt dumping children for new format
Kernel has a new format for process children
(ie /proc/<pid>/task/<tid>/children) so adopt
crtools for it.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 02:24:46 +04:00
Cyrill Gorcunov
894a626a52 dump: parse_threads - Pass single struct pstree_item instead of a few parameters
Parsing children will require to know the number
of threads found so in a sake of consistency pass
single struct pstree_item here as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 02:24:37 +04:00