Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Documentation/criu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ The following levels are available:
Use 'path' as a parent directory where to look for sets of image files.
This option makes sense in case of incremental dumps.

*--luo-session* 'id'::
Create a Live Update Orchestrator session named 'id', and use it to store
images.
This will disable writing images to files.

*--luo-session-fd* 'fd'::
Use 'fd' as the Live Update Orchestrator session to store images into.
This will disable writing images to files.

*-W*, *--work-dir* 'dir'::
Use directory 'dir' for putting logs, pidfiles and statistics. If not
specified, 'path' from *-D* option is taken.
Expand Down
1 change: 1 addition & 0 deletions criu/Makefile.crtools
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ obj-y += kerndat.o
obj-y += libnetlink.o
obj-y += log.o
obj-y += lsm.o
obj-y += luo.o
obj-y += mem.o
obj-y += memfd.o
obj-y += mount.o
Expand Down
21 changes: 21 additions & 0 deletions criu/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ void init_opts(void)
opts.file_validation_method = FILE_VALIDATION_DEFAULT;
opts.network_lock_method = NETWORK_LOCK_DEFAULT;
opts.ghost_fiemap = FIEMAP_DEFAULT;
opts.luo_session_fd = -1;
}

bool deprecated_ok(char *what)
Expand Down Expand Up @@ -701,6 +702,8 @@ int parse_options(int argc, char **argv, bool *usage_error, bool *has_exec_cmd,
BOOL_OPT("skip-file-rwx-check", &opts.skip_file_rwx_check),
{ "lsm-mount-context", required_argument, 0, 1099 },
{ "network-lock", required_argument, 0, 1100 },
{ "luo-session", required_argument, 0, 1101 },
{ "luo-session-fd", required_argument, 0, 1102 },
BOOL_OPT("mntns-compat-mode", &opts.mntns_compat_mode),
BOOL_OPT("unprivileged", &opts.unprivileged),
BOOL_OPT("ghost-fiemap", &opts.ghost_fiemap),
Expand Down Expand Up @@ -1045,6 +1048,24 @@ int parse_options(int argc, char **argv, bool *usage_error, bool *has_exec_cmd,
return 1;
}
break;
case 1101:
if (opts.use_luo) {
pr_err("--luo-session or --luo-session-id was supplied multiple times.\n");
return 1;
}
SET_CHAR_OPTS(luo_session, optarg);
opts.use_luo = true;
break;
case 1102:
if (sscanf(optarg, "%d", &opts.luo_session_fd) != 1) {
pr_err("Unable to parse a value of --luo-session-fd\n");
return 1;
} else if (opts.use_luo) {
pr_err("--luo-session or --luo-session-id was supplied multiple times.\n");
return 1;
}
opts.use_luo = true;
break;
case 'V':
pr_msg("Version: %s\n", CRIU_VERSION);
if (strcmp(CRIU_GITID, "0"))
Expand Down
16 changes: 16 additions & 0 deletions criu/cr-dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
#include "asm/dump.h"
#include "timer.h"
#include "sigact.h"
#include "luo.h"

/*
* Architectures can overwrite this function to restore register sets that
Expand Down Expand Up @@ -2125,11 +2126,21 @@ static int cr_dump_finish(int ret)
pr_info("fault: CRIU dump crashed!\n");
abort();
}
if (opts.use_luo && opts.luo_session)
luo_session_finish();
pr_err("Dumping FAILED.\n");
} else {
write_stats(DUMP_STATS);
pr_info("Dumping finished successfully\n");
/*
* LUO will only preserve session file descriptors that were open
* when kexec occurs, so we literally freeze in place.
*/
if (opts.use_luo && opts.luo_session)
luo_session_hang();
}


return post_dump_ret ?: (ret != 0);
}

Expand Down Expand Up @@ -2196,6 +2207,11 @@ int cr_dump_tasks(pid_t pid)
goto err;
}

if (opts.use_luo && opts.luo_session) {
if (luo_session_init(opts.luo_session))
goto err;
}

if (connect_to_page_server_to_send() < 0)
goto err;

Expand Down
10 changes: 10 additions & 0 deletions criu/cr-restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
#include "bpfmap.h"
#include "apparmor.h"
#include "pidfd.h"
#include "luo.h"

#include "parasite-syscall.h"
#include "files-reg.h"
Expand Down Expand Up @@ -2403,6 +2404,11 @@ int cr_restore_tasks(void)
if (fdstore_init())
return -1;

if (opts.use_luo && opts.luo_session) {
if (luo_session_open(opts.luo_session))
return -1;
}

/*
* For the AMDGPU plugin, its parallel restore feature needs to use fdstore to store
* its socket file descriptor. This allows the main process and the target process to
Expand Down Expand Up @@ -2431,6 +2437,10 @@ int cr_restore_tasks(void)
clean_cgroup:
fini_cgroup();
err:
if (opts.use_luo) {
luo_session_finish();
}

cr_plugin_fini(CR_PLUGIN_STAGE__RESTORE, ret);
return ret;
}
Expand Down
4 changes: 4 additions & 0 deletions criu/crtools.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ int main(int argc, char *argv[], char *envp[])
" --pidfile FILE write root task, service or page-server pid to FILE\n"
" -W|--work-dir DIR directory to cd and write logs/pidfiles/stats to\n"
" (if not specified, value of --images-dir is used)\n"
" --luo-session NAME liveupdate session ID to write images to\n"
" if specified, image files will not be written\n"
" --luo-session-fd N liveupdate session file descriptor to write images to \n"
" if specified, image files will not be written\n"
" --cpu-cap [CAP] CPU capabilities to write/check. CAP is comma-separated\n"
" list of: cpu, fpu, all, ins, none. To disable\n"
" a capability, use ^CAP. Empty argument implies all\n"
Expand Down
7 changes: 7 additions & 0 deletions criu/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "proc_parse.h"
#include "img-streamer.h"
#include "namespaces.h"
#include "luo.h"

bool ns_per_id = false;
bool img_common_magic = true;
Expand Down Expand Up @@ -608,6 +609,9 @@ static int do_open_image(struct cr_img *img, int dfd, int type, unsigned long of
if (opts.stream && !(oflags & O_FORCE_LOCAL)) {
ret = img_streamer_open(path, flags);
errno = EIO; /* errno value is meaningless, only the ret value is meaningful */
} else if (opts.use_luo && !(oflags & O_FORCE_LOCAL)) {
img->path = xstrdup(path);
ret = luo_image_open(img, flags);
} else if (root_ns_mask & CLONE_NEWUSER && type == CR_FD_PAGES && oflags & O_RDWR) {
/*
* For pages images dedup we need to open images read-write on
Expand Down Expand Up @@ -693,6 +697,9 @@ void close_image(struct cr_img *img)
*/
unlinkat(get_service_fd(IMG_FD_OFF), img->path, 0);
xfree(img->path);
} else if (opts.use_luo && (img->oflags & O_WRONLY) && !(img->oflags & O_FORCE_LOCAL)) {
luo_image_close(img);
xfree(img->path);
} else if (!empty_image(img))
bclose(&img->_x);

Expand Down
4 changes: 4 additions & 0 deletions criu/include/cr_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ struct cr_options {
int skip_file_rwx_check;
int allow_uprobes;

bool use_luo;
char *luo_session;
int luo_session_fd;

/*
* When we scheduler for removal some functionality we first
* deprecate it and it sits in criu for some time. By default
Expand Down