All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: svt-core@virtuozzo.com
Cc: andrey.drobyshev@virtuozzo.com, den@openvz.org
Subject: [PATCH hci-8.0/8.1] monitor/qmp: fix the RESUME event lost after cpr-exec #VSTOR-155261
Date: Thu, 19 Nov 2026 23:08:15 +0100	[thread overview]
Message-ID: <20261119220815.1644962-1-den@openvz.org> (raw)

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
-- 
2.55.0


             reply	other threads:[~2026-11-19 22:08 UTC|newest]

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

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=20261119220815.1644962-1-den@openvz.org \
    --to=den@openvz.org \
    --cc=andrey.drobyshev@virtuozzo.com \
    --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.