[CRIU] Re: [PATCH 06/12] parasite: Add interface for file descriptors draining

Cyrill Gorcunov gorcunov at openvz.org
Tue Mar 27 09:12:02 EDT 2012


On Tue, Mar 27, 2012 at 04:50:12PM +0400, Pavel Emelyanov wrote:
> > @@ -605,6 +605,57 @@ out:
> >  	return ret;
> >  }
> >  
> > +int parasite_drain_fds_seized(struct parasite_ctl *ctl, int *fds, int *lfds, int nr_fds)
> > +{
> > +	struct parasite_drain_fd args	= { };
> 
> I wouldn't allocate that much stack.

We do check for stack space at compile time, so instead of multiple
allocations better do only one at parasite injection time and
forget about it.

> > +
> > +	/* Verify the descriptors do match */
> > +	for (i = 0; i < nr_fds; i++) {
> > +		pid_t me = getpid();
> > +		if (sys_kcmp(me, ctl->pid, KCMP_FILE, fds[i], lfds[i])) {
> 
> I.e. me's fds[i] should be equal to other's lfds[i], meanwhile the fds array
> contains other's descriptors and the lfds one -- locally received ones.
> 
> How does it work?

They are equal, the fds[] is the fd numbers in dumpee, the ldf is the ones
received (and in same order), so they should point to the same struct file,
thus kcmp can check this condition (fds and ldfs are not same place in memory).

	Cyrill


More information about the CRIU mailing list