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

cgroup: support --cgroup-root on dump too

The problem here is again caused by systemd :). Every process lives in some
child cgroup and not the root one, so we end up with a bunch of stuff like:

/init.scope
/system.slice/...
/user.slice/...

and nothing in the root cgroup. However, systemd opens
/sys/fs/cgroup/systemd, changes the perms, and keeps a fd around.
Unfortuantely, we don't track the perms on the "real root" cgroup here,
because nothing is at that level, so when we restore, our cgroup perms
changing code doesn't catch this perms change, and we get:

(00.361723)      1: Error (criu/files-reg.c:1487): File sys/fs/cgroup/systemd has bad mode 040755 (expect 040775)

To fix this, let's just support the --cgroup-root argument on dump too, and
rewrite the cgroup paths we dump accordingly.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent d2647d33
...@@ -545,9 +545,10 @@ static int collect_cgroups(struct list_head *ctls) ...@@ -545,9 +545,10 @@ static int collect_cgroups(struct list_head *ctls)
int fd = -1; int fd = -1;
list_for_each_entry(cc, ctls, l) { list_for_each_entry(cc, ctls, l) {
char path[PATH_MAX], mopts[1024]; char path[PATH_MAX], mopts[1024], *root;
char prefix[] = ".criu.cgmounts.XXXXXX"; char prefix[] = ".criu.cgmounts.XXXXXX";
struct cg_controller *cg; struct cg_controller *cg;
struct cg_root_opt *o;
current_controller = NULL; current_controller = NULL;
...@@ -602,7 +603,17 @@ static int collect_cgroups(struct list_head *ctls) ...@@ -602,7 +603,17 @@ static int collect_cgroups(struct list_head *ctls)
return -1; return -1;
path_pref_len = snprintf(path, PATH_MAX, "/proc/self/fd/%d", fd); path_pref_len = snprintf(path, PATH_MAX, "/proc/self/fd/%d", fd);
snprintf(path + path_pref_len, PATH_MAX - path_pref_len, "%s", cc->path);
root = cc->path;
if (opts.new_global_cg_root)
root = opts.new_global_cg_root;
list_for_each_entry(o, &opts.new_cgroup_roots, node) {
if (!strcmp(cc->name, o->controller))
root = o->newroot;
}
snprintf(path + path_pref_len, PATH_MAX - path_pref_len, "%s", root);
ret = ftw(path, add_cgroup, 4); ret = ftw(path, add_cgroup, 4);
if (ret < 0) if (ret < 0)
......
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