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
Huang Qiang
0c23c5835e crtools: fix a bug that log_level may not work
If we use -v [num] to set log_level and we happen to set it in the end of
arguments, the [num] we set may not work. This patch will fix it.

Signed-off-by: Huang Qiang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-02 13:44:26 +04:00
Andrey Vagin
0fa83b0394 socket: increase socket buffers for restoring queues (v2)
Sizes of send and recv buffers are set to maximum to restore queues,
after that sizes of buffers are restored.

O_NONBLOCK is set to a socket to prevent blocking during restore.

#2411

v2: do the same for unix sockets.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-02 13:40:54 +04:00
Pavel Emelyanov
9f8ef2b802 Merge branch 'br-fetch' 2012-11-01 20:23:02 +04:00
Pavel Emelyanov
ce028b15db zdtm: Test that socket filter migrates well
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-01 19:22:06 +03:00
Pavel Emelyanov
d3397e8f8c sk: Support socket filters
One thing to note. The socket filter proggie is a set of struct-s
wuth 8 and 16 bits values in it. Protobuf doesn't support such thing
and it's too annoying to mess with yet another message for that.
Instead, I encode all this stuff into array of fixed64 fields to
handle endianity (yes, protobuf handles it, but each field is not
just 64-bit value, but a structure).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-01 19:20:33 +03:00
Pavel Emelyanov
a6a476ff23 skopts: Prepare for xmalloc-able entries on SkOptsEntry 2012-11-01 17:53:57 +03:00
Pavel Emelyanov
a723809c7d sock: Fix ret code collection when dumping sockets option
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-01 17:53:26 +03:00
Cyrill Gorcunov
6a9fecb5ea crtools: Add missing \n in pr_err
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-01 15:28:37 +04:00
Kinsbursky Stanislav
f7477bc2a6 zdtm: cleanup launcher output in case of passed test
Print PASS only once.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-01 14:48:05 +04:00
Kinsbursky Stanislav
a08f2030a1 test: add processes tree restoring test
This test makes sure, that processes tree is restored before opened files.
This is guaranteed by holding child's "/proc/<pid>/stat" file opened by parent.

It was inspired by OpenVZ bug:
#2404

IOW, OpenVZ can't restore container with such test inside.

v2:
1) Test renamed + carefull cleanup + minor updates.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-01 14:45:51 +04:00
Huang Qiang
f33df79e1e cr-restore: fix to print correct length of bootstrap
The length of bootstrap in the print is old and wrong, we need to fix
it and unify the length variable.

Signed-off-by: Huang Qiang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-01 14:44:14 +04:00
Pavel Emelyanov
60d382f990 inet: Make tcp_connection inline fn
Now it's used for images only.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 22:30:00 +03:00
Pavel Emelyanov
bf8b7c4f89 inet: Reshuffle proto-level socket dumping
We'll support other tcp states and udp-specific info eventually.
This introduced switch() looks more friendly to this future.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 22:25:57 +03:00
Pavel Emelyanov
8abab0dae7 udp: Warn when read queue is dropped on dump
It's not blocking dump, dgram sockets can lose data. Just emit
a warning in log.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 22:06:45 +03:00
Pavel Emelyanov
6de7b7b395 udp: Don't dump dgram socket with corked data in it
We can't dump application that put some data in write queue and is
about to add more, as there's currently no way to fetch this data
back, and just dropping it means breaking the app-level protocol.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 22:04:46 +03:00
Pavel Emelyanov
a897e060b8 parasite: Sanitize preprocessor arch checks
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 21:09:33 +03:00
Pavel Emelyanov
12ebda3184 tty: Factor out tty ioctls ENOTTY checking
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 21:06:43 +03:00
Pavel Emelyanov
5cfec27131 parasite: Sanitize args size checking
Move the checks to parasite_args() and make them build-time.
This gets rid of bunch of BUILD_BUG_ON-s in parasite.c.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 20:58:03 +03:00
Cyrill Gorcunov
385e1059cb zdtm: More detailed report on unmounting problem
It seems I've screwed the setup and mount points on
my testing machine thus mountpoint test become failing.

Nevertheless, better to report where exactly we've failed
for easier investigation.

