[CRIU] Re: [PATCH 2/4] image: add functions to close and re-open the network listen socket

Pavel Emelyanov xemul at parallels.com
Mon Aug 20 10:29:59 EDT 2012


On 08/20/2012 06:20 PM, Adrian Reber wrote:
> On Thu, Aug 16, 2012 at 08:10:41PM +0400, Pavel Emelyanov wrote:
>> On 08/16/2012 07:56 PM, Adrian Reber wrote:
>>> On Wed, Aug 15, 2012 at 02:53:13PM +0400, Pavel Emelyanov wrote:
>>>> On 08/15/2012 01:54 PM, Adrian Reber wrote:
>>>>> During the restore of the file descriptors all open network
>>>>> sockets have to be closed.
>>>>
>>>> I don't quite understand this requirement. Can you elaborate, please?
>>>
>>> I think it is during prepare_fs(). If the network socket is still open
>>> (using fd=3) prepare_fs() fails if the program to restore wants to open
>>> that file descriptor. Maybe there is another way to handle it but
>>> closing and later reopening it was my only idea.
>>
>> We face this when keep an image file with fds open. There's the move_img_fd()
>> thing for resolving this conflict, you should use it for image socket as well.
> 
> I think I need some help here. How do I now where to move my socket FDs?

You shouldn't care _where_ to move. The function semantics is: you pass a pointer
to some file descriptor (&A) and a value of some other one (B) into it. After the
function returns it makes sure that A != B.

In your case most likely you need to use it like

move_img_fd(&listen_socket, fd_we_are_currently_trying_to_restore);

> My restore test case needs the FDs 3 and 4, but 3 is used by the listen
> socket. How would I move the network listen socket to 5 or higher? How
> do I know which is the highest FD which will be free and not needed by
> the program which will be restored?
> 
> 		Adrian
> .
> 



More information about the CRIU mailing list