[CRIU] Missing Container Subdir in Cgroups
Pavel Emelyanov
xemul at parallels.com
Mon Jun 23 01:47:40 PDT 2014
On 06/21/2014 04:21 AM, Saied Kazemi wrote:
> 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.
Yes, the problem with cgroup FS tree is a bit deeper. Not only we should create the
directories of cgroups tasks live in, but also create the sub-directories with no tasks
e.g. to handle the case when a task does
mkdir "cg/subcg"
echo $pid > "cg/subcg/tasks"
and we dump this app in between these two calls.
Other than this we probably should take care of the configuration of these subcgroups,
e.g. mem.* files in memsg and other stuff.
And the third thing -- there may be cgroup FS mountpoints inside the mount namespace
we dump. These should be dumped as well.
> 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
>
More information about the CRIU
mailing list