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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
There was API change in linux kernel 3.2 -> 3.3 transition
| commit c8991362a0d3cf317dfbfb6cb946607870654e6d
Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
This eats response skb mem, but we don't need it.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
We can do it since we may not want to dump the missed sockets.
But later, when we will start dumping containers, we'll better
fail here, rather than in the dump stage.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
There's no need in img fd pointer in opening functions.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This patch adds support for restoring IPv4 listening sockets.
Based on unix sockets restore.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This is a precursor patch. Netlink request code is mostly the same for any
kind of sockets. Only 2 places differs: request creation and callback address.
This patch parametrizes netlink call function with a pointer to a request
structure, request size and receive callback, which replaces hard-coded unix
sockets parts.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
* @xemul:
crtools: Collect dumping fd parameters into one place
crtools: Toss dump_one_fd args around
crtools: Rename fd to lfd in dump_one_fd
crtools: Sanitize pstree construction
crtools: Remove unused printk_registers and co
crtools: Deduplicate file info showing code
crtools: Merge pstree collecting into showing
crtools: Remove unused and wrong arrays from pstree image
crtools: Remove lseeks after prep_cr_ calls
crtools: Cleanup collect_pstree in cr-show
Conflicts:
cr-dump.c
include/sockets.h
sockets.c
The conflicts are mostly because of commit
995ef5eca3b8d74cf192e41c307f5329d93f9795
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This allows us to get rid of open-coded "/proc/pid/X".
Based-on-patch-from: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
NLM_F_DUMP is already defined as (NLM_F_ROOT|NLM_F_MATCH)
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Sockets are special and we reuse fds in accept jobs.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Make the dump_one_fd fn accept local fd and integer target fd values
instead of target fd dir and target fd string name.
This saves couple of atoi-s (done once) and makes the next patch simpler.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
In case if relative bind path found we skip such
socket but forget to free previously allocated
memory.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
We collect all unix sockets in the current net namespace, but
a target process uses a few of them, so we may skip unsupported sockets
and if it is used by a target process, lookup_socket returns error.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Path is not needed there -- we can call the get_image_path() in prep_cr_fdset_
routines and in parasite-syscall.c when required.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Remove unneeded path argument (we do know the file data is read from) and
actually bogus show_header boolean.
Also introduce two helpers for showing header and tail.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>