criu/include
Saied Kazemi 0412152fc5 Add inherit fd support
There are cases where a process's file descriptor cannot be restored
from the checkpoint images.  For example, a pipe file descriptor with
one end in the checkpointed process and the other end in a separate
process (that was not part of the checkpointed process tree) cannot be
restored because after checkpoint the pipe will be broken.

There are also cases where the user wants to use a new file during
restore instead of the original file at checkpoint time.  For example,
the user wants to change the log file of a process from /path/to/oldlog
to /path/to/newlog.

In these cases, criu's caller should set up a new file descriptor to be
inherited by the restored process and specify the file descriptor with the
--inherit-fd command line option.  The argument of --inherit-fd has the
format fd[%d]:%s, where %d tells criu which of its own file descriptors
to use for restoring the file identified by %s.

As a debugging aid, if the argument has the format debug[%d]:%s, it tells
criu to write out the string after colon to the file descriptor %d.  This
can be used, for example, as an easy way to leave a "restore marker"
in the output stream of the process.

It's important to note that inherit fd support breaks applications
that depend on the state of the file descriptor being inherited.  So,
consider inherit fd only for specific use cases that you know for sure
won't break the application.

For examples please visit http://criu.org/Category:HOWTO.

v2: Added a check in send_fd_to_self() to avoid closing an inherit fd.
    Also, as an extra measure of caution, added checks in the inherit fd
    look up functions to make sure that the inherit fd hasn't been reused.
    The patch also includes minor cosmetic changes.

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-10 12:48:30 +03:00
..
asm-generic cr: collect short integer aliases in the single place 2014-04-08 15:35:46 +04:00
action-scripts.h scripts: Add ACT_MAX limit and make @action_names being const 2014-10-27 21:30:37 +04:00
bfd.h bfd: Don't flush read-only images 2014-11-05 15:38:17 +04:00
bug.h bug: Include <stdbool.h> 2014-02-21 16:27:16 +04:00
cgroup.h cg: add --cgroup-root option 2014-08-19 12:58:36 +04:00
compiler.h include/compiler.h: Cleanup 2013-02-15 17:34:38 +04:00
config-base.h config-base: Add F_SETPIPE_SZ/F_GETPIPE_SZ 2014-02-18 12:53:09 +04:00
cpu.h cpuinfo: Add "cpuinfo [dump|check]" commands, v2 2014-10-03 13:26:58 +04:00
cr-service-const.h service: move constants to cr-service-const.h 2013-12-18 14:26:10 +04:00
cr-service.h scripts: Use numeric action val in RPC notifications 2014-09-05 13:48:27 +04:00
cr-show.h img: Introduce the struct cr_img 2014-09-30 21:48:13 +04:00
cr_options.h Add inherit fd support 2014-12-10 12:48:30 +03:00
criu-log.h log: Add pr_warn_once helper 2014-02-28 13:34:29 +04:00
criu-plugin.h plugin: Explicit assign plugin hooks 2014-09-19 17:39:06 +04:00
crtools.h dump: get tasks ids from parasite 2014-11-07 17:14:32 +04:00
err.h headers: Add err.h header 2013-04-02 20:27:51 +04:00
errno.h headers: Move ERESTART codes to errno.h 2013-11-14 22:22:21 +04:00
eventfd.h anon-inode: Don't readlink fd/fd multiple times 2014-02-02 22:14:29 +04:00
eventpoll.h anon-inode: Don't readlink fd/fd multiple times 2014-02-02 22:14:29 +04:00
fcntl.h fsnotify: Open handle with O_PATH, v2 2014-02-25 23:38:35 +04:00
fifo.h img: Rename fdset -> imgset 2014-09-30 21:48:10 +04:00
file-ids.h files-ids: generate id-s accoding with mnt_id, st->st_dev and st->st_ino 2014-04-21 22:39:28 +04:00
file-lock.h locks: Don't dump locks in per-task manner (v3) 2014-09-02 17:44:46 +04:00
files-reg.h files-reg: Add try_collect_special_file 2014-10-23 17:51:49 +04:00
files.h Add inherit fd support 2014-12-10 12:48:30 +03:00
fs-magic.h remap: add a dead pid /proc remap 2014-09-19 17:42:48 +04:00
fsnotify.h fsnotify: merge fanotify mark image into fanotify image (v3) 2014-09-03 20:51:39 +04:00
image-desc.h criu: add constants about user namespaces 2014-11-07 17:00:32 +04:00
image.h img: Prepare to use bfd engine 2014-09-30 21:48:53 +04:00
imgset.h img: Introduce the struct cr_img 2014-09-30 21:48:13 +04:00
inet_diag.h headers: Unify include guards (in comments) and a few fixes 2012-12-25 22:40:24 +04:00
ipc_ns.h ns: Factor out namespace switching call 2014-09-30 21:54:11 +04:00
irmap.h irmap: Get root mntfd before releasing tasks on predump 2014-10-01 09:37:04 +04:00
kcmp-ids.h headers: Add extern specificator to functions 2013-11-15 17:00:58 +04:00
kcmp.h headers: Move kcmp_type to kcmp.h 2013-11-14 22:13:59 +04:00
kerndat.h tcp: don't split packets for restoring a send queue 2014-12-08 15:46:44 +03:00
libnetlink.h headers: Unify include guards (in comments) and a few fixes 2012-12-25 22:40:24 +04:00
list.h criu: Several formatting fixes 2014-01-14 09:33:19 +04:00
lock.h atomic: Use atomic_read instead of atomic_get 2013-08-16 19:37:06 +04:00
log.h img: Introduce the struct cr_img 2014-09-30 21:48:13 +04:00
magic.h criu: add constants about user namespaces 2014-11-07 17:00:32 +04:00
mem.h mem: Move shmem preparation routine and rename 2014-02-03 23:34:12 +04:00
mman.h headers: Move MADV definitions to own mman.h 2013-11-14 22:48:30 +04:00
mount.h img: Rename fdset -> imgset 2014-09-30 21:48:10 +04:00
namespaces.h ns: Rename "created" futex and comment what it is 2014-11-11 20:11:58 +04:00
net.h predump: Collect mnt and net namespaces properly 2014-10-02 14:30:31 +04:00
netfilter.h headers: Add extern specificator to functions 2013-11-15 17:00:58 +04:00
netlink_diag.h headers: Add missing __CR_ at last endif 2013-11-15 16:59:57 +04:00
packet_diag.h headers: Unify include guards (in comments) and a few fixes 2012-12-25 22:40:24 +04:00
page-pipe.h page-pipe: split dumping memory on chunks (v3) 2014-02-10 15:06:39 +04:00
page-read.h img: Introduce the struct cr_img 2014-09-30 21:48:13 +04:00
page-xfer.h mem: check existence of parent images before dumping pages (v2) 2014-11-29 19:32:40 +03:00
pagemap-cache.h pagemap-cache: Use page.h helpers 2014-02-21 16:29:41 +04:00
parasite-syscall.h parasite: Cleanup args size fetching 2014-11-11 20:11:34 +04:00
parasite.h dump: get tasks ids from parasite 2014-11-07 17:14:32 +04:00
pid.h headers: Add missing __CR_ at last endif 2013-11-15 16:59:57 +04:00
pipes.h collect: Shorten common images collecting code 2013-08-21 03:52:18 +04:00
plugin.h plugin: Rework plugins API, v2 2014-09-03 20:48:36 +04:00
posix-timer.h posix-timers: Helper for freeing proc parsed data 2014-04-17 12:01:02 +04:00
prctl.h prctl: Add new interface constants 2014-10-27 21:25:25 +04:00
proc_parse.h proc: delete parse_pid_stat_small() (v2) 2014-11-07 17:15:37 +04:00
protobuf-desc.h criu: add constants about user namespaces 2014-11-07 17:00:32 +04:00
protobuf.h img: Introduce the struct cr_img 2014-09-30 21:48:13 +04:00
pstree.h pstree: Add helper for adding helpers to pstree 2014-10-14 18:02:36 +04:00
ptrace.h dump: remove useless arguments from seize_task() 2014-11-07 17:14:54 +04:00
rbtree.h x86: moved x86-specific files into the directory arch/x86. 2013-01-09 17:02:47 +04:00
restorer.h restore: use breakpoints instead of tracing syscalls 2014-09-19 17:57:18 +04:00
rst-malloc.h whitespace-at-eol cleanup 2013-12-12 10:00:45 +04:00
rst_info.h restore: use breakpoints instead of tracing syscalls 2014-09-19 17:57:18 +04:00
servicefd.h cg: Restore tasks into proper cgroups 2014-05-27 23:48:06 +04:00
setproctitle.h crtools: check for setproctitle_init 2014-09-02 16:14:39 +04:00
shmem.h shmem: rework getting file descriptors for shared memory regions (v2) 2014-10-23 19:57:12 +04:00
sigframe.h parasite: don't include restorer.h in parasite-syscall.c 2013-11-06 12:39:36 +04:00
signalfd.h img: Rename fdset -> imgset 2014-09-30 21:48:10 +04:00
sk-inet.h headers: Add extern specificator to functions 2013-11-15 17:00:58 +04:00
sk-packet.h img: Rename fdset -> imgset 2014-09-30 21:48:10 +04:00
sk-queue.h crtools: move all stuff about vma together 2013-11-06 12:43:49 +04:00
sockets.h dump: pre-load kernel modules 2014-10-14 14:21:05 +04:00
stats.h stats: Fix restore pages stats 2014-02-04 14:03:10 +04:00
string.h make: config -- Add testing if we have libbsd installed 2014-03-26 01:44:23 +04:00
syscall-types.h namespaces: take into account USERNS id 2014-10-30 16:00:33 +04:00
sysctl.h add int(CTL_32) 2014-10-08 19:23:24 +04:00
sysfs_parse.h Added AUFS support. 2014-08-21 18:35:22 +04:00
timerfd.h timerfd: Implement check routine 2014-08-07 10:18:09 +04:00
tty.h tty: Add support of /dev/console 2014-10-27 21:35:39 +04:00
tun.h img: Rename fdset -> imgset 2014-09-30 21:48:10 +04:00
unix_diag.h x86: moved x86-specific files into the directory arch/x86. 2013-01-09 17:02:47 +04:00
util-pie.h headers: Drop uintX_t usage 2013-12-12 10:03:07 +04:00
util.h util: Fix the ispathsub corner case 2014-11-09 23:26:56 +04:00
uts_ns.h ns: Factor out namespace switching call 2014-09-30 21:54:11 +04:00
vdso.h vdso: Implement vDSO proxification of any vvar/vdso order 2014-08-04 15:35:03 +04:00
vma.h filemap: Get vma mnt_id early 2014-09-29 13:20:55 +04:00
xmalloc.h core: Allocate CoreEntry (except arch) with single xmalloc 2014-03-14 13:39:28 +04:00