On Fri, 9 Jan 2026 at 18:13, Fabiano Rosas <farosas@suse.de> wrote:
> (I sorted the includes)
* Could be expunged.
> Reviewed-by: Peter Xu <peterx@redhat.com>
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
> migration/channel.c | 66 +++++++++++++++++++++++++++++++++++++++----
> migration/channel.h | 4 +++
> migration/migration.c | 46 ++----------------------------
> 3 files changed, 67 insertions(+), 49 deletions(-)
>
> diff --git a/migration/channel.c b/migration/channel.c
> index f61d30d986..56c80b5cdf 100644
> --- a/migration/channel.c
> +++ b/migration/channel.c
> @@ -12,18 +12,74 @@
>
> #include "qemu/osdep.h"
> #include "channel.h"
> -#include "tls.h"
> +#include "exec.h"
> +#include "fd.h"
> +#include "file.h"
> +#include "io/channel-socket.h"
> +#include "io/channel-tls.h"
> #include "migration.h"
> #include "multifd.h"
> -#include "savevm.h"
> -#include "trace.h"
> #include "options.h"
> +#include "qapi/qapi-types-migration.h"
> #include "qapi/error.h"
> -#include "io/channel-tls.h"
> -#include "io/channel-socket.h"
> +#include "qemu-file.h"
> #include "qemu/yank.h"
> +#include "rdma.h"
> +#include "savevm.h"
> +#include "socket.h"
> +#include "tls.h"
> +#include "trace.h"
> #include "yank_functions.h"
>
> +void migration_connect_outgoing(MigrationState *s, MigrationAddress *addr,
> + Error **errp)
> +{
> + if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) {
> + SocketAddress *saddr = &addr->u.socket;
> + if (saddr->type == SOCKET_ADDRESS_TYPE_INET ||
> + saddr->type == SOCKET_ADDRESS_TYPE_UNIX ||
> + saddr->type == SOCKET_ADDRESS_TYPE_VSOCK) {
> + socket_connect_outgoing(s, saddr, errp);
> + } else if (saddr->type == SOCKET_ADDRESS_TYPE_FD) {
> + fd_connect_outgoing(s, saddr->u.fd.str, errp);
> + }
> +#ifdef CONFIG_RDMA
> + } else if (addr->transport == MIGRATION_ADDRESS_TYPE_RDMA) {
> + rdma_connect_outgoing(s, &addr->u.rdma, errp);
> +#endif
> + } else if (addr->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
> + exec_connect_outgoing(s, addr->u.exec.args, errp);
> + } else if (addr->transport == MIGRATION_ADDRESS_TYPE_FILE) {
> + file_connect_outgoing(s, &addr->u.file, errp);
> + } else {
> + error_setg(errp, "uri is not a valid migration protocol");
> + }
> +}
> +
> +void migration_connect_incoming(MigrationAddress *addr, Error **errp)
> +{
> + if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) {
> + SocketAddress *saddr = &addr->u.socket;
> + if (saddr->type == SOCKET_ADDRESS_TYPE_INET ||
> + saddr->type == SOCKET_ADDRESS_TYPE_UNIX ||
> + saddr->type == SOCKET_ADDRESS_TYPE_VSOCK) {
> + socket_connect_incoming(saddr, errp);
> + } else if (saddr->type == SOCKET_ADDRESS_TYPE_FD) {
> + fd_connect_incoming(saddr->u.fd.str, errp);
> + }
> +#ifdef CONFIG_RDMA
> + } else if (addr->transport == MIGRATION_ADDRESS_TYPE_RDMA) {
> + rdma_connect_incoming(&addr->u.rdma, errp);
> +#endif
> + } else if (addr->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
> + exec_connect_incoming(addr->u.exec.args, errp);
> + } else if (addr->transport == MIGRATION_ADDRESS_TYPE_FILE) {
> + file_connect_incoming(&addr->u.file, errp);
> + } else {
> + error_setg(errp, "unknown migration protocol");
> + }
> +}
> +
> bool migration_has_main_and_multifd_channels(void)
> {
> MigrationIncomingState *mis = migration_incoming_get_current();
> diff --git a/migration/channel.h b/migration/channel.h
> index 19aa5ab795..8264fe327d 100644
> --- a/migration/channel.h
> +++ b/migration/channel.h
> @@ -17,6 +17,7 @@
> #define QEMU_MIGRATION_CHANNEL_H
>
> #include "io/channel.h"
> +#include "qapi/qapi-types-migration.h"
>
> /* Migration channel types */
> typedef enum {
> @@ -38,4 +39,7 @@ int migration_channel_read_peek(QIOChannel *ioc,
> bool migration_has_main_and_multifd_channels(void);
> bool migration_has_all_channels(void);
>
> +void migration_connect_outgoing(MigrationState *s, MigrationAddress *addr,
> + Error **errp);
> +void migration_connect_incoming(MigrationAddress *addr, Error **errp);
> #endif
> diff --git a/migration/migration.c b/migration/migration.c
> index aa291f1fed..3c93fb23cc 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -20,13 +20,10 @@
> #include "qemu/main-loop.h"
> #include "migration/blocker.h"
> #include "exec.h"
> -#include "fd.h"
> #include "file.h"
> -#include "socket.h"
> #include "system/runstate.h"
> #include "system/system.h"
> #include "system/cpu-throttle.h"
> -#include "rdma.h"
> #include "ram.h"
> #include "migration/cpr.h"
> #include "migration/global_state.h"
> @@ -783,26 +780,7 @@ static void qemu_setup_incoming_migration(const char *uri, bool has_channels,
> return;
> }
>
> - if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) {
> - SocketAddress *saddr = &addr->u.socket;
> - if (saddr->type == SOCKET_ADDRESS_TYPE_INET ||
> - saddr->type == SOCKET_ADDRESS_TYPE_UNIX ||
> - saddr->type == SOCKET_ADDRESS_TYPE_VSOCK) {
> - socket_connect_incoming(saddr, errp);
> - } else if (saddr->type == SOCKET_ADDRESS_TYPE_FD) {
> - fd_connect_incoming(saddr->u.fd.str, errp);
> - }
> -#ifdef CONFIG_RDMA
> - } else if (addr->transport == MIGRATION_ADDRESS_TYPE_RDMA) {
> - rdma_connect_incoming(&addr->u.rdma, errp);
> -#endif
> - } else if (addr->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
> - exec_connect_incoming(addr->u.exec.args, errp);
> - } else if (addr->transport == MIGRATION_ADDRESS_TYPE_FILE) {
> - file_connect_incoming(&addr->u.file, errp);
> - } else {
> - error_setg(errp, "unknown migration protocol: %s", uri);
> - }
> + migration_connect_incoming(addr, errp);
>
> /* Close cpr socket to tell source that we are listening */
> cpr_state_close();
> @@ -2234,31 +2212,11 @@ static void qmp_migrate_finish(MigrationAddress *addr, Error **errp)
> MigrationState *s = migrate_get_current();
> Error *local_err = NULL;
>
> - if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) {
> - SocketAddress *saddr = &addr->u.socket;
> - if (saddr->type == SOCKET_ADDRESS_TYPE_INET ||
> - saddr->type == SOCKET_ADDRESS_TYPE_UNIX ||
> - saddr->type == SOCKET_ADDRESS_TYPE_VSOCK) {
> - socket_connect_outgoing(s, saddr, &local_err);
> - } else if (saddr->type == SOCKET_ADDRESS_TYPE_FD) {
> - fd_connect_outgoing(s, saddr->u.fd.str, &local_err);
> - }
> -#ifdef CONFIG_RDMA
> - } else if (addr->transport == MIGRATION_ADDRESS_TYPE_RDMA) {
> - rdma_connect_outgoing(s, &addr->u.rdma, &local_err);
> -#endif
> - } else if (addr->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
> - exec_connect_outgoing(s, addr->u.exec.args, &local_err);
> - } else if (addr->transport == MIGRATION_ADDRESS_TYPE_FILE) {
> - file_connect_outgoing(s, &addr->u.file, &local_err);
> - } else {
> - error_setg(&local_err, "uri is not a valid migration protocol");
> - }
> + migration_connect_outgoing(s, addr, &local_err);
>
> if (local_err) {
> migration_connect_error_propagate(s, error_copy(local_err));
> error_propagate(errp, local_err);
> - return;
> }
> }
>
> --
* Looks okay.
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Thank you.
---
- Prasad