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

1696 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
Cyrill Gorcunov
30936058a0 ns: Extend ns_desc to carry the length of the ns name
This will be needed for fast parsing of procfs ns references.

[ xemul: Add user_ns_desc here ]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 03:36:56 +04:00
Cyrill Gorcunov
4531f0ac7d files: Add ability to use read link in dump_one_reg_file
To be able to dump procfs namespace entries we will need to
analyze the link name first and then figure out if the file
referred indeed a procfs entry or it's plain regular file.

This means we read link early, and to escape double reading
of same link, once we read it we remember it in fd_parms
structure which we pass to dump_one_reg_file.

Still the dump_one_reg_file is not solely used from inside
of dump_one_file, but from a number of other places (fifo,
special files) where fd_parms is filled only partially
and fill_fd_params is not even called. Thus dump_one_reg_file
must be ready for such scenario and read the link name by own
if the caller has not provided one.

To achieve all this we do

 - extend fd_parms structure to have a reference on a new
   fd_link structure, thus if caller already read the link
   name it might assign the reference and call for dump_one_reg_file

 - tune up dump_one_reg_file to fill own copy of fd_link
   structure if the caller has not provied one

  [ xemul: Added const to fill_fdlink arg ]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 03:36:54 +04:00
Cyrill Gorcunov
19ce784db5 dump: Add missing FD_PARMS_INIT assignments
struct fd_parms is reused for two calls, so don't
forget to initialize it before dump_one_reg_file
call.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 03:36:01 +04:00
Pavel Emelyanov
61c6360c1d mem: Update soft-dirty detection to work on -mm tree
The soft-dirty API has changed slightly -- now the bit in
question _is_ in pagemap file (not pagemap2) but to see it
we have to reset soft-dirty for anyone first.

Teach the kerndat soft-dirty checker this fact. The actual
pagemap reading code already knows select pagemap/pagemap2
file itself.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-17 16:13:49 +04:00
Pavel Emelyanov
37c137092b mem/stats: Add stats about memory dumping
pages_scanned -- the amount of pages criu looked at for decision
pages_skipped_parent -- the amount of pages that were skipped, due to
                        they are present in parent image
pages_writted -- the amount of pages criu transfered into image

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-15 15:46:07 +04:00
Cyrill Gorcunov
c459e417f3 ns: Beautify namespaces.h
I'll need to modify this header so before anything
else lets beautify it

 - drop struct pstree_item declaration it's already in pstree.h
 - move struct cr_options to top
 - align members of struct ns_desc
 - move externs to top
 - add argument name to try_show_namespaces

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-15 00:37:44 +04:00
Pavel Emelyanov
a533820b7e dump: Introduce the pre-dump action
With this action criu will seize tasks, grab all its memory into
page-pipes, rest dirty tracker and will then release them. Writing
the memory from page-pipes would occur after tasks are unfreezed
and thus the frozen time should become reasonably small.

When pre-dump is in action, the dirty tracking is forcedly turned
off as well as tasks are resumed afterwards, not killed, by default.

