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

542 Commits

Author SHA1 Message Date
Pavel Emelyanov
6773090014 core: introduced the macro CORE_THREAD_INFO to access the machine-specific part of CoreEntry
This is the merge and a slight rework (no TI_SP macro) of Alexander's patches
about the subj.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-14 17:19:06 +04:00
Alexander Kartashov
58064d9b72 cr: use unsigned long type for integers representing a virtual address
This patch is intended to reduce the usage of the macro P() since
integer size mismatches sometimes may be fixed by this type generalization.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-14 14:18:59 +04:00
Alexander Kartashov
9209d9eb21 core: introduced the macro CORE_ENTRY__MARCH to represent the target architecture
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-14 14:17:04 +04:00
Andrey Vagin
979eb2a179 restore: restore pocesses which share one fdtable (v5)
Currenly crtools supports a case when a child shared a fd table
with parent.

Here is only two interesting things.
* Service descriptors should be cloned for each process
  who shared one fd table.
* One task should restore files and other tasks should sleep in this
* time.

v2: * allocate fdt_lock from shared memory
    * don't wait a child, if it doesn't share fdtable
v3: * don't move ids on the pstree image
v4: * save ids in a separate image
    * save fdinfo per id instead of pid
v5: fix alignment of service_fd_id

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:46 +04:00
Andrey Vagin
d50c786c7e files: dump fdinfo per files_id instead of pid
A few processes can share one fdtable.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:44 +04:00
Andrey Vagin
bb25ed38c8 files: close_old_fds before forking children (v2)
A few processes can share one fd table. Each process has own set of
service file descriptors and a process knows nothing about servic fds
of another processes. So if two process share one fd table,
close_old_fds will close servic descriptors of another process.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:42 +04:00
Andrey Vagin
20b5ed916f crtools: put kobj-ids into separate image file (v2)
It is read together with pstree items for checking what kind of
resources should be shared. Core is too big for reading it in
this place.

v2: fix check_core

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:39 +04:00
Pavel Emelyanov
748be83181 cr: Support rlimits
Dump the with "new" prlimit syscall that works on arbitrary pid.

Restore is done in restorer _after_ mappings mixup and _before_
caps drop to make it set any max value.

The RLIM_INFINITY is handled explicitly to help future 64<->32
bits migration.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-10 20:08:38 +04:00
Alexander Kartashov
3481b9aa60 FPU: introduced the support for multiple FPU architectures.
* The routine sigreturn_prep_xsave_frame() is renamed to sigreturn_prep_fpu_frame().

* Moved the routines sigreturn_prep_fpu_frame(), show_rt_xsave_frame(), and
  valid_xsave_frame() to the file crtools.c.

* Introduced the structure fpu_state_t to pass the FPU state to the restorer
  in a machine-independent way.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 19:01:44 +04:00
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