2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00
Commit Graph

2988 Commits

Author SHA1 Message Date
Andrey Vagin
64ecb2746c dump: save registers when the task is already infected
Otherwise a task can start to handle a signal and registers can be
changed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 19:28:34 +04:00
Andrey Vagin
0cda60e334 dump: update task registers if a signal is started handling
When we try to execute a parasite code, a signal can be started
handling, so we need to update a task registers, which will be saved in
a core file.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 19:25:24 +04:00
Andrey Vagin
9b656a47d0 dump: dumping signals when a task is stopped
Currently it's always stopped, but it will be changed, when a parasite
will be executed as a daemon.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 18:55:33 +04:00
Andrey Vagin
294d62dd37 parasite: allocate stack for each thread
It will be used for executed parasite as a daemon.
What we have previously -- the stack has been preallocated in parasite
blob itself and bootstrap procedure calculated the value needed for %rsp.

With this patch applied we provide every thread own stack as:

- find out how many threads are present
- calculate the summary size of all stacks
- when we ask dumpee to provide us memory area needed to run
  parasite code, we pass summary size needed for everything
- when parasite code is asked to run we calculate %rsp needed
  taking into account the thread number (ie offsets) and then
  setup proper %rsp via ptrace call, instead of calculating it
  in bootstrap parasite code

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 18:53:33 +04:00
Andrey Vagin
b21dd2bc0f parasite: save thread registers in parasite_thread_ctl
Now we restore thread registers immediately after a command,
but when we will execute a parasite, it will be impossible.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 18:49:42 +04:00
Andrey Vagin
3f48f35bfd parasite: use transparent thread indexes
We have three arrays for thread related data: item->threads,
parasite_ctl->thread and tid_state in parasite.

With this patch a thread will have the same index in all arrays.
The zero index is used for a thread leader.

In this case we don't need to search thread_state in parasite.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 18:47:11 +04:00
Cyrill Gorcunov
0772e47511 pstree: Bind CoreEntry to pstree and fill it with registers early
When parasite daemon mode will be implemented we get deprived of ability
to fetch registers at the late moment of dumping as we were, thus just
bind CoreEntry to pstree item and allocate CoreEntry'ies for every
thread found, once process tree is in seized state.

Then immediately fill CoreEntry'ies with registers. We use prctl
opcode for that but fetch a complete set of registers including
FPU state, and convert them into protobuf format.

Zombie tasks remains untouched, we allocate CoreEntry for them
right at moment of dumping becuase we don't need registers there
to be written on disk.

This way get_task_regs no longer need parasite_ctl argument
and it's zapped.

Still parasite_ctl has own copy of general registers set but
this is because we need them to be in cpu native format unlike
ones kept in CoreEntry.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 18:42:11 +04:00
Andrey Vagin
22396f7690 restore: construct sigframe in crtools
Before this patch sigframes were constructed in restorer. We are going
to construct sigframes for parasites. Both parasite and restorer should
be as thing as posible.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 17:39:52 +04:00
Andrey Vagin
45233b5ec9 restore: add a function for constructing sigframe
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 17:39:49 +04:00
Andrey Vagin
478bd99bc1 restore: split restore_gpregs on two parts
The first one fills sigframe and the second one restores another
registers.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 17:34:05 +04:00
Andrey Vagin
5978380bef restore: use a concrete object for constructing sigframe
struct thread_restore_args contains many pointers on different objects,
only a few of them are really required.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 17:32:47 +04:00
Andrey Vagin
3ac0ad8379 locks: add futex_wait_while_eq
Wait while futex @f value is equal to @v

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 16:43:26 +04:00
Cyrill Gorcunov
001be2ab9c vdso: No need to fetch pfn if marked vdso area has been met
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 16:40:49 +04:00
Cyrill Gorcunov
e7c64ae13c vdso: Add vdso_put_mark helper
Instead of opencoded mark injection provide
a helper for easier grepability.

[xemul: Go ahead and remove the INIT_VDSO_MARK at all]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 16:39:41 +04:00
Pavel Emelyanov
d2b415ca70 vdso: Cleanup vdso_proxify routine
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:34:01 +04:00
Cyrill Gorcunov
20b39341ca proc: Don't mark mishinted vdso
The [vdso] mark in procfs output is not reliable,
so since we know which prot it should has, escape
obvious mishints.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:27:21 +04:00
Cyrill Gorcunov
0ae67a7743 vdso: Escape double dumping of rt-vdso if proxy present
In case if we have created vdso proxy the rt-vdso should
not be dumped because it will be re-created on next restore
anyway. Thus with help of parasite service routine find
the rt-vdso and tear it off from VMAs list.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:27:20 +04:00
Cyrill Gorcunov
528106a5dc vdso: Mark runtime vdso if proxy needed
In case if we need vdso proxy there is a need
to recognize it somehow on further checkpoint
action. But such vdso won't be recognized by
the kernel and [vdso] mark won't appear in
procfs output. Thus we put own mark on it.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:27:19 +04:00
Cyrill Gorcunov
bc66eb535c vdso: Fetch page frame number on init
We will need it in parasite code to detect run time vdso area.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:27:18 +04:00
Cyrill Gorcunov
f267443134 vdso: Implement vdso proxy on restore
When a task being restored we may meet two situations

 - vdso in image doesn't match the runtime vdso provided
   by a kernel. For this case we need to patch dumpee
   vdso redirecting calls to runtime vdso, thus dumpee
   vdso become a proxy.

 - vdso in image does match the runtime vdso, in this
   case we simply remap runtime vdso to address where
   dumpee vdso lives. Plain remapping here is quite
   important and allows us to save vdso pfn which will
   be used in parasite code later.

