From: Fabiano Rosas <farosas@suse.de>
To: Prasad Pandit <ppandit@redhat.com>
Cc: qemu-devel@nongnu.org, peterx@redhat.com, berrange@redhat.com
Subject: Re: [PATCH v3 13/25] migration: Move setting of QEMUFile into migration_outgoing|incoming_setup
Date: Tue, 20 Jan 2026 15:01:34 -0300 [thread overview]
Message-ID: <87ldhs88ox.fsf@suse.de> (raw)
In-Reply-To: <CAE8KmOz4_RAM1QgJUuEwk=68-jwgt25O7vfPNOkce2vvEOED0w@mail.gmail.com>
Prasad Pandit <ppandit@redhat.com> writes:
> On Fri, 9 Jan 2026 at 18:12, Fabiano Rosas <farosas@suse.de> wrote:
>>
>> Centralize, on both sides of migration, the setting of the to_src_file
>> and from_dst_file QEMUFiles. This will clean up the interface with
>> channel.c and rdma.c, allowing those files to stop dealing with
>> QEMUFile themselves.
>>
>> (multifd_recv_new_channel was changed to return bool+errp for
>> convenience)
>>
>> Reviewed-by: Peter Xu <peterx@redhat.com>
>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>> ---
>> migration/channel.c | 9 +----
>> migration/migration.c | 84 ++++++++++++++++++++++++++-----------------
>> migration/migration.h | 2 ++
>> migration/multifd.c | 8 +++--
>> migration/multifd.h | 2 +-
>> 5 files changed, 61 insertions(+), 44 deletions(-)
>>
>> diff --git a/migration/channel.c b/migration/channel.c
>> index 26cb7bf059..6acce7b2a2 100644
>> --- a/migration/channel.c
>> +++ b/migration/channel.c
>> @@ -14,7 +14,6 @@
>> #include "channel.h"
>> #include "tls.h"
>> #include "migration.h"
>> -#include "qemu-file.h"
>> #include "trace.h"
>> #include "qapi/error.h"
>> #include "io/channel-tls.h"
>> @@ -80,14 +79,8 @@ void migration_channel_connect(MigrationState *s, QIOChannel *ioc)
>> return;
>> }
>>
>> - QEMUFile *f = qemu_file_new_output(ioc);
>> -
>> migration_ioc_register_yank(ioc);
>> -
>> - qemu_mutex_lock(&s->qemu_file_lock);
>> - s->to_dst_file = f;
>> - qemu_mutex_unlock(&s->qemu_file_lock);
>> -
>> + migration_outgoing_setup(ioc);
>> migration_connect(s);
>> }
>>
>> diff --git a/migration/migration.c b/migration/migration.c
>> index 1ea6125454..b7367eb5cf 100644
>> --- a/migration/migration.c
>> +++ b/migration/migration.c
>> @@ -930,17 +930,56 @@ out:
>> migrate_incoming_unref_outgoing_state();
>> }
>>
>> -/**
>> - * migration_incoming_setup: Setup incoming migration
>> - * @f: file for main migration channel
>> +static bool migration_has_main_and_multifd_channels(void);
>> +
>> +/*
>> + * Returns whether all the necessary channels to proceed with the
>> + * incoming migration have been established without error.
>> */
>> -static void migration_incoming_setup(QEMUFile *f)
>> +bool migration_incoming_setup(QIOChannel *ioc, uint8_t channel, Error **errp)
>> {
>> MigrationIncomingState *mis = migration_incoming_get_current();
>> + QEMUFile *f;
>>
>> - assert(!mis->from_src_file);
>> - mis->from_src_file = f;
>> - qemu_file_set_blocking(f, false, &error_abort);
>> + if (multifd_recv_setup(errp) != 0) {
>> + return false;
>> + }
>> +
>> + switch (channel) {
>> + case CH_MAIN:
>> + f = qemu_file_new_input(ioc);
>> + assert(!mis->from_src_file);
>> + mis->from_src_file = f;
>> + qemu_file_set_blocking(f, false, &error_abort);
>> + break;
>> +
>> + case CH_MULTIFD:
>> + if (!multifd_recv_new_channel(ioc, errp)) {
>> + return false;
>> + }
>> + break;
>> +
>> + case CH_POSTCOPY:
>> + assert(!mis->postcopy_qemufile_dst);
>> + f = qemu_file_new_input(ioc);
>> + postcopy_preempt_new_channel(mis, f);
>> + return false;
>> +
>> + default:
>> + g_assert_not_reached();
>> + }
>> +
>> + return migration_has_main_and_multifd_channels();
>> +}
>> +
>> +void migration_outgoing_setup(QIOChannel *ioc)
>> +{
>> + MigrationState *s = migrate_get_current();
>> + QEMUFile *f = qemu_file_new_output(ioc);
>> +
>> + qemu_mutex_lock(&s->qemu_file_lock);
>> + s->to_dst_file = f;
>> + qemu_mutex_unlock(&s->qemu_file_lock);
>> }
>
> * Shouldn't migration_outgoing_setup() also return bool, to be
> consistent with migration_incoming_setup() above? OR make
> migration_incoming_setup() return void.
>
That would be a change simply to make the signatures consistent. It's
not indicative (granted, as it usually is) of a consistency in
design. The reason migration_incoming_setup() returns bool is to follow
the recommendation of returning whether errp is set. Here, there's no
errp, so no need.
(before multifd_send_setup moved to the migration thread, maybe we could
still make both functions more analogous, but I'm not sure how much
benefit that would have brought)
>> /* Returns true if recovered from a paused migration, otherwise false */
>> @@ -988,7 +1027,11 @@ void migration_incoming_process(void)
>>
>> void migration_fd_process_incoming(QEMUFile *f)
>> {
>> - migration_incoming_setup(f);
>> + MigrationIncomingState *mis = migration_incoming_get_current();
>> +
>> + assert(!mis->from_src_file);
>> + mis->from_src_file = f;
>> + qemu_file_set_blocking(f, false, &error_abort);
>> migration_incoming_process();
>> }
>
> * Is it possible to move above mis->from_src_file = f part to
> migration_incoming_setup()?
>
Yes, patch 14.
>
>> @@ -1011,8 +1054,6 @@ static bool migration_has_main_and_multifd_channels(void)
>> void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
>> {
>> MigrationIncomingState *mis = migration_incoming_get_current();
>> - Error *local_err = NULL;
>> - QEMUFile *f;
>> uint8_t channel;
>> uint32_t channel_magic = 0;
>> int ret = 0;
>> @@ -1066,28 +1107,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
>> channel = CH_POSTCOPY;
>> }
>>
>> - if (multifd_recv_setup(errp) != 0) {
>> - return;
>> - }
>> -
>> - if (channel == CH_MAIN) {
>> - f = qemu_file_new_input(ioc);
>> - migration_incoming_setup(f);
>> - } else if (channel == CH_MULTIFD) {
>> - /* Multiple connections */
>> - multifd_recv_new_channel(ioc, &local_err);
>> - if (local_err) {
>> - error_propagate(errp, local_err);
>> - return;
>> - }
>> - } else if (channel == CH_POSTCOPY) {
>> - assert(!mis->postcopy_qemufile_dst);
>> - f = qemu_file_new_input(ioc);
>> - postcopy_preempt_new_channel(mis, f);
>> - return;
>> - }
>> -
>> - if (migration_has_main_and_multifd_channels()) {
>> + if (migration_incoming_setup(ioc, channel, errp)) {
>> migration_incoming_process();
>> }
>> }
>> diff --git a/migration/migration.h b/migration/migration.h
>> index d134881eaf..4dcf299719 100644
>> --- a/migration/migration.h
>> +++ b/migration/migration.h
>> @@ -530,6 +530,8 @@ void migrate_set_state(MigrationStatus *state, MigrationStatus old_state,
>> void migration_fd_process_incoming(QEMUFile *f);
>> void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp);
>> void migration_incoming_process(void);
>> +bool migration_incoming_setup(QIOChannel *ioc, uint8_t channel, Error **errp);
>> +void migration_outgoing_setup(QIOChannel *ioc);
>>
>> bool migration_has_all_channels(void);
>>
>> diff --git a/migration/multifd.c b/migration/multifd.c
>> index 3fb1a07ba9..4980ed4f04 100644
>> --- a/migration/multifd.c
>> +++ b/migration/multifd.c
>> @@ -1521,7 +1521,7 @@ bool multifd_recv_all_channels_created(void)
>> * Try to receive all multifd channels to get ready for the migration.
>> * Sets @errp when failing to receive the current channel.
>> */
>> -void multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
>> +bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
>> {
>> MultiFDRecvParams *p;
>> Error *local_err = NULL;
>> @@ -1536,7 +1536,7 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
>> "failed to receive packet"
>> " via multifd channel %d: ",
>> qatomic_read(&multifd_recv_state->count));
>> - return;
>> + return false;
>> }
>> trace_multifd_recv_new_channel(id);
>> } else {
>> @@ -1549,7 +1549,7 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
>> id);
>> multifd_recv_terminate_threads(error_copy(local_err));
>> error_propagate(errp, local_err);
>> - return;
>> + return false;
>> }
>> p->c = ioc;
>> object_ref(OBJECT(ioc));
>> @@ -1558,4 +1558,6 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
>> qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p,
>> QEMU_THREAD_JOINABLE);
>> qatomic_inc(&multifd_recv_state->count);
>> +
>> + return true;
>> }
>> diff --git a/migration/multifd.h b/migration/multifd.h
>> index 9b6d81e7ed..89a395aef2 100644
>> --- a/migration/multifd.h
>> +++ b/migration/multifd.h
>> @@ -42,7 +42,7 @@ int multifd_recv_setup(Error **errp);
>> void multifd_recv_cleanup(void);
>> void multifd_recv_shutdown(void);
>> bool multifd_recv_all_channels_created(void);
>> -void multifd_recv_new_channel(QIOChannel *ioc, Error **errp);
>> +bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp);
>> void multifd_recv_sync_main(void);
>> int multifd_send_sync_main(MultiFDSyncReq req);
>> bool multifd_queue_page(RAMBlock *block, ram_addr_t offset);
>> --
>
> * Change looks okay.
> Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
>
> Thank you.
> ---
> - Prasad
next prev parent reply other threads:[~2026-01-20 18:02 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 12:40 [PATCH v3 00/25] migration: Cleanup early connection code Fabiano Rosas
2026-01-09 12:40 ` [PATCH v3 01/25] migration: Remove redundant state change Fabiano Rosas
2026-01-13 12:33 ` Prasad Pandit
2026-01-13 13:25 ` Fabiano Rosas
2026-01-09 12:40 ` [PATCH v3 02/25] migration: Fix state change at migration_channel_process_incoming Fabiano Rosas
2026-01-13 12:39 ` Prasad Pandit
2026-01-13 13:27 ` Fabiano Rosas
2026-01-09 12:40 ` [PATCH v3 03/25] migration/tls: Remove unused parameter Fabiano Rosas
2026-01-19 12:37 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 04/25] migration: Cleanup TLS handshake hostname passing Fabiano Rosas
2026-01-20 11:02 ` Prasad Pandit
2026-01-20 11:11 ` Daniel P. Berrangé
2026-01-20 11:37 ` Prasad Pandit
2026-01-20 14:51 ` Fabiano Rosas
2026-01-09 12:40 ` [PATCH v3 05/25] migration: Move postcopy_try_recover into migration_incoming_process Fabiano Rosas
2026-01-19 11:38 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 06/25] migration: Use migrate_mode() to query for cpr-transfer Fabiano Rosas
2026-01-19 12:06 ` Prasad Pandit
2026-01-20 17:52 ` Fabiano Rosas
2026-01-09 12:40 ` [PATCH v3 07/25] migration: Free the error earlier in the resume case Fabiano Rosas
2026-01-15 11:54 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 08/25] migration: Move error reporting out of migration_cleanup Fabiano Rosas
2026-01-19 12:32 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 09/25] migration: Expand migration_connect_error_propagate to cover cancelling Fabiano Rosas
2026-01-20 9:15 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 10/25] migration: yank: Move register instance earlier Fabiano Rosas
2026-01-20 9:01 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 11/25] migration: Fold migration_cleanup() into migration_connect_error_propagate() Fabiano Rosas
2026-01-16 12:25 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 12/25] migration: Handle error in the early async paths Fabiano Rosas
2026-01-16 11:17 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 13/25] migration: Move setting of QEMUFile into migration_outgoing|incoming_setup Fabiano Rosas
2026-01-19 12:22 ` Prasad Pandit
2026-01-20 18:01 ` Fabiano Rosas [this message]
2026-01-09 12:40 ` [PATCH v3 14/25] migration/rdma: Use common connection paths Fabiano Rosas
2026-01-19 12:27 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 15/25] migration: Start incoming from channel.c Fabiano Rosas
2026-01-19 12:24 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 16/25] migration/channel: Rename migration_channel_connect Fabiano Rosas
2026-01-20 11:10 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 17/25] migration: Rename instances of start Fabiano Rosas
2026-01-20 11:21 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 18/25] migration: Move channel code to channel.c Fabiano Rosas
2026-01-09 12:40 ` [PATCH v3 19/25] migration: Move transport connection code into channel.c Fabiano Rosas
2026-01-20 9:40 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 20/25] migration: Move channel parsing to channel.c Fabiano Rosas
2026-01-20 10:15 ` Prasad Pandit
2026-01-20 18:18 ` Fabiano Rosas
2026-01-09 12:40 ` [PATCH v3 21/25] migration: Move URI " Fabiano Rosas
2026-01-20 10:20 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 22/25] migration: Free cpr-transfer MigrationAddress along with gsource Fabiano Rosas
2026-01-20 11:17 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 23/25] migration: Move CPR HUP watch to cpr-transfer.c Fabiano Rosas
2026-01-20 11:24 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 24/25] migration: Remove qmp_migrate_finish Fabiano Rosas
2026-01-20 11:07 ` Prasad Pandit
2026-01-09 12:40 ` [PATCH v3 25/25] migration/channel: Centralize calling migration_channel_connect_outgoing Fabiano Rosas
2026-01-19 11:28 ` Prasad Pandit
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=87ldhs88ox.fsf@suse.de \
--to=farosas@suse.de \
--cc=berrange@redhat.com \
--cc=peterx@redhat.com \
--cc=ppandit@redhat.com \
--cc=qemu-devel@nongnu.org \
/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.