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
Cyrill Gorcunov
bcc7bab7e3 zdtm: Use SIGWINCH+SIGALRM instead of SIGTRAP in pthread01
Otherwise test with -d option get fail (this is because
SIGTRAP get cleared by our parasizte engine).

The proper fix most likely will require kernel patching
or redesign of parasite code. Meanwhile to make test
working we switch to the signal which just known to work.

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-11-27 19:33:29 +04:00
Cyrill Gorcunov
b675d8a2ee zdtm: pthread01 -- Fix missed sigprocmask -> pthread_sigmask transition
It has escaped me on previous pass.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-27 19:33:14 +04:00
Cyrill Gorcunov
12e3d7c43e zdtm: pthread00 -- Use task waiters instead of mmap+sleep pair
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-27 19:32:57 +04:00
Cyrill Gorcunov
8ee07313f2 zdtm: pthread00 -- Rename thread functions to more sensible names
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-27 19:32:16 +04:00
Cyrill Gorcunov
78e9c40a04 zdtm: Drop mutex from pthread00 test
The tls_data is used for read-cycles only thus
there is no need for mutex since this area get
filled earlier than fork() issued.

Same time on restore the tls filled before the
program restarts.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-27 19:31:53 +04:00
Cyrill Gorcunov
593c8d1048 zdtm: Make pthread00 to wait with 0
P_ALL is an argument for waitid, not waitpid.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-27 19:31:31 +04:00
Cyrill Gorcunov
465c59457d zdtm: Make pthread00 to use exit(0)
No need for error code here, we test results
by special bitmap.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-27 19:31:06 +04:00
Andrey Vagin
20e8eefb01 cr-dump: show virtual PID-s in a log file
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-27 19:20:20 +04:00
Andrey Vagin
bae333dfcb restorer: fix a race condition between access and unmap to task_entries
If we have tree threads, a following situation can occur:

T2: dec task_entries->nr_in_progress
T3: dec task_entries->nr_in_progress
T3: futex(&task_entries->nr_in_progress, WAKE_UP);
T1: unmap task_entries
T2: futex(&task_entries->nr_in_progress, WAKE_UP) -> EFAULT -> BUG_ON()

This patch adds a futex for synchronising threads.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-26 18:46:11 +04:00
Cyrill Gorcunov
6b1d64ca9a tty: Use find_next_bit helper in tty_verify_active_pairs
Since we have find_next_bit in our sources now, lets
use for_each_bit helper to speedup a search procedure.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-26 18:38:28 +04:00
Cyrill Gorcunov
aa53547aed bitops: Add for_each_bit helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-26 18:38:15 +04:00
Stanislav Kinsbursky
c5083e4750 make: add pie to include dirs for crtools
cr-restore.c includes parasite-blob.h, which is now located in pie/ dir.

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-23 17:12:41 +04:00
Andrey Vagin
13a7498c2a crtools: add EOL to error messages
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-23 16:43:33 +04:00
Andrey Vagin
b7cffae5d4 zdtm: adapt all tcp tests for ipv6
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-23 16:37:39 +04:00
Andrey Vagin
6b2d7f0799 net: don't prevent to dump ipv6 tcp connections
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-23 16:36:37 +04:00
Andrey Vagin
312d1c86f3 netfilter: add ability to block ipv6 connections
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-23 16:36:22 +04:00
Andrey Vagin
a77d00347a test: add a script for executing all app-emu test cases
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-22 19:08:29 +04:00
Andrey Vagin
f8d6dad7f8 test/app-emu: wait while tasks are dying before starting restore
Otherwise some PID-s may be busy.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-22 19:08:14 +04:00
Andrey Vagin
f2adcc41e1 test/app-emu: add options --shell-job
[xemul: s/-j/--shell-job/g]

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-22 19:06:18 +04:00
Cyrill Gorcunov
c19cbc5c52 tty: Don't flush tty data on checkpoint stage
In case if we're dumping the peer which another
end belongs not to us but some other application
the attempts to flush data may lead to endless
SIGTTOU storm:

 | 1158  ioctl(53, TCFLSH, 0x2)            = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
 | 1158  --- SIGTTOU {si_signo=SIGTTOU, si_code=SI_KERNEL, si_value={int=5, ptr=0x5}} ---
 | 1158  --- stopped by SIGTTOU ---
 | 1158  ioctl(53, TCFLSH, 0x2)            = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
 | 1158  --- SIGTTOU {si_signo=SIGTTOU, si_code=SI_KERNEL, si_value={int=5, ptr=0x5}} ---
 | 1158  --- stopped by SIGTTOU ---

