Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- hw/block/dataplane/virtio-blk.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c index 704a763..dce2675 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -51,30 +51,23 @@ void virtio_blk_data_plane_notify(VirtIOBlockDataPlane *s, VirtQueue *vq) qemu_bh_schedule(s->bh); } -static void notify_guest_bh(void *opaque) +static void notify_vq(int i, void *opaque) { VirtIOBlockDataPlane *s = opaque; - unsigned nvqs = s->conf->num_queues; - unsigned long bitmap[BITS_TO_LONGS(nvqs)]; - unsigned j; - - memcpy(bitmap, s->batch_notify_vqs, sizeof(bitmap)); - memset(s->batch_notify_vqs, 0, sizeof(bitmap)); + VirtQueue *vq = virtio_get_queue(s->vdev, i); - for (j = 0; j < nvqs; j += BITS_PER_LONG) { - unsigned long bits = bitmap[j]; + if (virtio_should_notify(s->vdev, vq)) { + event_notifier_set(virtio_queue_get_guest_notifier(vq)); + } - while (bits != 0) { - unsigned i = j + ctzl(bits); - VirtQueue *vq = virtio_get_queue(s->vdev, i); +} - if (virtio_should_notify(s->vdev, vq)) { - event_notifier_set(virtio_queue_get_guest_notifier(vq)); - } +static void notify_guest_bh(void *opaque) +{ + VirtIOBlockDataPlane *s = opaque; + unsigned nvqs = s->conf->num_queues; - bits &= bits - 1; /* clear right-most bit */ - } - } + bitmap_foreach(s->batch_notify_vqs, nvqs, notify_vq, s); } /* Context: QEMU global mutex held */ -- 2.9.0