[CRIU] [PATCH] cgroup: skip restoring special cpuset props during main prop restore

Tycho Andersen tycho.andersen at canonical.com
Fri Mar 4 08:47:21 PST 2016


As the comment says, we don't need to restore speical cpuset props twice,
and indeed it can cause the restore to fail, e.g.:

(00.092356) Error (cgroup.c:1240): cg: Failed writing 0-3 to cpuset//lxc/centoss/cpuset.cpus
(00.582490)     18: Error (cgroup.c:1009): cg: Can't move 18 into systemd//lxc/centos/system.slice/systemd-journald.service/tasks (-1/-1): No such file or directory
(00.582497)     18: Error (cgroup.c:1124): cg: Can't move into systemd//lxc/centos/system.slice/systemd-journald.service/tasks (-1/-1): No such file or directory
(00.582567)     43: Error (cgroup.c:1009): cg: Can't move 43 into systemd//lxc/centos/system.slice/console-getty.service/tasks (-1/-1): No such file or directory
(00.582573)     43: Error (cgroup.c:1124): cg: Can't move into systemd//lxc/centos/system.slice/console-getty.service/tasks (-1/-1): No such file or directory
(00.582886)      1: Error (cr-restore.c:1306): 18 exited, status=1
(00.594670) Error (cr-restore.c:1308): 7906 killed by signal 9
(00.623099) Error (cr-restore.c:2138): Restoring FAILED.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 criu/cgroup.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/criu/cgroup.c b/criu/cgroup.c
index 7c14851..609509c 100644
--- a/criu/cgroup.c
+++ b/criu/cgroup.c
@@ -1308,10 +1308,29 @@ static int prepare_cgroup_dir_properties(char *path, int off, CgroupDirEntry **e
 		off2 += sprintf(path + off, "/%s", e->dir_name);
 		if (e->n_properties > 0) {
 			for (j = 0; j < e->n_properties; ++j) {
+				int k;
+				bool special = false;
+
 				if (!strcmp(e->properties[j]->name, "freezer.state")) {
 					add_freezer_state_for_restore(e->properties[j], path, off2);
 					continue; /* skip restore now */
 				}
+
+				/* Skip restoring special cpuset props now.
+				 * They were restored earlier, and can cause
+				 * the restore to fail if some other task has
+				 * entered the cgroup.
+				 */
+				for (k = 0; special_cpuset_props[k]; k++) {
+					if (!strcmp(e->properties[j]->name, special_cpuset_props[k])) {
+						special = true;
+						break;
+					}
+				}
+
+				if (special)
+					continue;
+
 				if (restore_cgroup_prop(e->properties[j], path, off2) < 0)
 					return -1;
 			}
-- 
2.5.0



More information about the CRIU mailing list