2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

cg: add --cgroup-root option

The motivation for this is to be able to restore containers into cgroups other
than what they were dumped in (if, e.g. they might conflict with an existing
container). Suppose you have a container in:

memory:/mycontainer
cpuacct,cpu:/mycontainer
blkio:/mycontainer
name=systemd:/mycontainer

You could then restore them to /mycontainer2 via --cgroup-root /mycontainer2.
If you want to restore different controllers to different paths, you can
provide multiple arguments, for example, passing:

--cgroup-root /mycontainer2 --cgroup-root cpuacct,cpu:/specialcpu \
--cgroup-root name=systemd:/specialsystemd

Would result in things being restored to:

memory:/mycontainer2
cpuacct,cpu:/specialcpu
blkio:/mycontainer2
name=systemd:/specialsystemd

i.e. a --cgroup-root without a controller prefix specifies the new default root
for all cgroups.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Tycho Andersen
2014-08-15 17:02:21 -05:00
committed by Pavel Emelyanov
parent 513b0dc3e0
commit 94f6c87c9f
4 changed files with 119 additions and 1 deletions

View File

@@ -35,6 +35,7 @@
#include "cr-service.h"
#include "plugin.h"
#include "mount.h"
#include "cgroup.h"
struct cr_options opts;
@@ -47,6 +48,7 @@ void init_opts(void)
INIT_LIST_HEAD(&opts.veth_pairs);
INIT_LIST_HEAD(&opts.scripts);
INIT_LIST_HEAD(&opts.ext_mounts);
INIT_LIST_HEAD(&opts.new_cgroup_roots);
opts.cpu_cap = CPU_CAP_ALL;
opts.manage_cgroups = false;
@@ -169,6 +171,7 @@ int main(int argc, char *argv[])
{ "ext-mount-map", required_argument, 0, 'M'},
{ "exec-cmd", no_argument, 0, 59},
{ "manage-cgroups", no_argument, 0, 60},
{ "cgroup-root", required_argument, 0, 61},
{ },
};
@@ -358,6 +361,21 @@ int main(int argc, char *argv[])
case 60:
opts.manage_cgroups = true;
break;
case 61:
{
char *aux;
aux = strchr(optarg, ':');
if (!aux) {
opts.new_global_cg_root = optarg;
} else {
*aux = '\0';
if (new_cg_root_add(optarg, aux + 1))
return -1;
}
}
break;
case 'M':
{
char *aux;
@@ -547,6 +565,10 @@ usage:
" -M|--ext-mount-map KEY:VALUE\n"
" add external mount mapping\n"
" --manage-cgroups dump or restore cgroups the process is in\n"
" --cgroup-root [controller:]/newroot\n"
" change the root cgroup the controller will be\n"
" installed into. No controller means that root is the\n"
" default for all controllers not specified.\n"
"\n"
"* Logging:\n"
" -o|--log-file FILE log file name\n"