[PATCH 27/33] migration/socket: keep fds non-block

Vladimir Sementsov-Ogievskiy posted 33 patches 3 months ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, "Gonglei (Arei)" <arei.gonglei@huawei.com>, Zhenwei Pi <pizhenwei@bytedance.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Raphael Norwitz <raphael@enfabrica.net>, Jason Wang <jasowang@redhat.com>, Fam Zheng <fam@euphon.net>, "Alex Bennée" <alex.bennee@linaro.org>, "Daniel P. Berrangé" <berrange@redhat.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Laurent Vivier <lvivier@redhat.com>
There is a newer version of this series
[PATCH 27/33] migration/socket: keep fds non-block
Posted by Vladimir Sementsov-Ogievskiy 3 months ago
For migration channel keep fds non-blocking property as is.
It's needed for future local migration of fds.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 migration/socket.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/migration/socket.c b/migration/socket.c
index 5ec65b8c03..9f7b6919cf 100644
--- a/migration/socket.c
+++ b/migration/socket.c
@@ -129,6 +129,7 @@ static void socket_accept_incoming_migration(QIONetListener *listener,
     }
 
     qio_channel_set_name(QIO_CHANNEL(cioc), "migration-socket-incoming");
+    qio_channel_socket_keep_nonblock(QIO_CHANNEL(cioc));
     migration_channel_process_incoming(QIO_CHANNEL(cioc));
 }
 
-- 
2.48.1
Re: [PATCH 27/33] migration/socket: keep fds non-block
Posted by Peter Xu 2 months, 3 weeks ago
On Wed, Aug 13, 2025 at 07:48:48PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> For migration channel keep fds non-blocking property as is.
> It's needed for future local migration of fds.

It is pretty risky.  This changes the attribute for all the iochannels that
migration incoming side uses, including multifd / postcopy / ...

I left comment in previous patch as a pure question trying to understand
whether the feature is needed.  If it is, here it might still be good to:

  - Above the line add a comment explaning why
  - Only apply it to whatever channel that matters.  In this case, IIUC
    only the main channel matters

Thanks,

> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  migration/socket.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/migration/socket.c b/migration/socket.c
> index 5ec65b8c03..9f7b6919cf 100644
> --- a/migration/socket.c
> +++ b/migration/socket.c
> @@ -129,6 +129,7 @@ static void socket_accept_incoming_migration(QIONetListener *listener,
>      }
>  
>      qio_channel_set_name(QIO_CHANNEL(cioc), "migration-socket-incoming");
> +    qio_channel_socket_keep_nonblock(QIO_CHANNEL(cioc));
>      migration_channel_process_incoming(QIO_CHANNEL(cioc));
>  }
>  
> -- 
> 2.48.1
> 

-- 
Peter Xu
Re: [PATCH 27/33] migration/socket: keep fds non-block
Posted by Vladimir Sementsov-Ogievskiy 2 months, 3 weeks ago
On 20.08.25 16:30, Peter Xu wrote:
> On Wed, Aug 13, 2025 at 07:48:48PM +0300, Vladimir Sementsov-Ogievskiy wrote:
>> For migration channel keep fds non-blocking property as is.
>> It's needed for future local migration of fds.
> 
> It is pretty risky.  This changes the attribute for all the iochannels that
> migration incoming side uses, including multifd / postcopy / ...

But for now nobody (except CPR-transfer) really pass fds through migration,
and for CPR-transfer it's obviously better to preserve the state by default (see
my answer in previous patch).

So I think, we are in a point, where we can chose the good default, and
document it.

> 
> I left comment in previous patch as a pure question trying to understand
> whether the feature is needed.  If it is, here it might still be good to:
> 
>    - Above the line add a comment explaning why
>    - Only apply it to whatever channel that matters.  In this case, IIUC
>      only the main channel matters
> 

I still think that preserving non-blocking flag "as is" is good default for migration,
please look at my answer in previous patch. However, in this series I may adopt
to any approach.

> 
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>> ---
>>   migration/socket.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/migration/socket.c b/migration/socket.c
>> index 5ec65b8c03..9f7b6919cf 100644
>> --- a/migration/socket.c
>> +++ b/migration/socket.c
>> @@ -129,6 +129,7 @@ static void socket_accept_incoming_migration(QIONetListener *listener,
>>       }
>>   
>>       qio_channel_set_name(QIO_CHANNEL(cioc), "migration-socket-incoming");
>> +    qio_channel_socket_keep_nonblock(QIO_CHANNEL(cioc));
>>       migration_channel_process_incoming(QIO_CHANNEL(cioc));
>>   }
>>   
>> -- 
>> 2.48.1
>>
> 


-- 
Best regards,
Vladimir
Re: [PATCH 27/33] migration/socket: keep fds non-block
Posted by Peter Xu 2 months, 3 weeks ago
On Thu, Aug 21, 2025 at 03:15:24PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> On 20.08.25 16:30, Peter Xu wrote:
> > On Wed, Aug 13, 2025 at 07:48:48PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> > > For migration channel keep fds non-blocking property as is.
> > > It's needed for future local migration of fds.
> > 
> > It is pretty risky.  This changes the attribute for all the iochannels that
> > migration incoming side uses, including multifd / postcopy / ...
> 
> But for now nobody (except CPR-transfer) really pass fds through migration,
> and for CPR-transfer it's obviously better to preserve the state by default (see
> my answer in previous patch).
> 
> So I think, we are in a point, where we can chose the good default, and
> document it.
> 
> > 
> > I left comment in previous patch as a pure question trying to understand
> > whether the feature is needed.  If it is, here it might still be good to:
> > 
> >    - Above the line add a comment explaning why
> >    - Only apply it to whatever channel that matters.  In this case, IIUC
> >      only the main channel matters
> > 
> 
> I still think that preserving non-blocking flag "as is" is good default for migration,
> please look at my answer in previous patch. However, in this series I may adopt
> to any approach.

I also commented in the previous patch, let's see whether we can make it
not only the default for migration, but the default for iochannels (hence,
any chance to drop the new feature flag completely..).

If that won't fly, I think this is fine.  In that case, please explicitly
mention that it's intentional to change all iochannels that migration uses
in the commit message, and we can also add a comment inline explaining why
we set this default for all migration channels.

Thanks,

-- 
Peter Xu