[CRIU] [PATCH] Fix restoring cgroup across hosts

Hui Kang hkang.sunysb at gmail.com
Mon Aug 10 09:43:10 PDT 2015


On Mon, Aug 10, 2015 at 12:35 PM, Pavel Emelyanov <xemul at parallels.com>
wrote:

> On 08/10/2015 06:00 PM, Hui Kang wrote:
> > The process to be restored may not have certain cgroup dir, e.g
> > cpu/[PID]/cpu.shares. Currently restoring  will fail in closing
> > the file. If this is the case, the fileno is -1 and we can ignore
> > this and let the restore proceed.
>
> If the file is missing then the fopen() itself should return -1.
>
Hi, Pavel
The file is not missing in the destination, e.g., cpu/cpu.shares. The open
and write are successful, e.g., fileno returning 5. Only fclose return
error. But if you check fileno(f) after fclose, it returns -1. That's why I
added the additional check for this.




>
> > Signed-off-by: Hui Kang <hkang.sunysb at gmail.com>
> > ---
> >  cgroup.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/cgroup.c b/cgroup.c
> > index a4e0146..f4e49b3 100644
> > --- a/cgroup.c
> > +++ b/cgroup.c
> > @@ -974,7 +974,7 @@ static int restore_cgroup_prop(const CgroupPropEntry
> * cg_prop_entry_p,
> >               return -1;
> >       }
> >
> > -     if (fclose(f) != 0) {
> > +     if ((fclose(f) != 0) && (fileno(f) >= 0)) {
> >               pr_perror("Failed closing %s", path);
> >               return -1;
> >       }
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20150810/33ebb1aa/attachment.html>


More information about the CRIU mailing list