diff options
| author | Eugenio Pérez <eperezma@redhat.com> | 2022-07-20 08:59:36 +0200 |
|---|---|---|
| committer | Jason Wang <jasowang@redhat.com> | 2022-07-20 16:58:08 +0800 |
| commit | 432efd144e990b6e040862de25f8f0b6a6eeb03d (patch) | |
| tree | 4f8082b0be158a82bf3289c2a94876bce1454d34 /hw/virtio/vhost-shadow-virtqueue.c | |
| parent | ac4cfdc6f39c06732d27554523f9d5f8a53b4ffa (diff) | |
| download | focaccia-qemu-432efd144e990b6e040862de25f8f0b6a6eeb03d.tar.gz focaccia-qemu-432efd144e990b6e040862de25f8f0b6a6eeb03d.zip | |
vhost: add vhost_svq_push_elem
This function allows external SVQ users to return guest's available buffers. Signed-off-by: Eugenio Pérez <eperezma@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'hw/virtio/vhost-shadow-virtqueue.c')
| -rw-r--r-- | hw/virtio/vhost-shadow-virtqueue.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index 8314405e01..1669b1fcd1 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -428,6 +428,22 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq, return g_steal_pointer(&svq->desc_state[used_elem.id].elem); } +/** + * Push an element to SVQ, returning it to the guest. + */ +void vhost_svq_push_elem(VhostShadowVirtqueue *svq, + const VirtQueueElement *elem, uint32_t len) +{ + virtqueue_push(svq->vq, elem, len); + if (svq->next_guest_avail_elem) { + /* + * Avail ring was full when vhost_svq_flush was called, so it's a + * good moment to make more descriptors available if possible. + */ + vhost_handle_guest_kick(svq); + } +} + static void vhost_svq_flush(VhostShadowVirtqueue *svq, bool check_for_avail_queue) { |