On 23/10/2025 03:26, Peter Xu wrote:
> It's almost there, except that currently it relies on a global flag showing
> that it's in incoming migration.
>
> Change it to detect coroutine instead.
>
> Then we achieved two things in one shot:
>
> - Drop migration_started_on_destination, which is not needed anymore, and
> - It starts to work in a thread when loadvm using RDMA
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
> ---
> migration/rdma.c | 15 +--------------
> 1 file changed, 1 insertion(+), 14 deletions(-)
>
> diff --git a/migration/rdma.c b/migration/rdma.c
> index e6837184c8..13dd391c14 100644
> --- a/migration/rdma.c
> +++ b/migration/rdma.c
> @@ -357,13 +357,6 @@ typedef struct RDMAContext {
> /* Index of the next RAMBlock received during block registration */
> unsigned int next_src_index;
>
> - /*
> - * Migration on *destination* started.
> - * Then use coroutine yield function.
> - * Source runs in a thread, so we don't care.
> - */
> - int migration_started_on_destination;
> -
> int total_registrations;
> int total_writes;
>
> @@ -1352,12 +1345,7 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *rdma,
> {
> struct rdma_cm_event *cm_event;
>
> - /*
> - * Coroutine doesn't start until migration_fd_process_incoming()
> - * so don't yield unless we know we're running inside of a coroutine.
> - */
> - if (rdma->migration_started_on_destination &&
> - migration_incoming_get_current()->state == MIGRATION_STATUS_ACTIVE) {
> + if (qemu_in_coroutine()) {
> yield_until_fd_readable(comp_channel->fd);
> } else {
> /* This is the source side, we're in a separate thread
> @@ -3884,7 +3872,6 @@ static void rdma_accept_incoming_migration(void *opaque)
> return;
> }
>
> - rdma->migration_started_on_destination = 1;
> migration_fd_process_incoming(f);
> }
>