2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 21:38:16 +00:00

2322 Commits

Author SHA1 Message Date
Pavel Emelyanov
5a469e1894 restorer: Lost tgt vmas lenght in restorer memory blob hinting
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 02:56:14 +04:00
Pavel Emelyanov
845f3ee973 fd: Indirect fd opening states engine
Put the states into in one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 00:34:37 +04:00
Pavel Emelyanov
1ea03bf80c fd: Relax file master checking in open and post_open
pid == pid && fd == fd equals fle == fle :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 00:21:14 +04:00
Pavel Emelyanov
cc41192f10 fd: Standartize arguments for fd opening stages handlers
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 00:17:57 +04:00
Pavel Emelyanov
b0502e4fe8 fd: Split fd opening and serving out routines
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 00:08:39 +04:00
Konstantin Khlebnikov
ae4796d025 zdtm: new testcase for unhashed proc entries
Testcase: fork child, chdir into /proc/$pid and kill child.

test for http://bugzilla.openvz.org/show_bug.cgi?id=2315

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrey Wagin <avagin@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 16:09:40 +04:00
Andrey Vagin
e628b63b17 zdtm: close an external tty
Redirect standard descriptors of a test init process in to the log file.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 16:09:13 +04:00
Andrey Vagin
499e4486f5 zdtm: run test in a new session
It was lost for tests which executed in a new namespaces.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 16:08:39 +04:00
Andrey Vagin
0e4ec77612 zdtm: check restore of TCP connections (v2)
The test creates two processes.
A first process creates a tcp server, a second one connects to it.
The first process is dumped and restored.
Then the test checks that the TCP connection is alive.

v2: fix compilation :)

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 14:56:30 +04:00
Andrey Vagin
689317bf4e zdtm: add a set of function for creating a tcp connection
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 14:55:08 +04:00
Cyrill Gorcunov
0910b72b3d tty: Use is_service_fd where appropriate
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 14:45:14 +04:00
Cyrill Gorcunov
45cc85eea4 Speed up service-fd retrieval
We're using get_service_fd in file engine,
better to make it fast. This patch caches
the limits system provides us, instead of
calling getrlimit() every time.

This patch introduces is_service_fd helper
which will be used instead of get_service_fd
where it make sense.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-13 14:45:06 +04:00
Pavel Emelyanov
b354a09cd7 rst: Brush up shared resources collection
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:11:33 +04:00
Pavel Emelyanov
ccce9fed2a tty: Brush up ctl tty preparation
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:09:05 +04:00
Pavel Emelyanov
1838bee1be tty: Remove unused constants from header
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:07:34 +04:00
Cyrill Gorcunov
682b9d672c app-test: check screen application
Add test for screen c/r.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:03:01 +04:00
Cyrill Gorcunov
8895729906 zdtm: Add pty04 test
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:02:53 +04:00
Cyrill Gorcunov
1603f88836 zdtm: Add pty03 test
Non-opened control terminal

* Set a control terminal
* Close a file descriptor on it
* Dump/restore
* Open the control terminal (/dev/tty)
* Check, that it connected to the master end

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:02:46 +04:00
Cyrill Gorcunov
bc962a28d2 zdtm: Add pty02 test
The test is tricky -- it opens master in task 1
and dup it in task 2, then close in task 1 and
do C/R.

Thus we need to setup SID of master terminal
somehow in children, which usually fails in
currnt tty restore implementation.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:02:39 +04:00
Cyrill Gorcunov
1a41fcfc21 zdtm: Add pty01 test
Two slaves on same pty.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:02:32 +04:00
Cyrill Gorcunov
20d6762d93 tty: Add restoration of controlling terminal v4
The idea behind is pretty simple -- once we find
that there is a controlling terminal present we
do call ioctl on appropriate /dev/pts/N.

This is done in a bit unusuall manner. When we
find that there is a controling terminal present
we do create an additional FdinfoEntry for it
with object id taken from existing master peer.

The file engine stack this new FdinfoEntry on
fd_info_head head list. Thus we will have at
least two entries on this list. One for real
Fdinfo associated with master peer and one for
our new generated Fdfinfo entry, it depends on
pid which one become a file master.

Finally we do use post_open_fd hook in our
tty code which allows us to open controlling
terminal and yield proper ioctl on it.

v2:
 - restore control terminals via service fd,
   still need to speedup service fd retrieval.

v3:
 - use prepare_ctl_tty() helper to generate
   control terminal fdinfo entry

v4:
 - use post_open_fd

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:58 +04:00
Cyrill Gorcunov
d5dfab7745 check: Add check_tty
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:56 +04:00
Cyrill Gorcunov
a365befaea tty: Add show method
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:55 +04:00
Cyrill Gorcunov
89a7a45d37 tty: Add checkpoint/restore for unix terminals v6
Usually the PTYs represent a pair of links -- master peer and slave
peer. Master peer must be opened before slave. Internally, when kernel
creates master peer it also generates a slave interface in a form of
/dev/pts/N, where N is that named pty "index". Master/slave connection
unambiguously identified by this index.

Still, one master can carry multiple slaves -- for example a user opens
one master via /dev/ptmx and appropriate /dev/pts/N in sequence.
The result will be the following

master
`- slave 1
`- slave 2

both slave will have same master index but different file descriptors.
Still inside the kernel pty parameters are same for both slaves. Thus
only one slave parameters should be restored, there is no need to carry
all parameters for every slave peer we've found.

Not yet addressed problems:

- At moment of restore the master peer might be already closed for
  any reason so to resolve such problem we need to open a fake master
  peer with proper index and hook a slave on it, then we close
  master peer.

- Need to figure out how to deal with ttys which have some
  data in buffers not yet flushed, at moment this data will
  be simply lost during c/r

- Need to restore control terminals

- Need to fetch tty flags such as exclusive/packet-mode,
  this can't be done without kernel patching

[ avagin@:
   - ideas on contol terminals restore
   - overall code redesign and simplification
]

v4:
 - drop redundant pid from dump_chrdev
 - make sure optional fown is passed on regular ptys
 - add a comments about zeroifying termios
 - get rid of redundant empty line in files.c

v5 (by avagin@):
 - complete rework of tty image format, now we have
   two files -- tty.img and tty-info.img. The idea
   behind to reduce data being stored.

v6 (by xemul@):
 - packet mode should be set to true in image,
   until properly fetched from the kernel
 - verify image data on retrieval

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:54 +04:00
Cyrill Gorcunov
5340807b87 Add separate list for slave tty fds on restore v2
When we will be restoring ttys we need that restore
procedure for master peers will be yielded earlier
than for slave peers due to ttys specifics. With this
commit we introduce @tty_slaves list which will allow
us to order tty file restore procesure.

Because we need to fetch which list to be used depending
on tty type this patch extend select_ps_list with fdinfo_list_entry
parameter.

v2 (by xemul@):
 - make sure the epoll list is still last

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:52 +04:00
Andrey Vagin
e3afdd0f29 tmpfs: replace all short tar options on long analogs
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 18:34:19 +04:00
Pavel Emelyanov
93de669270 proc: Don't report error in case fdinfo for epoll fd is empty
This is normal situation -- eventpoll fd may have no fds attached
thus resulting in empty fdinfo file. Report OK in that case.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 17:55:15 +04:00
Andrey Vagin
278d83af20 eventpoll: popullate eventfd in post_open()
Otherwise a transport fd may be added to eventfd...

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 17:50:49 +04:00
Andrey Vagin
403dcb9de5 files: place the state POST_CREATE after the state RECV
It will be used for restoring epollfd.
Currently a transport fd may be added to epollfd.
epollfd should be populated, when all descriptors were already received.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 17:50:22 +04:00
Andrey Vagin
ca567e76c3 sk-unix: add a peer only if it's not in a list yet
I tried to fix that by:
commit bc2ac71c1abddbe76893c0dc1f0421311786070c
Author: Andrey Vagin <avagin@openvz.org>
Date:   Wed Sep 12 15:16:39 2012 +0400

    sk-unix: don't add a socket in a second time

but made a mistake and now a peer would be added only if it's in a list.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 17:49:36 +04:00
Andrey Vagin
3c51808f1a zdtm: make several connections to a file dgram socket
Before we checked only one connection.
With this patch the test reproduces a bug:

Error (sk-unix.c:395): BUG at sk-unix.c:395

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 15:16:41 +04:00
Andrey Vagin
bc2ac71c1a sk-unix: don't add a socket in a second time
A socket can be added in a list two times, if two other sockets
are connected to it.

This patch fixes a problem:
    Error (sk-unix.c:395): BUG at sk-unix.c:395

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 15:16:39 +04:00
Andrey Vagin
0c72ab18e0 sk-unix: add more information messages
* A message about external sockets is printed before any action.
* Add a message, when a peer is added in a list of sockets.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 15:16:21 +04:00
Konstantin Khlebnikov
1d6f3cce98 zdtm: don't start state-tests on global stop
$ make cleanout stop
rm -f -r *.pid *.out* *.test* *.state
./conntracks --statefile=conntracks.state --outfile=conntracks.out start
make: *** [conntracks.state] Error 1

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:38:01 +04:00
Konstantin Khlebnikov
1ca043ea1a zdtm: fix bashisms
`< $FILE` isn't posix compatible and doesn't work in dash

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:37:51 +04:00
Konstantin Khlebnikov
80a8cb80f2 zdtm.sh: fix bashisms
fix obvious bashisms to make script more portable

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:37:36 +04:00
Konstantin Khlebnikov
fd735d8be3 zdtm: fix struct tpacket_req3 redeclaration
Linux has it since v3.2

cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -I../../lib   packet_sock.c ../../lib/libzdtmtst.a   -o packet_sock
packet_sock.c:70:8: error: redefinition of ‘struct tpacket_req3’
In file included from packet_sock.c:23:0:
/usr/include/linux/if_packet.h:245:8: note: originally defined here

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:36:41 +04:00
Konstantin Khlebnikov
cfa2150490 zdtm: fix comilation for non-constant PAGE_SIZE
On some systems PAGE_SIZE is declared as sysconf(_SC_PAGESIZE) in <sys/user.h>
this is non-constant expression, so it cannot be used in type declarations.

cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0   -c -o ns.o ns.c
ns.c:124:7: error: variably modified ‘stack’ at file scope

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:36:30 +04:00
Konstantin Khlebnikov
dccb15cc0f zdtm: fix compilation in test_msg()
cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0   -c -o msg.o msg.c
msg.c: In function ‘test_msg’:
msg.c:40:6: error: variable ‘len’ set but not used [-Werror=unused-but-set-variable]

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 14:36:21 +04:00
Pavel Emelyanov
720cab0bd8 fd: Sanitize open_fd with send_fd_to_self helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 22:27:21 +04:00
Pavel Emelyanov
8cc9477d46 fd: Rename tmp to ret in open_fd
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 22:20:21 +04:00
Pavel Emelyanov
97dba0eb8f fd: Fast path post open
Check for post_open callback presense before any other checks.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 22:07:21 +04:00
Pavel Emelyanov
84d1ffb986 fd: Move rst fd list iteration into helper
Same again -- for code to be cleaner.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 21:47:14 +04:00
Pavel Emelyanov
455aa8cd37 fd: Move ps fd list selection to separate routine
Just for cleaner (from my pov) code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 21:33:19 +04:00
Cyrill Gorcunov
ccc6b7285f parasite: Initialize fd in parasite_get_proc_fd
Otherwise I get

 | parasite.c: In function ‘parasite_service’:
 | parasite.c:383:11: error: ‘fd’ may be used uninitialized in this function [-Werror=uninitialized]
 | cc1: all warnings being treated as errors

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 18:56:24 +04:00
Andrey Vagin
30b08baa52 zdtm: open an one unlinked files two times
A few test check restoring of file descriptors to a one file struct.
Here is better to check, that a few file struct can be linked to one unlinked file.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 18:00:16 +04:00
Andrey Vagin
b11eeea381 restore: auto-unlink for ghost files (v2)
A ghost file is used for restoring descriptors of an unlinked file.
It is created, opened and deleted.

Currently ghost files are collected in root task and then removed
by crtools when everybody is restored. This scheme doesn't work,
ghost_file_list is not shared, plus tasks may live in different mount
namespace.

It was broken by the following commit:
bd4e5d2f restore: prepare shared objects after initializing namespaces

We can't just move clear_ghost_files(), because we need to wait, until
all processes have not opened a ghost file.
We can add one more global barrier or move clear_ghost_files() in
a restore code bellow an existent barrier.

Here is a better sollution, a gost file is deleted by the last user.

v2: Use the type atomic_t and fix a commit message.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 17:59:59 +04:00
Andrey Vagin
09d179602f atomic: add atomic_dec_and_test
This code is copied from the Linux kernel.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 17:55:23 +04:00
Andrey Vagin
834d996b91 crtools: add a separate type for atomic variables
It's a struct to prevent using usual arithmetic operations.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-11 17:55:15 +04:00
Andrey Vagin
c627c03714 mm: taking into account a gurad page to find a space for a restorer vma
Actually a gurad page is a part of a stack vma and we don't want to remap
it by a restorer vma.

The crtools on restore find a place for a restorer vma, which will not
intersect with other VMAs. A guard page is a part of a stack VMA, if
we don't take into account it, we can place the restorer VMA on it and
that case is a bug.

Would not this lead to situation where we expand stack manually? Every new
c/r cycle add one page to the bottom of stack, no? No:

strace:
mmap(0x5f4d0e0cc000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_GROWSDOWN, -1, 0) =
0x5f4d0e0cc000

/proc/PID/maps:
5f4d0e0cd000-5f4d0e0cd000 rw-p 00000000 00:00 0
.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-10 14:35:38 +04:00