016a62
From 335e94e588ded0f1163ef20c72d78fcf725b1236 Mon Sep 17 00:00:00 2001
016a62
From: Julia Suvorova <jusual@redhat.com>
016a62
Date: Tue, 4 Feb 2020 18:20:04 +0000
016a62
Subject: [PATCH 3/6] clean up callback when del virtqueue
016a62
016a62
RH-Author: Julia Suvorova <jusual@redhat.com>
016a62
Message-id: <20200204182007.183537-2-jusual@redhat.com>
016a62
Patchwork-id: 93703
016a62
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH 1/4] clean up callback when del virtqueue
016a62
Bugzilla: 1708480
016a62
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
016a62
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
016a62
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
016a62
016a62
From: liujunjie <liujunjie23@huawei.com>
016a62
016a62
Before, we did not clear callback like handle_output when delete
016a62
the virtqueue which may result be segmentfault.
016a62
The scene is as follows:
016a62
1. Start a vm with multiqueue vhost-net,
016a62
2. then we write VIRTIO_PCI_GUEST_FEATURES in PCI configuration to
016a62
triger multiqueue disable in this vm which will delete the virtqueue.
016a62
In this step, the tx_bh is deleted but the callback virtio_net_handle_tx_bh
016a62
still exist.
016a62
3. Finally, we write VIRTIO_PCI_QUEUE_NOTIFY in PCI configuration to
016a62
notify the deleted virtqueue. In this way, virtio_net_handle_tx_bh
016a62
will be called and qemu will be crashed.
016a62
016a62
Although the way described above is uncommon, we had better reinforce it.
016a62
016a62
CC: qemu-stable@nongnu.org
016a62
Signed-off-by: liujunjie <liujunjie23@huawei.com>
016a62
Signed-off-by: Jason Wang <jasowang@redhat.com>
016a62
(cherry picked from commit 7da2d99fb9fbf30104125c061caaff330e362d74)
016a62
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
016a62
---
016a62
 hw/virtio/virtio.c | 2 ++
016a62
 1 file changed, 2 insertions(+)
016a62
016a62
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
016a62
index fce199e..6356bf3 100644
016a62
--- a/hw/virtio/virtio.c
016a62
+++ b/hw/virtio/virtio.c
016a62
@@ -1609,6 +1609,8 @@ void virtio_del_queue(VirtIODevice *vdev, int n)
016a62
 
016a62
     vdev->vq[n].vring.num = 0;
016a62
     vdev->vq[n].vring.num_default = 0;
016a62
+    vdev->vq[n].handle_output = NULL;
016a62
+    vdev->vq[n].handle_aio_output = NULL;
016a62
 }
016a62
 
016a62
 static void virtio_set_isr(VirtIODevice *vdev, int value)
016a62
-- 
016a62
1.8.3.1
016a62