2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00
Commit Graph

89 Commits

Author SHA1 Message Date
Pavel Emelyanov
bcf9ee3d1c fdset: Helper for getting fd out of a set
This patch does

s/$fdset->fds[$nr]/fdset_fd($fdset, $nr)/

over the code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:59 +04:00
Pavel Emelyanov
f1429be087 dump: Don't include sk-queues fd in task set
This fd is global, so make it such. It will stop being just a global
variable soon.

Plus, remove the pid arg from format.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:44 +04:00
Pavel Emelyanov
1c12a31893 udp: Restore UDP sockets
Reuse the TCP socket restore, just add connect() and sanity checks
for protocol.

This is OK, since UDP connect doesn't go to network for connection
and (unlike unix sockets) doesn't require peer to be "online". It
just puts the peer's creds on socket and returns.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
bad126e7a5 sock: Add dst creds to socket structs
These are required for inet sockets, but were not added since listen
sockets do not have them.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
ba562bc272 show: Fix inet sockets show "loglevel"
Showers should use pr_msg to avoid loglevel issues.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
b198d76e40 udp: Allow dumping udp sockets
Just a small fixlet in can_dump_inet_sk.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
625c45ea79 udp: Collect socket with diag
Partially reuse the existing TCP code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Cyrill Gorcunov
7aa8e4b6e2 log: log-engine slight redesign
The messages are filtered by their type

    LOG_MSG     - plain messages, they escape any (!) log level
                  filtration and go to stdout
    LOG_ERROR   - error messages
    LOG_WARN    - warning messages
    LOG_INFO    - informative messages
    LOG_DEBUG   - debug messages

By default the LOG_WARN log level is used, thus LOG_INFO
and LOG_DEBUG messages will not appear in output stream.

pr_panic helper was replaced with pr_err, pr_warning
shorthanded to pr_warn and old printk if rather pr_msg
now.

Because we share messages between "show" and "dump" actions,
before the "show" action proceed we need to tune up
log level and set it to LOG_INFO.

Also note that printing of VMA and siginfo now
became LOG_INFO messages, it was not that correct
to print them regardless the log level.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-02 01:05:43 +04:00
Kinsbursky Stanislav
46535130c6 restore: UNIX sockets queue support
Based on xemul@ patches.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-29 17:42:30 +04:00
Kinsbursky Stanislav
e518c44c7c show: UNIX sockets queue support
Based on xemul@ patches.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-29 17:42:30 +04:00
Kinsbursky Stanislav
131f5a1d49 dump: UNIX sockets queue support
Based on xemul@ patches.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-29 17:42:30 +04:00
Kinsbursky Stanislav
e6f39a41bf restore: socket queues support
This patch was designed to be generic and thus usable for all kinds of
sockets. Not sure, thah this goal has been reached, but at least I tried.

Key ideas:
1) sockets queue dump file have to be readed first and then packets entries
   with offset for it's data in image will be collected in doubly linked list by
   read_sockets_queue() function.

Note: list will contain sockets queues for all (!) the sockets of the task.

2) socket queue can be restored by restore_socket_queue(), which selects
   packets from the list by passed id and use sendfile() top send them to the
   passed socket. It also removes packet from the list and frees it.

Based on xemul@ patches.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-29 17:42:30 +04:00
Kinsbursky Stanislav
c19012326d dump: socket queues support
This patch was designed to be generic and thus usable for all kinds of
sockets. Not sure, thah this goal has been reached, but at least I tried.

Key ideas:
1) On-stack structure for collecting sockets queues and then passing them to
   parasite code.
2) Singly linked list is used for collecting structures, representing sockets
   of any kind (!) with queues.

