2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 05:48:05 +00:00

2322 Commits

Author SHA1 Message Date
Pavel Emelyanov
7cdfc8b3c5 ghostf: Move remap_id ghost bit clear to open_remap_ghost
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:16:51 +04:00
Pavel Emelyanov
246d8336c6 files: Add path len arg to check_path_remap
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-26 06:15:43 +04:00
Andrey Vagin
e1b02a48c1 cr-restore: block SIGCHLD for restoring namespaces
Restore of namespaces requires executions of external tools
(ip, tar, etc). We want to know return codes, so we should
block a default sigchld handler. Before we did that for each
command, I suggest to block SIGCHLD, then restore namespace and
unblock SIGCHLD.

The default sigchld handler is used for catching target processes,
but all this processes (except a current one ) are started after
restoring namespaces.

Currently we forgot to block SIGCHLD before executing "ip",
and this bug was caught.

Reported-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-25 15:59:13 +04:00
Andrey Vagin
c4148d7907 cr-restore: exit if someone can not be restored
Forgot to handle an error path in a one place.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-25 15:54:51 +04:00
Cyrill Gorcunov
f95ff79c6d restorer: Add "memory" constraint into asm statement
It seems otherwise older gcc compilers do treat this
statement as incomplete.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Reported-by: Huang Qiang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-25 15:33:12 +04:00
Pavel Emelyanov
d81c9a4618 criu: Version 0.2 release
The biggest acheivement since v0.1 -- initial support for LXC containers!

Other less notable (but still great) things done are:

* Implemented support for TTY-s
* Added support for packet sockets
* Bug-fix here and there

Note, that images generated by v0.1 tool are accepted by v0.2 one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
v0.2
2012-09-20 13:44:18 +04:00
Cyrill Gorcunov
1de8adbf71 tty: Verify active pairs once dump complete
We don't support yet detached terminals migration,
so fail early if we can't proceed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-20 13:35:39 +04:00
Cyrill Gorcunov
a3c886de62 tty: Mark living peers in tty_active_pairs bitmap
Will need it to verify that live tty pairs exist.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-20 13:35:38 +04:00
Cyrill Gorcunov
dd783030e6 tty: Rename tty_test_and_set_index to tty_test_and_set
To trace paired ttys we will need one more bitmap
so rename tty_test_and_set_index to tty_test_and_set
because we will need this helper in another context.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-20 13:35:37 +04:00
Pavel Emelyanov
850d74c4c5 ipc: Fix uninitialized ptr xfree-ing
CC       ipc_ns.o
  ipc_ns.c: In function ‘dump_ipc_msg’:
  ipc_ns.c:240:2: error: ‘message’ may be used uninitialized in this function [-Werror=uninitialized]
  ipc_ns.c:192:17: note: ‘message’ was declared here
  cc1: all warnings being treated as errors

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-19 20:32:30 +04:00
Stanislav Kinsbursky
e929b43742 ipc: message queues dump update for new kernel API
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Tested-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-19 20:09:59 +04:00
Cyrill Gorcunov
a0b497e035 docs: Prepare for 0.2
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-19 17:04:27 +04:00
Cyrill Gorcunov
89ab41d245 parasite: Make sure the arguments passed do never overwrite args zone
We do have build-time tests for that but it's not enough, better to
be on safe side and double check the arguments size.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-19 16:18:00 +04:00
Andrey Vagin
d7d600c127 tcp: save and restore rcv_wscale (v2)
rcv_wscale is a symetric parameter with snd_wscale.

Both this parameters are set on a connection handshake.

Without this value a remote window size can't be interpreted correctly,
because a value from a packet should be shifted on rcv_wscale.

This patch doesn't break a back compatibility, a rcv window
will be restored with the same bug (rcv_wscale = 0).

v2: Update to a new kernel interface:
	[PATCH] tcp: restore rcv_wscale in a repair mode (v2)

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-19 16:17:11 +04:00
Andrey Vagin
df5f44425e proc: use bigger buffer for one line from mountinfo
Before 256 bytes were used for that, it may be not enough.
For example it was not enough for a NFS point on my test system.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-19 15:02:25 +04:00
Cyrill Gorcunov
e3eaf90e8e parasite: Increase stack size up to 16K
In commit 97cfb707 we extended scm_fdset structure
up to 7K thus we need to increase the parasite stack
size enough to hold it. It was not noticed simply because
we were poking arguments area of memory.

