mbox series

[RFC,0/4] crypto,io,migration: Add support to gnutls_bye()

Message ID 20250206175824.22664-1-farosas@suse.de (mailing list archive)
Headers show
Series crypto,io,migration: Add support to gnutls_bye() | expand

Message

Fabiano Rosas Feb. 6, 2025, 5:58 p.m. UTC
Hi,

We've been discussing a way to stop multifd recv threads from getting
an error at the end of migration when the source threads close the
iochannel without ending the TLS session.

The original issue was introduced by commit 1d457daf86
("migration/multifd: Further remove the SYNC on complete") which
altered the synchronization of the source and destination in a manner
that causes the destination to already be waiting at recv() when the
source closes the connection.

One approach would be to issue gnutls_bye() at the source after all
the data has been sent. The destination would then gracefully exit
when it gets EOF.

Aside from stopping the recv thread from seeing an error, this also
creates a contract that all connections should be closed only after
the TLS session is ended. This helps to avoid masking a legitimate
issue where the connection is closed prematurely.

Fabiano Rosas (4):
  crypto: Allow gracefully ending the TLS session
  io: tls: Add qio_channel_tls_bye
  migration/multifd: Terminate the TLS connection
  migration: Check migration error after loadvm

 crypto/tlssession.c         | 40 ++++++++++++++++++
 include/crypto/tlssession.h | 22 ++++++++++
 include/io/channel-tls.h    | 12 ++++++
 io/channel-tls.c            | 84 +++++++++++++++++++++++++++++++++++++
 io/trace-events             |  5 +++
 migration/multifd.c         | 34 ++++++++++++++-
 migration/savevm.c          |  6 ++-
 migration/tls.c             |  5 +++
 migration/tls.h             |  2 +-
 9 files changed, 207 insertions(+), 3 deletions(-)

Comments

Maciej S. Szmigiero Feb. 6, 2025, 9:08 p.m. UTC | #1
On 6.02.2025 18:58, Fabiano Rosas wrote:
> Hi,
> 
> We've been discussing a way to stop multifd recv threads from getting
> an error at the end of migration when the source threads close the
> iochannel without ending the TLS session.
> 
> The original issue was introduced by commit 1d457daf86
> ("migration/multifd: Further remove the SYNC on complete") which
> altered the synchronization of the source and destination in a manner
> that causes the destination to already be waiting at recv() when the
> source closes the connection.
> 
> One approach would be to issue gnutls_bye() at the source after all
> the data has been sent. The destination would then gracefully exit
> when it gets EOF.
> 
> Aside from stopping the recv thread from seeing an error, this also
> creates a contract that all connections should be closed only after
> the TLS session is ended. This helps to avoid masking a legitimate
> issue where the connection is closed prematurely.
> 

Thanks for quickly posting this RFC.

I've applied these patches on top of the current QEMU git master,
ported my patch set on top of it, dropped my premature_ok patches
and can confirm that the tests still pass.

Thanks,
Maciej