[CRIU] [PATCH] cg: don't try to copy special props to cpuset:/
Tycho Andersen
tycho.andersen at canonical.com
Thu Oct 2 16:40:08 PDT 2014
We can't write to cpuset's root cg (indeed, we didn't create it and it has
stuff in it), so ignore this special case.
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
cgroup.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/cgroup.c b/cgroup.c
index 29e373d..36e3487 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -886,7 +886,7 @@ static int find_value(const char *controller, const char *path, const char *prop
*pos = 0;
snprintf(prefix, PATH_MAX, "%s/%s", controller, my_path);
} else {
- snprintf(fpath, PATH_MAX, "%s", controller);
+ snprintf(prefix, PATH_MAX, "%s", controller);
}
snprintf(fpath, PATH_MAX, "%s/%s", prefix, prop);
@@ -964,6 +964,17 @@ static int copy_special_cg_props(const char *controller, char *path)
if (find_value(controller, path, prop, buf, prefix, missing_path) < 0)
return -1;
+ /*
+ * If the path that was missing is "/", we should skip
+ * copying this property, since cpuset won't allow us
+ * to write to it because there are already processes
+ * there (e.g. init). The root cg had no restrictions
+ * on cpuset resources here, so ignoring this and
+ * writing nothing is safe.
+ */
+ if (strcmp(missing_path, "/") == 0)
+ continue;
+
if (copy_recursive(prefix, missing_path, prop, buf) < 0) {
pr_err("copying prop %s failed\n", prop);
return -1;
--
1.9.1
More information about the CRIU
mailing list