<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 10, 2015 at 12:42 PM, Tycho Andersen <span dir="ltr"><<a href="mailto:tycho.andersen@canonical.com" target="_blank">tycho.andersen@canonical.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Mon, Aug 10, 2015 at 12:30:47PM -0400, Hui Kang wrote:<br>
> On Mon, Aug 10, 2015 at 11:16 AM, Tycho Andersen <<br>
> <a href="mailto:tycho.andersen@canonical.com">tycho.andersen@canonical.com</a>> wrote:<br>
><br>
> > On Mon, Aug 10, 2015 at 03:00:42PM +0000, Hui Kang wrote:<br>
> > > The process to be restored may not have certain cgroup dir, e.g<br>
> > > cpu/[PID]/cpu.shares. Currently restoring will fail in closing<br>
> > > the file. If this is the case, the fileno is -1 and we can ignore<br>
> > > this and let the restore proceed.<br>
> > ><br>
> > > Signed-off-by: Hui Kang <<a href="mailto:hkang.sunysb@gmail.com">hkang.sunysb@gmail.com</a>><br>
> > > ---<br>
> > > cgroup.c | 2 +-<br>
> > > 1 file changed, 1 insertion(+), 1 deletion(-)<br>
> > ><br>
> > > diff --git a/cgroup.c b/cgroup.c<br>
> > > index a4e0146..f4e49b3 100644<br>
> > > --- a/cgroup.c<br>
> > > +++ b/cgroup.c<br>
> > > @@ -974,7 +974,7 @@ static int restore_cgroup_prop(const CgroupPropEntry<br>
> > * cg_prop_entry_p,<br>
> > > return -1;<br>
> > > }<br>
> > ><br>
> > > - if (fclose(f) != 0) {<br>
> > > + if ((fclose(f) != 0) && (fileno(f) >= 0)) {<br>
> ><br>
> > If we put these in the other order we can avoid the fclose all<br>
> > together, I think.<br>
> ><br>
> ><br>
> Thanks for your suggestions. However, the fileno only turns to -1 after<br>
> fclose(f). This is because file is closed.<br>
> Prior to that, fileno(f) returns 5, which looks normal for<br>
> cgroup/cpu/cpus.share.<br>
<br>
</div></div>Ah, so doesn't this patch mask any error entirely then? As Pavel<br>
points out, if the file doesn't exist, shouldn't the fopenat() give<br>
you a bad fd?<br></blockquote><div><br></div><div>When I move the criu images (only have cpusets.cpus set) to a different host and restore suing cgroup-manage=full, cpu.shares exists in the destination. fopenat and fprintf returns OK, only fclose failed due to "invalid argument". So we need another check.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Tycho<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
><br>
> > Tycho<br>
> ><br>
> > > pr_perror("Failed closing %s", path);<br>
> > > return -1;<br>
> > > }<br>
> > > --<br>
> > > 1.9.1<br>
> > ><br>
> > > _______________________________________________<br>
> > > CRIU mailing list<br>
> > > <a href="mailto:CRIU@openvz.org">CRIU@openvz.org</a><br>
> > > <a href="https://lists.openvz.org/mailman/listinfo/criu" rel="noreferrer" target="_blank">https://lists.openvz.org/mailman/listinfo/criu</a><br>
> ><br>
</div></div></blockquote></div><br></div></div>