When a disk is attached to scsi-bus, virtio_scsi_hotplug will take care
of protecting the block device with op blockers. Currently we haven't
enabled block jobs (like what's done in virtio_blk_data_plane_create),
but it is necessary to honor "device IO" op blocker first before we do.
This is useful to make sure that guest IO requests are paused during qmp
transactions (such as multi-disk snapshot or backup).
A counter is added to the virtio-scsi device, which keeps track of
currently blocked disks. If it goes from 0 to 1, the ioeventfds are
disabled; when it goes back to 0, they are re-enabled.
Also in device initialization, push the enabling of ioeventfds to before
return, so the virtio_scsi_clear_aio is not needed there. Rename it,
pair with an enabling variant, fix one coding style issue, then use it
in the device pause points.
Signed-off-by: Fam Zheng <address@hidden>
hw/scsi/virtio-scsi-dataplane.c | 82 +++++++++++++++++++++++++++++++----------
hw/scsi/virtio-scsi.c | 3 ++
include/hw/virtio/virtio-scsi.h | 3 ++
3 files changed, 68 insertions(+), 20 deletions(-)