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

Pavel Emelyanov xemul at virtuozzo.com
Thu Jun 9 07:42:31 PDT 2016


On 06/09/2016 05:17 PM, Kirill Tkhai wrote:
> 
> 
> On 09.06.2016 16:44, Pavel Emelyanov wrote:
>> On 06/09/2016 04:31 PM, Kirill Tkhai wrote:
>>>
>>>
>>> On 09.06.2016 16:15, Pavel Emelyanov wrote:
>>>> 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.
>>>
>>> I don't understand your comment. Could you please explain what you mean?
>>
>> The "return 0" you've removed doesn't mean "receive descriptor". It means "OK,
>> the descriptor is already at the place we want it to". And renaming this
>> into "go ahead and to fd-specific receiving" is confusing.
>>
>> Describe what operation you plan to "virtualize" with this callback.
> 
> It's quite difficult to choose true name for this. It's not a specific operation,
> it's just about a time between open and post_open. We may add new state
> in fd_open_state::states instead..

Please, explain what you're trying to do with this callback.

>>>>>  
>>>>>  	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