2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-24 19:08:11 +00:00
criu/include/cr_options.h

97 lines
2.1 KiB
C
Raw Permalink Normal View History

#ifndef __CR_OPTIONS_H__
#define __CR_OPTIONS_H__
#include <stdbool.h>
#include "list.h"
/*
* CPU capability options.
*/
#define CPU_CAP_NONE (0u)
#define CPU_CAP_ALL (-1u)
#define CPU_CAP_FPU (1u) /* Only FPU capability required */
#define CPU_CAP_CPU (2u) /* Strict CPU capability required */
#define CPU_CAP_INS (4u) /* Instructions CPU capatibility */
#define CPU_CAP_DEFAULT (CPU_CAP_FPU)
struct cg_root_opt {
struct list_head node;
char *controller;
char *newroot;
};
/*
* Cgroup management options.
*/
#define CG_MODE_IGNORE (0u << 0) /* Zero is important here */
#define CG_MODE_NONE (1u << 0)
#define CG_MODE_PROPS (1u << 1)
#define CG_MODE_SOFT (1u << 2)
#define CG_MODE_FULL (1u << 3)
#define CG_MODE_STRICT (1u << 4)
#define CG_MODE_DEFAULT (CG_MODE_SOFT)
/*
* Ghost file size we allow to carry by default.
*/
#define DEFAULT_GHOST_LIMIT (1 << 20)
struct cr_options {
int final_state;
char *show_dump_file;
char *show_fmt;
bool check_ms_kernel;
bool show_pages_content;
union {
bool restore_detach;
bool daemon_mode;
};
restore: Introduce the --restore-sibling option We have a slight mess with how criu restores root task. Right now we have the following options. 1) CLI a) Usually task calling criu `- criu `- root restored task b) when --restore-detached AND root has pdeath_sig task calling criu `- criu `- root restored task 2) Library/SWRK task using lib/swrk `- criu `- root restored task 3) Standalone service a) Usually service `- service sub task `- root restored task b) when root has pdeath_sig criu service `- criu sub task `- root restored task It would be better is CRIU always restored the root task as sibling, but we have 3 constraints: First, the case 1.a is kept for zdtm to run tests in pid namespaces on 3.11, which in turn doesn't allow CLONE_PARENT | CLONE_NEWPID. Second, CLI w/o --restore-detach waits for the restored task to die and this behavior can be "expected" already. Third, in case of standalone service tasks shouldn't become service's children. And I have one "plan". The p.haul project while live migrating tasks on destination node starts a service, which uses library/swrk mode. In this case the restored processes become p.haul service's kids which is also not great. That said, here's the option called --restore-child that pairs the --restore-detach like this: * detached AND child: task `- criu restore (exits at the end) `- root task The root task will become task's child. This will be default to library/swrk. This is what LXC needs. * detach AND !child task `- criu restore (exits at the end) `- root task The root task will get re-parented to init. This will be compatible with 1.3. This will be default to standalone service and to my wish with the p.haul case. * !detach AND child task `- criu restore (waits for root task to die) `- root task This should be deprecated, so that criu restore doesn't mess with task <-> root task signalling. * !detach AND !child task `- criu restore (waits for root task to die) `- root task This is how plain criu restore works now. Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Acked-by: Tycho Andersen <tycho.andersen@canonical.com> Acked-by: Andrew Vagin <avagin@openvz.org>
2014-09-10 15:46:06 +04:00
bool restore_sibling;
bool ext_unix_sk;
struct list_head ext_unixsk_ids;
bool shell_job;
bool handle_file_locks;
bool tcp_established_ok;
bool evasive_devices;
bool link_remap_ok;
unsigned int rst_namespaces_flags;
bool log_file_per_pid;
bool swrk_restore;
char *output;
char *root;
char *pidfile;
char *freeze_cgroup;
struct list_head veth_pairs;
struct list_head scripts;
struct list_head ext_mounts;
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-09 23:20:00 +03:00
struct list_head inherit_fds;
char *libdir;
bool use_page_server;
unsigned short ps_port;
char *addr;
int ps_socket;
bool track_mem;
char *img_parent;
bool auto_dedup;
unsigned int cpu_cap;
bool force_irmap;
criu: Add exec-cmd option (v3) The --exec-cmd option specifies a command that will be execvp()-ed on successful restore. This way the command specified here will become the parent process of the restored process tree. Waiting for the restored processes to finish is responsibility of this command. All service FDs are closed before we call execvp(). Standad output and error of the command are redirected to the log file when we are restoring through the RPC service. This option will be used when restoring LinuX Containers and it seems helpful for perf or other use cases when restored processes must be supervised by a parent. Two directions were researched in order to integrate CRIU and LXC: 1. We tell to CRIU, that after restoring container is should execve() lxc properly explaining to it that there's a new container hanging around. 2. We make LXC set himself as child subreaper, then fork() criu and ask it to detach (-d) from restore container afterwards. Being a subreaper, it should get the container's init into his child list after it. The main reason for choosing the first option is that the second one can't work with the RPC service. If we call restore via the service then criu service will be the top-most task in the hierarchy and will not be able to reparent the restore trees to any other task in the system. Calling execve from service worker sub-task (and daemonizing it) should solve this. Signed-off-by: Deyan Doychev <deyandoichev@gmail.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-03-22 20:14:00 +04:00
char **exec_cmd;
unsigned int manage_cgroups;
char *new_global_cg_root;
struct list_head new_cgroup_roots;
bool autodetect_ext_mounts;
bool enable_external_sharing;
bool enable_external_masters;
bool aufs; /* auto-deteced, not via cli */
bool overlayfs;
size_t ghost_limit;
};
extern struct cr_options opts;
extern void init_opts(void);
#endif /* __CR_OPTIONS_H__ */