From cc9a8ce29ba364abcf019f6fe44b218255b9e4d7 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Wed, 8 Feb 2017 07:05:34 +0100 Subject: [PATCH 1/8] virtio-blk: Release s->rq queue at system_reset RH-Author: Fam Zheng Message-id: <20170208070534.10571-1-famz@redhat.com> Patchwork-id: 73642 O-Subject: [RHEL-7.3.z qemu-kvm PATCH] virtio-blk: Release s->rq queue at system_reset Bugzilla: 1420049 RH-Acked-by: Paolo Bonzini RH-Acked-by: Laszlo Ersek RH-Acked-by: Laurent Vivier At system_reset, there is no point in retrying the queued request, because the driver that issued the request won't be around any more. Analyzed-by: Laszlo Ersek Reported-by: Laszlo Ersek Signed-off-by: Fam Zheng Reviewed-by: Laszlo Ersek Message-id: 1470278654-13525-2-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi (cherry picked from commit 26307f6aa451708b8c60a49d605a78bbd29f70ef) Conflicts: hw/block/virtio-blk.c The context is different. The hunk is placed below bdrv_drain_all() with the comment updated to match downstream. There is no virtio_blk_free_request in qemu-kvm in RHEL 7, use g_free(). Signed-off-by: Fam Zheng Signed-off-by: Miroslav Rezanina --- hw/block/virtio-blk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 4f6aa22..462ac81 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -474,6 +474,7 @@ static void virtio_blk_dma_restart_cb(void *opaque, int running, static void virtio_blk_reset(VirtIODevice *vdev) { VirtIOBlock *s = VIRTIO_BLK(vdev); + VirtIOBlockReq *req; #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE if (s->dataplane) { @@ -487,6 +488,13 @@ static void virtio_blk_reset(VirtIODevice *vdev) */ bdrv_drain_all(); bdrv_set_enable_write_cache(s->bs, s->original_wce); + /* We drop queued requests after bdrv_drain_all() because bdrv_drain_all() + * itself can produce them. */ + while (s->rq) { + req = s->rq; + s->rq = req->next; + g_free(req); + } } /* coalesce internal state, copy to pci i/o region 0 -- 1.8.3.1