From 23e5c04580e425a5194140da3a88c11ca54e4640 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 10 Oct 2018 00:02:46 +0200 Subject: [PATCH 1/2] cgfsng: fix lxc.pivot directory creation Signed-off-by: Christian Brauner --- src/lxc/cgroups/cgfsng.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 71dfe72e6..cc8bf8f2b 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -1152,6 +1152,7 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops, for (int i = 0; ops->hierarchies[i]; i++) { int ret; + char *chop; struct hierarchy *h = ops->hierarchies[i]; if (!h->monitor_full_path) @@ -1169,10 +1170,17 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops, PIVOT_CGROUP, "cgroup.procs", NULL); + chop = strrchr(pivot_path, '/'); + if (chop) + *chop = '\0'; + ret = mkdir_p(pivot_path, 0755); if (ret < 0 && errno != EEXIST) goto next; + if (chop) + *chop = '/'; + /* Move ourselves into the pivot cgroup to delete our own * cgroup. */ From d5fc4dd406b07a576d5d593a0b77c98ea0ecce7e Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 10 Oct 2018 00:03:13 +0200 Subject: [PATCH 2/2] cgfsng: improve loggin on monitor cgroup destroy Signed-off-by: Christian Brauner --- src/lxc/cgroups/cgfsng.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index cc8bf8f2b..4aa8fe160 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -1175,8 +1175,10 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops, *chop = '\0'; ret = mkdir_p(pivot_path, 0755); - if (ret < 0 && errno != EEXIST) + if (ret < 0 && errno != EEXIST) { + SYSWARN("Failed to create cgroup \"%s\"\n", pivot_path); goto next; + } if (chop) *chop = '/'; @@ -1185,8 +1187,10 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops, * cgroup. */ ret = lxc_write_to_file(pivot_path, pidstr, len, false, 0666); - if (ret != 0) + if (ret != 0) { + SYSWARN("Failed to move monitor %s to \"%s\"\n", pidstr, pivot_path); goto next; + } ret = recursive_destroy(h->monitor_full_path); if (ret < 0)