2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

2322 Commits

Author SHA1 Message Date
Pavel Emelyanov
f429de662e creds: Support supplementary groups
Dumping them is performed via parasite, since calling the getgroups
is the only way of getting the complete list. Currently the nr of
groups to dump is limited explicitly with the size of shared memory
between crtools and parasite. This is MUCH more that we have seen
on real apps so far.

Restoring is done early, before restorer blob not to carry the undefined
array of grpous in there. This is OK, since groups do not affect us at
that point and are not affected by subsequent creds restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-11 17:07:02 +04:00
Pavel Emelyanov
013d26bdd8 syscalls: Add getgroups syscall
Getting groups can be done vie proc, but there's only 32 on them,
while task may have up to 65k :( We will use parasite for that and
thus require this syscall definition.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-11 17:07:01 +04:00
Pavel Emelyanov
699a33e1b9 creds: Dump creds with the help of parasite
Currently move there the secbits dumping, which is not dumped
via misc-dumping command. This patch is required to support
per-task groups dumping (setgroups/getgroups) -- we'll have to
drain the groups from parasite.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-11 17:06:58 +04:00
Pavel Emelyanov
7db199c783 parasite: Remove double args copy
There's a shared memory between crtools and parasite. No need in copying
args back and forth, just get the args pointer in crtools and work on it.
Where not possible (misc, fds drain) do explicit memecpy (to be fixed).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-11 17:05:25 +04:00
Andrey Vagin
7c8496f5b0 pipe00: replace polling on waiting
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-10 17:31:19 +04:00
Cyrill Gorcunov
062f468817 pstree: Define symbolic name for init process
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-09 19:57:15 +04:00
Pavel Emelyanov
e2912397b5 log: Set log level in parasite
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-08 19:56:12 +04:00
Cyrill Gorcunov
3ef0d9735b dump: No need to init root_item->sibling
It's already done in alloc_pstree_item() by
recently merged commit.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-08 19:00:11 +04:00
Cyrill Gorcunov
e0be540401 pstree: Move struct pid to pstree.h
I believe this make sense to keep this structure
in pstree.h where pstree related data lives.

Also I've added some comments on struct pid members.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-08 18:59:36 +04:00
Cyrill Gorcunov
17a1548a5b pstree: Rename @list member to @sibling
To be close to the kernel naming.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-08 18:59:26 +04:00
Cyrill Gorcunov
9c60b1f4ad pstree: pstree_item members tuning up
- @list member closer to @children
 - add some comments on memebers
 - add space lines for members grouping

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-08 18:59:12 +04:00
Pavel Emelyanov
df83b2c2fb parasite: Use simple logging engine
Just as for restorer, but simper, as the parasite logging
is just sys_write_msg :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-07 21:12:40 +04:00
Pavel Emelyanov
ddf68b7940 restorer: Use the simple logging engine
Remove the restorer-log and link log-simple into restorer
blob. Now we can use the normal pr_foo API.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-07 21:11:49 +04:00
Pavel Emelyanov
b85bf75cf0 log: Introduce a simple printf-like logging engine
It's supposed to be used by parasite and restorer blob. It
has API equal to the core one -- with setfd, set_loglevel and
(the main thing) print_on_level fn. It currently supports only
strings, decimal and hex numbers (int and long).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-07 21:06:46 +04:00
Pavel Emelyanov
37a7b35e88 log: Move default loglevel macro to header
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-07 21:03:53 +04:00
Pavel Emelyanov
9a54d64539 log: Merge two loglevel checks
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 20:55:23 +04:00
Cyrill Gorcunov
2b56175e49 log: Don't print time-stamp on LOG_MSG
Otherwise "show" action become unreadable.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 19:22:23 +04:00
Cyrill Gorcunov
16ca152d23 pstree: Add few comments in prepare_pstree_ids
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 17:29:26 +04:00
Cyrill Gorcunov
f318f40415 pstree: Drop redundant nil test in prepare_pstree
This as well releases pb entry on error path, not
a big deal since we're exiting in case of error
but still.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 17:29:04 +04:00
Cyrill Gorcunov
d82b853dc8 pstree: Init pstree_item::list inside __alloc_pstree_item
This is a bit fishy that we do init @children list here
but not @list itself. Better be solid and init everything
in one place.

Also no need to poke @threads and @nr_threads, we're using
xzalloc here anyway.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 17:25:09 +04:00
Cyrill Gorcunov
9c263a6c8c pstree: Simplify pstree_item_next
It's a deep first search used here so the code can be shrinked.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 17:23:41 +04:00
Cyrill Gorcunov
59e80d4f48 pstree: Fix typo in prepare_pstree_ids message
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 17:21:54 +04:00
Stanislav Kinsbursky
3583578d7c protobuf: fixed typo in pb_write_one
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 16:04:48 +04:00
Pavel Emelyanov
87cf4ad128 log: Add relative timestamp before each log line
I find this handy.

Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 02:18:01 +04:00
Andrey Vagin
30f0acb43e parasite: fix size of cmd
cmd is declarated in parasite-head-x86-64.S
__export_parasite_cmd:
        .long 0

Its size is 4 bytes, so it should be int instead of long.

This patch fixes a bug in parasite execute,
where a part of args are overwritten by cmd.

memcpy(ctl->addr_cmd, &cmd, sizeof(cmd));

Reported-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 00:44:35 +04:00
Cyrill Gorcunov
79d00c29c0 zdtm: Don't forget to create /dev/ptmx in new root
Otherwise pty tests might fault.

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-02 23:08:02 +04:00
Pavel Emelyanov
c6e0a402bc dump: Fix up error path of pages dump
Call the fini stage even if the dump failed.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-29 08:28:53 +04:00
Pavel Emelyanov
fab5f12fcc dump: Open pagemap only once
When dumping pages we use 3 commands for parasite -- prep,
dump (per-vma) and fini. Open the pagemap file in prep,
insteam of in each per-vma dump.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-29 08:23:55 +04:00
Cyrill Gorcunov
6a5ac97186 tty: Fix copying of termios character map
The system termios structure and our PB
equivalent defined quite different, while
first defined as plain array we use dynamically
allocated memory. Thus the use of min() macro
is incorrect here and always produce the size of
pointer.

Fix it using the size of array from the system
provided structure. The BUILD_BUG_ON will prevent
from accidental changes.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-02 20:26:11 +04:00
Cyrill Gorcunov
8a4ec72b2f zdtm: Move pty tests back to ns compatible list
Test pty03 is not yet ready for ns, will be addressed later.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-02 19:22:03 +04:00
Cyrill Gorcunov
4b99537cd4 zdtm: Mount devpts in new root
In case if we enter the new rootfs don't forget to
mount devpts, otherwise ttys can't be connected.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-02 19:21:30 +04:00
Andrey Vagin
0ee1eed5fd zdtm: simplify a case, when a root should be changed
We don't need to umount each points one by one,
if we are goning to do pivot_root().

"""
pivot_root moves the root file system of the current process to the
directory put_old and makes new_root the new root file system.
"""

So I suggest to do pivot_root() and then detach the old root, all
other mount points will be unmounted automatically.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-02 19:20:32 +04:00
Victor Konyashkin
c52be774f0 zdtm: It's need add format to fprintf
It's need add format to fprintf to avoid following error in Ubuntu 12.04:
msg.c:59:2: error: format not a string literal and no format arguments [-Werror=format-security]

Signed-off-by: Victor Konyashkin  <vkonyashkin@parallels.com>
Acked-by: Andrey Vagin <avagin@openvz.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-02 19:19:35 +04:00
Andrey Vagin
d33d2290bd files: rework a function for closing all descriptors (v2)
It reads /proc/PID/fd and close all descriptors except service fds.

v2: s/is_one_of_service_fds/is_any_service_fd

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-29 11:01:53 +04:00
Andrey Vagin
edf8ec3fe3 zdtm: add ability to make several iterations of dump/restore
Use the -i <num> option to zdtm.sh

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 19:50:40 +04:00
Andrey Vagin
595e2c7694 files-reg: don't forgot about mntns_root in linked-remap
All operations with files should be relative to mntns_root

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 19:15:52 +04:00
Andrey Vagin
e149e12586 sk-queue: use write/read instread of sendfile
sendfile uses sendpage() and all data are splitted on pages and
a new skb is allocated for each page. It creates a big overhead on SNDBUF.

sendfile() isn't suatable for DGRAM sockets, because message boundaries
should be saved.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 16:44:05 +04:00
Andrey Vagin
1ce1cca2ac sk-queue: don't block on restore of socket queues
If a socket queue doesn't have a free space, a error should be returned,
because nobody reads this socket.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 16:42:15 +04:00
Andrey Vagin
ea20f5d221 mntns: fix indentions
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 14:13:20 +04:00
Andrey Vagin
a2fd8cd0a5 mntns: simplify a case, when a root should be changed
We don't need to clean_mnt_ns(), if we are goning to do pivot_root().

"""
pivot_root moves the root file system of the current process to the
directory put_old and makes new_root the new root file system.
"""

So I suggest to do pivot_root() and then detach the old root, all
other mount points will be unmounted automatically.

This patch fixes a problem, when a new root is mounted above a non-root
mount point. It's a default configuration for OpenVZ.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 14:13:18 +04:00
Andrey Vagin
e3fbb63080 crtools: use a special function for executing external utils
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 14:09:58 +04:00
Andrey Vagin
cd2be93ba4 util: add a function for executing an extrenal tools (v2)
For executing an external tools we need to block a SIGCHLD
and to juggle file descriptors.

SIGCHLD is blocked for getting an exit code.

A problem with file descriptors can be if we want to set 2 to STDIN,
1 to STDERR, 0 to STDOUT for example.

v2: use helpers reopen_fd_as and move_img_fd

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 14:09:57 +04:00
Andrey Vagin
af02c2698f sk-queue: don't overwrite a return code
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 14:02:50 +04:00
Andrey Vagin
9f2e9014f8 sk-queue: recvmsg saves a error code in errno
Probably sys_recvmsg was used earlier, which returns a error code.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 14:02:04 +04:00
Cyrill Gorcunov
eb3f46f33d pstree: Exit with error instead of BUG if image corrupted
No need to panic if image corrupted and we can exit
out graciously.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-28 14:01:17 +04:00
Pavel Emelyanov
4797f7236e help: Add newline at the end of action scripts help messages
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 20:11:54 +04:00
Pavel Emelyanov
1be08acc7c remap: Add cmdline option to allow linked remap
By default crtools shouldn't modify the environment, except for
killing the dumped tasks. The link remap does so and should sit
under explicit cmdline option.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:39:23 +04:00
Pavel Emelyanov
fe187fe0ed zdtm: Test that opened and unlinked files with non zero link count work
Same as unlink_fstat0x, but leave one link alive.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:25:15 +04:00
Pavel Emelyanov
563b116096 files: Support opened-and-unlinked files with non zero link count
These are not ghost, as they are still on fs, so we cannot take
them with us in the image. Neither we can easily find the other name
of that file. Sad :(

To make it work we linkat() the new name to that file using the
AT_EMPTY_PATH flag to link directly to the opened fd. If we could
openat() the fd's parent we would better do it, but we can't and
thus have to create the link name by explicit absolute path :(

This modifies the fs we're dumping, so I'll introduce one more cmd
line option for that soon.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:22:52 +04:00
Pavel Emelyanov
aab7e72ff1 rst file: Introduce the file_remap abstraction
For linked remaps we'll use similar technique as for ghost
files, but lighter. For that sake make reg_file_info remap
to file_remap, not to the whole host_file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:20:06 +04:00