qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Halsey Pian <halsey.pian@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Bug] qemu_coroutine_enter abort and report error "Co-routine re-entered recursively"
Date: Fri, 06 Mar 2015 10:44:42 +0100	[thread overview]
Message-ID: <54F9770A.6030205@redhat.com> (raw)
In-Reply-To: <009a01d057db$baf86640$30e932c0$@gmail.com>



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 “"Co-routine re-entered recursively” .
> 
> 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!

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:

1) use one AioContext per file, and add an AioContext-based event loop
to each thread (see backends/iothread.c);

2) use one AioContext per file, add it (as a GSource) to a GMainContext
and use a GMainLoop-based event loop to each thread;

3) use aio_context_acquire and aio_context_release around each blk_* or
bdrv_* call.

Paolo

  parent reply	other threads:[~2015-03-06  9:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-06  7:03 [Qemu-devel] [Bug] qemu_coroutine_enter abort and report error "Co-routine re-entered recursively" Halsey Pian
2015-03-06  7:15 ` Halsey Pian
2015-03-06  9:44 ` Paolo Bonzini [this message]
2015-03-06 11:10   ` Halsey Pian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54F9770A.6030205@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=halsey.pian@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).