2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 21:07:43 +00:00

433 Commits

Author SHA1 Message Date
Alexander Kartashov
e1e2346880 cr: Introduce stubs for tls dump/restore
Leave them empty for x86, will be used on ARM.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 19:01:22 +04:00
Alexander Kartashov
7b7a08dde5 auxv: save and restore AUXV's in a machine-independent way.
The size of an auxv is the machine pointer but a 64-bit integer is reserved
in a MmEntry protobuf message to store an auxv. Moreover the number of auxv's
varies from one architecture to another. So the following is proposed
to alleviate the issue.

* Introduced the type auxv_t representing a machine-pointer sized integer.

* The size of auxv array is extracted from a MmEntry message instead of using
  the value of the macro AT_VECTOR_SIZE.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:40:33 +04:00
Alexander Kartashov
cbffef75b7 cr-restore.c: wrapped the restorer blob trampoline assembly into the macro JUMP_TO_RESTORER_BLOB.
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:39:23 +04:00
Alexander Kartashov
6f61488f21 x86: moved x86-specific files into the directory arch/x86.
* The following files goes into the directory arch/x86/include/asm unmodified:
  - include/atomic.h,
  - include/linkage.h,
  - include/memcpy_64.h,
  - include/types.h,
  - include/bitops.h,
  - pie/parasite-head-x86-64.S,
  - include/processor-flags.h,
  - include/syscall-x86-64.def.

* Changed include directives in the source files that include the headers
  listed above.

* Modified build scripts to reflect the source moves.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:02:47 +04:00
Pavel Emelyanov
087739d402 rst: Remove xid_fail
It was required as a temp stub for MySQL restore. Now it
just spoils the code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-26 18:15:03 +03:00
Andrey Vagin
134937bc87 make: add ability to collect code coverage (v2)
gcc is executed with the option --coverage.
lcov creates HTML pages containing the source code annotated with
coverage information.

make GCOV=1
make test
make gcov
Look at gcov/html/index.html

v2: declare the weak __gcov_flush

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-25 22:43:14 +04:00
Andrey Vagin
6a25678243 restore: remove an unused field from task_restore_core_args
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 18:58:32 +04:00
Andrey Vagin
9cd9a93e79 restore: unify handling of thread args of leaders and other threads
Currently we have an array for thread_args, but leader's thread_args
is a part of task_args.
Here is two problems. The array has a space for leader's thread args,
but it is unused. Code which fills thread args is duplicated two
times. This patch fixed both problem. It replaces thread_args on a
pointer from task_args and deletes code, which fills leaders
thread_args.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 18:58:23 +04:00
Andrey Vagin
ff9a760bcd restore: fill up thread_args a bit earlier
It's preparation for the next patch.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 18:58:16 +04:00
Andrey Vagin
48d0e78e36 crtools: change the minimal address for the restorer blob
It should be bigger than CONFIG_LSM_MMAP_MIN_ADDR.

v2: set a correct value

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 18:58:14 +04:00
Cyrill Gorcunov
3eb28f9fbc restore: Restore FPU state
Since at moment we stick with sigreturn restore
we need to form a proper FPU frame and set a pointer
to it inside sigreturn frame.

For this sake we read the FPU image and here are two
cases are possible

 - no fpu data at all -- nothing to restore, simpliest
   case

 - xsave frame is present but the host cpu supports only
   fxsave instruction: we refuse to continue, since it means
   there are no ymm registers on the machine where we're trying
   to restore

 - fxsave frame is present but the host cpu has xsave feature:
   at moment we refuse to continue, requiring complete match
   between "checkpoint and restore hosts", but in real we could
   extend logic and form complete xsave frame from fxsave and
   continue processing

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:43 +04:00
Cyrill Gorcunov
41ebf5c377 cpu: Add testing if host cpu is suitable to FPU c/r
The cpu we're running on must at least support fxsave feature.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-21 17:35:36 +04:00
Pavel Emelyanov
1d1860224e rst: Remove excessive arg from open_vmas()
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-10 16:08:07 +03:00
Pavel Emelyanov
87fe1834cd rst: Sanitize restore function call flow
The dedicated prepare_and_sigreturn makes code harder to read.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-10 16:04:46 +03:00
Pavel Emelyanov
be79f38d6c pstree: Sanitize pstree preparation code
We have 3 calls for that, two called directly from cr-restore,
one -- from one the former. Clean this mess and write short
comments on each stage.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-10 15:50:47 +03:00
Pavel Emelyanov
dbbd8d400a rst: Don't allocate PATH_MAX on stack for proc mountpoint
Use direct name assignment, it's enough.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 15:50:41 +03:00
Pavel Emelyanov
da8dbe43bc rst: Move premmaped* variables on rst_info
This thing on pstre_item was created to carry task-specific
information across the "restore" code-flow.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 13:19:01 +03:00
Pavel Emelyanov
39d60cdfef rst: Sanitize sigchld handler
The error handling was not obvious. Clean it up.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 13:08:56 +03:00
Pavel Emelyanov
815049bcdb rst: Fix message about inability to restore pid 1 outside pidns
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-06 10:58:32 +03:00
Pavel Emelyanov
4cd9998544 rst: Brush up fake vs real tasks post-pgid restore codeflow
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 18:49:36 +03:00
Pavel Emelyanov
9e7ae345db rst: Remove unused arg from restore_one_helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 18:43:28 +03:00
Andrey Vagin
caf875454f signal: fix logig about SIGMAX (v2)
A value of signo is in [1, SIGMAX].
Currenly signals are enumirated from 1 to SIGMAX, but SIGMAX
is not included. This patch fixes this mestake.

v2: * save backward compatibility
    * set a correct value of SIGMAX = 64. It can not be in a
    separate patch, because a format is changed again.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 19:26:54 +04:00
Pavel Emelyanov
360c50d429 rst: Relax nr_in_progress set in stage switching
When resetting nr_in_progress for next stage no need
in waking up anyone. Nobody waits for it yet :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 17:40:19 +03:00
Pavel Emelyanov
7eaad99ff4 rst: Helper for switching restore stages
Switching to a new stage is 4-step procedure which
deserves its own helper. Besides, now the information
about how many tasks participage in each stage is
collected in one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 17:37:13 +03:00
Pavel Emelyanov
e0d0dc821d rst: Rename task_entries->nr to ->nr_threads
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 17:22:45 +03:00
Pavel Emelyanov
2482c5a24b rst: Move initial nr_in_progress initialization
It's better to init it closer to the rest of rst orchestration.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 17:12:37 +03:00
Pavel Emelyanov
70af6cdd62 rst: Helper for restore stage barrier
When finishing a stage we have to report this (decrement the
number of tasks in stage) and wait while stage switch. Write
a helper that does both.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-12-04 16:59:41 +03:00
Pavel Emelyanov
03d0758df3 Revert "net: Introduce netdev index to name resolver"
This reverts commit ef3771d566dacb8ee9fe71b744d56f08674fe3db.
With new SO_BINDTODEVICE getting API it's not required.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-28 20:27:16 +03:00
Pavel Emelyanov
9df1786aea rst: Move and rewrite comment about how restorer blob is prepared
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-27 22:16:00 +03:00
Pavel Emelyanov
14915d01fd rst: Remove unneeded core file 2nd opening
Presumablty it was lost while reworking core entry restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-27 22:03:36 +03:00
Pavel Emelyanov
827c633b26 rst: Write pidfile in separate fn
Just for better readability.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-27 21:59:58 +03: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
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
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
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
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
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