[CRIU] [PATCH] cgroups: don't take into account a leading / for the "/" parent

Andrew Vagin avagin at openvz.org
Mon Aug 25 05:06:55 PDT 2014


Without this patch, we dump somethin like this:
{
	cnames: "hugetlb"
	dirs: 	{
		dir_name: ""
		children: 		{
			dir_name: "ewroot"
			children: <empty>
			properties: <empty>
		}

		properties: <empty>
	}

}

it's obvious, that dir_name should be newroot. I can't check this patch,
because cgroups02 doesn't work. Tycho, could you look at this?

[root at jenkins workspace]# bash test/zdtm.sh static/cgroup02
Execute zdtm/live/static/cgroup02
./cgroup02 --pidfile=cgroup02.pid --outfile=cgroup02.out --dirname=cgroup02.test
Dump 21776
Executing pre-restore hook
Cleaning cgclean.RRZfsP
rmdir: failed to remove ‘cgclean.RRZfsP/newroot’: No such file or directory
rmdir: failed to remove ‘cgclean.RRZfsP/zdtmtstroot’: No such file or directory
Left there is:
cgroup.clone_children  cgroup.procs  cgroup.sane_behavior  notify_on_release  release_agent  tasks
Cleaning cgclean.naxRMr
rmdir: failed to remove ‘cgclean.naxRMr/newroot’: No such file or directory
rmdir: failed to remove ‘cgclean.naxRMr/zdtmtstroot’: No such file or directory
Left there is:
cgroup.clone_children  cgroup.procs  cgroup.sane_behavior  notify_on_release  release_agent  tasks
Restore
Test: zdtm/live/static/cgroup02, Result: FAIL
==================================== ERROR ====================================
Test: zdtm/live/static/cgroup02, Namespace:
Dump log   : /var/lib/jenkins/jobs/CRIU/workspace/test/dump/static/cgroup02/21776/1/dump.log
--------------------------------- grep Error ---------------------------------
------------------------------------- END -------------------------------------
Restore log: /var/lib/jenkins/jobs/CRIU/workspace/test/dump/static/cgroup02/21776/1/restore.log
--------------------------------- grep Error ---------------------------------
(00.022961)  21776: Error (cgroup.c:958): cg: Can't move into defaultroot//oldroot/tasks (-1/-1): No such file or directory
(00.023181) Error (cr-restore.c:1152): 21776 exited, status=255
(00.023202) Error (cr-restore.c:1762): Restoring FAILED.
------------------------------------- END -------------------------------------
================================= ERROR OVER =================================

Cc: Tycho Andersen <tycho.andersen at canonical.com>
Signed-off-by: Andrew Vagin <avagin at openvz.org>
---
 cgroup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cgroup.c b/cgroup.c
index d4b71a3..bf22998 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -676,7 +676,9 @@ static int dump_cg_dirs(struct list_head *dirs, size_t n_dirs, CgroupDirEntry **
 
 	list_for_each_entry(cur, dirs, siblings) {
 		cgroup_dir_entry__init(cde);
-		cde->dir_name = cur->path + poff + 1 /* leading / */;
+		cde->dir_name = cur->path + poff;
+		if (poff > 1) /* parent isn't "/" */
+			cde->dir_name++; /* leading / */
 		cde->n_children = cur->n_children;
 		if (cur->n_children > 0)
 			if (dump_cg_dirs(&cur->children, cur->n_children, &cde->children, strlen(cur->path)) < 0) {
-- 
1.9.3



More information about the CRIU mailing list