Received: from eggs.gnu.org ([2001:4830:134:3::10]:50671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bT4wa-0007mD-To for qemu-devel@nongnu.org; Fri, 29 Jul 2016 06:23:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bT4wW-0001LM-Ne for qemu-devel@nongnu.org; Fri, 29 Jul 2016 06:23:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bT4wW-0001L5-HP for qemu-devel@nongnu.org; Fri, 29 Jul 2016 06:23:00 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 741C63F725 for ; Fri, 29 Jul 2016 10:22:59 +0000 (UTC) From: Fam Zheng Date: Fri, 29 Jul 2016 18:22:57 +0800 Message-Id: <1469787777-10688-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH] virtio-blk: Release s->rq queue at system_reset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, lersek@redhat.com 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 --- hw/block/virtio-blk.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 475a822..89eca65 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -654,6 +654,7 @@ static void virtio_blk_reset(VirtIODevice *vdev) { VirtIOBlock *s = VIRTIO_BLK(vdev); AioContext *ctx; + VirtIOBlockReq *req; /* * This should cancel pending requests, but can't do nicely until there @@ -661,6 +662,11 @@ static void virtio_blk_reset(VirtIODevice *vdev) */ ctx = blk_get_aio_context(s->blk); aio_context_acquire(ctx); + while (s->rq) { + req = s->rq; + s->rq = req->next; + virtio_blk_free_request(req); + } blk_drain(s->blk); if (s->dataplane) { -- 2.7.4