2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-23 02:17:22 +00:00
criu/lib/criu.h

72 lines
2.5 KiB
C
Raw Normal View History

/*
* (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>
void criu_set_service_address(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_set_pid(int pid);
void criu_set_images_dir_fd(int fd); /* must be set for dump/restore */
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);
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);
void criu_set_log_level(int log_level);
void criu_set_log_file(char *log_file);
void criu_set_cpu_cap(unsigned int cap);
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
void criu_set_exec_cmd(int argc, char *argv[]);
/* 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);
#endif /* __CRIU_LIB_H__ */