The memory map of args and stack for parasite look like

  +-----------+   min address
  |           | |
  | arguments | v (8K)
  |           |
  +-----------+
  |           |
  |   stack   | ^ (16K)
  |           | |
  +-----------+   max address

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-19 15:01:55 +04:00
Cyrill Gorcunov
a3c6869ca1 reg-files: No need for atomic @users
We're under lock anyway.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:13:20 +04:00
Cyrill Gorcunov
997b295d67 files-reg: Use global mutex to serialize ghost file creation
Otherwise there is a race between files with same names:

link(name -> ghost)                link(name->ghost)
open(name)
unlink(name)
                                   open(name) -> ENOENT

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:12:58 +04:00
Andrey Vagin
08e559b3f2 tcp: rename functions for unlocking tcp connections
One function is used on restoring and one is used on dumping,
so each function has own prefix rst or cpt.
The both functions have the same effect, so the main part of the names
is same and it describes "unlock_tcp_connections".

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:07:03 +04:00
Andrey Vagin
3223165c32 app-test: dump and restore a Linux Container
network-script.sh is used for locking and unlocking network in CT.

Here is an example of an LXC config:
lxc.console=none
lxc.utsname = test-lxc
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.name = eth0
lxc.mount = /root/test-lxc/etc/fstab
lxc.rootfs = /root/test-lxc-root/

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:06:47 +04:00
Andrey Vagin
5ec8a1c313 cr-restore: unlock connections at the last moment
Restore must not fail after unlocking connections.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:06:14 +04:00
Andrey Vagin
772d6853d2 crtools: collect inet sockets to crtools
Early we moved prepare_shared() to a root task,
because several preparation actions should be executed
in a target namespace set (e.g.: ghost files).

TCP sockets are a subset of init sockets,
they should be unlocked before resume. It's convient to do
from crtools.
An image can't be read more than one time, because we want to
send it via network.

For this two reasons prepare_shared is spitted in two parts,
one for crtools and one for a root task.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:06:06 +04:00
Andrey Vagin
3957a9a69a cr-dump: lock network before dump and unlock in case of errors
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:05:55 +04:00
Andrey Vagin
fbea445df4 cd-dump: lock connection with iptables rules only in a current netns
For another netns we don't need to lock separate connections,
an external chanel can be locked.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:05:49 +04:00
Andrey Vagin
8e90ed8c4d util: add a function for running scripts
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:05:39 +04:00
Andrey Vagin
45fa18487d tcp: split the list tcp_repair_sockets on rst and cpt parts
because here are two types of entries

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:05:32 +04:00
Andrey Vagin
4c2a226458 crtools: add ability to execute external scripts (v2)
Scripts are executed when external actions required.
CRTOOLS_SCRIPT_ACTION contains a required action.
If a script doesn't know a current action, it should exit with 0.

The first usecase will be lock/unlock network.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:05:23 +04:00
Andrey Vagin
c27ff2baac tcp: unset TCP_REPAIR at the last moment after unlocking network (v2)
TCP_REPAIR should be droppet when a network is unlocked.
A network should be unlocked at the last moment, because
after this moment restore must not failed, otherwise a state of
a tcp connection can be changed and a state of one side in our image
will be invalid.

v2: use xremalloc instead of mmap and remmap

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:02:57 +04:00
Andrey Vagin
7e22e60f83 net: add ability to use tcp_repair_off from a restorer code
Use sys_setsockopt and declare a function in a header as "static inline"

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 20:02:39 +04:00
Andrey Vagin
1da4441598 zdtm: add a stream test case for TCP connections
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 18:23:46 +04:00
Andrey Vagin
06282f407c zdtm: handle a partial read/write in socket-tcp
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 18:23:35 +04:00
Cyrill Gorcunov
a2b215a19b pstree: Use max() helper in max_pid assignment
It shrinks code a bit.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-17 18:22:13 +04:00
Pavel Emelyanov
8fc6dbfadd files: Formalize fd restore priorities
There are places when we have to select which fd to ->open
and which to ->receive. To avoid deadlocks we sort them in
an ascending order on { pid, fd } pair.

