Commit f95b05eb authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

opts: add --manage-cgroups option

criu managed cgroups is now an opt-in thing, so by default criu does not manage
(i.e. dump or restore) cgroups. This allows users to use the previous behavior.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 8b019e0b
......@@ -10,6 +10,7 @@
#include "list.h"
#include "xmalloc.h"
#include "cgroup.h"
#include "cr_options.h"
#include "pstree.h"
#include "proc_parse.h"
#include "util.h"
......@@ -583,7 +584,7 @@ int dump_task_cgroup(struct pstree_item *item, u32 *cg_id)
* The on-stack ctls is moved into cs inside
* the get_cg_set routine.
*/
if (cs != criu_cgset && collect_cgroups(&cs->ctls))
if (cs != criu_cgset && opts.manage_cgroups && collect_cgroups(&cs->ctls))
return -1;
}
......@@ -1148,7 +1149,8 @@ static int prepare_cgroup_sfd(CgroupEntry *ce)
goto err;
}
if (prepare_cgroup_dirs(paux, off + name_off, ctrl->dirs, ctrl->n_dirs))
if (opts.manage_cgroups &&
prepare_cgroup_dirs(paux, off + name_off, ctrl->dirs, ctrl->n_dirs))
goto err;
}
......
......@@ -304,6 +304,9 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
if (req->has_cpu_cap)
opts.cpu_cap = req->cpu_cap;
if (req->has_manage_cgroups)
opts.manage_cgroups = req->manage_cgroups;
return 0;
}
......
......@@ -49,6 +49,7 @@ void init_opts(void)
INIT_LIST_HEAD(&opts.ext_mounts);
opts.cpu_cap = CPU_CAP_ALL;
opts.manage_cgroups = false;
}
static int parse_ns_string(const char *ptr)
......@@ -167,6 +168,7 @@ int main(int argc, char *argv[])
{ "force-irmap", no_argument, 0, 58},
{ "ext-mount-map", required_argument, 0, 'M'},
{ "exec-cmd", no_argument, 0, 59},
{ "manage-cgroups", no_argument, 0, 60},
{ },
};
......@@ -353,6 +355,9 @@ int main(int argc, char *argv[])
case 59:
has_exec_cmd = true;
break;
case 60:
opts.manage_cgroups = true;
break;
case 'M':
{
char *aux;
......@@ -541,6 +546,7 @@ usage:
" --force-irmap force resolving names for inotify/fsnotify watches\n"
" -M|--ext-mount-map KEY:VALUE\n"
" add external mount mapping\n"
" --manage-cgroups dump or restore cgroups the process is in\n"
"\n"
"* Logging:\n"
" -o|--log-file FILE log file name\n"
......
......@@ -51,6 +51,7 @@ struct cr_options {
unsigned int cpu_cap;
bool force_irmap;
char **exec_cmd;
bool manage_cgroups;
};
extern struct cr_options opts;
......
......@@ -152,6 +152,12 @@ void criu_set_root(char *root)
opts->root = strdup(root);
}
void criu_set_manage_cgroups(bool manage)
{
opts->has_manage_cgroups = true;
opts->manage_cgroups = manage;
}
void criu_set_log_file(char *log_file)
{
opts->log_file = strdup(log_file);
......
......@@ -47,6 +47,7 @@ void criu_set_log_level(int log_level);
void criu_set_log_file(char *log_file);
void criu_set_cpu_cap(unsigned int cap);
void criu_set_root(char *root);
void criu_set_manage_cgroups(bool manage);
int criu_set_exec_cmd(int argc, char *argv[]);
int criu_add_ext_mount(char *key, char *val);
int criu_add_veth_pair(char *in, char *out);
......
......@@ -45,6 +45,7 @@ message criu_opts {
repeated string exec_cmd = 22;
repeated ext_mount_map ext_mnt = 23;
optional bool manage_cgroups = 24;
}
message criu_dump_resp {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment