eaiovnaovbqoebvqoeavibavo PK0Z-   criu-log.hnu[/* This file defines types and macros for CRIU plugins. Copyright (C) 2013 Parallels, Inc This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __CRIU_LOG_H__ #define __CRIU_LOG_H__ #include "log.h" extern int log_init(const char *output); extern void log_fini(void); extern int log_init_by_pid(pid_t pid); extern void log_closedir(void); extern int log_keep_err(void); extern char *log_first_err(void); extern void log_set_fd(int fd); extern int log_get_fd(void); extern void log_set_loglevel(unsigned int loglevel); extern unsigned int log_get_loglevel(void); struct timeval; extern void log_get_logstart(struct timeval *); extern int write_pidfile(int pid); #define DEFAULT_LOG_FILENAME "criu.log" static inline int pr_quelled(unsigned int loglevel) { return log_get_loglevel() < loglevel && loglevel != LOG_MSG; } #endif /* __CR_LOG_LEVELS_H__ */ PK0Z~h$$criu.hnu[/* * (C) Copyright 2013 Parallels, Inc. (www.parallels.com). * * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser General Public License * (LGPL) version 2.1 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-2.1.html * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, you can find it here: * www.gnu.org/licenses/lgpl.html */ #ifndef __CRIU_LIB_H__ #define __CRIU_LIB_H__ #include #include "version.h" #ifdef __GNUG__ extern "C" { #endif enum criu_service_comm { CRIU_COMM_SK, CRIU_COMM_FD, CRIU_COMM_BIN }; enum criu_cg_mode { CRIU_CG_MODE_IGNORE, CRIU_CG_MODE_NONE, CRIU_CG_MODE_PROPS, CRIU_CG_MODE_SOFT, CRIU_CG_MODE_FULL, CRIU_CG_MODE_STRICT, CRIU_CG_MODE_DEFAULT, }; int criu_set_service_address(const char *path); void criu_set_service_fd(int fd); int criu_set_service_binary(const char *path); /* * Set opts to defaults. _Must_ be called first before using any functions from * the list down below. 0 on success, -1 on fail. */ int criu_init_opts(void); void criu_free_opts(void); /* * For backward compatibility with the mod_lsapi */ void criu_set_service_comm(enum criu_service_comm); void criu_set_pid(int pid); void criu_set_images_dir_fd(int fd); /* must be set for dump/restore */ int criu_set_parent_images(const char *path); void criu_set_work_dir_fd(int fd); void criu_set_leave_running(bool leave_running); void criu_set_ext_unix_sk(bool ext_unix_sk); int criu_add_unix_sk(unsigned int inode); void criu_set_tcp_established(bool tcp_established); void criu_set_tcp_skip_in_flight(bool tcp_skip_in_flight); void criu_set_tcp_close(bool tcp_close); void criu_set_weak_sysctls(bool val); void criu_set_evasive_devices(bool evasive_devices); void criu_set_shell_job(bool shell_job); void criu_set_file_locks(bool file_locks); void criu_set_track_mem(bool track_mem); void criu_set_auto_dedup(bool auto_dedup); void criu_set_force_irmap(bool force_irmap); void criu_set_link_remap(bool link_remap); void criu_set_log_level(int log_level); void criu_set_root_only(bool root_only); int criu_set_log_file(const char *log_file); void criu_set_cpu_cap(unsigned int cap); int criu_set_root(const char *root); void criu_set_manage_cgroups(bool manage); void criu_set_manage_cgroups_mode(enum criu_cg_mode mode); int criu_set_freeze_cgroup(const char *name); int criu_set_lsm_profile(const char *name); void criu_set_timeout(unsigned int timeout); void criu_set_auto_ext_mnt(bool val); void criu_set_ext_sharing(bool val); void criu_set_ext_masters(bool val); int criu_set_exec_cmd(int argc, char *argv[]); int criu_add_ext_mount(const char *key, const char *val); int criu_add_veth_pair(const char *in, const char *out); int criu_add_cg_root(const char *ctrl, const char *path); int criu_add_enable_fs(const char *fs); int criu_add_skip_mnt(const char *mnt); void criu_set_ghost_limit(unsigned int limit); int criu_add_irmap_path(const char *path); int criu_add_inherit_fd(int fd, const char *key); int criu_add_external(const char *key); int criu_set_page_server_address_port(const char *address, int port); /* * The criu_notify_arg_t na argument is an opaque * value that callbacks (cb-s) should pass into * criu_notify_xxx() calls to fetch arbitrary values * from notification. If the value is not available * some non-existing one is reported. */ typedef struct _CriuNotify *criu_notify_arg_t; void criu_set_notify_cb(int (*cb)(char *action, criu_notify_arg_t na)); /* Get pid of root task. 0 if not available */ int criu_notify_pid(criu_notify_arg_t na); /* Here is a table of return values and errno's of functions * from the list down below. * * Return value errno Description * ---------------------------------------------------------------------------- * 0 undefined Success. * * >0 undefined Success(criu_restore() only). * * -BADE rpc err (0 for now) RPC has returned fail. * * -ECONNREFUSED errno Unable to connect to CRIU. * * -ECOMM errno Unable to send/recv msg to/from CRIU. * * -EINVAL undefined CRIU doesn't support this type of request. * You should probably update CRIU. * * -EBADMSG undefined Unexpected response from CRIU. * You should probably update CRIU. */ int criu_check(void); int criu_dump(void); int criu_restore(void); int criu_restore_child(void); /* * Perform dumping but with preliminary iterations. Each * time an iteration ends the ->more callback is called. * The callback's return value is * - positive -- one more iteration starts * - zero -- final dump is performed and call exits * - negative -- dump is aborted, the value is returned * back from criu_dump_iters * * The @pi argument is an opaque value that caller may * use to request pre-dump statistics (not yet implemented). */ typedef void *criu_predump_info; int criu_dump_iters(int (*more)(criu_predump_info pi)); /* * Same as the list above, but lets you have your very own options * structure and lets you set individual options in it. */ typedef struct criu_opts criu_opts; int criu_local_init_opts(criu_opts **opts); void criu_local_free_opts(criu_opts *opts); int criu_local_set_service_address(criu_opts *opts, const char *path); void criu_local_set_service_fd(criu_opts *opts, int fd); void criu_local_set_service_fd(criu_opts *opts, int fd); void criu_local_set_pid(criu_opts *opts, int pid); void criu_local_set_images_dir_fd(criu_opts *opts, int fd); /* must be set for dump/restore */ int criu_local_set_parent_images(criu_opts *opts, const char *path); int criu_local_set_service_binary(criu_opts *opts, const char *path); void criu_local_set_work_dir_fd(criu_opts *opts, int fd); void criu_local_set_leave_running(criu_opts *opts, bool leave_running); void criu_local_set_ext_unix_sk(criu_opts *opts, bool ext_unix_sk); int criu_local_add_unix_sk(criu_opts *opts, unsigned int inode); void criu_local_set_tcp_established(criu_opts *opts, bool tcp_established); void criu_local_set_tcp_skip_in_flight(criu_opts *opts, bool tcp_skip_in_flight); void criu_local_set_tcp_close(criu_opts *opts, bool tcp_close); void criu_local_set_weak_sysctls(criu_opts *opts, bool val); void criu_local_set_evasive_devices(criu_opts *opts, bool evasive_devices); void criu_local_set_shell_job(criu_opts *opts, bool shell_job); void criu_local_set_file_locks(criu_opts *opts, bool file_locks); void criu_local_set_track_mem(criu_opts *opts, bool track_mem); void criu_local_set_auto_dedup(criu_opts *opts, bool auto_dedup); void criu_local_set_force_irmap(criu_opts *opts, bool force_irmap); void criu_local_set_link_remap(criu_opts *opts, bool link_remap); void criu_local_set_log_level(criu_opts *opts, int log_level); void criu_local_set_root_only(criu_opts *opts, bool root_only); int criu_local_set_log_file(criu_opts *opts, const char *log_file); void criu_local_set_cpu_cap(criu_opts *opts, unsigned int cap); int criu_local_set_root(criu_opts *opts, const char *root); void criu_local_set_manage_cgroups(criu_opts *opts, bool manage); void criu_local_set_manage_cgroups_mode(criu_opts *opts, enum criu_cg_mode mode); int criu_local_set_freeze_cgroup(criu_opts *opts, const char *name); int criu_local_set_lsm_profile(criu_opts *opts, const char *name); void criu_local_set_timeout(criu_opts *opts, unsigned int timeout); void criu_local_set_auto_ext_mnt(criu_opts *opts, bool val); void criu_local_set_ext_sharing(criu_opts *opts, bool val); void criu_local_set_ext_masters(criu_opts *opts, bool val); int criu_local_set_exec_cmd(criu_opts *opts, int argc, char *argv[]); int criu_local_add_ext_mount(criu_opts *opts, const char *key, const char *val); int criu_local_add_veth_pair(criu_opts *opts, const char *in, const char *out); int criu_local_add_cg_root(criu_opts *opts, const char *ctrl, const char *path); int criu_local_add_enable_fs(criu_opts *opts, const char *fs); int criu_local_add_skip_mnt(criu_opts *opts, const char *mnt); void criu_local_set_ghost_limit(criu_opts *opts, unsigned int limit); int criu_local_add_irmap_path(criu_opts *opts, const char *path); int criu_local_add_cg_props(criu_opts *opts, const char *stream); int criu_local_add_cg_props_file(criu_opts *opts, const char *path); int criu_local_add_cg_dump_controller(criu_opts *opts, const char *name); int criu_local_add_inherit_fd(criu_opts *opts, int fd, const char *key); int criu_local_add_external(criu_opts *opts, const char *key); int criu_local_set_page_server_address_port(criu_opts *opts, const char *address, int port); void criu_local_set_notify_cb(criu_opts *opts, int (*cb)(char *action, criu_notify_arg_t na)); int criu_local_check(criu_opts *opts); int criu_local_dump(criu_opts *opts); int criu_local_restore(criu_opts *opts); int criu_local_restore_child(criu_opts *opts); int criu_local_dump_iters(criu_opts *opts, int (*more)(criu_predump_info pi)); #ifdef __GNUG__ } #endif #endif /* __CRIU_LIB_H__ */ PK0Z˗VJJ rpc.protonu[syntax = "proto2"; message criu_page_server_info { optional string address = 1; optional int32 port = 2; optional int32 pid = 3; optional int32 fd = 4; } message criu_veth_pair { required string if_in = 1; required string if_out = 2; }; message ext_mount_map { required string key = 1; required string val = 2; }; message join_namespace { required string ns = 1; required string ns_file = 2; optional string extra_opt = 3; } message inherit_fd { required string key = 1; required int32 fd = 2; }; message cgroup_root { optional string ctrl = 1; required string path = 2; }; message unix_sk { required uint32 inode = 1; }; enum criu_cg_mode { IGNORE = 0; CG_NONE = 1; PROPS = 2; SOFT = 3; FULL = 4; STRICT = 5; DEFAULT = 6; }; message criu_opts { required int32 images_dir_fd = 1; optional int32 pid = 2; /* if not set on dump, will dump requesting process */ optional bool leave_running = 3; optional bool ext_unix_sk = 4; optional bool tcp_established = 5; optional bool evasive_devices = 6; optional bool shell_job = 7; optional bool file_locks = 8; optional int32 log_level = 9 [default = 2]; optional string log_file = 10; /* No subdirs are allowed. Consider using work-dir */ optional criu_page_server_info ps = 11; optional bool notify_scripts = 12; optional string root = 13; optional string parent_img = 14; optional bool track_mem = 15; optional bool auto_dedup = 16; optional int32 work_dir_fd = 17; optional bool link_remap = 18; repeated criu_veth_pair veths = 19; /* DEPRECATED, use external instead */ optional uint32 cpu_cap = 20 [default = 0xffffffff]; optional bool force_irmap = 21; repeated string exec_cmd = 22; repeated ext_mount_map ext_mnt = 23; /* DEPRECATED, use external instead */ optional bool manage_cgroups = 24; /* backward compatibility */ repeated cgroup_root cg_root = 25; optional bool rst_sibling = 26; /* swrk only */ repeated inherit_fd inherit_fd = 27; /* swrk only */ optional bool auto_ext_mnt = 28; optional bool ext_sharing = 29; optional bool ext_masters = 30; repeated string skip_mnt = 31; repeated string enable_fs = 32; repeated unix_sk unix_sk_ino = 33; /* DEPRECATED, use external instead */ optional criu_cg_mode manage_cgroups_mode = 34; optional uint32 ghost_limit = 35 [default = 0x100000]; repeated string irmap_scan_paths = 36; repeated string external = 37; optional uint32 empty_ns = 38; repeated join_namespace join_ns = 39; optional string cgroup_props = 41; optional string cgroup_props_file = 42; repeated string cgroup_dump_controller = 43; optional string freeze_cgroup = 44; optional uint32 timeout = 45; optional bool tcp_skip_in_flight = 46; optional bool weak_sysctls = 47; optional bool lazy_pages = 48; optional int32 status_fd = 49; optional bool orphan_pts_master = 50; optional string config_file = 51; optional bool tcp_close = 52; optional string lsm_profile = 53; optional string tls_cacert = 54; optional string tls_cacrl = 55; optional string tls_cert = 56; optional string tls_key = 57; optional bool tls = 58; optional bool tls_no_cn_verify = 59; optional bool root_only = 60; /* optional bool check_mounts = 128; */ } message criu_dump_resp { optional bool restored = 1; } message criu_restore_resp { required int32 pid = 1; } message criu_notify { optional string script = 1; optional int32 pid = 2; } enum criu_req_type { EMPTY = 0; DUMP = 1; RESTORE = 2; CHECK = 3; PRE_DUMP = 4; PAGE_SERVER = 5; NOTIFY = 6; CPUINFO_DUMP = 7; CPUINFO_CHECK = 8; FEATURE_CHECK = 9; VERSION = 10; WAIT_PID = 11; PAGE_SERVER_CHLD = 12; } /* * List of features which can queried via * CRIU_REQ_TYPE__FEATURE_CHECK */ message criu_features { optional bool mem_track = 1; optional bool lazy_pages = 2; } /* * Request -- each type corresponds to must-be-there * request arguments of respective type */ message criu_req { required criu_req_type type = 1; optional criu_opts opts = 2; optional bool notify_success = 3; /* * When set service won't close the connection but * will wait for more req-s to appear. Works not * for all request types. */ optional bool keep_open = 4; /* * 'features' can be used to query which features * are supported by the installed criu/kernel * via RPC. */ optional criu_features features = 5; /* 'pid' is used for WAIT_PID */ optional uint32 pid = 6; } /* * Response -- it states whether the request was served * and additional request-specific information */ message criu_resp { required criu_req_type type = 1; required bool success = 2; optional criu_dump_resp dump = 3; optional criu_restore_resp restore = 4; optional criu_notify notify = 5; optional criu_page_server_info ps = 6; optional int32 cr_errno = 7; optional criu_features features = 8; optional string cr_errmsg = 9; optional criu_version version = 10; optional int32 status = 11; } /* Answer for criu_req_type.VERSION requests */ message criu_version { required int32 major_number = 1; required int32 minor_number = 2; optional string gitid = 3; optional int32 sublevel = 4; optional int32 extra = 5; optional string name = 6; } PK0Z\ version.hnu[/* Autogenerated, do not edit */ #ifndef __CR_VERSION_H__ #define __CR_VERSION_H__ #define CRIU_VERSION "3.13" #define CRIU_VERSION_MAJOR 3 #define CRIU_VERSION_MINOR 13 #define CRIU_GITID "0" #endif /* __CR_VERSION_H__ */ PK0ZX criu-plugin.hnu[/* * This file defines types and macros for CRIU plugins. * Copyright (C) 2013-2014 Parallels, Inc * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __CRIU_PLUGIN_H__ #define __CRIU_PLUGIN_H__ #include #include #define CRIU_PLUGIN_GEN_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) #define CRIU_PLUGIN_VERSION_MAJOR 0 #define CRIU_PLUGIN_VERSION_MINOR 2 #define CRIU_PLUGIN_VERSION_SUBLEVEL 0 #define CRIU_PLUGIN_VERSION_OLD CRIU_PLUGIN_GEN_VERSION(0,1,0) #define CRIU_PLUGIN_VERSION \ CRIU_PLUGIN_GEN_VERSION(CRIU_PLUGIN_VERSION_MAJOR, \ CRIU_PLUGIN_VERSION_MINOR, \ CRIU_PLUGIN_VERSION_SUBLEVEL) /* * Plugin hook points and their arguments in hooks. */ enum { CR_PLUGIN_HOOK__DUMP_UNIX_SK = 0, CR_PLUGIN_HOOK__RESTORE_UNIX_SK = 1, CR_PLUGIN_HOOK__DUMP_EXT_FILE = 2, CR_PLUGIN_HOOK__RESTORE_EXT_FILE = 3, CR_PLUGIN_HOOK__DUMP_EXT_MOUNT = 4, CR_PLUGIN_HOOK__RESTORE_EXT_MOUNT = 5, CR_PLUGIN_HOOK__DUMP_EXT_LINK = 6, CR_PLUGIN_HOOK__MAX }; #define DECLARE_PLUGIN_HOOK_ARGS(__hook, ...) \ typedef int (__hook ##_t)(__VA_ARGS__) DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_UNIX_SK, int fd, int id); DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_UNIX_SK, int id); DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_EXT_FILE, int fd, int id); DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_EXT_FILE, int id); DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_EXT_MOUNT, char *mountpoint, int id); DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_EXT_MOUNT, int id, char *mountpoint, char *old_root, int *is_file); DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_EXT_LINK, int index, int type, char *kind); enum { CR_PLUGIN_STAGE__DUMP, CR_PLUGIN_STAGE__PRE_DUMP, CR_PLUGIN_STAGE__RESTORE, CR_PLUGIN_STAGE_MAX }; /* * Plugin descriptor. */ typedef struct { const char *name; int (*init)(int stage); void (*exit)(int stage, int ret); unsigned int version; unsigned int max_hooks; void *hooks[CR_PLUGIN_HOOK__MAX]; } cr_plugin_desc_t; extern cr_plugin_desc_t CR_PLUGIN_DESC; #define CR_PLUGIN_REGISTER(___name, ___init, ___exit) \ cr_plugin_desc_t CR_PLUGIN_DESC = { \ .name = ___name, \ .init = ___init, \ .exit = ___exit, \ .version = CRIU_PLUGIN_VERSION, \ .max_hooks = CR_PLUGIN_HOOK__MAX, \ }; static inline int cr_plugin_dummy_init(int stage) { return 0; } static inline void cr_plugin_dummy_exit(int stage, int ret) { } #define CR_PLUGIN_REGISTER_DUMMY(___name) \ cr_plugin_desc_t CR_PLUGIN_DESC = { \ .name = ___name, \ .init = cr_plugin_dummy_init, \ .exit = cr_plugin_dummy_exit, \ .version = CRIU_PLUGIN_VERSION, \ .max_hooks = CR_PLUGIN_HOOK__MAX, \ }; #define CR_PLUGIN_REGISTER_HOOK(__hook, __func) \ static void __attribute__((constructor)) cr_plugin_register_hook_##__func (void) \ { \ CR_PLUGIN_DESC.hooks[__hook] = (void *)__func; \ } /* Public API */ extern int criu_get_image_dir(void); /* * Deprecated, will be removed in next version. */ typedef int (cr_plugin_init_t)(void); typedef void (cr_plugin_fini_t)(void); typedef int (cr_plugin_dump_unix_sk_t)(int fd, int id); typedef int (cr_plugin_restore_unix_sk_t)(int id); typedef int (cr_plugin_dump_file_t)(int fd, int id); typedef int (cr_plugin_restore_file_t)(int id); typedef int (cr_plugin_dump_ext_mount_t)(char *mountpoint, int id); typedef int (cr_plugin_restore_ext_mount_t)(int id, char *mountpoint, char *old_root, int *is_file); typedef int (cr_plugin_dump_ext_link_t)(int index, int type, char *kind); #endif /* __CRIU_PLUGIN_H__ */ PK0Z-   criu-log.hnu[PK0Z~h$$Fcriu.hnu[PK0Z˗VJJ w+rpc.protonu[PK0Z\ @version.hnu[PK0ZX Bcriu-plugin.hnu[PKo+S