No description
Find a file
Andrey Vagin 595b772ad2 parasite: Switch parasite to daemon mode (v2)
Parasite daemon mode it quite tricky. One may consider
it as consisting of two parts

 - daemon mode for thread leader
 - daemon mode for regular threads

Thread leader daemon
--------------------

Once thread leader parasite code switched initialized,
it starts spinning on socket listening for commands
to handle.

If the command destination is the thread leader itself it
handles it and replies back the ack to the caller (iow
the main crtools code).

If the recepient is not thread leader but one of threads,
then thread leader wakes up the thread by futex and makes
it to handle the command waiting on futex for result. Once
result obtained, the ack is being sending back to caller.

Thread daemon
-------------

On initialization thread daemon starts waiting a command on futex.
The futex is triggered by thread leader daemon when command received.
Once command is received and handled, the result is reported back to
the thread leader daemon, which in turn send ack message.

Both thread-leader and regular threads require own stack to operate
on since they all are present in memory simultaneously. Thus we use
call_daemon_thread() helper which takes care of providing stack
to the callee.

TODO:

 - ARM requires own wrappers on damonize/trap low-level code,
   at moment x86-64 is only covered

v2: remove PARASITE_CMD_DAEMONIZED and s->ack
    parasite: use a propper command for getting ack

