We're bindmounting cgroups for container so if say a container is having CTID=200 then @cgroups and @mountinfo output will contain /200 as a root. Which makes Docker to lookup for appropriate directory inside /sys/fs/cgroup/<controller> which of course not present because of been bindmounted from the node (note we can't bindmount into <controller>/<container> here because it confuses container's systemd instance and it stuck on boot).
Thus we simply mangle root here so when one is accessing @cgroups or @mountinfo kernel shows '/' instead of $ctid which makes both docker and systemd happy. https://jira.sw.ru/browse/PSBM-33757 Signed-off-by: Cyrill Gorcunov <gorcu...@virtuozzo.com> CC: Vladimir Davydov <vdavy...@virtuozzo.com> CC: Konstantin Khorenko <khore...@virtuozzo.com> CC: Pavel Emelyanov <xe...@virtuozzo.com> CC: Andrey Vagin <ava...@virtuozzo.com> --- kernel/cgroup.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) Index: linux-pcs7.git/kernel/cgroup.c =================================================================== --- linux-pcs7.git.orig/kernel/cgroup.c +++ linux-pcs7.git/kernel/cgroup.c @@ -1386,10 +1386,24 @@ static int cgroup_remount(struct super_b return ret; } +#ifdef CONFIG_VE +int cgroup_show_path(struct seq_file *m, struct dentry *dentry) +{ + if (!ve_is_super(get_exec_env())) + seq_puts(m, "/"); + else + seq_dentry(m, dentry, " \t\n\\"); + return 0; +} +#endif + static const struct super_operations cgroup_ops = { .statfs = simple_statfs, .drop_inode = generic_delete_inode, .show_options = cgroup_show_options, +#ifdef CONFIG_VE + .show_path = cgroup_show_path, +#endif .remount_fs = cgroup_remount, }; @@ -1807,6 +1821,21 @@ int cgroup_path(const struct cgroup *cgr return 0; } +#ifdef CONFIG_VE + /* + * Containers cgroups are bind-mounted from node + * so they are like '/' from inside, thus we have + * to mangle cgroup path output. + */ + if (!ve_is_super(get_exec_env())) { + if (cgrp->parent && !cgrp->parent->parent) { + if (strlcpy(buf, "/", buflen) >= buflen) + return -ENAMETOOLONG; + return 0; + } + } +#endif + start = buf + buflen - 1; *start = '\0'; _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel