2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-24 10:58:36 +00:00

92 Commits

Author SHA1 Message Date
Pavel Emelyanov
080282df7c unix: Simplify unix post-open callback
The fd we want to work on is the 2nd argument, no need
in calculating it out of file_desc.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-24 22:08:46 +04:00
Pavel Emelyanov
8471081244 unix: Add support for shutdown sockets
Get the info from kernel diag message (it should always be there)
and restore the shutdown at the very end.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-24 18:39:54 +04:00
Pavel Emelyanov
8fc6dbfadd files: Formalize fd restore priorities
There are places when we have to select which fd to ->open
and which to ->receive. To avoid deadlocks we sort them in
an ascending order on { pid, fd } pair.

Make this idea more formal by introducing an explicit function
doing this check and call it where appropriate (pipe.c master
selection is also simplified to fit new ... API).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 22:09:22 +04:00
Andrey Vagin
ca567e76c3 sk-unix: add a peer only if it's not in a list yet
I tried to fix that by:
commit bc2ac71c1abddbe76893c0dc1f0421311786070c
Author: Andrey Vagin <avagin@openvz.org>
Date:   Wed Sep 12 15:16:39 2012 +0400

    sk-unix: don't add a socket in a second time

but made a mistake and now a peer would be added only if it's in a list.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 17:49:36 +04:00
Andrey Vagin
bc2ac71c1a sk-unix: don't add a socket in a second time
A socket can be added in a list two times, if two other sockets
are connected to it.

This patch fixes a problem:
    Error (sk-unix.c:395): BUG at sk-unix.c:395

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 15:16:39 +04:00
Andrey Vagin
0c72ab18e0 sk-unix: add more information messages
* A message about external sockets is printed before any action.
* Add a message, when a peer is added in a list of sockets.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 15:16:21 +04:00
Andrey Vagin
582df5130b unix-sk: allocate unix_sk_info from a shared pool
Because unix_sk_info contains a futex, which may be used from a few
processes, we need to collect unix sockets into shared mem regions.

Reported-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 17:24:22 +04:00
Pavel Emelyanov
3158389d2d show: Show unix inodes and peers both in hex
Currently peer is %d, but this is wrong. It should be paired
with inode easily.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-21 16:37:27 +04:00
Stanislav Kinsbursky
768d88f228 protobuf: use pretty output for unix sockets
New custom specificator:

'S': output as string (unprintable characters replaced by dots)

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-21 16:27:07 +04:00
Pavel Emelyanov
7cb674109b unix: Remove conn-jobs
After previous rework (513dde00) they are no longer needed.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-20 17:51:33 +04:00
Andrey Vagin
351b23bb1a sk-unix: fix indents
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-20 17:50:23 +04:00
Andrey Vagin
513dde00d2 sk-unix: connect unix sockets in post_open
Move logic from run_unix_connections to post_open().

I don't fix indents in this patch for easy reviewing.
They are fixed in the next patch.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-20 17:50:16 +04:00
Andrey Vagin
5a0038a9eb sk-unix: fix connection to external sockets
Don't need to wait external sockets, they should exist.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-20 14:52:00 +04:00
Pavel Emelyanov
98759c76bb unix: Don't poll-wait on unix peer to be bound
Long time ago the conn jobs were implemented in a bad
manner -- they tried to connect to peer until it succeeds
sleeping in the middle.

Time to stop doing so and switch to proper futex-based
waiting for bound event.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-17 16:51:25 +04:00
Pavel Emelyanov
fb5a5671c8 sock: Do strict socket family checks when looking up collected socket
We hash socket with inode and family, but search only by inode. Well,
yes, family should match, since all sockets are in one sockfs in kernel,
but let's make sure _we_ did things right by checking the family as well.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-15 19:16:12 +04:00
Pavel Emelyanov
51133437c9 fd: Remove per-filetype make_gen_id abstraction
It doesn't makemuch sense in pulling this further. The generic genid generation seems to
be enough for eny file type.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-11 22:41:29 +04:00
Pavel Emelyanov
64149b40f2 code: A little but more checkpatch fixes over code
There are more in test/ (and checkpatch.pl crashes in the middle =),
but seem to be all.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-11 22:19:34 +04:00
Pavel Emelyanov
f1b41e0824 code: Replace 0x%x with %#x in messages
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-11 21:55:48 +04:00
Pavel Emelyanov
b91445701b img: Introduce generic routine for collecting image entries
On restore we typically read an image and put the entries into
some hash/list/whatever to work on them later. It's handy to have
a generic routine for doing so.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-09 13:16:46 +04:00
Pavel Emelyanov
b1b0a39a58 pb: Rewrite object reading to use pb-descs
The pb_read thing is no longer a macros. This will allow to
factor out objects collecting on restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:22:00 +04:00
Pavel Emelyanov
2398c55e41 pb: Rewrite object writing to use pb-descs
The pb_write thing is no longer a macros.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:21:59 +04:00
Pavel Emelyanov
b0cf603b18 netlink: Pass argument through do_rtnl_req engine
Will need it int netns dumping callbacks later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:36:12 +04:00
Pavel Emelyanov
cffe1ea172 netlink: Remove handmade rtnl macros/definitions
All we need is (should be) in rtnetlink.h

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:36:12 +04:00
Andrey Vagin
c69be631e1 mntns: crtools: stat pathes relatively of a mntns root
If we dump tasks with mntns, we should look at pathes from point of a mntns root.

