On Tue, Dec 05, 2017 at 01:51:55PM +0800, Peter Xu wrote:
> @@ -4429,6 +4515,13 @@ void monitor_cleanup(void)
>       */
>      iothread_stop(mon_global.mon_iothread);
>  
> +    /*
> +     * After we have IOThread to send responses, it's possible that
> +     * when we stop the IOThread there are still replies queued in the
> +     * responder queue.  Flush all of them.
> +     */
> +    monitor_qmp_bh_responder(NULL);

This doesn't work because monitor_qmp_bh_responder() does not guarantee
that the full response has been written when it returns.

When qemu_chr_fe_write() returns EAGAIN then qemu_chr_fe_add_watch() is
used to register an event loop callback when the chardev becomes
writable again.  But you stopped the event loop using iothread_stop() so
we will never complete the write.

I suggest draining the monitor while the IOThread is still running
(that way the AioContext and GMainContext are still operational).  You
can:
1. Suspend the monitor so new commands will not be read.
2. Wait until all responses and outbuf are empty.

Another option is moving the chardev back to the main loop but I'm not
sure if the chardev subsystem supports that.

Attachment: signature.asc
Description: PGP signature

Reply via email to