Commit 24a6fb44 authored by Sasha Levin's avatar Sasha Levin Committed by Will Deacon
Browse files

kvm tools: Prepare support for VIRTIO_RING_F_EVENT_IDX

This patch is the base for enabling support for event index feature in the virtio spec.
We do so by updating and evaluating the used/avail event idx in the virtio ring functions.

Actual usage of this flag is in the following patches.

The results are less notifications between the guest and host, and in
result faster operation of the virt queues.

Signed-off-by: default avatarSasha Levin <>
Signed-off-by: default avatarPekka Enberg <>
parent a8e6b4b9
......@@ -38,6 +38,8 @@ static inline bool virt_queue__available(struct virt_queue *vq)
if (!vq->vring.avail)
return 0;
vring_avail_event(&vq->vring) = vq->last_avail_idx;
return vq->vring.avail->idx != vq->last_avail_idx;
......@@ -51,6 +53,11 @@ static inline void *guest_pfn_to_host(struct kvm *kvm, u32 pfn)
return guest_flat_to_host(kvm, (unsigned long)pfn << VIRTIO_PCI_QUEUE_ADDR_SHIFT);
static inline int virtio_queue__should_signal(struct virt_queue *vq)
return vring_used_event(&vq->vring) <= vq->vring.used->idx;
struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, u32 head, u32 len);
u16 virt_queue__get_iov(struct virt_queue *queue, struct iovec iov[], u16 *out, u16 *in, struct kvm *kvm);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment