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

92 Commits

Author SHA1 Message Date
Andrey Vagin
f0e0ee7a5c unix: fix calculation of pointers
CID 1141016 (#1 of 1): Extra sizeof expression (SIZEOF_MISMATCH)
suspicious_pointer_arithmetic: Adding "40UL /* sizeof (FilePermsEntry)
*/" to pointer "(FownEntry *)perms" of type "FownEntry *" is suspicious
because adding an integral value to this pointer automatically scales
that value by the size, 48 bytes, of the pointed-to type, "FownEntry".
Most likely, "sizeof (FilePermsEntry)" is extraneous and should be
replaced with 1.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-23 13:59:59 +04:00
Andrey Vagin
07d9e11374 unix: fix double free on error paths
CID 1141011 (#1 of 1): Double free (USE_AFTER_FREE)
24. double_free: Calling "free(void *)" frees pointer "ue" which has
already been freed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-23 13:59:23 +04:00
Andrey Vagin
9e3f4451e1 unix: add ability to set callbacks for external sockets (v5)
We don't know a state behind an external socket. It depends on logic
of the program, which handles this socket.

This patch adds ability to load a library with callbacks for dumping
and restoring external sockets.

This patch introduces two callbacks cr_plugin_dump_unix_sk and
cr_plugin_restore_unix_sk. If a callback can not handle a socket, it
must return -ENOTSUP.

The main questions, what kind of information should be tranfered in
these callbacks. Pls, think a few minutes about that and send me
your opinion.

v2: Use uflags instread of adding a new field
v3: clean up
v4: Unsuitable callbacks return -ENOTSUP.
v5: set USK_CALLBACK, if a socket was dumped by callback.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:28:41 +04:00
Andrey Vagin
afc61ba562 unux: postpone dumping sockets v2
Unix sockets are dumped, when a peer socket is found.
We are going to dump external sockets with help plugins. For the we need
to set the USK_CALLBACK flags in unix entry. Currently a socket is
dumped immediately when it's transfered, but we can be sure that a
socket is not external, only when we have its peer.

v2: add comments in code
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:27:36 +04:00
Andrey Vagin
59162cccf7 sk-unix/dump: allocate UnixSkEntry dynamically
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:27:35 +04:00
Andrey Vagin
8f66bf9794 unix: link a socket to its peer
We are going to add callback-s for dumping external sockets.
All external sockets are added into unix_list, but for dumping we need
to know all peers.

And one more thing is that a socket is not closed before its peer is
not be dumped. We are going to transfer the socket decriptor in the
callback.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 15:27:34 +04:00
Pavel Emelyanov
873d1dac9d unix: Move odev to kdev conversion into phys_stat_dev_match
This is more correct, as if st_dev == phys_dev check fails
we have to treat phys_dev as kdev for path resolve device
comparison.

Howver, this is not the case for non-btrfs FSs, and for the
latter one doesn't change anything as it uses anon devices
which are equal for kdev and odev cases.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 08:44:15 +04:00
Cyrill Gorcunov
1ba08ca664 mount: Extend phys_stat_dev_match to use path resolving instead of btrfs engine
Instead of scanning btrfs subvolumes (which can be even unaccessbile
if mount point lays on directory instead of subvolume itself) we use
path resolving feature here -- once we need to figure out if some
device number need to be altered up to mount point (as we know stat()
called on subvolume returns st_dev for subvolume itself, but not
one that associated with a superblock and shown in /proc/self/mountinfo
output).

This as well implies that we need to check if device number for ghost
files are to be updated to match mountinfo, thus we use phys_stat_resolve_dev
helper here.

After this patch the previously merged btrfs engine is no longer needed
(at least it seems so) and can be dropped.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 16:05:22 +04:00
Cyrill Gorcunov
9e6bd8c512 sk-unix: Don't fail if socket path lays on btrfs volume
Because socket migh lay on btrfs volume (thus the device
number reported by diag module won't be the same as obtained
from stat(2)) we need to do an additional test and try
to resolve device number with help of btrfs engine.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-04 19:23:33 +04:00
Cyrill Gorcunov
d7141750d2 sk-unix: Use pr_warn instead of pr_perror if socket path can't be stat'ed
The error message is rather confusing people. In worst case (if
it happened that we need this uncollected socket), criu will
print out real error message later.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-28 15:38:52 +04:00
Cyrill Gorcunov
75ebb6d02c sk-unix: Print the name of sockets being dropped
Useful for bug hunting.

 | (00.005209) unix: Dropping path /mnt/disk1/new_subvol/criu/test/zdtm/live/static/sockets00.test
 | for unlinked bound sk 0x26.0x1d4e real 0x23.0x1d4e

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-28 15:36:33 +04:00
Andrey Vagin
4850fd94a8 crtools: move cr_options in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:17:52 +04:00
Andrey Vagin
1300cf4915 crtools: move all stuff about fdset in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 15:24:48 +04:00
Pavel Emelyanov
0a8a162146 unix: Increase verbosity of "can't dump this socket" check
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-10 11:17:42 +04:00
Pavel Emelyanov
cfe72ab77a service: Put service sk inode into separate variable
I'm about to get rid of service state struct.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-28 06:06:53 +04:00
Ruslan Kuprieiev
3f1aeb2c86 unix: SOCK_SEQPACKET
Everything in the sk-unix.c is ready for seq-packet sockets.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-30 18:44:57 +04:00
Pavel Emelyanov
4b6e1d6dc0 unix: Print sockets IDs in hex when collect skips them
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 11:40:40 +04:00
Pavel Emelyanov
3ebb368299 unix: Print "socket not found" error message on dump
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 11:39:54 +04:00
Pavel Emelyanov
5f47e0a67f service: Simplify dump-responce sending
We need 2 parameters only to form it properly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:40:04 +04:00
Pavel Emelyanov
e866b7c043 rpc: Split rpc req-s from rpc-resps
Now we don't have generic criu_msg thing -- instead, we have
explicit request (with per-type args) and explicit responce
(yet again -- with per-type args).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:36:12 +04:00
Ruslan Kuprieiev
98b5541492 v2 rpc: change some "required" fields to "optional"
The most of fields are to be changed to "optional", because they are
optional in fact.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:21:13 +04:00
Pavel Emelyanov
54a6a79455 unix: Check service client for being null
For regular dumps this thing is not initialized.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-13 16:42:01 +04:00
Ruslan Kuprieiev
d74073a593 unix: Handle service socket on dump and restore
Service connection is actually an 'external' one from unix sockets engine POV,
but we don't want to dump it as such. Thus, we explicitly find one and dump it
as half-closed connection. On restore we push an artificial message into it
to report to the program that the dump-request was served, but the program is
restored.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-13 15:53:20 +04:00
Pavel Emelyanov
9a6bc0fdab unix: Add comments about icons and external sockets
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-10 12:24:11 +04:00
Ruslan Kuprieiev
14fff50719 v2 fix data loss when dumping semi-closed unix stream connection.
This patch fixes running into loop and data loss, when dumping
semi-closed unix stream connection.

patchv2 has error check, that was missed in v1.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-28 16:52:17 +04:00
Pavel Emelyanov
b18fb09eb9 show: Replace one-line show_foo calls with args array
We have generic do_pb_show() call and tons of show_foo
routines, that just call one with proper args. Compact
the code by putting the args into array and calling
the do_pb_show() in one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-24 04:00:32 +04:00
Pavel Emelyanov
84737e2796 build: Generate most of the pb-desc automatically
These contain linkage between number, data type and routines
for pb messages we write/read to/from image files. Most of them
have simple number-type-routines mapping, so introduce a generating
script for that.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-23 21:47:31 +04:00
Pavel Emelyanov
60e6d38868 collect: Shorten common images collecting code
Now we have a set of cinfo-s, it's possible to collect all
this stuff in a plan for-loop.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 03:52:18 +04:00
Pavel Emelyanov
64e7d2435a collect: Reduce amount of args to collect_image call
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 03:27:06 +04:00
Pavel Emelyanov
9917c4fe34 rst: Compact file-descs collects a bit
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-21 01:06:58 +04:00
Pavel Emelyanov
72ec39f10c util: Rename pie's util-net.c into util.c
Will put more things there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-29 12:43:30 +04:00
Cyrill Gorcunov
ec6b8e77e5 net: unix -- Print collected socket names
Quite convenient to know which exactly names are used.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-11 19:10:25 +04:00
Pavel Emelyanov
1148edc1a6 unix: Support semi-closed stream connection
Unix socket and have no peer, but be in established state.
Such types of sockets appear when one end of a connection
closes and leaves the peer in full-shutdown state.

Check this and handle properly on restore.

Reported-by: Florian Gross <Florian.S.Gross@web.de>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-02 02:28:43 +04:00
Pavel Emelyanov
d020ebb36d files: Compact the code by removing per-file dump helpers
Since *all* of them just call do_dump_gen_file with proper ops,
just call one directly. Compacts the code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-06-14 00:11:08 +04:00
Pavel Emelyanov
add21b75c9 show: Remove options args from ->show callback
This thing is global, we can address one explicitly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-08 00:23:42 +04:00
Kir Kolyshkin
41c7ca8218 Fix typos in comments
This is less useful than fixing typos in output messages, but anyway.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 12:46:46 +04:00
Pavel Emelyanov
7bdba0f745 unix: Add _all_ peers into must-dump list
When dumping a unix socket we must make sure, that all connections
are dumped or -x option is used. Currently only peers with non-matching
ids are added into check. Fix this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-02 23:27:45 +04:00
Andrey Vagin
d2b1d6f2aa socket: prevent dumping of sockets if they are not collected
The idea is simple. If the collection of given type of sockets failed,
crtools can't be sure, that it's able to dump such sockets correctly.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-28 18:23:18 +04:00
Cyrill Gorcunov
f95d509d2e sk-unix: Don't zap error returned
If error happened during queue read don't zap it.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-27 13:39:14 +04:00
Pavel Emelyanov
6b8c824fcc unix: More verbose output on ext unix socket dumping.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-26 19:38:25 +04:00
Pavel Emelyanov
f52d53c585 unix: Make more descriptive error logging for ext socket restore failure
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-26 19:32:53 +04:00
Andrey Vagin
f3cd454cd4 sk-unix: dump/restore a file permissions
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-30 03:28:01 +04:00
Andrey Vagin
0fc129a121 files: pass a file descriptor on an fdinfo image instead of cr_fdset
Currently fdinfo dumps for each task, so CR_FD_FDINFO is in cr_fdset.
A few tasks can share one fd table and the set of descriptors will be
dumped once and a image name will contain files_id instead of pid.
In this case CR_FD_FDINFO will go away from cr_fdset.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-11 14:47:09 +04:00
Alexander Kartashov
6f61488f21 x86: moved x86-specific files into the directory arch/x86.
* The following files goes into the directory arch/x86/include/asm unmodified:
  - include/atomic.h,
  - include/linkage.h,
  - include/memcpy_64.h,
  - include/types.h,
  - include/bitops.h,
  - pie/parasite-head-x86-64.S,
  - include/processor-flags.h,
  - include/syscall-x86-64.def.

* Changed include directives in the source files that include the headers
  listed above.

* Modified build scripts to reflect the source moves.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:02:47 +04:00
Andrey Vagin
08ffa65ed5 socket: don't fail if DIAG_SHUTDOWN is absent
A error message is printed.

We want to save ability to try crtools on non C/R kernel.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-29 17:43:32 +04:00
Andrey Vagin
1eb2212530 unix: restore file params and sockopts for all standalone sockets
We can have a situation, when a socket is bound, but isn't listen yet.

I can't find a situation, when we should not restore parameters.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-02 14:38:48 +04:00
Andrey Vagin
e5a8065713 unix: don't restore name for unix stream established sockets
A stream socket may be bound, but is not listen yet.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-02 14:37:45 +04:00
Andrey Vagin
434c107d7c unix: allow to dump closed sockets
Looks like it can be restored already.

#2408

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-02 14:37:33 +04:00
Pavel Emelyanov
a6a476ff23 skopts: Prepare for xmalloc-able entries on SkOptsEntry 2012-11-01 17:53:57 +03:00
Pavel Emelyanov
7d8ad0bc47 unix: Lost master socket opts restore
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-24 22:12:57 +04:00