virtio: virtqueue_ordered_flush - VIRTIO_F_IN_ORDER support
authorJonah Palmer <jonah.palmer@oracle.com>
Wed, 10 Jul 2024 12:55:17 +0000 (08:55 -0400)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 21 Jul 2024 18:45:56 +0000 (14:45 -0400)
commit844619147c5110f335cbbbad51cda6a898c7ef33
tree1ed8cf01d18098c3351b5619e7947052c274c4d0
parentb44135daa3721778f4656ca3c15bd9b3060f1176
virtio: virtqueue_ordered_flush - VIRTIO_F_IN_ORDER support

Add VIRTIO_F_IN_ORDER feature support for the virtqueue_flush operation.

The goal of the virtqueue_ordered_flush operation when the
VIRTIO_F_IN_ORDER feature has been negotiated is to write elements to
the used/descriptor ring in-order and then update used_idx.

The function iterates through the VirtQueueElement used_elems array
in-order starting at vq->used_idx. If the element is valid (filled), the
element is written to the used/descriptor ring. This process continues
until we find an invalid (not filled) element.

For packed VQs, the first entry (at vq->used_idx) is written to the
descriptor ring last so the guest doesn't see any invalid descriptors.

If any elements were written, the used_idx is updated.

Signed-off-by: Jonah Palmer <jonah.palmer@oracle.com>
Message-Id: <20240710125522.4168043-5-jonah.palmer@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
hw/virtio/virtio.c