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