so simply don't flush data, the initial attempt to use
TCIOFLUSH was rather "hey, we don't have a way to
say the kernel to freeze tty link for a while, lets
try to workaround this limitation" but without proper
kernel help this won't work anyway as Andrey has discovered.

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-11-22 19:04:12 +04:00
Andrey Vagin
281f0c7d10 test/app-emu: dump/restore of VNC server
* Execute VNC server and glxgears
* Dump/restore
* Check, that VNC server accepts connections

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-22 18:56:48 +04:00
Stanislav Kinsbursky
a519e0c824 make: insert Makefile.inc into Makefile
Makefile.inc is included only into Makefile now. So let's insert it's content
into Makefile itself.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-22 18:54:21 +04:00
Stanislav Kinsbursky
712058a333 make: cleanup pie build
This patch simplifies pie build. Main change is replaces explicit rules by
implicit which reduces Makefile size and makes it more readable.

Notes:
1) intermediate build files are preserved.
2) Both blobs are linked with util-net.o. Restorer blob doesn't require it,
but this allows to avoid explicit rule for it.

v3:
1) Fixed parasite build.
2) Fixed blobs deps - %.bin and %.bin.o can now be build in parallel.
3) Updated restorer link: restorer is not linked with util-net.o anymore.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-22 18:53:59 +04:00
Stanislav Kinsbursky
a14e85a9b0 make: move pie files and build to separated directory
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-22 18:53:29 +04:00
Stanislav Kinsbursky
d44ff5c7a0 make: move syscalls files and build to separated directory
This patch set moves all syscalls data to "arch/$(ARCH)" directory ("arch/x86"
in this particular case).
It does also some cleanup to syscalls-x86-64.sh.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-22 18:52:59 +04:00
Stanislav Kinsbursky
760e595f09 make: cleanup the whole infrastructure a bit
Main things:
1) Variables are defined properly (":=" or ":=" instead of "+"). Otherwise,
because we call nested makefiles, and such variables like CFLAGS are
inheriting it's previous state.
2) SYS-OBJ renamed to SYSCALL-LIB.
3) Inlcude of Makefile.inc removed from protobuf/Makefile

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-22 18:51:41 +04:00
Cyrill Gorcunov
4cff708663 tty: Make sure the controlling terminal is restored by session leader
The controling terminal should be sestored by a session leader,
thus we need to test if the SID we've found in process tree
is a leader.

Otherwise we might have pretty interesting situation: the user
passed -j on dump, ie telling us to inherit shell jobs and on
restore procedure the SID get inherited from the crtools but
session leader for this sid doesn't belong to our peocess tree
and thus we should not try to restore controlling terminal
but inherit it as well.

Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 21:05:17 +04:00
Andrey Vagin
ed5f540c99 zdtm: add new test case for testing logic about COW memory (v2)
This test tests the following combinations:

1. parent and child have a cow-ed mapping
2. parent and child have just coinciding mappings

the pages state in both should be in all possible combinations of

 a. write mapped
 b. read mapped
 c. not touched
 d. before fork
 e. after fork

v2: * wait until a child are not prepared
    * check a FILE | PRIVATE mappings

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:36 +04:00
Andrey Vagin
68d5cb63ae restore: add statistics about restored pages
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:34 +04:00
Andrey Vagin
5d712b7430 cr-restore: remove unshared pages from inherited private mappings (v2)
A parent process can change a few pages after forking a child and
all this pages should not be avaliable from the child.

Each vma has a bitmap of existent pages. Parent's and child's bitmaps
can be compared and all pages which are not present in a child bitmap
are dropped.

v2: don't check page_bitmap on NULL

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:33 +04:00
Andrey Vagin
52247b12cf restorer: don't need to restore pages content in restorer
All memory content are restored before entering in restorer.c.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:31 +04:00
Andrey Vagin
949af72bd5 restore: restore content of private mappings before forking children
It's required for restoring copy-on-write regions.

The similar code will be removed from restorer.c.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:30 +04:00
Andrey Vagin
d02844c8fb restore: use a new scheme for restoring of file private mappings
With this patch vma->shmid contains file id before mapping a region,
then it contains of a temporary address.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:28 +04:00
Andrey Vagin
71f3f7e67b restorer: remap private vmas to correct places (v3)
All private vmas are placed in a premmapped region and
they are sorted by start addresses, so they should be shifted apart.