Fixed-by: Andrey Vagin <avagin@openvz.org>
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 20:22:23 +04:00
arch parasite-syscall: Add "trap" postfix to parasite execute functions 2013-05-24 19:57:55 +04:00
Documentation Documentation/Makefile: fix clean target 2013-05-10 11:01:57 +04:00
include parasite: Switch parasite to daemon mode (v2) 2013-05-24 20:22:23 +04:00
pie parasite: Switch parasite to daemon mode (v2) 2013-05-24 20:22:23 +04:00
protobuf protobuf: Prepare scaffolds for procfs NS entries 2013-05-18 03:37:00 +04:00
scripts make: config -- Add test for prlimit call 2013-05-23 15:12:56 +04:00
test zdtm: check one-shot posix timers 2013-05-24 13:04:52 +04:00
.gitignore git: Drop include/config.h from monitoring 2013-05-24 20:12:07 +04:00
.mailmap repo: Add mailmap file 2012-03-25 23:31:20 +04:00
COPYING Add LGPL licence for library directory 2013-04-01 12:29:06 +04:00
cr-check.c cr: Fix permissions on several files 2013-05-15 17:50:57 +04:00
cr-dump.c dump: save registers when the task is already infected 2013-05-24 19:28:34 +04:00
cr-exec.c parasite: use transparent thread indexes 2013-05-24 18:47:11 +04:00
cr-restore.c restore: construct sigframe in crtools 2013-05-24 17:39:52 +04:00
cr-show.c protobuf: Prepare scaffolds for procfs NS entries 2013-05-18 03:37:00 +04:00
CREDITS Add the CREDITS file 2012-07-30 13:52:37 +04:00
crtools crtools: rename binary to criu 2013-04-30 20:17:55 +04:00
crtools.c page-server: introduce the --daemon long option 2013-05-20 19:11:19 +04:00
eventfd.c show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
eventpoll.c show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
fifo.c Fix typos in comments 2013-04-15 12:46:46 +04:00
file-ids.c x86: moved x86-specific files into the directory arch/x86. 2013-01-09 17:02:47 +04:00
file-lock.c Fix typos in log messages 2013-04-15 12:46:25 +04:00
files-reg.c files: Add ability to use read link in dump_one_reg_file 2013-05-18 03:36:54 +04:00
files.c ns: Add c/r for /proc/$pid/ns/$ids references 2013-05-18 04:00:05 +04:00
fsnotify.c show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
image.c protobuf: Prepare scaffolds for procfs NS entries 2013-05-18 03:37:00 +04:00
ipc_ns.c ipc_ns: allocate enough memrory for the buffer 2013-05-21 19:06:03 +04:00
kcmp-ids.c x86: moved x86-specific files into the directory arch/x86. 2013-01-09 17:02:47 +04:00
kerndat.c pagemap: Move PME_ constants to the header 2013-05-23 12:50:43 +04:00
libnetlink.c netlink: return errno from do_rtnl_req 2013-03-28 18:21:11 +04:00
log.c log: log_init -- Check for dup return code 2013-04-12 20:50:27 +04:00
Makefile vdso: Introduce vdso pie-engine 2013-05-24 13:27:13 +04:00
Makefile.config make: config -- Add test for prlimit call 2013-05-23 15:12:56 +04:00
Makefile.crtools restore: add a function for constructing sigframe 2013-05-24 17:39:49 +04:00
Makefile.inc Makefiles: add install target 2013-05-03 01:56:30 +04:00
mem.c parasite: Switch parasite to daemon mode (v2) 2013-05-24 20:22:23 +04:00
mount.c ns: Extend ns_desc to carry the length of the ns name 2013-05-18 03:36:56 +04:00
namespaces.c ns: Add c/r for /proc/$pid/ns/$ids references 2013-05-18 04:00:05 +04:00
net.c ns: Extend ns_desc to carry the length of the ns name 2013-05-18 03:36:56 +04:00
netfilter.c Don't use \Newline in pr_perror 2013-05-16 17:05:45 +04:00
page-pipe.c page-pipe: fixed format strings 2013-04-30 18:31:34 +04:00
page-read.c page-read: fixed format strings 2013-04-30 18:31:35 +04:00
page-xfer.c page-server: Add daemonize call return check 2013-05-21 19:05:15 +04:00
parasite-syscall.c parasite: Switch parasite to daemon mode (v2) 2013-05-24 20:22:23 +04:00
pipes.c img: Get rid of open_image_ro helper 2013-04-09 19:22:21 +04:00
proc_parse.c proc: Don't mark mishinted vdso 2013-05-24 13:27:21 +04:00
protobuf.c protobuf: Prepare scaffolds for procfs NS entries 2013-05-18 03:37:00 +04:00
pstree.c parasite: use transparent thread indexes 2013-05-24 18:47:11 +04:00
ptrace.c Change crtools to criu in criu messages 2013-05-10 11:02:20 +04:00
rbtree.c code: Fix spaced indentation where found 2012-08-11 21:36:03 +04:00
README README: crtools to criu rename 2013-05-10 11:02:02 +04:00
shmem.c shmem: Print shmem ID on dump in decimal 2013-05-16 16:20:17 +04:00
sigframe.c restore: construct sigframe in crtools 2013-05-24 17:39:52 +04:00
signalfd.c show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
sk-inet.c show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
sk-netlink.c show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
sk-packet.c show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
sk-queue.c show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
sk-tcp.c make: Introduce compile time include/config.h generation 2013-05-20 16:02:14 +04:00
sk-unix.c show: Remove options args from ->show callback 2013-05-08 00:23:42 +04:00
sockets.c Change crtools to criu in comments 2013-05-10 11:02:27 +04:00
stats.c mem/stats: Add stats about memory dumping 2013-05-15 15:46:07 +04:00
sysctl.c sysctl: Don't forget to close fds 2013-04-05 08:23:17 +04:00
tty.c tty: Don't try to restore a group on inherited terminal if session leader present 2013-05-07 22:35:33 +04:00
util.c proc: use vma flags for determing vmas with MAP_GROWSDOWN 2013-05-21 19:03:57 +04:00
uts_ns.c ns: Extend ns_desc to carry the length of the ns name 2013-05-18 03:36:56 +04:00

criu
====

An utility to checkpoint/restore tasks.

Some code snippets are borrowed from

 - Linux kernel (http://kernel.org/)
 - git (http://git-scm.com/)
 - kvm-tools (https://github.com/penberg/linux-kvm)
 - ptrace-parasite (https://code.google.com/p/ptrace-parasite/)

Many thanks to these projects.

Licensed under GPLv2 (http://www.gnu.org/licenses/gpl-2.0.txt)