On Thu, 18 Jun 2026 11:58:27 +0100, Daniel P. Berrangé <berrange@redhat.com> wrote:
The removal sequence is:
1. Remove from mon_list under monitor_lock. This must happen before disconnecting chardev handlers to prevent event broadcast from calling monitor_flush_locked() after the gcontext reset, which would create an out_watch on the wrong GMainContext (see monitor_cancel_out_watch()). 2. Cancel any pending out_watch while gcontext still points to the correct context. 3. Disconnect chardev handlers, passing context=NULL and close the connection. 4. Drain pending requests from any in-flight monitor_qmp_read(). 5. Destroy the monitor object
[...]
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> -- Marc-André Lureau <marcandre.lureau@redhat.com>