All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, Leonardo Bras <leobras.c@gmail.com>,
	Lukas Straub <lukasstraub2@web.de>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Juan Quintela <quintela@redhat.com>
Subject: Re: [PATCH 1/1] yank: Unregister function when using TLS migration
Date: Thu, 27 May 2021 09:35:15 -0400	[thread overview]
Message-ID: <YK+gE+/qqDCp4eEv@t490s> (raw)
In-Reply-To: <YK+cA3Bl/MFGBhmy@redhat.com>

On Thu, May 27, 2021 at 02:17:55PM +0100, Daniel P. Berrangé wrote:
> On Thu, May 27, 2021 at 09:09:09AM -0400, Peter Xu wrote:
> > On Thu, May 27, 2021 at 01:37:42PM +0100, Daniel P. Berrangé wrote:
> > > On Thu, May 27, 2021 at 08:23:52AM -0400, Peter Xu wrote:
> > > > On Thu, May 27, 2021 at 09:46:54AM +0100, Daniel P. Berrangé wrote:
> > > > > On Wed, May 26, 2021 at 05:58:58PM -0400, Peter Xu wrote:
> > > > > > On Wed, May 26, 2021 at 11:21:03PM +0200, Lukas Straub wrote:
> > > > > > > On Wed, 26 May 2021 16:40:35 -0400
> > > > > > > Peter Xu <peterx@redhat.com> wrote:
> > > > > > > 
> > > > > > > > On Wed, May 26, 2021 at 05:05:40PM -0300, Leonardo Bras wrote:
> > > > > > > > > After yank feature was introduced, whenever migration is started using TLS,
> > > > > > > > > the following error happens in both source and destination hosts:
> > > > > > > > > 
> > > > > > > > > (qemu) qemu-kvm: ../util/yank.c:107: yank_unregister_instance:
> > > > > > > > > Assertion `QLIST_EMPTY(&entry->yankfns)' failed.
> > > > > > > > > 
> > > > > > > > > This happens because of a missing yank_unregister_function() when using
> > > > > > > > > qio-channel-tls.
> > > > > > > > > 
> > > > > > > > > Fix this by also allowing TYPE_QIO_CHANNEL_TLS object type to perform
> > > > > > > > > yank_unregister_function() in channel_close() and multifd_load_cleanup().
> > > > > > > > > 
> > > > > > > > > Fixes: 50186051f ("Introduce yank feature")
> > > > > > > > > Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1964326
> > > > > > > > > Signed-off-by: Leonardo Bras <leobras.c@gmail.com>  
> > > > > > > > 
> > > > > > > > Leo,
> > > > > > > > 
> > > > > > > > Thanks for looking into it!
> > > > > > > > 
> > > > > > > > So before looking int the fix... I do have a doubt on why we only enable yank
> > > > > > > > on socket typed, as I think tls should also work with qio_channel_shutdown().
> > > > > > > > 
> > > > > > > > IIUC the confused thing here is we register only for qio-socket, however tls
> > > > > > > > will actually call migration_channel_connect() twice, first with a qio-socket,
> > > > > > > > then with the real tls-socket.  For tls I feel like we have registered with the
> > > > > > > > wrong channel - instead of the wrapper socket ioc, we should register to the
> > > > > > > > final tls ioc?
> > > > > > > > 
> > > > > > > > Lukas, is there a reason?
> > > > > > > > 
> > > > > > > 
> > > > > > > Hi,
> > > > > > > There is no specific reason. Both ways work equally well in preventing
> > > > > > > qemu from hanging. shutdown() for tls-channel just makes it abort a
> > > > > > > little sooner (by not attempting to encrypt and send data anymore).
> > > > > > > 
> > > > > > > I don't lean either way. I guess registering it on the tls-channel
> > > > > > > makes is a bit more explicit and clearer.
> > > > > > 
> > > > > > Agreed, because IMHO logically the migration code should not be aware of
> > > > > > internals of IOChannels, e.g., we shouldn't need to know ioc->master is the
> > > > > > socket ioc of tls ioc to unregister.
> > > > > 
> > > > > I think it is atually better to ignore the TLS channel and *always* yank
> > > > > on the undering socket IO channel. The yank functionality is intended to
> > > > > be used in a scenario where we know the channels are broken.  If yank
> > > > > calls the high level IO channel it is potentially going to try to do a
> > > > > cleanup shutdown that we know will fail because of the broken network.
> > > > 
> > > > Could you elaborate what's the "cleanup shutdown"?
> > > > 
> > > > The yank calls migration_yank_iochannel:
> > > > 
> > > > void migration_yank_iochannel(void *opaque)
> > > > {
> > > >     QIOChannel *ioc = QIO_CHANNEL(opaque);
> > > > 
> > > >     qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);
> > > > }
> > > > 
> > > > Where qio_channel_shutdown for tls is nothing but delivers that to the master
> > > > channel:
> > > > 
> > > > static int qio_channel_tls_shutdown(QIOChannel *ioc,
> > > >                                     QIOChannelShutdown how,
> > > >                                     Error **errp)
> > > > {
> > > >     QIOChannelTLS *tioc = QIO_CHANNEL_TLS(ioc);
> > > > 
> > > >     qatomic_or(&tioc->shutdown, how);
> > > > 
> > > >     return qio_channel_shutdown(tioc->master, how, errp);
> > > > }
> > > > 
> > > > So I thought it was a nice wrapper just for things like this, and I didn't see
> > > > anything it does more than the io_shutdown for the socket channel.  Did I miss
> > > > something?
> > > 
> > > Today thats the case, but don't assume it will be the case forever.
> > > There is a mechanism in TLS for doing clean shutdown which we've
> > > debated including.
> > > 
> > > In general apps *can* just call the shutdown method on the QIOChannelTLS
> > > object no matter what.  Yank is just a little bit special because of its
> > > need to be guaranteed to work even when the network is dead. So yank
> > > should always directly call the low level QIOChannelSocket, so thre is
> > > a strong guarantee it can't block on something.
> > 
> > Hmm, I am still not fully convinced that that's a valid reason the migration
> > code should be aware of how the socket is managed in tls channels...
> > 
> > Does that sound more like a good reason to introduce QIOChannelShutdown with
> > QIO_CHANNEL_SHUTDOWN_FORCE so it'll always not block if FORCE set?  Then we can
> > switch the yank function to use that.
> > 
> > What do you think?
> 
> I think that's unneccessary - the migration code already does similar
> things elsewhere when it wants to distinguish TLS usage, so this is not
> anything new conceptually.

But IMHO the other option is to reduce tls difference and treat it the same as
the other channels as much as possible.. probably starting from reworking the
yank calls..

And IIUC it's not only about migration.  E.g., all the existing yank functions
are based on the fact that current channel shutdown() won't block as it's
called in the QMP oob handler:

char_socket_yank_iochannel[409] qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);
nbd_yank[1783]                 qio_channel_shutdown(QIO_CHANNEL(s->sioc), QIO_CHANNEL_SHUTDOWN_BOTH, NULL);

I have no idea whether they'll use tls or not, I don't see strictly on why they
can't at least in the future... If tls starts to introduce shutdown() that can
block, IMHO the cleaner solution is to separate the use of block/nonblock
shutdown() because we do have scenarios that do not want shutdown() to block,
by either introduce QIO_CHANNEL_SHUTDOWN_FORCE or QIO_CHANNEL_SHUTDOWN_FULL
which guarantees full cleanup of the tls channel even slower.

We also have other call sites for channel shutdown()s besides yank, I didn't
check but I feel like it's always good to provide non-blocking solutions when
the caller wants, as it does look like a valid requirement as long as the
change is trivial (IIUC it'll be a small patch and conditionally do either
quick/slow version of shutdown for tls only).

Thanks,

-- 
Peter Xu



  parent reply	other threads:[~2021-05-27 13:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 20:05 [PATCH 1/1] yank: Unregister function when using TLS migration Leonardo Bras
2021-05-26 20:40 ` Peter Xu
2021-05-26 21:21   ` Lukas Straub
2021-05-26 21:58     ` Peter Xu
2021-05-27  8:46       ` Daniel P. Berrangé
2021-05-27 12:23         ` Peter Xu
2021-05-27 12:37           ` Daniel P. Berrangé
2021-05-27 13:09             ` Peter Xu
2021-05-27 13:17               ` Daniel P. Berrangé
2021-05-27 13:34                 ` Dr. David Alan Gilbert
2021-05-27 13:35                 ` Peter Xu [this message]
2021-05-27 15:05             ` Lukas Straub
2021-05-26 21:24 ` Lukas Straub
2021-05-26 21:56   ` Leonardo Brás

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YK+gE+/qqDCp4eEv@t490s \
    --to=peterx@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=leobras.c@gmail.com \
    --cc=lukasstraub2@web.de \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.