This is a prerequisite for iterative migration.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-14 12:00:40 +04:00
Pavel Emelyanov
094330c33b stats: Add writing-memory-image timing
Dumping memory is draining it from parasite, for pre-dump
this time would be reasonably small. _Writing_ the memory
would occur _after_ tasks unseize and resume.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-14 11:52:45 +04:00
Pavel Emelyanov
1b54484537 parasite: Split parasite cure routine into local and remote parts
For pre-dump we'll need to cure the target task(s), but keep the
parasite_ctl (for its local args mapping) for memory image write.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-14 11:48:51 +04:00
Pavel Emelyanov
d416e6a135 mem-snap: Redefine CLI options for mem snapshot
They are not documented, thus OK for now. Two options --
* one to specify where the parent images are
* one to reset dirty memory tracking

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-14 11:04:57 +04:00
Pavel Emelyanov
d9c3b91cf1 mem: Place mprotect and dump_pages args in one parasite args area
This is required for (soon to be) pre-dump command -- this command
will have to keep parasite args with pagemap (iovecs) some time after
parasite is executed. Since we call mprotect cmd _after_ pages dump
we can thus spoil these iovecs. To address this vmas to mprotect and
iovecs to dump are located in one parasite args area one after another
without intersections.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-14 11:02:18 +04:00
Pavel Emelyanov
eb41d26d4a pages: Rename parasite args->nr to args->nr_segs
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 23:05:37 +04:00
Pavel Emelyanov
c15d4ee66a dump: Cleanup dump_pages_seized arguments and declaration
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 14:09:19 +04:00
Pavel Emelyanov
d7e547dfb7 cr: Remove opts argument from cr_dump_tasks
Options are collected in global variable, no need to have them on stack.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 14:08:55 +04:00
Pavel Emelyanov
1e18128423 stats: Dump-time statistics
Basic timings for dump (freeze, frozen, mem dump).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 13:53:31 +04:00
Pavel Emelyanov
bd1d6186be stats: Write dump stats after dump is finished
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 13:51:53 +04:00
Pavel Emelyanov
d770f4ef23 stats: Protobuf file introduction introduction
We'll have one more "image" file generated by dump and (surprisingly)
restore commands -- the stats one. It will contain in a single pb
object all the statistics collected by dump/restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 13:50:15 +04:00
Pavel Emelyanov
e75148dc03 util: Move user-per-sec constant into util.h header
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 13:50:09 +04:00
Kir Kolyshkin
43ce038e6e criu dump: don't require -t
and warn if it is used.

v2: fix help text as well

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-08 13:41:42 +04:00
Pavel Emelyanov
add21b75c9 show: Remove options args from ->show callback
This thing is global, we can address one explicitly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-08 00:23:42 +04:00
Pavel Emelyanov
cd537beda5 show: Get rid of flags argument from payload handler
We can "guess" one w/o addirional (obfuscating) argument to
the pb showing engine.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-08 00:00:24 +04:00
Andrey Vagin
4c36be84af restore: change type of blk_sigset on k_rtsigset_t
pie/restorer.c: In function ‘restore_thread_common’:
pie/restorer.c:262:39: error: incompatible types when assigning to type
‘k_rtsigset_t’ from type ‘u64’
   RT_SIGFRAME_UC(sigframe).uc_sigmask = args->blk_sigset;
                                       ^

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-29 17:54:25 +04:00
Andrey Vagin
a724acf571 restore: handle errors of setting credentials (v2)
v2: handle errors from setXids and securebits manipulations
    handle errors of restoring creds after finishing CR_STATE_RESTORE_CREDS,
    because a sigchild handler is already restored in this moment.
    Only the current process is killed in a error case.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-29 16:32:24 +04:00
Pavel Emelyanov
379abca968 check: Introduce --ms option
This option skips checking for features, that are known to
be absent in mainstream kernel.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-23 23:38:47 +04:00
Andrey Vagin
a34057c192 restore: add a synchronisation point after restoring credentials
For security reason processes can be resumed only when all
credentials are restored. Otherwise someone can attach to a
process, which are not restored credentials yet and execute
some code.

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

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-19 15:58:50 +04:00
Pavel Emelyanov
f34d63bfb1 fd: Comment file_desc_ops
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-16 14:47:10 +04:00
Pavel Emelyanov
8f9dd8f76c page-server: Make open_page_server_xfer static
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-16 12:09:16 +04:00
Pavel Emelyanov
1e78c91d20 page-xfer: Fix page writing API
Split it into two parts -- writing pagemap and writing
pages. This is required for page-server part, sinc it
cannot provide one big pipe with all the pages at once.
Thus it needs to feed pages in portions.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-16 11:59:19 +04:00
Pavel Emelyanov
dbbb9ec38f mem: Comment page-read, page-xfer and page-pipe
These three are quite complex things, so write general comments about
what they are doing.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-16 11:34:53 +04:00
Pavel Emelyanov
199dba2361 soft-dirty: Check that kernel reports soft-dirty bits
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 13:24:32 +04:00