I found blk_drain() is invoked by virtio_blk_reset(), so only the second question remains :).
发件人: zhukeqian <> 发送时间: 2023年1月16日 16:18 收件人: 'Michael S. Tsirkin' <m...@redhat.com>; 'Stefan Hajnoczi' <stefa...@redhat.com>; 'Peter Maydell' <peter.mayd...@linaro.org> 抄送: qemu-devel@nongnu.org; Wubin (H) <wu.wu...@huawei.com>; Chentao (Boby) <boby.c...@huawei.com>; Wanghaibin (D) <wanghaibin.w...@huawei.com>; Zhangbo (Oscar) <oscar.zhan...@huawei.com>; limingwang (A) <limingw...@huawei.com>; Wangyan <wangyan...@huawei.com>; lihuachao <lihuach...@huawei.com> 主题: [QUESTION] About virtio and eventloop Hi all maintainers and community friends, Recently I am reviewing and learning the virtio and eventloop implementation of latest QEMU, and now I have a questions for help: In general, the IO requests of virtio is popped in iothread/mainloop and may submitted to “async IO Engine” (io_uring/linux aio/threadpool). Once the IO operation is done, the “async IO engine” will send notification to iothread/mainloop through evenfd or bottomhalf, and the completion action for the IO request (add used ring and notify guest) is done in iothread/mainloop. And let’s look at the “deactive” procedure of virtio-pci devices (when guest write 0 to device status or system triggered reset), the basic requirement is that device should stop handling IO requests and accessing virtqueue before returning back to guest, as the guest may destroy virqueue once deactivation is done. QEMU invokes stop_ioeventfd() callback to perform above actions. It unregisters ioeventfd from eventloop and KVM, 1. but I can’t find code that ensuring IO operations in “async IO engine” are done. 2. And if IO operation is blocked, is vCPU thread will blocked when do deactivate? It’s great that if anyone can help! Thanks, Keqian