Based on xemul@ patches.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-29 17:42:30 +04:00
Cyrill Gorcunov
ef97467da9 log: Add log-levels
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-20 14:23:28 +04:00
Kir Kolyshkin
76a0186c1c sockets.c: use pr_perror() where appropriate
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-11 11:58:32 +04:00
Kir Kolyshkin
41fb6b3f6b show_unixsk(): avoid buffer overflow
Say in case of corrupted img file

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-11 11:58:23 +04:00
Kir Kolyshkin
bf1ca46d43 show_unixsk(): show backlog for real
This is probably a typo in commit 1a1979c

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-11 11:58:15 +04:00
Kir Kolyshkin
82e548ecca socket.c: use const whenever possible
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-10 18:07:19 +04:00
Kir Kolyshkin
d5fa75c004 sockets.c: Fix/unify some error messages
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-10 18:07:19 +04:00
Kir Kolyshkin
fb59be3c11 sockets.c cleanup: break long lines
No code change, pure cleanup

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-10 18:07:19 +04:00
Kir Kolyshkin
26a7056c26 sockets.c cleanup: no need for backslash when "calling" a define
Fix too long line while at it.
No code change, pure cleanup.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-10 18:07:19 +04:00
Pavel Emelyanov
54091c9b73 sockets: Fix dgram socketpair restore
These are connected, but don't have names. Thus the connect
job fails on them. Use fake ones.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-10 16:06:49 +04:00
Pavel Emelyanov
f27c83c70c sockets: Off by one in fake address preparation
The fake bind name is trimmed on 1 char.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-10 16:06:39 +04:00
Pavel Emelyanov
82a8a8ff95 sockets: Decode kernel dev_t into stat's one
Unix diag and stat report dev_t-s in different formats. Cast one to
another when comparing in unix dumping.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-08 16:11:27 +04:00
Pavel Emelyanov
02c8793c6e sockets: Fix file-bound sockets check
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-08 12:55:21 +04:00
Pavel Emelyanov
5b8c7bbf84 sockets: Helper for scheduling acc job
There's only one place with this, but the helper makes the code look
almost perfectly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:28:08 +04:00
Pavel Emelyanov
bc9089e57e sockets: Use RW API in bind sk helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:58 +04:00
Pavel Emelyanov
57eea3d3fd sockets: Helper for binding unix socket
This one reads a name from image, does preparations for bind and calls bind.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:51 +04:00
Pavel Emelyanov
e1ed063f79 sockets: Merge dgram and stream listeners
They fully coincide now, just need to distinguish them by socket type.
Thus, add the type member on the unix_sk_listen and merge two hashes.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:43 +04:00
Pavel Emelyanov
2d9873e051 sockets: Helper for scheduling conn job
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:31 +04:00
Pavel Emelyanov
b845fa3424 sockets: Merge dgram and stream conn jobs
Structure used is the same, logic of connection is the same, and the
infrastructure is ready for this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:24 +04:00
Pavel Emelyanov
23cf6f84d9 sockets: Replace sockets conn job flags with type
Required for simpler future patching.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:16 +04:00
Pavel Emelyanov
8f70115461 sockets: Factor dgram conn job structures more
The unix_dgram_peer coincides with the unix_conn_job.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:09 +04:00
Pavel Emelyanov
5bff96f758 sockets: Factor dgram conn job structures
The unix_dgram_bound fully coincides with the unix_sk_listen.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:01 +04:00
Pavel Emelyanov
fe598403df sockets: Delay dgram connection
By the time we try to resolve datagram socket connection name the other
end may not yet be on the hash. Move the address resolution into the
conn job.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:26:52 +04:00
Pavel Emelyanov
aeabf03133 sockets: Datagram connection fix
The address length should be the real length, not the buffer size.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:26:43 +04:00
Cyrill Gorcunov
6f589a4f6e sockets: Fix a few problems if compiled with DEBUG=1
sockets.c: In function ‘show_one_inet_img’:
sockets.c:151:2: error: format ‘%d’ expects argument of type ‘int’, but argument 9 has type ‘char *’ [-Werror=format]
sockets.c: In function ‘open_unix_sk_stream’:
sockets.c:925:10: error: unknown escape sequence: '\C' [-Werror]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-01 17:23:44 +04:00
Cyrill Gorcunov
229defc928 Make sure no uninitialized values are used
I've got it if -O2 compilation option used.

 | cr-restore.c:1069:5: error: ‘ret’ may be used uninitialized in this function [-Werror=uninitialized]
 | sockets.c:1145:7: error: ‘sk’ may be used uninitialized in this function [-Werror=uninitialized]

