On Thu, Dec 21, 2017 at 08:57:02PM +0800, Fam Zheng wrote: > On Tue, 12/19 16:45, Peter Xu wrote: > > For those monitors who has enabled IO thread, we'll offload the > > s/has/have/ > > > responding procedure into IO thread. The main reason is that chardev is > > not thread safe, and we need to do all the read/write IOs in the same > > thread. For use_io_thr=true monitors, that thread is the IO thread. > > > > We do this isolation in similar pattern as what we have done to the > > request queue: we first create one response queue for each monitor, then > > instead of reply directly in main thread, we queue the responses and > > s/reply/replying/ > > s/main thread/the main thread/
Fixed all. > > > kick the IO thread to do the rest of the job for us. > > > > A funny thing after doing this is that, when the QMP clients send "quit" > > to QEMU, it's possible that we close the IOThread even earlier than > > replying to that "quit". So another thing we need to do before cleaning > > up the monitors is that we need to flush the response queue (we don't > > need to do that for command queue; after all we are quitting) to make > > sure replies for handled commands are always flushed back to clients. > > > > Signed-off-by: Peter Xu <pet...@redhat.com> > > Reviewed-by: Fam Zheng <f...@redhat.com> Thanks! -- Peter Xu