From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Lukas Straub <lukasstraub2@web.de>,
Leonardo Bras Soares Passos <lsoaresp@redhat.com>,
qemu-devel@nongnu.org, Juan Quintela <quintela@redhat.com>
Subject: Re: [PATCH 3/5] migration: Introduce migration_ioc_[un]register_yank()
Date: Wed, 21 Jul 2021 10:58:17 +0100 [thread overview]
Message-ID: <YPfvuaKLjeuX+K3A@work-vm> (raw)
In-Reply-To: <20210721012134.792845-4-peterx@redhat.com>
* Peter Xu (peterx@redhat.com) wrote:
> There're plenty of places in migration/* that checks against either socket or
> tls typed ioc for yank operations. Provide two helpers to hide all these
> information.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> migration/channel.c | 15 ++-------------
> migration/multifd.c | 8 ++------
> migration/qemu-file-channel.c | 8 ++------
> migration/yank_functions.c | 28 ++++++++++++++++++++++++++++
> migration/yank_functions.h | 2 ++
> 5 files changed, 36 insertions(+), 25 deletions(-)
>
> diff --git a/migration/channel.c b/migration/channel.c
> index 01275a9162..c4fc000a1a 100644
> --- a/migration/channel.c
> +++ b/migration/channel.c
> @@ -44,13 +44,7 @@ void migration_channel_process_incoming(QIOChannel *ioc)
> TYPE_QIO_CHANNEL_TLS)) {
> migration_tls_channel_process_incoming(s, ioc, &local_err);
> } else {
> - if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) ||
> - object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS)) {
> - yank_register_function(MIGRATION_YANK_INSTANCE,
> - migration_yank_iochannel,
> - QIO_CHANNEL(ioc));
> - }
> -
> + migration_ioc_register_yank(ioc);
> migration_ioc_process_incoming(ioc, &local_err);
> }
>
> @@ -94,12 +88,7 @@ void migration_channel_connect(MigrationState *s,
> } else {
> QEMUFile *f = qemu_fopen_channel_output(ioc);
>
> - if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) ||
> - object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS)) {
> - yank_register_function(MIGRATION_YANK_INSTANCE,
> - migration_yank_iochannel,
> - QIO_CHANNEL(ioc));
> - }
> + migration_ioc_register_yank(ioc);
>
> qemu_mutex_lock(&s->qemu_file_lock);
> s->to_dst_file = f;
> diff --git a/migration/multifd.c b/migration/multifd.c
> index ab41590e71..377da78f5b 100644
> --- a/migration/multifd.c
> +++ b/migration/multifd.c
> @@ -987,12 +987,8 @@ int multifd_load_cleanup(Error **errp)
> for (i = 0; i < migrate_multifd_channels(); i++) {
> MultiFDRecvParams *p = &multifd_recv_state->params[i];
>
> - if ((object_dynamic_cast(OBJECT(p->c), TYPE_QIO_CHANNEL_SOCKET) ||
> - object_dynamic_cast(OBJECT(p->c), TYPE_QIO_CHANNEL_TLS))
> - && OBJECT(p->c)->ref == 1) {
> - yank_unregister_function(MIGRATION_YANK_INSTANCE,
> - migration_yank_iochannel,
> - QIO_CHANNEL(p->c));
> + if (OBJECT(p->c)->ref == 1) {
> + migration_ioc_unregister_yank(p->c);
> }
>
> object_unref(OBJECT(p->c));
> diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c
> index fad340ea7a..867a5ed0c3 100644
> --- a/migration/qemu-file-channel.c
> +++ b/migration/qemu-file-channel.c
> @@ -107,12 +107,8 @@ static int channel_close(void *opaque, Error **errp)
> int ret;
> QIOChannel *ioc = QIO_CHANNEL(opaque);
> ret = qio_channel_close(ioc, errp);
> - if ((object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) ||
> - object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS))
> - && OBJECT(ioc)->ref == 1) {
> - yank_unregister_function(MIGRATION_YANK_INSTANCE,
> - migration_yank_iochannel,
> - QIO_CHANNEL(ioc));
> + if (OBJECT(ioc)->ref == 1) {
> + migration_ioc_unregister_yank(ioc);
> }
> object_unref(OBJECT(ioc));
> return ret;
> diff --git a/migration/yank_functions.c b/migration/yank_functions.c
> index 96c90e17dc..23697173ae 100644
> --- a/migration/yank_functions.c
> +++ b/migration/yank_functions.c
> @@ -11,6 +11,9 @@
> #include "qapi/error.h"
> #include "io/channel.h"
> #include "yank_functions.h"
> +#include "qemu/yank.h"
> +#include "io/channel-socket.h"
> +#include "io/channel-tls.h"
>
> void migration_yank_iochannel(void *opaque)
> {
> @@ -18,3 +21,28 @@ void migration_yank_iochannel(void *opaque)
>
> qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);
> }
> +
> +/* Return whether yank is supported on this ioc */
> +static bool migration_ioc_yank_supported(QIOChannel *ioc)
> +{
> + return object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) ||
> + object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS);
> +}
> +
> +void migration_ioc_register_yank(QIOChannel *ioc)
> +{
> + if (migration_ioc_yank_supported(ioc)) {
> + yank_register_function(MIGRATION_YANK_INSTANCE,
> + migration_yank_iochannel,
> + QIO_CHANNEL(ioc));
> + }
> +}
> +
> +void migration_ioc_unregister_yank(QIOChannel *ioc)
> +{
> + if (migration_ioc_yank_supported(ioc)) {
> + yank_unregister_function(MIGRATION_YANK_INSTANCE,
> + migration_yank_iochannel,
> + QIO_CHANNEL(ioc));
> + }
> +}
> diff --git a/migration/yank_functions.h b/migration/yank_functions.h
> index 055ea22523..74c7f18c91 100644
> --- a/migration/yank_functions.h
> +++ b/migration/yank_functions.h
> @@ -15,3 +15,5 @@
> * @opaque: QIOChannel to shutdown
> */
> void migration_yank_iochannel(void *opaque);
> +void migration_ioc_register_yank(QIOChannel *ioc);
> +void migration_ioc_unregister_yank(QIOChannel *ioc);
> --
> 2.31.1
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2021-07-21 10:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 1:21 [PATCH 0/5] migrations: Fix potential rare race of migration-test after yank Peter Xu
2021-07-21 1:21 ` [PATCH 1/5] migration: Fix missing join() of rp_thread Peter Xu
2021-07-21 9:49 ` Dr. David Alan Gilbert
2021-07-21 1:21 ` [PATCH 2/5] migration: Shutdown src in await_return_path_close_on_source() Peter Xu
2021-07-21 9:55 ` Dr. David Alan Gilbert
2021-07-21 15:40 ` Peter Xu
2021-07-21 18:00 ` Dr. David Alan Gilbert
2021-07-21 18:12 ` Peter Xu
2021-07-21 15:57 ` Daniel P. Berrangé
2021-07-21 1:21 ` [PATCH 3/5] migration: Introduce migration_ioc_[un]register_yank() Peter Xu
2021-07-21 9:58 ` Dr. David Alan Gilbert [this message]
2021-07-21 1:21 ` [PATCH 4/5] migration: Teach QEMUFile to be QIOChannel-aware Peter Xu
2021-07-21 10:27 ` Dr. David Alan Gilbert
2021-07-21 10:57 ` Daniel P. Berrangé
2021-07-21 1:21 ` [PATCH 5/5] migration: Move the yank unregister of channel_close out Peter Xu
2021-07-21 10:39 ` Dr. David Alan Gilbert
2021-07-21 15:45 ` Peter Xu
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=YPfvuaKLjeuX+K3A@work-vm \
--to=dgilbert@redhat.com \
--cc=lsoaresp@redhat.com \
--cc=lukasstraub2@web.de \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--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.