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

2398 Commits

Author SHA1 Message Date
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
Pavel Emelyanov
86c848e186 rst: Remove unused extern fns declarations
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-13 20:52:40 +03:00
Pavel Emelyanov
e6617b5e2e parasite: Macro for getting parasite symbols
Same as previous patch -- easier to read and possible
to use tags.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-13 20:51:32 +03:00
Pavel Emelyanov
f86bbe6a9c restore: Introduce a macro to get restorer symbol address
This makes code more readable, saves one ptr on stack and
lets us jump into restorer code using tags.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-13 20:15:13 +03:00
Pavel Emelyanov
23bf4faa0d check: Set error log level before checking
Not to spoil screen with false warnings.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:04:24 +03:00
Cyrill Gorcunov
54148db18f zdtm: Add new pthread01 test
To test threads blocked signals restoration.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:43:02 +04:00
Cyrill Gorcunov
2ee5a42f3e restore: Add restoration of the blocked threads signals from the image
To unify the code for both thread leader and regular threads
we move blocked signals for thread leader into threads argument
area and use restore_thread_common() helper.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:43:01 +04:00
Cyrill Gorcunov
5da22b01fe dump: Fix message in thread dumping
And add missing new line in message.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:59 +04:00
Cyrill Gorcunov
7266efdec5 dump: Show blocked signals when dumping
For debug purpose.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:58 +04:00
Cyrill Gorcunov
5b7e3b8dae dump: Checkpoint per-thread blocked signals
I've moved dump_thread helper a bit lower in file
since I've to call for find_thread_state helper.
After all this groups all thread related functions
in one slab.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:56 +04:00
Cyrill Gorcunov
f107e8e9e2 dump: Save and remove per-thread argumens in parasite
This patch starts using parasite_init_threads_seized and
parasite_fini_threads_seized helpers to save per-thread
data in parasite and remove it on cure procedure.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:55 +04:00
Cyrill Gorcunov
80928f8c1b parasite: Declare @tid as pid_t in parasite_dump_thread
Just to be consistent with types we're using.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:54 +04:00
Cyrill Gorcunov
c8754da9ae parasite: Rename parasite_dump_tid_info to parasite_dump_thread
We will need to extend the structure to keep not only tid/tid_addr
but blocked signals as well, thus rename it to more generic
parasite_dump_thread.

The command PARASITE_CMD_DUMP_TID_ADDR renamed to
PARASITE_CMD_DUMP_THREAD for the same sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:53 +04:00
Cyrill Gorcunov
9dc332a593 parasite-syscall: Add parasite_[init|fini]_threads_seized helpers
We will use them from crtools code to save and restore blocked
signals mask of threads.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:51 +04:00
Cyrill Gorcunov
98544842ac parasite: Switch parasite thread leader to use thread helpers
- the init() now calls for init_thread() to save blocked
   signals mask in per-thread data

 - the fini() now calls for fini_thread() to restore the
   blocked signals, note: we could use thread_leader directly
   but i think calling for fini_thread() is more generic

 - dump_misc() now uses per-thread data

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:50 +04:00
Cyrill Gorcunov
e441109efa parasite: Add [init|fini]_thread helpers
These helpers will be needed to save a blocked signals
mask for dumpee threads.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:49 +04:00
Cyrill Gorcunov
616b96421e parasite: Rework init/fini to reserve/free space for per-thread data
The per-thread information requires own space in parasite data.
In particular we will keep the blocked signals bound to thread
pids.

For this sake the caller need to provide the parasite how many
threads will be used to calculate space.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:48 +04:00
Cyrill Gorcunov
4be701794e protobuf: Add @blk_sigset to thread_core_entry
It will hold the blocked signals for threads.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 17:42:47 +04:00
Cyrill Gorcunov
9a5b427470 restore: check_core -- Add missing test for thread_info in non-zombie task
Otherwise we might get nil dereference in sigreturn restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 12:35:03 +04:00
Cyrill Gorcunov
475aa87225 restore: check_core -- Move core->ids check under separate if() statement
We will need to extend non-zombie tests.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 12:34:56 +04:00
Cyrill Gorcunov
71a65a96f5 zdtm: Update futex-rl test for thread leader
Don't forget to test thread leader as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-12 12:33:53 +04:00
Cyrill Gorcunov
300d2f2626 protobuf: Drop dangling \Space
No func change.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-11 13:28:59 +04:00
Cyrill Gorcunov
058d83b464 protobuf: Return -1 on error in do_pb_read_one
Better to stick with the convention we're trying
to follow in general -- negative codes for error.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-11 13:28:25 +04:00
Pavel Emelyanov
6b2e13fcd9 proc: Fix anon shmem mapping detection
Linux kernel emulates anon-shared mappings by mapping internal
tmpfs file in. We try to detect this by checking that the file
under map is such, but do it with error -- major == 0 check is
wrong, as regular tmpfs file can be such as well as btrfs or
ecryptfs can screw things up.

The only working way of doing this is to get the dev_t of this
internal tmpfs mount.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-06 19:07:38 +03:00
Cyrill Gorcunov
bbf33fa68f parasite: Print error code in parasite_dump_tty
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-06 18:18:31 +04:00