[PATCH RFC 3/9] migration/rdma: Allow qemu_rdma_wait_comp_channel work with thread

Peter Xu posted 9 patches 1 month ago
Maintainers: Alex Williamson <alex.williamson@redhat.com>, "Cédric Le Goater" <clg@redhat.com>, Hailiang Zhang <zhanghailiang@xfusion.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Li Zhijian <lizhijian@fujitsu.com>
[PATCH RFC 3/9] migration/rdma: Allow qemu_rdma_wait_comp_channel work with thread
Posted by Peter Xu 1 month ago
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.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/rdma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/migration/rdma.c b/migration/rdma.c
index e6837184c8..ed4e20b988 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -1357,7 +1357,8 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *rdma,
      * 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) {
+        migration_incoming_get_current()->state == MIGRATION_STATUS_ACTIVE &&
+        qemu_in_coroutine()) {
         yield_until_fd_readable(comp_channel->fd);
     } else {
         /* This is the source side, we're in a separate thread
-- 
2.50.1
Re: [PATCH RFC 3/9] migration/rdma: Allow qemu_rdma_wait_comp_channel work with thread
Posted by Zhijian Li (Fujitsu) 2 days, 14 hours ago

On 28/08/2025 04:59, 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.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>


Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>


> ---
>   migration/rdma.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/migration/rdma.c b/migration/rdma.c
> index e6837184c8..ed4e20b988 100644
> --- a/migration/rdma.c
> +++ b/migration/rdma.c
> @@ -1357,7 +1357,8 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *rdma,
>        * 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) {
> +        migration_incoming_get_current()->state == MIGRATION_STATUS_ACTIVE &&
> +        qemu_in_coroutine()) {
>           yield_until_fd_readable(comp_channel->fd);
>       } else {
>           /* This is the source side, we're in a separate thread
Re: [PATCH RFC 3/9] migration/rdma: Allow qemu_rdma_wait_comp_channel work with thread
Posted by Fabiano Rosas 1 week, 4 days ago
Peter Xu <peterx@redhat.com> writes:

> 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.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  migration/rdma.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/migration/rdma.c b/migration/rdma.c
> index e6837184c8..ed4e20b988 100644
> --- a/migration/rdma.c
> +++ b/migration/rdma.c
> @@ -1357,7 +1357,8 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *rdma,
>       * 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) {
> +        migration_incoming_get_current()->state == MIGRATION_STATUS_ACTIVE &&
> +        qemu_in_coroutine()) {
>          yield_until_fd_readable(comp_channel->fd);
>      } else {
>          /* This is the source side, we're in a separate thread

Reviewed-by: Fabiano Rosas <farosas@suse.de>