Make this idea more formal by introducing an explicit function
doing this check and call it where appropriate (pipe.c master
selection is also simplified to fit new ... API).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 22:09:22 +04:00
Pavel Emelyanov
a0560c4298 pipes: Fix wrong pipe info check on master selection
The currently observed list entry should be examined, not
the original one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 22:02:21 +04:00
Pavel Emelyanov
62cf23b93a files: Hide pslist selection logic into file desc handlers
Don't do explicit switch by file type in files.c and don't export
intimate knowledge of pty being master/slave. Use a file desc op
for that.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 21:53:51 +04:00
Cyrill Gorcunov
e0b39c5fd9 zdtm: Make pty tests being non-ns
Until I figure out how to make them work in ns.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 20:47:12 +04:00
Pavel Emelyanov
1d3e1ae6df tty: Remove no longer relevant TODO comment
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 18:26:37 +04:00
Pavel Emelyanov
cc87632f16 tty: Handle tty collecting error
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 18:24:43 +04:00
Pavel Emelyanov
990f80dd0f tty: Sanitize slavery and ctl tty setups
We need to do two non-trivial things with ttys -- interconnect
slaves to masters (or to each other) and setup ctl-tty restoring
task.

Now this is done in subsequently depending on each other steps:

1. collect ttys
2. interconnect slaves and mark ctl-tty tasks
3. collect fake fds for tty-ctl tasks
4. setup orphaned slaves

We can relax this logic in two ways:

1. don't split marking ctl-tty tasks and then creating fds for them
   do it in one step at the end
2. don't interconnect slaves with masters and orphaned slaves in
   two steps -- do it in one place after fds are collected

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 18:12:59 +04:00
Pavel Emelyanov
ff875dc494 tty: Cleanup tty mutex preparation
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 17:58:46 +04:00
Cyrill Gorcunov
aa247d8631 zdtm: Enable pty tests
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 17:50:47 +04:00
Cyrill Gorcunov
4ae20428c0 tty: Restore orphan slavery peers
In case if there is no master peer associated
with a slave peer we have two cases

 - the master peer was closed before slave
 - we just have no master peer at all, but
   only slave one

This patch addresses only first case -- we open
fake master and hook slaves on it, then close it
immediately.

The second case will be addressed later.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 17:50:46 +04:00
Cyrill Gorcunov
da762de63f tty: Rework tty entry verification
tty entries might have no parameters assigned if they
are hanging on closed master, we should take into
account when we do verify them.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 17:50:45 +04:00
Cyrill Gorcunov
0105e543a7 tty: Dump a hanging up terminal
If we've met a hanging up terminal we can escape
lot of work but dump a minimum information needed
for restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 17:50:44 +04:00
Cyrill Gorcunov
07aa668282 tty: Squash tty_get_sid, tty_get_pgrp into tty_get_sid_pgrp
This patch squashes tty_get_sid, tty_get_pgrp into
one tty_get_sid_pgrp helper (which allows to detect
if dumping terminal is hanging up, the real use of
this ability will be addressed in next patch).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 17:50:42 +04:00
Cyrill Gorcunov
978cecd629 tty: Make termios and winsize being optional params
The dangling slave peers might have no data associate
with them if master peer is closed and link is hanging
up. Thus make this parameters optional to not blow the
image with data which never will be used.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 17:50:41 +04:00
Andrey Vagin
52a2c9fd77 restorer: unify log functions
Add ability to use the same macros in restorer code.
In the future we will add ability to show arguments like printf.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 15:14:11 +04:00
Pavel Emelyanov
667953c00f restorer: Don't memcpy restorer blob in each task on restore
Instead -- mmap it once in root task and then mremap it later.
No mremap of original restorer can be done, since in that case
the restorer vma would be tied to crtools binary which in turn
will make set-exe-file prctl to fail with EBUSY.

Note -- after mremap the original vmas list becomes non relevant,
but it's OK. Only new holes appear inside which is OK for munmap.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-14 14:51:40 +04:00
Pavel Emelyanov
80d5fb285f restorer: Mmap restorer blob separately from the rest
This will avoid exec bit on restorer args and will make
it possible for shared restorer eventually.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 04:10:48 +04:00
Pavel Emelyanov
63ce82e7f6 restore: Sanitize restorer code + args layout
There was a strange thing -- task args size is aligned, but when
threads args ptr is get this alignment was lost. Fix this and make
all the bufs page-aligned.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 03:01:48 +04:00