Note after this patch the restored task may have two
vdso in memory. Proper dumping of such situation will
be addressed in future patches.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:27:17 +04:00
Cyrill Gorcunov
b051c66fb6 vdso: Remap runtime vdso copy to safe place
Runtime vdso need to be kept in some safe place when all
self-vmas are unmapped. So we reserve space for it in restorer
blob area and then remap it into. It's quite important to do
a remap here rather than data copy because otherwise pfn
of vdso disappear and in future we won't be able to detect
vdso are on dumping stage.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:27:16 +04:00
Cyrill Gorcunov
e44b3dbe84 vdso: Initialize vdso data on startup
During criu startup we need to fill symbol table of own
run-time vdso provided by the kernel. We will need this
data for vdso proxy.

Because this functions are not used in restorer code,
we move them out of PIE (since PIE code must remain
as small as possible).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:27:15 +04:00
Cyrill Gorcunov
61cc86ddd2 vdso: Introduce vdso pie-engine
It's quite minimal at moment and provides only two helpers

 - vdso_redirect_calls, to patch vdso area redirectling
   calls to some new place.

 - vdso_fill_symtable, to parse vma area as vdso library
   and fill symbols table with offsets and names.

Because these routines will be needed in both regular criu
code and restorer code -- we compile it in pie format.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:27:13 +04:00
Cyrill Gorcunov
9208108c9f make: Define program object deps as separate variable
Will need to extend it to support vdso-pie code which
used in both -- pie code and plain executable code.

I know it's ugly and I must invent some more elegant
way, but need some solution at moment to be able to
compile existing code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:24:29 +04:00
Vladimir Davydov
5dbab1a711 zdtm: check one-shot posix timers
With the patch zdtm will check not only periodic timers, but also
one-shot ones.

 Set one-shot timer to expire in a very long interval (INT_MAX in the
 test), and check its remaining value after checkpoint/restore. The
 following relationship must hold:

 initial_value - remaining_value = time_passed

Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:04:52 +04:00
Andrey Vagin
fc07b9ae0e zdtm.sh: save archive with dump files
An archive is saved in unsuccessful case.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-23 20:30:10 +04:00
Andrey Vagin
97ee174a99 zdtm.sh: use tmpfs for dump files
It's optional. It's going to be used in jenkins.

time bash -x test//zdtm.sh  static/maps04
real	0m40.220s
user	0m0.096s
sys	0m12.822s