With this patch I get

 | ./mountpoints --pidfile=mountpoints.pid --outfile=mountpoints.out
 | 20:26:07.398:  1745: umount(`/dev') failed: Device or resource busy
 | 20:26:07.398:  1745: umount(`/vz') failed: Device or resource busy
 | 20:26:07.399:  1745: umount(`/vz') failed: Device or resource busy
 | 20:26:07.399:  1745: umount(`/vz') failed: Device or resource busy
 | 20:26:07.399:  1745: umount(`/vz') failed: Device or resource busy
 | 20:26:07.399:  1745: FAIL: mountpoints.c:60: Can't umount all the filesystems (errno = 16)
 | 20:26:07.404:  1744: ERR: test.c:298: Test exited with unexpectedly with code 1
 |  (errno = 4)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 21:42:13 +04:00
Cyrill Gorcunov
0678ea2e15 sk-inet: More detailed error parsing on unconnected socket
errno is no guaranteed to be clear if call exit with
success. Thus make sure we've ret negative here and
test for errno then.

http://bugzilla.openvz.org/show_bug.cgi?id=2412

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 20:54:20 +04:00
Cyrill Gorcunov
b110af6eec sk-inet: No need for 128 byte address
The SO_PEERNAME sockopt reports -EINVAL if the len passed is greater
than the real one, and copies part of the address otherwise. Need to
pass there "good" optlen not to get -EINVAL falsely. On the other
hand, since we only need to check for connected/not-connected it's
enough to push there 1 byte.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 20:53:49 +04:00
Cyrill Gorcunov
76221d96c7 tty: Drop tty_lookup_task_sid helper
It's almost the same as find_first_sid, lets use
it instead.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 19:05:00 +04:00
Andrey Vagin
28eb57eddf zdtm: Check full tcp buffers with custom sizes (v2)
* Increase sizes of tcp rcv and snd bufffers
* Fill buffers
* Dump/Restore
* Check, that all data were restored

This test reproduces a problem from buf #2411

v2: don't use test_waitsig() in external processes, because they
   can be out of this pid name-space.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 19:04:01 +04:00
Cyrill Gorcunov
484905d4ef zdtm: Add tty02 test enabled by default
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 18:25:33 +04:00
Cyrill Gorcunov
598a4c21d6 tty: Open slave peers with O_NOCTTY
We have own mechanism to restore controlling
terminal thus we don't need the kernel to create
it in implicit way.

#2409

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 18:24:16 +04:00
Cyrill Gorcunov
6c53c74a06 tty: Rework tty_find_restoring_task
It's being found that we fail to restore tasks which
are not session leaders but have controlling terminals.

This patch reworks tty_find_restoring_task logic to fix
the problem. The problem itself basically was the following --
in case if there no sid present even on master peer or on both
master/slave peers, we were trying to find a restoring task,
and that's wrong since we have peers which do not belong our
session.

#2409

Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 18:24:15 +04:00
Pavel Emelyanov
2b9d87fe6b rst: Fix creds vs threads restoration
Writing to last_pid sysctl is CAP_SYS_ADMIN potected. Thus restoring
creds before it won't work in all the cases.

Fix this by making all threads restore creds themselves, and the
thread group leader -- after all of them.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrey Vagin <avagin@parallels.com>
2012-10-30 10:04:37 +03:00
Andrey Vagin
762f493bc3 zdtm: check a non-controlling terminal
Here are two things:
* A test process is a session leader
* It has a terminal, which are not conrolling for anyone.

For bug #2409

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 10:28:06 +04:00
Cyrill Gorcunov
b1f1154c8a auxv: Use real size of the auxv vector
The size of vector depends on the kernel config
so use the real size of a vector dumped. Otherwise
we might fail on restore.

Reported-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 19:54:12 +04:00
Pavel Emelyanov
84ed00b674 rst: Fixup threads creds restore
Threads do not share creds, thus they should restore them from
group leader (or restore them in the same state which is less
appealing).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 18:39:37 +03:00
Pavel Emelyanov
09afabb422 rst: Merge common thread param restoring for task and threads
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 17:13:11 +03:00
Pavel Emelyanov
f1228904d5 rst: Merge registers restoring code for task and threads restore
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 17:08:46 +03:00
Pavel Emelyanov
1bc50df94b rst: Remove unused field from task_restore_args
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 17:01:26 +03:00
Pavel Emelyanov
f8142ba352 rst: Make thread_restore_args be part of task_restore_args
The former is actually the parameters of thread group leader, so
it's natural to have them on-task.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 17:00:18 +03:00
Cyrill Gorcunov
0a77f4f1f9 parasite: Get rid of redundant PTRACE_INTERRUPT/PTRACE_CONT tail
The tail PTRACE_INTERRUPT/PTRACE_CONT call in parasite calling code
is redundant as far as I can say, thus get rid of it.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:40:45 +04:00
Cyrill Gorcunov
4eb37687a1 app-emu: Add job test
For tty migration testing.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:40:06 +04:00
Huang Qiang
eb9b1ab240 cr-restore: remove the duplicate round_up for restore_thread_vma_len
With some historical changes, the second page-aligned for
restore_thread_vma_len is reduplicate. So remove it.

Signed-off-by: Huang Qiang <h.huangqiang@huawei.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:38:53 +04:00
Cyrill Gorcunov
e8d511943c tty: Don't try to restore controlling terminal via ptmx
The slave peer should be restoring the controlling terminal.
It works for most of programs but need some more investigation
in future.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:37:42 +04:00
Cyrill Gorcunov
f0606bc8d9 tty: Introduce deferred checking of tty sids
The dumping of tty peers is somewhat tricky. And it became more
complex once we allowed to migrate/inherit sessions.

It's being found (in screen c/r) that we've a problem in looking
up of session leaders while dumping tty.

Let me explain with more details. Here is an example of screen
session

  PID   GID   SID
20567 20567 20567           SCREEN
20568 20568 20568  pts/3     \_ /bin/bash

The screen opens master peer (ptmx) and then provides
bash the slave peer (pts/3) where bash sets up a session
leader on it.

Thus we get interesting scenario -- our pstree construction
is done in lazy fashion, we run parasite code to fetch sid/pgid
of a process tree item only when we're really dumping the task.

Thus when we start dumping ptmx peer (which belongs to SCREEN)
we've not yet constructed the process tree item for children
(ie /bin/bash) and the lookup function in tty code (which walks
over all process items in a tree) simply fails to find sid of
child, because we've not yet dumped it.

Thus, to resolve such situation we verify tty sids at late stage
of dumping.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:37:34 +04:00
Cyrill Gorcunov
84da534261 tty: Fixup error message in dump_pty_info()
The sid may be present not only on slave peer
so fix up the message. Also extend it showing
peer type.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:37:18 +04:00
Cyrill Gorcunov
f8fa75ae86 tty: Make tty_type to use @major argument
This makes this helper more wide usable.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:37:11 +04:00
Cyrill Gorcunov
4dc29af3ee tty: Use new ioctls granted by parasite
No need for tricks, we fetch everything we need
from the parasite.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:37:00 +04:00
Cyrill Gorcunov
73217b7a7d tty: parasite -- Add support for new kernel ioctls to fetch state
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:36:46 +04:00
Cyrill Gorcunov
8c1807ab38 tty: Add some comments in tty_find_restoring_task
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:36:35 +04:00
Cyrill Gorcunov
371caf2ff8 tty: Fix tty inheritance in case if zero sid fetched
In case if at checkpoint time we've fetched zero sid
associated with tty peer it doesn't obligatory means
that we've met a hangig up terminal, in particular
zero sid may be obtained if the slave peer do not
belong to the session the task run in but inherited
from the parent. Thus if --shell-job passed we should
handle such situation gracefully.

[ https://bugzilla.openvz.org/show_bug.cgi?id=2405 ]

Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:36:18 +04:00
Cyrill Gorcunov
5cb163411e tty: Lookup for controlling tty iif sid provided
This is rather a code tossing for the next patch.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:35:47 +04:00
Cyrill Gorcunov
1b060e1470 app-test: java -- Use --shell-job option
Since we support tty migration, use it here,
otherwise it'll fail.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-29 13:35:34 +04:00
Vladimir Davydov
fd19a1fc3a zdtm: make posix timer migration test use corresponding clocks
For vz containers, monotonic time freezes when a container is
checkpointed. This makes the zdtm posix timer test fail.

To fix this, obtain time passed, which is used to check timer results,
using the clock used by the timer.

Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Acked-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-26 21:27:03 +04:00
Pavel Emelyanov
df553964df zdtm: Fix sleep time unwanted overflow
After sleep 0.9 there occurs sleep 0.10 which is not what
we want. Stop incrementing on 0.9

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-26 14:58:34 +04:00
Cyrill Gorcunov
3d3e312b38 zdtm: Don't fail maps02 madvise when some kernel madv is not supported
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-26 14:57:20 +04:00