Here is one more problem with overlapped temporary and target regions,
mremap could not remap such cases directly, so for such cases a vma is
remapped away and then remapped on a target place.

v2: fix accoding with Pavel's comments
v3: add a huge comment with pictures

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:27 +04:00
Andrey Vagin
f3e322a10f restore: don't unmap premmapped private vma-s (v2)
Private vma-s are mapped before forking children, then they are
remapped to corrected places in restorer.c.

In restorer all unneeded vma-s are unmaped. VMA-s from premmapped
regions should not be unmaped.

v2: replace guard pages on arithmetic in restorer

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:25 +04:00
Andrey Vagin
1a9d87de10 restore: map private vma-s before forking children (v3)
In this case private vma-s will be inherited by children,
it allows to restore copy-on-write reqions.

This code compares child and parent vma lists. If it found
two vma-s with the same start and end addresses, it decides
that the child inherites this vmas from the parent.

This code calculates a size of all private vma-s, then allocate
a memory region for all vma-s and maps them one by one. If a vma is
inherited it will be remaped to an allocated place.

As a result all vma-s will be placed in a continious memory region
and sorted by start addresses. This logic will be used for remap
vma-s to correct address.

v2: fix accoding with Pavel's comments ( clean up and simplify )
v3: simplify code and check that VMA-s are sorted

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:48:23 +04:00
Andrey Vagin
f2e4825338 restore: add helper for getting a temporary address of vma
A private vma will be mapped in a temporary place and an address will
be saved in vma->shmid, because nobody was used this field for private
vma-s before. For easy reading vma_premmapped_addr will be used for
getting the temporary address.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:39:12 +04:00
Andrey Vagin
9f9d0e05b1 restore: collect vma-s before creating children (v3)
A private vma's should be inherited by children for
restoring copy-on-write regions.

v2: free parent's vma-s in this patch.
v3: split patch on two parts

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:39:09 +04:00
Andrey Vagin
3265078877 restore: Make target vmas list global
Makes further patching simpler

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:39:08 +04:00
Andrey Vagin
11ed3531a1 restore: release all previous entries from the vma list
Those will be inherited from parent. Before this patch this list was
always empty, but it will change soon.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:39:06 +04:00
Andrey Vagin
c430e2ee6b restore: don't worry if an vma image file is absent
read_vmas will be called for zombies

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:39:05 +04:00
Andrey Vagin
d5bc93e68b restore: don't add unneeded vma with zero start and end addresses
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:39:03 +04:00
Andrey Vagin
ec583c7408 restore: split read_and_open_vmas into parts read_vmas and open_vmas (v2)
read_vmas will be called bedore forking children to restore
copy-on-write memory.

v2: don't open an image one more time

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:39:02 +04:00
Andrey Vagin
0c77eaba1b mm: add a macros to determing private vma-s (v2)
Now this macros returns true only for anon | priv vmas.
It will be expanded to file | priv in a follow patch.

v2: check flags together.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:39:01 +04:00
Andrey Vagin
5373a22747 bitmap: add a function for finding the next set bit in a memory region
This code is borrowed from the Linux kernel sources.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:39:00 +04:00
Andrey Vagin
187419498f syscall: add sys_mremap
It will be used in restorer.c

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 20:38:58 +04:00
Andrey Vagin
380a904947 zdtm: add stream/socket-tcp in the list
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 17:24:40 +04:00
Andrey Vagin
456413c98f tcp: check a state in refresh_inet_sk (v2)
A socket can get fin and a state will be changed on CLOSE_WAIT,
which is not supported yet.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 17:17:51 +04:00
Andrey Vagin
e10829370d tcp: refresh a data about tcp connection after blocking it (v5)
We have a window between getting info about tcp connections
and blocking them.

#2419

v2: clean upV
v3: don't update lengthes of queues for listen sockets,
    they don't used.
v4: check that a state of a tcp connection is ESTABLISHED or CLOSE
v5: * don't check state, because it can be changed only on TCP_CLOSE.
    In this case it will be changed again after restoring.
    * refresh a socket after enabling the repair mode

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-20 17:17:30 +04:00
Cyrill Gorcunov
124e70097d zdtm: Fix pthread01 test case
- use pthread_sigmask instead of sigprocmask
 - show_sigset should take the size of dereferenced variable
 - zeroify sigsets before use, since libc has own definition
   for sigset which doesn't match one the kernel uses

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

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-15 18:13:23 +04:00