2013-12-18 01:04:40 +04:00
|
|
|
/*
|
|
|
|
* (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 <stdbool.h>
|
|
|
|
|
2015-07-24 12:41:03 +03:00
|
|
|
#ifdef __GNUG__
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-07-16 15:42:00 +03:00
|
|
|
enum criu_service_comm {
|
|
|
|
CRIU_COMM_SK,
|
2015-07-30 16:40:22 -04:00
|
|
|
CRIU_COMM_FD,
|
|
|
|
CRIU_COMM_BIN
|
2015-07-16 15:42:00 +03:00
|
|
|
};
|
|
|
|
|
2015-08-06 15:39:00 +03:00
|
|
|
enum criu_cg_mode {
|
|
|
|
CRIU_CG_MODE_IGNORE = 0,
|
|
|
|
CRIU_CG_MODE_NONE = 1,
|
|
|
|
CRIU_CG_MODE_PROPS = 2,
|
|
|
|
CRIU_CG_MODE_SOFT = 3,
|
|
|
|
CRIU_CG_MODE_FULL = 4,
|
|
|
|
CRIU_CG_MODE_STRICT = 5,
|
|
|
|
CRIU_CG_MODE_DEFAULT = 6
|
|
|
|
};
|
|
|
|
|
2013-12-18 01:04:40 +04:00
|
|
|
void criu_set_service_address(char *path);
|
2015-07-16 15:42:00 +03:00
|
|
|
void criu_set_service_fd(int fd);
|
2015-07-30 16:40:22 -04:00
|
|
|
void criu_set_service_binary(char *path);
|
2015-07-16 15:42:00 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* You can choose if you want libcriu to connect to service socket
|
2015-10-12 12:50:04 +03:00
|
|
|
* by itself, use provided file descriptor or spawn swrk by itself
|
2015-07-16 15:42:00 +03:00
|
|
|
*/
|
|
|
|
void criu_set_service_comm(enum criu_service_comm);
|
2013-12-18 01:04:40 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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_set_pid(int pid);
|
|
|
|
void criu_set_images_dir_fd(int fd); /* must be set for dump/restore */
|
2014-06-25 17:15:57 +04:00
|
|
|
void criu_set_parent_images(char *path);
|
2014-02-04 18:27:20 +04:00
|
|
|
void criu_set_work_dir_fd(int fd);
|
2013-12-18 01:04:40 +04:00
|
|
|
void criu_set_leave_running(bool leave_running);
|
|
|
|
void criu_set_ext_unix_sk(bool ext_unix_sk);
|
2015-07-29 14:05:50 +03:00
|
|
|
int criu_add_unix_sk(unsigned int inode);
|
2013-12-18 01:04:40 +04:00
|
|
|
void criu_set_tcp_established(bool tcp_established);
|
|
|
|
void criu_set_evasive_devices(bool evasive_devices);
|
|
|
|
void criu_set_shell_job(bool shell_job);
|
|
|
|
void criu_set_file_locks(bool file_locks);
|
2014-06-25 17:15:57 +04:00
|
|
|
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);
|
2013-12-18 01:04:40 +04:00
|
|
|
void criu_set_log_level(int log_level);
|
|
|
|
void criu_set_log_file(char *log_file);
|
2014-02-28 18:59:55 +04:00
|
|
|
void criu_set_cpu_cap(unsigned int cap);
|
2014-06-25 17:06:37 +04:00
|
|
|
void criu_set_root(char *root);
|
2014-08-06 22:23:00 +04:00
|
|
|
void criu_set_manage_cgroups(bool manage);
|
2015-08-06 15:39:00 +03:00
|
|
|
void criu_set_manage_cgroups_mode(enum criu_cg_mode mode);
|
2015-04-21 10:33:55 -06:00
|
|
|
void criu_set_auto_ext_mnt(bool val);
|
|
|
|
void criu_set_ext_sharing(bool val);
|
|
|
|
void criu_set_ext_masters(bool val);
|
2014-03-27 16:43:00 +04:00
|
|
|
int criu_set_exec_cmd(int argc, char *argv[]);
|
2014-06-25 17:34:17 +04:00
|
|
|
int criu_add_ext_mount(char *key, char *val);
|
2014-06-25 17:37:50 +04:00
|
|
|
int criu_add_veth_pair(char *in, char *out);
|
2014-08-22 16:12:05 +04:00
|
|
|
int criu_add_cg_root(char *ctrl, char *path);
|
2015-05-06 12:22:00 +03:00
|
|
|
int criu_add_enable_fs(char *fs);
|
|
|
|
int criu_add_skip_mnt(char *mnt);
|
2015-08-10 17:20:50 +03:00
|
|
|
void criu_set_ghost_limit(unsigned int limit);
|
2015-09-16 07:27:00 +03:00
|
|
|
int criu_add_irmap_path(char *path);
|
2014-06-26 13:58:53 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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);
|
2013-12-18 01:04:40 +04:00
|
|
|
|
|
|
|
/* Here is a table of return values and errno's of functions
|
|
|
|
* from the list down below.
|
|
|
|
*
|
|
|
|
* Return value errno Description
|
|
|
|
* ----------------------------------------------------------------------------
|
2013-12-18 15:50:27 +04:00
|
|
|
* 0 undefined Success.
|
2013-12-18 01:04:40 +04:00
|
|
|
*
|
2013-12-18 15:50:27 +04:00
|
|
|
* >0 undefined Success(criu_restore() only).
|
2013-12-18 01:04:40 +04:00
|
|
|
*
|
2013-12-18 15:50:27 +04:00
|
|
|
* -BADE rpc err (0 for now) RPC has returned fail.
|
2013-12-18 01:04:40 +04:00
|
|
|
*
|
2013-12-18 15:50:27 +04:00
|
|
|
* -ECONNREFUSED errno Unable to connect to CRIU.
|
2013-12-18 01:04:40 +04:00
|
|
|
*
|
2013-12-18 15:50:27 +04:00
|
|
|
* -ECOMM errno Unable to send/recv msg to/from CRIU.
|
2013-12-18 01:04:40 +04:00
|
|
|
*
|
2013-12-18 15:50:27 +04:00
|
|
|
* -EINVAL undefined CRIU doesn't support this type of request.
|
2013-12-18 01:04:40 +04:00
|
|
|
* You should probably update CRIU.
|
|
|
|
*
|
2013-12-18 15:50:27 +04:00
|
|
|
* -EBADMSG undefined Unexpected response from CRIU.
|
2013-12-18 01:04:40 +04:00
|
|
|
* You should probably update CRIU.
|
|
|
|
*/
|
|
|
|
int criu_check(void);
|
|
|
|
int criu_dump(void);
|
|
|
|
int criu_restore(void);
|
2014-06-17 21:10:46 +04:00
|
|
|
int criu_restore_child(void);
|
2013-12-18 01:04:40 +04:00
|
|
|
|
2014-06-26 18:52:34 +04:00
|
|
|
/*
|
|
|
|
* 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));
|
|
|
|
|
2015-07-13 14:55:00 +03:00
|
|
|
/*
|
|
|
|
* Same as the list above, but lets you have your very own options
|
|
|
|
* structure and lets you set individual options in it.
|
|
|
|
*/
|
2015-07-31 15:57:00 +03:00
|
|
|
typedef struct criu_opts criu_opts;
|
2015-07-15 04:45:02 +03:00
|
|
|
|
|
|
|
int criu_local_init_opts(criu_opts **opts);
|
|
|
|
|
2015-07-16 15:42:00 +03:00
|
|
|
void criu_local_set_service_address(criu_opts *opts, char *path);
|
|
|
|
void criu_local_set_service_fd(criu_opts *opts, int fd);
|
|
|
|
void criu_local_set_service_comm(criu_opts *opts, enum criu_service_comm);
|
|
|
|
|
|
|
|
void criu_local_set_service_fd(criu_opts *opts, int fd);
|
|
|
|
|
2015-07-15 04:45:02 +03:00
|
|
|
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 */
|
|
|
|
void criu_local_set_parent_images(criu_opts *opts, 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);
|
2015-07-29 14:05:50 +03:00
|
|
|
int criu_local_add_unix_sk(criu_opts *opts, unsigned int inode);
|
2015-07-15 04:45:02 +03:00
|
|
|
void criu_local_set_tcp_established(criu_opts *opts, bool tcp_established);
|
|
|
|
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_log_file(criu_opts *opts, char *log_file);
|
|
|
|
void criu_local_set_cpu_cap(criu_opts *opts, unsigned int cap);
|
|
|
|
void criu_local_set_root(criu_opts *opts, char *root);
|
|
|
|
void criu_local_set_manage_cgroups(criu_opts *opts, bool manage);
|
2015-08-06 15:39:00 +03:00
|
|
|
void criu_local_set_manage_cgroups_mode(criu_opts *opts, enum criu_cg_mode mode);
|
2015-07-15 04:45:02 +03:00
|
|
|
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, char *key, char *val);
|
|
|
|
int criu_local_add_veth_pair(criu_opts *opts, char *in, char *out);
|
|
|
|
int criu_local_add_cg_root(criu_opts *opts, char *ctrl, char *path);
|
|
|
|
int criu_local_add_enable_fs(criu_opts *opts, char *fs);
|
|
|
|
int criu_local_add_skip_mnt(criu_opts *opts, char *mnt);
|
2015-08-10 17:20:50 +03:00
|
|
|
void criu_local_set_ghost_limit(criu_opts *opts, unsigned int limit);
|
2015-09-16 07:27:00 +03:00
|
|
|
int criu_local_add_irmap_path(criu_opts *opts, char *path);
|
2016-05-30 18:49:00 +03:00
|
|
|
int criu_local_add_cg_props(criu_opts *opts, char *stream);
|
|
|
|
int criu_local_add_cg_props_file(criu_opts *opts, char *path);
|
|
|
|
int criu_local_add_cg_dump_controller(criu_opts *opts, char *name);
|
2015-07-15 04:45:02 +03:00
|
|
|
|
|
|
|
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));
|
2015-07-13 14:55:00 +03:00
|
|
|
|
2015-07-24 12:41:03 +03:00
|
|
|
#ifdef __GNUG__
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-12-18 01:04:40 +04:00
|
|
|
#endif /* __CRIU_LIB_H__ */
|