cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

Pablo Greco e6a3ae
From 0f56ff85e38a3925ba8c63af9fcf6a0708f0d10f Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Julia Suvorova <jusual@redhat.com>
Pablo Greco e6a3ae
Date: Tue, 4 Feb 2020 18:20:05 +0000
Pablo Greco e6a3ae
Subject: [PATCH 4/6] virtio: add ability to delete vq through a pointer
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Julia Suvorova <jusual@redhat.com>
Pablo Greco e6a3ae
Message-id: <20200204182007.183537-3-jusual@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 93705
Pablo Greco e6a3ae
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH 2/4] virtio: add ability to delete vq through a pointer
Pablo Greco e6a3ae
Bugzilla: 1708480
Pablo Greco e6a3ae
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
From: "Michael S. Tsirkin" <mst@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Devices tend to maintain vq pointers, allow deleting them trough a vq pointer.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Pablo Greco e6a3ae
Reviewed-by: David Hildenbrand <david@redhat.com>
Pablo Greco e6a3ae
Reviewed-by: David Hildenbrand <david@redhat.com>
Pablo Greco e6a3ae
(cherry picked from commit 722f8c51d8af223751dfb1d02de40043e8ba067e)
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 hw/virtio/virtio.c         | 13 +++++++++----
Pablo Greco e6a3ae
 include/hw/virtio/virtio.h |  2 ++
Pablo Greco e6a3ae
 2 files changed, 11 insertions(+), 4 deletions(-)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
Pablo Greco e6a3ae
index 6356bf3..624f6e2 100644
Pablo Greco e6a3ae
--- a/hw/virtio/virtio.c
Pablo Greco e6a3ae
+++ b/hw/virtio/virtio.c
Pablo Greco e6a3ae
@@ -1601,16 +1601,21 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
Pablo Greco e6a3ae
     return &vdev->vq[i];
Pablo Greco e6a3ae
 }
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
+void virtio_delete_queue(VirtQueue *vq)
Pablo Greco e6a3ae
+{
Pablo Greco e6a3ae
+    vq->vring.num = 0;
Pablo Greco e6a3ae
+    vq->vring.num_default = 0;
Pablo Greco e6a3ae
+    vq->handle_output = NULL;
Pablo Greco e6a3ae
+    vq->handle_aio_output = NULL;
Pablo Greco e6a3ae
+}
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
 void virtio_del_queue(VirtIODevice *vdev, int n)
Pablo Greco e6a3ae
 {
Pablo Greco e6a3ae
     if (n < 0 || n >= VIRTIO_QUEUE_MAX) {
Pablo Greco e6a3ae
         abort();
Pablo Greco e6a3ae
     }
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
-    vdev->vq[n].vring.num = 0;
Pablo Greco e6a3ae
-    vdev->vq[n].vring.num_default = 0;
Pablo Greco e6a3ae
-    vdev->vq[n].handle_output = NULL;
Pablo Greco e6a3ae
-    vdev->vq[n].handle_aio_output = NULL;
Pablo Greco e6a3ae
+    virtio_delete_queue(&vdev->vq[n]);
Pablo Greco e6a3ae
 }
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
 static void virtio_set_isr(VirtIODevice *vdev, int value)
Pablo Greco e6a3ae
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
Pablo Greco e6a3ae
index 9c1fa07..90471a1 100644
Pablo Greco e6a3ae
--- a/include/hw/virtio/virtio.h
Pablo Greco e6a3ae
+++ b/include/hw/virtio/virtio.h
Pablo Greco e6a3ae
@@ -163,6 +163,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
 void virtio_del_queue(VirtIODevice *vdev, int n);
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
+void virtio_delete_queue(VirtQueue *vq);
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
 void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
Pablo Greco e6a3ae
                     unsigned int len);
Pablo Greco e6a3ae
 void virtqueue_flush(VirtQueue *vq, unsigned int count);
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae