[CRIU] Missing Container Subdir in Cgroups

Saied Kazemi saied at google.com
Fri Jun 20 17:21:47 PDT 2014


CRIU fails to restore a process running inside a Docker container with the
error message:

(00.035110)      1: Error (cgroup.c:278): cg: Can't move into
blkio//docker/2fda692b0fd31c20197b84b8ca5e172679dfaf9028c7322b7bb43acf061626cf/tasks
(-1/-1)

This is because the container subdirectory (i.e., 64-character ID above) is
not created under docker.

I applied the following quick patch as a workaround and was able to
successfully restore and resume a process running inside a Docker
container.  But the issue requires more study and changes as simply
recreating the directories on demand may not be enough.

diff --git a/cgroup.c b/cgroup.c
index 60b560c..538cf17 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -368,13 +368,15 @@ static int prepare_cgroup_sfd(CgSetEntry *root_set)
        for (i = 0; i < root_set->n_ctls; i++) {
                ControllerEntry *ce = root_set->ctls[i];
                char *opt = ce->name;
+               char *cp;
+               int poff = off;

                if (strstartswith(ce->name, "name=")) {
-                       sprintf(paux + off, "/%s", ce->name + 5);
+                       poff += sprintf(paux + off, "/%s", ce->name + 5);
                        sprintf(aux, "none,%s", ce->name);
                        opt = aux;
                } else
-                       sprintf(paux + off, "/%s", ce->name);
+                       poff += sprintf(paux + off, "/%s", ce->name);

                if (mkdir(paux, 0700)) {
                        pr_perror("Can't make cgyard subdir");
@@ -385,6 +387,28 @@ static int prepare_cgroup_sfd(CgSetEntry *root_set)
                        pr_perror("Can't mount %s cgyard", ce->name);
                        goto err;
                }
+
+               continue;
+
+               if ((cp = ce->path) == NULL)
+                       continue;
+
+               while (*cp) {
+                       while (*cp && *cp == '/') {
+                               cp++;
+                               continue;
+                       }
+                       paux[poff] = '/';
+                       while (*cp && *cp != '/') {
+                               paux[++poff] = *cp++;
+                               continue;
+                       }
+                       if (paux[poff] != '/') {
+                               paux[++poff] = '\0';
+                               if (mkdir(paux, 0700) == 0)
+                                       pr_info("Created directory %s\n",
paux);
+                       }
+               }
        }

        pr_debug("Opening %s as cg yard\n", cg_yard);

Please let me know what you think.

--Saied
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20140620/ca1b4521/attachment-0001.html>


More information about the CRIU mailing list