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

Pavel Emelyanov xemul at parallels.com
Wed Dec 11 07:05:18 PST 2013


> @@ -583,6 +591,14 @@ static int do_open_reg(struct reg_file_info *rfi, void *arg)
>  		return fd;
>  	}
>  
> +	if (rfi->rfe->need_callback) {
> +		if (cr_plugin_restore_file(fd, rfi->rfe->id)) {
> +			pr_err("Unable to restore %#x\n", rfi->rfe->id);
> +			close(fd);

How about reporting error back to caller?

> +		}
> +		return fd;
> +	}
> +
>  	if ((rfi->rfe->pos != -1ULL) &&
>  			lseek(fd, rfi->rfe->pos, SEEK_SET) < 0) {
>  		pr_perror("Can't restore file pos");
> diff --git a/files.c b/files.c
> index 6eb7282..ad7077f 100644
> --- a/files.c
> +++ b/files.c
> @@ -39,6 +39,8 @@
>  #include "protobuf.h"
>  #include "protobuf/fs.pb-c.h"
>  
> +#include "plugin.h"
> +
>  #define FDESC_HASH_SIZE	64
>  static struct hlist_head file_desc_hash[FDESC_HASH_SIZE];
>  
> @@ -239,8 +241,21 @@ static int fill_fd_params(struct parasite_ctl *ctl, int fd, int lfd,
>  	return 0;
>  }
>  
> -static int dump_unsupp_fd(const struct fd_parms *p, char *more, char *info)
> +static int dump_unsupp_fd(struct fd_parms *p, int lfd,
> +				const int fdinfo, char *more, char *info)
>  {
> +	cr_plugin_dump_file_t *cb;
> +	int ret;
> +
> +	ret = cr_plugin_dump_file(lfd, 0, true, &cb);

Why do you call plugin for every single FD pointing to a file? Maybe it's
better to call it for only one?

> +	if (ret < 0 && ret != CRIU_CB_SKIP)
> +		return -1;
> +
> +	if (ret == 0) {
> +		p->cb = cb;
> +		return do_dump_gen_file(p, lfd, &regfile_dump_ops, fdinfo);
> +	}
> +
>  	pr_err("Can't dump file %d of that type [%o] (%s %s)\n",
>  			p->fd, p->stat.st_mode, more, info);
>  	return -1;


More information about the CRIU mailing list