From 928998018b7c1665c5f033e1609ae32e27a3d2c2 Mon Sep 17 00:00:00 2001 From: Julia Suvorova Date: Wed, 4 Mar 2020 20:07:52 -0500 Subject: [PATCH 10/12] virtio: add ability to delete vq through a pointer RH-Author: Julia Suvorova Message-id: <20200304200754.32708-3-jusual@redhat.com> Patchwork-id: 94153 O-Subject: [RHEL-7.9 qemu-kvm-rhev PATCH 2/4] virtio: add ability to delete vq through a pointer Bugzilla: 1721403 RH-Acked-by: Stefano Garzarella RH-Acked-by: Maxim Levitsky RH-Acked-by: Michael S. Tsirkin From: "Michael S. Tsirkin" Devices tend to maintain vq pointers, allow deleting them trough a vq pointer. Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand Reviewed-by: David Hildenbrand (cherry picked from commit 722f8c51d8af223751dfb1d02de40043e8ba067e) Signed-off-by: Jon Maloy --- hw/virtio/virtio.c | 13 +++++++++---- include/hw/virtio/virtio.h | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index d228b9297d..29d8502500 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1602,16 +1602,21 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size, return &vdev->vq[i]; } +void virtio_delete_queue(VirtQueue *vq) +{ + vq->vring.num = 0; + vq->vring.num_default = 0; + vq->handle_output = NULL; + vq->handle_aio_output = NULL; +} + void virtio_del_queue(VirtIODevice *vdev, int n) { if (n < 0 || n >= VIRTIO_QUEUE_MAX) { abort(); } - vdev->vq[n].vring.num = 0; - vdev->vq[n].vring.num_default = 0; - vdev->vq[n].handle_output = NULL; - vdev->vq[n].handle_aio_output = NULL; + virtio_delete_queue(&vdev->vq[n]); } static void virtio_set_isr(VirtIODevice *vdev, int value) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 302975889b..8b348be70c 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -164,6 +164,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size, void virtio_del_queue(VirtIODevice *vdev, int n); +void virtio_delete_queue(VirtQueue *vq); + void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len); void virtqueue_flush(VirtQueue *vq, unsigned int count); -- 2.18.2