From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eTLBX-0004nQ-Tm for qemu-devel@nongnu.org; Mon, 25 Dec 2017 00:20:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eTLBW-0001Ey-Vc for qemu-devel@nongnu.org; Mon, 25 Dec 2017 00:20:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58600) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eTLBW-0001Ee-NX for qemu-devel@nongnu.org; Mon, 25 Dec 2017 00:20:22 -0500 Date: Mon, 25 Dec 2017 13:20:11 +0800 From: Peter Xu Message-ID: <20171225052011.GG2443@xz-mi> References: <20171219084557.9801-1-peterx@redhat.com> <20171219084557.9801-23-peterx@redhat.com> <20171221125702.GS10812@lemon> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20171221125702.GS10812@lemon> Subject: Re: [Qemu-devel] [RFC v6 22/27] qmp: isolate responses into io thread List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: qemu-devel@nongnu.org, Stefan Hajnoczi , "Daniel P . Berrange" , Paolo Bonzini , Juan Quintela , mdroth@linux.vnet.ibm.com, Eric Blake , Laurent Vivier , Markus Armbruster , marcandre.lureau@redhat.com, "Dr . David Alan Gilbert" 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 > > Reviewed-by: Fam Zheng Thanks! -- Peter Xu