time bash -x test//zdtm.sh -t static/maps04
real	0m9.904s
user	0m0.074s
sys	0m1.630s

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-23 20:29:49 +04:00
Andrey Vagin
c9c9fe479e zdtm: fix sigpending to check blocked signal masks
Here are a few bugs which hide each other.
* memcmp(&newset, &oldset, sizeof(newset) returns 0 is masks are equal.
* sigprocmask return sigset_t and it contains extra bits for the future,
so we need to initialize all this bits otherwise they will contain
random data.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-23 20:27:58 +04:00
Cyrill Gorcunov
a21cdb8437 asm: Add builtin_memcpy, builtin_memcmp generic helpers
Will need them in pie code soon.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-23 16:51:14 +04:00
Cyrill Gorcunov
17f6c36305 asm: Move builtin_memcpy helper into asm/string.h
There will be a couple of more builtin helpers needed
in pie code soon. Thus to unify approach do

 - rename asm/memcpy_64.h to asm/string.h

 - introduce include/asm-generic/string.h file
   where all helpers are implemented if optimized
   variant is not  yet provided

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-23 16:51:06 +04:00
Cyrill Gorcunov
54b32cb1fd x86: Implement prlimit proxy
RHEL6 is shipped with libc 2.12 where no prlimit
helper provided (which was pushed into libc itself
since 2.13). So we implement own proxy for convenience.

Note, if libc does support prlimit itself we simply
don't use any proxy and call it directly.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-23 15:12:58 +04:00
Cyrill Gorcunov
a5fcc8b021 x86: syscall -- Add sys_prlimit64 call
We will need it for own prlimit proxy call.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-23 15:12:57 +04:00
Cyrill Gorcunov
fc7c13ded0 make: config -- Add test for prlimit call
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-23 15:12:56 +04:00
Cyrill Gorcunov
88b13cffbe mem: Add PME_ bits for page frame retrieval
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-23 12:51:27 +04:00
Cyrill Gorcunov
58cb8b2769 pagemap: Move PME_ constants to the header
This constants are system wide, so move them to mem.h
header for reuse sake.

[ xemul: It was kerndat.h in the patch ]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-23 12:50:43 +04:00
Cyrill Gorcunov
52509a20c7 mem: Beautify mem.h
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-23 12:48:57 +04:00
Andrey Vagin
0bca286722 ipc_ns: allocate enough memrory for the buffer
==22653== Syscall param read(buf) points to unaddressable byte(s)
==22653==    at 0x50480B0: __read_nocancel (in /usr/lib64/libpthread-2.17.so)
==22653==    by 0x40CF7C: parasite_dump_pages_seized (mem.c:244)
==22653==    by 0x41681D: cr_dump_tasks (cr-dump.c:1533)
==22653==    by 0x40448C: main (crtools.c:309)

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-21 19:06:03 +04:00
Andrey Vagin
084a630dfd zdtm: use a current stack for preccesses created by clone()
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-21 19:05:38 +04:00
Pavel Tikhomirov
9a726d4f9e page-server: Add daemonize call return check
On ubuntu this don't compile if no check.

Signed-off-by: Pavel Tikhomirov <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-21 19:05:15 +04:00
Andrey Vagin
653053b40c proc: use vma flags for determing vmas with MAP_GROWSDOWN
When a kernel didn't show vma flags, we set MAP_GROWSDOWN for stack
vmas, but it's not reliable. E.g. thread stacks are mapped without
MAP_GROWSDOWN.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-21 19:03:57 +04:00
Andrey Vagin
84e84cbb65 proc: add vma_area in a list after parsing all parameters
The size of vma can be changed after parsing flags. For example we need
to add a guard page for vma with MAP_GROWSDOWN.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-21 19:03:48 +04:00
Cyrill Gorcunov
11b525f30e zdtm: Update proc-self test
The link must be read after restore on original
file descriptor since namespace id do change between
c/r sessions.

https://bugzilla.openvz.org/show_bug.cgi?id=2599

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-21 13:09:37 +04:00
Andrey Vagin
b2846be8c3 page-server: introduce the --daemon long option
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-20 19:11:19 +04:00
Cyrill Gorcunov
66cc9b6657 make: Introduce compile time include/config.h generation
It's being reported that some systems (as Ubuntu 13.04) already
have struct tcp_repair_opt definition in their system headers.

| sk-tcp.c:25:8: error: redefinition of struct tcp_repair_opt
| sk-tcp.c:31:2: error: redeclaration of enumerator TCP_NO_QUEUE

So add a facility for compile time testing for reported entities
to be present on a system. For this we generate include/config.h
where all tested entries will lay and source code need to include
it only in places where really needed.

Reported-by: Vasily Averin <vvs@parallels.com>
Acked-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-20 16:02:14 +04:00
Cyrill Gorcunov
234dce785f make: Add scripts/utilities.mak
Some features need to be tested on the system
where the project is compiled, so instead of
drowning into autoconf hell lets try to handle
all this with make facility.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-20 16:02:07 +04:00
Andrey Vagin
4f1d2a1005 page-server: allow to execute page-server in the background (v2)
page-server creates a listen socket and only then goes into the
background, so we can be sure, that page-server is ready for work after
detaching.

v2: call daemon() in a proper place and reuse the option -d

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-20 15:00:40 +04:00
Pavel Emelyanov
e8e1cae2f9 zdtm: Wire proc-self test in
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 04:02:18 +04:00
Cyrill Gorcunov
650164e037 test: zdtm -- Add proc-self test
Just open /proc/self/ns/net and check if
it remains the same on restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 04:01:20 +04:00
Pavel Emelyanov
ec50a07727 ns: Add c/r for /proc/$pid/ns/$ids references
Based on work done by Cyrill Corcunov (many thanks for that).

In this commit we implement c/r for files which have opened
/proc/$pid/ns/$ids entries.

The idea is rather simple one

Checkpoint
==========

- Check if the file name is the one of known to be ns ref
- If match then write protobuf entry

Restore
=======

- Read all ns entries from the image
- When criu tries to open one we lookup over process
  tree to figure out which PID should be used in path
  and then just open it

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 04:00:05 +04:00
Cyrill Gorcunov
a49325b524 protobuf: Prepare scaffolds for procfs NS entries
[ xemul: rename pb.cflag -> pb.ns_cflag ]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 03:37:00 +04:00