On Fri, Oct 28, 2011 at 1:29 PM, Kevin Wolf <kw...@redhat.com> wrote: > Am 28.10.2011 13:50, schrieb Paolo Bonzini: >> On 10/28/2011 01:33 PM, Kevin Wolf wrote: >>> I'm afraid that we can only avoid things like this reliably if we >>> convert all devices to be direct users of AIO/coroutines. The current >>> block layer infrastructure doesn't emulate the behaviour of bdrv_read >>> accurately as bottom halves can be run in the nested main loop. >>> >>> For floppy, the following seems to be a quick fix (Lucas, Cleber, does >>> this solve your problems?), though it's not very satisfying. And I'm not >>> quite sure yet why it doesn't always happen with kill() in >>> posix-aio-compat.c. >> >> Another "fix" is to change idle bottom halves (at least the one in >> hw/dma.c) to 10ms timers. > > Which would be using the fact that timers are only executed in the real > main loop. Which makes me wonder if it would be enough for floppy if we > changed qemu_bh_poll() to take a bool run_idle_bhs that would be true in > the main loop and false an qemu_aio_wait(). > > Still this wouldn't be a general solution as normal BHs have the very > same problem if they are scheduled before a bdrv_read/write call. To > solve that I guess we'd have to reintroduce AsyncContext, but it has its > own problems and was removed for a reason. > > Or we make some serious effort now to convert devices to AIO.
Zhi Yong: We were just talking about converting devices to aio. If you have time to do that for fdc, sd, or any other synchronous API users in hw/ that would be helpful. Please let us know which device you are refactoring so we don't duplicate work. Stefan