All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
To: "Denis V. Lunev" <den@openvz.org>, svt-core@virtuozzo.com
Subject: Re: [PATCH hci-8.0/8.1] monitor/qmp: fix the RESUME event lost after cpr-exec #VSTOR-155261
Date: Fri, 20 Nov 2026 12:34:59 +0200	[thread overview]
Message-ID: <791d0ef3-8225-4ea5-962c-8ee009ac3b12@virtuozzo.com> (raw)
In-Reply-To: <20261119220815.1644962-1-den@openvz.org>

On 11/20/26 12:08 AM, Denis V. Lunev wrote:
> From: Denis V. Lunev <den@openvz.org>
> 
> After cpr-exec the new QEMU keeps the QMP connection of the old one. It
> hands the monitor over to the monitor I/O thread and goes on without
> waiting, so the main thread loads the incoming state and starts the VM
> while the monitor may not be attached yet. Until it is, every event is
> dropped. Where the attach lands decides the outcome:
> 
>   main thread:  load state ... | VM starts, RESUME ... | incoming ends
>   attached in:       A                   B                    C
> 
>   A  qemu-update works.
>   B  RESUME is dropped. virsh qemu-update waits for it and hangs.
>   C  The monitor no longer knows the connection is inherited and waits
>      for capabilities negotiation, which libvirt never repeats. Every
>      later command fails and no event is delivered.
> 
> A late I/O thread gives B or C. Wait for it when cpr-exec is incoming,
> so the attach is always in A. Other starts keep the asynchronous path.
> 
> Fixes: d9a445fa80da ("migration/cpr-exec: preserve monitor state")
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> ---
>  monitor/qmp.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/monitor/qmp.c b/monitor/qmp.c
> index 22e253bfcd4..4df1341b18b 100644
> --- a/monitor/qmp.c
> +++ b/monitor/qmp.c
> @@ -24,6 +24,7 @@
>  
>  #include "qemu/osdep.h"
>  
> +#include "block/aio-wait.h"
>  #include "chardev/char-io.h"
>  #include "monitor-internal.h"
>  #include "migration/cpr.h"
> @@ -554,8 +555,14 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
>           * since chardev might be running in the monitor I/O
>           * thread.  Schedule a bottom half.
>           */
> -        aio_bh_schedule_oneshot(iothread_get_aio_context(mon_iothread),
> +        if (cpr_exec_is_incoming()) {
> +            /* Attach before the incoming VM starts, or its events are lost */
> +            aio_wait_bh_oneshot(iothread_get_aio_context(mon_iothread),
>                                  monitor_qmp_setup_handlers_bh, mon);
> +        } else {
> +            aio_bh_schedule_oneshot(iothread_get_aio_context(mon_iothread),
> +                                    monitor_qmp_setup_handlers_bh, mon);
> +        }
>          /* The bottom half will add @mon to @mon_list */
>      } else {
>          qemu_chr_fe_set_handlers(&mon->common.chr, monitor_can_read,
> 
> base-commit: 6688edf6175aac2750e35e6f58f4b2a92c73dfdc

Reviewed-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>

      reply	other threads:[~2026-11-20 10:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 22:08 Denis V. Lunev
2026-11-20 10:34 ` Andrey Drobyshev [this message]

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=791d0ef3-8225-4ea5-962c-8ee009ac3b12@virtuozzo.com \
    --to=andrey.drobyshev@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=svt-core@virtuozzo.com \
    /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.