Blame SOURCES/kvm-virtio-add-ability-to-delete-vq-through-a-pointer.patch

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