On Fri, 9 Jan 2026 at 18:13, Fabiano Rosas <farosas@suse.de> wrote:
> Leave migration_ioc_process_incoming to do only the channel
> identification process and move the migration start into
> channel.c. Both routines will be renamed in the next patches to better
> reflect their usage.
>
> Reviewed-by: Peter Xu <peterx@redhat.com>
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
> migration/channel.c | 12 ++++++++++--
> migration/channel.h | 5 +++--
> migration/migration.c | 13 +++++--------
> migration/migration.h | 3 ++-
> 4 files changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/migration/channel.c b/migration/channel.c
> index 6acce7b2a2..b8d757c17b 100644
> --- a/migration/channel.c
> +++ b/migration/channel.c
> @@ -33,6 +33,7 @@ void migration_channel_process_incoming(QIOChannel *ioc)
> {
> MigrationIncomingState *mis = migration_incoming_get_current();
> Error *local_err = NULL;
> + MigChannelType ch;
>
> trace_migration_set_incoming_channel(
> ioc, object_get_typename(OBJECT(ioc)));
> @@ -41,9 +42,16 @@ void migration_channel_process_incoming(QIOChannel *ioc)
> migration_tls_channel_process_incoming(ioc, &local_err);
> } else {
> migration_ioc_register_yank(ioc);
> - migration_ioc_process_incoming(ioc, &local_err);
> - }
> + ch = migration_ioc_process_incoming(ioc, &local_err);
> + if (!ch) {
> + goto out;
> + }
>
> + if (migration_incoming_setup(ioc, ch, &local_err)) {
> + migration_incoming_process();
> + }
> + }
> +out:
> if (local_err) {
> error_report_err(local_err);
> migrate_set_state(&mis->state, mis->state, MIGRATION_STATUS_FAILED);
> diff --git a/migration/channel.h b/migration/channel.h
> index 93dedbf52b..b361e1c838 100644
> --- a/migration/channel.h
> +++ b/migration/channel.h
> @@ -19,11 +19,12 @@
> #include "io/channel.h"
>
> /* Migration channel types */
> -enum {
> +typedef enum {
> + CH_NONE,
> CH_MAIN,
> CH_MULTIFD,
> CH_POSTCOPY
> -};
> +} MigChannelType;
>
> void migration_channel_process_incoming(QIOChannel *ioc);
>
> diff --git a/migration/migration.c b/migration/migration.c
> index 7d56d73769..a052b99a19 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -1038,10 +1038,10 @@ static bool migration_has_main_and_multifd_channels(void)
> return true;
> }
>
> -void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
> +MigChannelType migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
> {
> MigrationIncomingState *mis = migration_incoming_get_current();
> - uint8_t channel;
> + MigChannelType channel = CH_NONE;
> uint32_t channel_magic = 0;
> int ret = 0;
>
> @@ -1060,7 +1060,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
> ret = migration_channel_read_peek(ioc, (void *)&channel_magic,
> sizeof(channel_magic), errp);
> if (ret != 0) {
> - return;
> + goto out;
> }
>
> channel_magic = be32_to_cpu(channel_magic);
> @@ -1075,7 +1075,6 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
> channel = CH_MAIN;
> } else {
> error_setg(errp, "unknown channel magic: %u", channel_magic);
> - return;
> }
> } else if (mis->from_src_file && migrate_multifd()) {
> /*
> @@ -1087,16 +1086,14 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
> channel = CH_MAIN;
> } else {
> error_setg(errp, "non-peekable channel used without multifd");
> - return;
> }
> } else {
> assert(migrate_postcopy_preempt());
> channel = CH_POSTCOPY;
> }
>
> - if (migration_incoming_setup(ioc, channel, errp)) {
> - migration_incoming_process();
> - }
> +out:
> + return channel;
> }
>
> /**
> diff --git a/migration/migration.h b/migration/migration.h
> index cd6cfd62ba..b55cc40613 100644
> --- a/migration/migration.h
> +++ b/migration/migration.h
> @@ -28,6 +28,7 @@
> #include "postcopy-ram.h"
> #include "system/runstate.h"
> #include "migration/misc.h"
> +#include "channel.h"
>
> #define MIGRATION_THREAD_SNAPSHOT "mig/snapshot"
> #define MIGRATION_THREAD_DIRTY_RATE "mig/dirtyrate"
> @@ -527,7 +528,7 @@ struct MigrationState {
> void migrate_set_state(MigrationStatus *state, MigrationStatus old_state,
> MigrationStatus new_state);
>
> -void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp);
> +MigChannelType 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);
> --
* Looks right.
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Thank you.
---
- Prasad