From fa375a2aa1b77130defc9271e3e22c38fc065e36 Mon Sep 17 00:00:00 2001 From: Peter Fang Date: Sun, 17 Mar 2019 02:11:12 -0700 Subject: [PATCH] dm: virtio: ensure interrupt delivery in virtio-blk virtio-blk never sets used_all_avail when calling vq_endchains(), which may become problematic if VIRTIO_F_NOTIFY_ON_EMPTY is enabled. Provide vq_endchains() with that info to ensure the delivery of an interrupt when the avail ring is drained in the case of VIRTIO_F_NOTIFY_ON_EMPTY. Tracked-On: #2763 Signed-off-by: Peter Fang Reviewed-by: Shuo A Liu --- devicemodel/hw/pci/virtio/virtio_block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devicemodel/hw/pci/virtio/virtio_block.c b/devicemodel/hw/pci/virtio/virtio_block.c index cb7d384c0..2920af79e 100644 --- a/devicemodel/hw/pci/virtio/virtio_block.c +++ b/devicemodel/hw/pci/virtio/virtio_block.c @@ -201,7 +201,7 @@ virtio_blk_done(struct blockif_req *br, int err) */ pthread_mutex_lock(&blk->mtx); vq_relchain(&blk->vq, io->idx, 1); - vq_endchains(&blk->vq, 0); + vq_endchains(&blk->vq, !vq_has_descs(&blk->vq)); pthread_mutex_unlock(&blk->mtx); }