]> git.proxmox.com Git - mirror_qemu.git/commitdiff
virtio: add ability to delete vq through a pointer
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 9 Dec 2019 16:46:13 +0000 (11:46 -0500)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 5 Jan 2020 12:03:03 +0000 (07:03 -0500)
Devices tend to maintain vq pointers, allow deleting them trough a vq pointer.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
hw/virtio/virtio.c
include/hw/virtio/virtio.h

index 04716b5f6ce1ccfb3f21a5b81b770fd8468b553d..31dd140990f784884b541b293105592287776b55 100644 (file)
@@ -2330,17 +2330,22 @@ 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;
+    g_free(vq->used_elems);
+}
+
 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;
-    g_free(vdev->vq[n].used_elems);
+    virtio_delete_queue(&vdev->vq[n]);
 }
 
 static void virtio_set_isr(VirtIODevice *vdev, int value)
index c32a815303730700e60c2ddd06c427189149cb98..e18756d50d21259dda81bf1d1b1da69e3d87b5dd 100644 (file)
@@ -183,6 +183,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);