On 1/5/22 12:13, Hanna Reitz wrote:
- assert(s->bus->dma->aiocb == NULL); + + /* + * Wait for potentially still-scheduled BHs, like ide_trim_bh_cb() + * (blk_drain() will only poll if there are in-flight requests on the + * BlockBackend, which there may not necessarily be, e.g. when the + * guest has issued a zero-length TRIM request) + */ + while (s->bus->dma->aiocb) { + bool progress = aio_poll(qemu_get_aio_context(), true); + assert(progress); + }
I think the right way to do this is to do blk_inc_in_flight before scheduling the bottom half and blk_dec_in_flight in the BH callback. See virtio_blk_dma_restart_cb for an example.
Paolo