[CRIU] [PATCH v4 11/15] files: Add file_desc_ops::receive method

Pavel Emelyanov xemul at virtuozzo.com
Thu Jun 9 06:15:21 PDT 2016


On 06/01/2016 07:03 PM, Kirill Tkhai wrote:
> Currently, nothing is done for master files in receive_fd().
> Add a receive method, which may be useful for subsystems,
> which need it (for queuer-less dgram sockets, going in following
> patches).
> 
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
>  criu/files.c         |    3 ++-
>  criu/include/files.h |   10 +++++++++-
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/criu/files.c b/criu/files.c
> index bb3b142..22668ec 100644
> --- a/criu/files.c
> +++ b/criu/files.c
> @@ -1053,12 +1053,13 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
>  
>  static int receive_fd(int pid, struct fdinfo_list_entry *fle)
>  {
> +	struct file_desc *d = fle->desc;
>  	int tmp;
>  	struct fdinfo_list_entry *flem;
>  
>  	flem = file_master(fle->desc);
>  	if (flem->pid == pid)
> -		return 0;
> +		return d->ops->receive ? d->ops->receive(d, fle->fe->fd) : 0;

Erm... This path is not receiving an fd, it's just us who's the
file master.

>  
>  	pr_info("\tReceive fd for %d\n", fle->fe->fd);
>  
> diff --git a/criu/include/files.h b/criu/include/files.h
> index 5e3d6dc..f0d5f23 100644
> --- a/criu/include/files.h
> +++ b/criu/include/files.h
> @@ -90,7 +90,15 @@ struct file_desc_ops {
>  	int			(*open)(struct file_desc *d);
>  	/*
>  	 * Called on a file when all files of that type are opened
> -	 * and with the fd being the "restored" one.
> +	 * and with the fd being the "restored" one. This may be used
> +	 * to receive some additional file descriptors that are needed
> +	 * at post_open stage.
> +	 */
> +	int			(*receive)(struct file_desc *d, int fd);
> +	/*
> +	 * Called on a file when all files of that type are opened
> +	 * and with the fd being the "restored" one and all data need
> +	 * to complete restore is received.
>  	 */
>  	int			(*post_open)(struct file_desc *d, int fd);
>  	/*
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> .
> 



More information about the CRIU mailing list