* [PATCH hci-8.0/8.1] monitor/qmp: fix the RESUME event lost after cpr-exec #VSTOR-155261
@ 2026-11-19 22:08 Denis V. Lunev
2026-11-20 10:34 ` Andrey Drobyshev
0 siblings, 1 reply; 2+ messages in thread
From: Denis V. Lunev @ 2026-11-19 22:08 UTC (permalink / raw)
To: svt-core; +Cc: andrey.drobyshev, den
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH hci-8.0/8.1] monitor/qmp: fix the RESUME event lost after cpr-exec #VSTOR-155261
2026-11-19 22:08 [PATCH hci-8.0/8.1] monitor/qmp: fix the RESUME event lost after cpr-exec #VSTOR-155261 Denis V. Lunev
@ 2026-11-20 10:34 ` Andrey Drobyshev
0 siblings, 0 replies; 2+ messages in thread
From: Andrey Drobyshev @ 2026-11-20 10:34 UTC (permalink / raw)
To: Denis V. Lunev, svt-core
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>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-20 10:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 22:08 [PATCH hci-8.0/8.1] monitor/qmp: fix the RESUME event lost after cpr-exec #VSTOR-155261 Denis V. Lunev
2026-11-20 10:34 ` Andrey Drobyshev
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.