Skip to content
Merged
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
10 changes: 10 additions & 0 deletions crun.1
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ the pre-dump. It is important to use a relative path from the actual
checkpoint directory specified via \fB--image-path\fP\&. It will fail
if an absolute path is used.

.PP
\fB--manage-cgroups-mode\fP=\fIMODE\fP
Specify which CRIU mange cgroup mode should be used. Permitted values are
\fBsoft\fP, \fBignore\fP, \fBfull\fP or \fBstrict\fP\&. Default is \fBsoft\fP\&.

.SH RESTORE OPTIONS
.PP
crun [global options] restore [options] CONTAINER
Expand Down Expand Up @@ -482,6 +487,11 @@ Detach from the container's process
\fB--pid-file\fP=\fIFILE\fP
Where to write the PID of the container

.PP
\fB--manage-cgroups-mode\fP=\fIMODE\fP
Specify which CRIU mange cgroup mode should be used. Permitted values are
\fBsoft\fP, \fBignore\fP, \fBfull\fP or \fBstrict\fP\&. Default is \fBsoft\fP\&.


.SH Extensions to OCI
.SH \fB\fCrun.oci.seccomp.receiver=PATH\fR
Expand Down
8 changes: 8 additions & 0 deletions crun.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ the pre-dump. It is important to use a relative path from the actual
checkpoint directory specified via **--image-path**. It will fail
if an absolute path is used.

**--manage-cgroups-mode**=_MODE_
Specify which CRIU manage cgroup mode should be used. Permitted values are
**soft**, **ignore**, **full** or **strict**. Default is **soft**.

## RESTORE OPTIONS

crun [global options] restore [options] CONTAINER
Expand Down Expand Up @@ -379,6 +383,10 @@ Detach from the container's process
**--pid-file**=_FILE_
Where to write the PID of the container

**--manage-cgroups-mode**=_MODE_
Specify which CRIU manage cgroup mode should be used. Permitted values are
**soft**, **ignore**, **full** or **strict**. Default is **soft**.

# Extensions to OCI

## `run.oci.seccomp.receiver=PATH`
Expand Down
30 changes: 30 additions & 0 deletions src/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include <unistd.h>
#include <errno.h>
#include <regex.h>
#ifdef HAVE_CRIU
# include <criu/criu.h>
#endif

#include "crun.h"
#include "libcrun/container.h"
Expand All @@ -43,6 +46,7 @@ enum
OPTION_FILE_LOCKS,
OPTION_PARENT_PATH,
OPTION_PRE_DUMP,
OPTION_MANAGE_CGROUPS_MODE,
};

static char doc[] = "OCI runtime";
Expand All @@ -61,12 +65,32 @@ static struct argp_option options[]
{ "parent-path", OPTION_PARENT_PATH, "DIR", 0, "path for previous criu image files in pre-dump", 0 },
{ "pre-dump", OPTION_PRE_DUMP, 0, 0, "dump container's memory information only, leave the container running after this", 0 },
#endif
{ "manage-cgroups-mode", OPTION_MANAGE_CGROUPS_MODE, "MODE", 0, "cgroups mode: 'soft' (default), 'ignore', 'full' and 'strict'", 0 },
{
0,
} };

static char args_doc[] = "checkpoint CONTAINER";

int
crun_parse_manage_cgroups_mode (char *param arg_unused)
{
#ifdef HAVE_CRIU
if (strcmp (param, "soft") == 0)
return CRIU_CG_MODE_SOFT;
else if (strcmp (param, "ignore") == 0)
return CRIU_CG_MODE_IGNORE;
else if (strcmp (param, "full") == 0)
return CRIU_CG_MODE_FULL;
else if (strcmp (param, "strict") == 0)
return CRIU_CG_MODE_STRICT;
else
libcrun_fail_with_error (0, "unknown cgroup mode specified");
#else
return 0;
#endif
}

static error_t
parse_opt (int key, char *arg arg_unused, struct argp_state *state arg_unused)
{
Expand Down Expand Up @@ -111,6 +135,10 @@ parse_opt (int key, char *arg arg_unused, struct argp_state *state arg_unused)
cr_options.file_locks = true;
break;

case OPTION_MANAGE_CGROUPS_MODE:
cr_options.manage_cgroups_mode = crun_parse_manage_cgroups_mode (argp_mandatory_argument (arg, state));
break;

default:
return ARGP_ERR_UNKNOWN;
}
Expand All @@ -131,6 +159,8 @@ crun_command_checkpoint (struct crun_global_arguments *global_args, int argc, ch
0,
};

cr_options.manage_cgroups_mode = -1;

argp_parse (&run_argp, argc, argv, ARGP_IN_ORDER, &first_arg, &cr_options);
crun_assert_n_args (argc - first_arg, 1, 2);

Expand Down
1 change: 1 addition & 0 deletions src/checkpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "crun.h"

int crun_parse_manage_cgroups_mode (char *param);
int crun_command_checkpoint (struct crun_global_arguments *global_args, int argc, char **argv, libcrun_error_t *error);

#endif
1 change: 1 addition & 0 deletions src/libcrun/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ struct libcrun_checkpoint_restore_s
const char *console_socket;
char *parent_path;
bool pre_dump;
int manage_cgroups_mode;
};
typedef struct libcrun_checkpoint_restore_s libcrun_checkpoint_restore_t;

Expand Down
5 changes: 5 additions & 0 deletions src/libcrun/criu.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,11 @@ libcrun_container_checkpoint_linux_criu (libcrun_container_status_t *status, lib
criu_set_tcp_established (cr_options->tcp_established);
criu_set_file_locks (cr_options->file_locks);
criu_set_orphan_pts_master (true);
if (cr_options->manage_cgroups_mode == -1)
/* Defaulting to CRIU_CG_MODE_SOFT just as runc */
criu_set_manage_cgroups_mode (CRIU_CG_MODE_SOFT);
else
criu_set_manage_cgroups_mode (cr_options->manage_cgroups_mode);
criu_set_manage_cgroups (true);

ret = criu_dump ();
Expand Down
7 changes: 7 additions & 0 deletions src/restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <regex.h>

#include "crun.h"
#include "checkpoint.h"
#include "libcrun/container.h"
#include "libcrun/status.h"
#include "libcrun/utils.h"
Expand All @@ -42,6 +43,7 @@ enum
OPTION_PID_FILE,
OPTION_CONSOLE_SOCKET,
OPTION_FILE_LOCKS,
OPTION_MANAGE_CGROUPS_MODE,
};

static char doc[] = "OCI runtime";
Expand All @@ -64,6 +66,7 @@ static struct argp_option options[]
{ "console-socket", OPTION_CONSOLE_SOCKET, "SOCKET", 0,
"path to a socket that will receive the master end of the tty", 0 },
{ "file-locks", OPTION_FILE_LOCKS, 0, 0, "allow file locks", 0 },
{ "manage-cgroups-mode", OPTION_MANAGE_CGROUPS_MODE, "MODE", 0, "cgroups mode: 'soft' (default), 'ignore', 'full' and 'strict'", 0 },
{
0,
} };
Expand Down Expand Up @@ -118,6 +121,10 @@ parse_opt (int key, char *arg arg_unused, struct argp_state *state arg_unused)
crun_context.pid_file = argp_mandatory_argument (arg, state);
break;

case OPTION_MANAGE_CGROUPS_MODE:
cr_options.manage_cgroups_mode = crun_parse_manage_cgroups_mode (argp_mandatory_argument (arg, state));
break;

default:
return ARGP_ERR_UNKNOWN;
}
Expand Down