[CRIU] [PATCH] uffd.c: create lazy-pages socket in image directory

Mike Rapoport rppt at linux.vnet.ibm.com
Sat Jan 14 23:22:54 PST 2017


On Fri, Jan 13, 2017 at 06:31:15PM +0300, Pavel Emelyanov wrote:
> On 01/13/2017 01:47 PM, Adrian Reber wrote:
> > From: Adrian Reber <areber at redhat.com>
> > 
> > runc uses the work-dir and image-dir option to control where
> > criu is running. This means that criu chdir()-s to work-dir
> > and the lazy-pages socket cannot be found as it is in the image
> > directory.
> 
> Bu the socket __should__ be in work directory, is it really there? If no,
> then that's the bug, we should bind() socket in proper place.

The socket __is__ created in the working directory. The socket may not be
found if 'criu restore' and 'criu lazy-pages' use different --work-dir...
 
> Cc Mike
> 
> > I think there was a problem with too long socket names which make it
> > impossible to include the full path. Therefore this change tries to
> > fchdir() to the image directory before accessing the lazy-pages socket
> > and chdir()-s back to the work-dir after that.
> > 
> > Signed-off-by: Adrian Reber <areber at redhat.com>
> > ---
> >  criu/uffd.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/criu/uffd.c b/criu/uffd.c
> > index 516b800..fcedb65 100644
> > --- a/criu/uffd.c
> > +++ b/criu/uffd.c
> > @@ -247,12 +247,16 @@ int prepare_lazy_pages_socket(void)
> >  		return -1;
> >  
> >  	len = offsetof(struct sockaddr_un, sun_path) + strlen(sun.sun_path);
> > +	/* change to image dir in case work dir has changed */
> > +	fchdir(criu_get_image_dir());
> >  	if (connect(new_fd, (struct sockaddr *) &sun, len) < 0) {
> >  		pr_perror("connect to %s failed", sun.sun_path);
> >  		close(new_fd);
> > +		chdir(opts.work_dir);
> >  		return -1;
> >  	}
> >  
> > +	chdir(opts.work_dir);
> >  	return 0;
> >  }
> >  
> > 
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> 



More information about the CRIU mailing list