In first case 'ret' indeed might be uninitialized, and
in second case "goto err" was called too early. Fix them both.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-01 15:24:39 +04:00
Kir Kolyshkin
6c9d6a86a4 sockets.c: fix printf format warnings
sockets.c: In function ‘try_dump_socket’:
sockets.c:366:3: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘__ino_t’

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-31 15:57:25 +04:00
Kir Kolyshkin
0b237ae9f2 pr_perror(): print error at the end of line
This is a standard convention to print error message (i.e. strerror(errno))
at the end of line, like this:

        Cannot remove file: Permission denied

So pr_perror is fixed to follow this convention (using GNU extension
%m helps a lot here). Unfortunately, due to this we have to make
pr_perror() print a new line character, too, so we had to strip it
from the all pr_perror() invocations.

That (appending a newline) also makes pr_perror() a black sheep
in the herd of pr_* helpers, but what can we do? Worst case scenario
is an extra newline after an error message, not too harmful.

An alternative approach (stripping the newline from the passed format
string and re-adding it) was discussed thoroughly, and it was decided
that such a hack looks a bit too dirty.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-31 15:49:15 +04:00
Cyrill Gorcunov
29bda9aae5 sockets: Restore in-flight unix stream sockets
It's done in two steps

 - On checkpoint we find which icons are present
   over all sockets and setup peer number to
   appropriate listening socket

 - On restore we collect listening sockets and once
   we find in-flight connection we search for appropriate
   listening socket name and use it to call connect() then

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-27 23:21:06 +04:00
Cyrill Gorcunov
f974de9c49 sockets: Add SK_HASH_LINK helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-27 23:21:06 +04:00
Cyrill Gorcunov
641844c349 sockets: Allow to dump unix sockets with inflight connections
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-27 23:21:06 +04:00
Cyrill Gorcunov
b21c2c8c1d sockets: Print icons numbers in debug printing
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-27 23:21:06 +04:00
Cyrill Gorcunov
b0e4a2edcd sockets: Add nr_icons member to track number of icons instead of zero ended array
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-27 23:21:06 +04:00
Cyrill Gorcunov
ff83500f5c sockets: sockest: Show collected socket once they get hashed
Otherwise debug printing has no inode number in report.
Not really it's that important but very convenient
if you need detailed output.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-27 23:21:06 +04:00
Cyrill Gorcunov
9b2e191392 sockets: Nitpick on error printing in open_inet_sk
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-27 20:19:01 +04:00
Cyrill Gorcunov
9d913b6551 sockets: Fix freeing dgram sockets data
Otherwise use-after-free error happens.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-27 02:33:32 +04:00
Cyrill Gorcunov
b0467f2d8c sockets: Report relative name itself
This is more informative to know which exactly name failed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-25 16:55:36 +04:00
Pavel Emelyanov
164ccc095f crtools: R/W API rewrite
Kill all the macros for reading/writing image parts. New API looks like

* write_img_buf/write_img
  Write an object into an image. Reports 0 for OK, -1 for error. The _buf
  version accepts object size as an argument, the other one uses sizeof()

* read_img_buf/read_img
  Reads an object from image. Reports 0 for OK, -1 for error or EOF.

* read_img_buf_eof/read_img
  Reads an object from image. Reports 1 for OK, 0 for EOF and -1 for error.
  This is not symmetrical with the previous one, but it was done deliberately
  to make it possible to write code like

  ret = read_img_bug_eof();
  if (ret <= 0)
	return ret; /* 0 means OK, all is done, -1 means error was met */.

  ... /* 1 means object was read, can proceed */

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-23 01:43:10 +04:00