Now we support a situation when a root of an init task has the same root as the
mntns root, because we have not another way to get a root of mntns.

A path to an unix socket is copied, because the origin copy will be gone
out from the function, where it was created.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-01 07:00:48 +04:00
Andrey Vagin
bed6c34b17 socket: skip unsupported sockets
Before this patch, it stopped if stat() failed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-20 09:46:15 +04:00
Pavel Emelyanov
9fc1d6bbeb fdinfo: Make fdinfo.type be an enum
This types specifies a strict set of what is hidden behind
the fd. Thus these numbers should be in the description of
the fdinfo message.

Plus protobuf makes shure nothing else will be there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 10:18:37 +04:00
Cyrill Gorcunov
0cf04ac781 protobuf: Drop old sk_opts_entry structure
We've switched to SkOptsEntry, no need to carry this
obsolete one.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 09:44:41 +04:00
Cyrill Gorcunov
0468355c12 protobuf: Drop fown_t type
We are ready to use FownEntry everywhere,
so drop fown_t type and clean up source code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 09:39:00 +04:00
Cyrill Gorcunov
c9ea79db93 protobuf: Convert unix_sk_entry to PB engine v3
v2:
 - Use alloc_socket_opts/free_socket_opts helpers
 - Use pb_prep_fown helper
v3:
 - Add missing ui->name = NULL

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 09:32:55 +04:00
Cyrill Gorcunov
a1fe3caf04 protobuf: Start switching our image entries to Google's protobuf
A short story -- there were a long conversation on which format should
be used to keep checkpointed data on disk image. We ended up in using
Google's Protocol Buffers (see https://developers.google.com/protocol-buffers/
for detailed description). Thus image entries should be convered to PB.

This patch converts fdinfo_entry to PB "message fdinfo_entry".

Build note: one should have protobuf and protobuf-c installed to be able
to build crtools.

 - http://code.google.com/p/protobuf/
 - http://code.google.com/p/protobuf-c/

Inspired-by: Pavel Emelianov <xemul@parallels.com>
Inspired-by: Kinsbursky Stanislav <skinsbursky@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-17 07:10:41 +04:00
Cyrill Gorcunov
29e8c85627 sockets, unix: Use unix_sk_entry as a reference in unix_sk_info
For PB transition.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-13 11:57:49 +04:00
Cyrill Gorcunov
2db18f5e16 files: Use fdinfo_entry * in fdinfo_list_entry structure
We will need to use pointer here (to PB object) anyway
so better to make it in a separate patch for bisectability sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-09 15:04:35 +04:00
Pavel Emelyanov
03b06a8b65 unix: Beautify the unixsk image show output
Print IDs with %#x to get rid of spaces between 0x and numbers.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-17 10:56:29 +04:00
Cyrill Gorcunov
c26b68dce8 sockets, unix: Use general machnism for checkpoint/restore v2
Use fdtype_ops facility to c/r unix sockets.

v2
 - BUG_ON added in dump_one_unix_fd if socket
   is already dumped since we never should dump
   same socket several times
 - The order of restore remains as it was before,
   the lookup is done via socket inode numbers

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-30 12:54:31 +04:00
Stanislav Kinsbursky
41195598cf parasite: remove excessive header deps from parasite.h and friends
The task is not complete - this is just a part of what have to be done. I.e.
looks like a lot of excessive deps can be fixed.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-30 12:50:18 +04:00
Andrey Vagin
066ec066a0 crtools: remove unused variables (v3)
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-18 19:01:21 +04:00
Cyrill Gorcunov
32e07745cc sockets: Print error message on unexpected socket state
While been playing with sockets dumping I found a case where
we exit without descriptive error message. Fix it.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-11 17:39:45 +04:00
Pavel Emelyanov
7f82ae1133 sockets: Prepare for dumping/restoring/showing socket options
Those sitting on the SOL_SOCKET level are common to different
socket families and will be handled in a generic code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-10 14:29:57 +04:00
Pavel Emelyanov
a604c63cdb restore: Move type from file_desc to file_desc_ops
This saves some space on dynamic file_desc and makes file_desc_ops
looks closer to fdinfo_ops used on dump.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 15:41:05 +04:00
Cyrill Gorcunov
3dc0088be3 sockets: Print ino's with %x format in collect_unix_sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-03 16:25:46 +04:00
Cyrill Gorcunov
635a1247fc sockets: Print peer number in show_one_unix, show_one_unix_img
Also convert all ino into %x format.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-03 16:24:34 +04:00
Pavel Emelyanov
52cb8d43b9 sk: Move unix socket code to separate file
Funny, but after this git thinks, that I've renamed the sockets.c
file into sk-unix.c one and fixed it a little bit %)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-26 15:30:39 +04:00