[CRIU] [PATCH 7/8] files: add ability to set callbacks for files (v3)

Andrew Vagin avagin at parallels.com
Sun Dec 15 10:02:18 PST 2013


On Sun, Dec 15, 2013 at 07:23:54PM +0400, Andrew Vagin wrote:
> On Thu, Dec 12, 2013 at 09:12:58PM +0400, Andrey Vagin wrote:
> > Here is nothing interecting. If a file can't be dumped by criu,
> > plugins are called. If one of plugins knows how to dump the file,
> > the file entry is marked as need_callback. On restore if we see
> > this mark, we execute plugins for restoring the file.
> > 
> > v2: Callbacks are called for all files, which are not supported by CRIU.
> > v3: Call plugins for a file instead of file descriptor. A few file
> > descriptors can be associated with one file.
> > 
> > Signed-off-by: Andrey Vagin <avagin at openvz.org>
> > ---
> ...
> > @@ -583,6 +589,15 @@ static int do_open_reg(struct reg_file_info *rfi, void *arg)
>         fd = open(rfi->path, rfi->rfe->flags);
>         if (fd < 0) {
>                 pr_perror("Can't open file %s on restore", rfi->path);
> >  		return fd;
> >  	}
> > 
> > +	if (rfi->rfe->need_callback) {
> 
> I'm not sure that criu should open a file. Maybe it should be done in
> a callback...

Looks like a callback should open a file. It can be useful for
restoring anon_inode (like timerfd)

> 
> > +		if (cr_plugin_restore_file(fd, rfi->rfe->id)) {
> > +			pr_err("Unable to restore %#x\n", rfi->rfe->id);
> > +			close(fd);
> > +			return -1;
> > +		}
> > +		return fd;
> > +	}
> > +
> >  	if ((rfi->rfe->pos != -1ULL) &&
> >  			lseek(fd, rfi->rfe->pos, SEEK_SET) < 0) {
> >  		pr_perror("Can't restore file pos");


More information about the CRIU mailing list