From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTq9k-0005e1-AX for qemu-devel@nongnu.org; Fri, 06 Mar 2015 06:11:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YTq9h-0006UL-45 for qemu-devel@nongnu.org; Fri, 06 Mar 2015 06:11:00 -0500 Received: from mail-pd0-x22b.google.com ([2607:f8b0:400e:c02::22b]:34675) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTq9g-0006UE-Sk for qemu-devel@nongnu.org; Fri, 06 Mar 2015 06:10:57 -0500 Received: by pdno5 with SMTP id o5so241309pdn.1 for ; Fri, 06 Mar 2015 03:10:56 -0800 (PST) From: "Halsey Pian" References: <009a01d057db$baf86640$30e932c0$@gmail.com> <54F9770A.6030205@redhat.com> In-Reply-To: <54F9770A.6030205@redhat.com> Date: Fri, 6 Mar 2015 19:10:43 +0800 Message-ID: <001d01d057fe$3916f560$ab44e020$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Subject: Re: [Qemu-devel] [Bug] qemu_coroutine_enter abort and report error "Co-routine re-entered recursively" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: 'Paolo Bonzini' , qemu-devel@nongnu.org Cc: halsey.pian@gmail.com > -----Original Message----- > From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of = Paolo Bonzini > Sent: 2015=E5=B9=B43=E6=9C=886=E6=97=A5 17:45 > To: Halsey Pian; qemu-devel@nongnu.org > Subject: Re: [Bug] qemu_coroutine_enter abort and report error = "Co-routine re-entered recursively" >=20 >=20 >=20 > On 06/03/2015 08:03, Halsey Pian wrote: > > I have two threads to write two seperate qcow2 files, but after a > > while, the writing would be aborted in qemu_coroutine_enter, and > > report error =E2=80=9C"Co-routine re-entered recursively=E2=80=9D . > > > > Qemu should be thread safe, right? It seems that there are some > > variables is not thread safe? Could you have a chance to look it? = Thanks! >=20 > QEMU is thread safe but you need to add explicit locking or use = separate event loops in each thread. If you want to write from > separate thread, you need to do one of the following: >=20 > 1) use one AioContext per file, and add an AioContext-based event loop = to each thread (see backends/iothread.c); >=20 > 2) use one AioContext per file, add it (as a GSource) to a = GMainContext and use a GMainLoop-based event loop to each thread; >=20 > 3) use aio_context_acquire and aio_context_release around each blk_* = or > bdrv_* call. >=20 > Paolo Hi Paolo, Thanks for your immediate reply.=20 I checked relevant source code, and I'm trying changing AioContext. = Would keep changing based on your comments. Thank you! [Halsey]=20