From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mbbcx-0001QJ-Rw for qemu-devel@nongnu.org; Thu, 13 Aug 2009 10:50:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mbbct-0001Oz-DV for qemu-devel@nongnu.org; Thu, 13 Aug 2009 10:50:03 -0400 Received: from [199.232.76.173] (port=54974 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mbbct-0001Ov-6n for qemu-devel@nongnu.org; Thu, 13 Aug 2009 10:49:59 -0400 Received: from verein.lst.de ([213.95.11.210]:36247) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1Mbbcs-0006wa-DN for qemu-devel@nongnu.org; Thu, 13 Aug 2009 10:49:58 -0400 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id n7DEnuVL008445 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Thu, 13 Aug 2009 16:49:56 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id n7DEnuuZ008444 for qemu-devel@nongnu.org; Thu, 13 Aug 2009 16:49:56 +0200 Date: Thu, 13 Aug 2009 16:49:56 +0200 From: Christoph Hellwig Message-ID: <20090813144956.GA8364@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] virtio-blk: handle NULL returns from bdrv_aio_{read, write} List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org The bdrv_aio_{read,write} routines can return a NULL pointer when the I/O submission fails. Currently we ignore this and will wait forever for an I/O completion and leading to a hang of the guest. I can easily reproduce this using the native Linux AIO patch, but it's also possible using normal pthreads-based AIO. Signed-off-by: Christoph Hellwig Index: qemu-kvm/hw/virtio-blk.c =================================================================== --- qemu-kvm.orig/hw/virtio-blk.c +++ qemu-kvm/hw/virtio-blk.c @@ -254,14 +254,24 @@ static void virtio_blk_handle_scsi(VirtI static void virtio_blk_handle_write(VirtIOBlockReq *req) { - bdrv_aio_writev(req->dev->bs, req->out->sector, &req->qiov, - req->qiov.size / 512, virtio_blk_rw_complete, req); + BlockDriverAIOCB *acb; + + acb = bdrv_aio_writev(req->dev->bs, req->out->sector, &req->qiov, + req->qiov.size / 512, virtio_blk_rw_complete, req); + if (!acb) { + virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); + } } static void virtio_blk_handle_read(VirtIOBlockReq *req) { - bdrv_aio_readv(req->dev->bs, req->out->sector, &req->qiov, - req->qiov.size / 512, virtio_blk_rw_complete, req); + BlockDriverAIOCB *acb; + + acb = bdrv_aio_readv(req->dev->bs, req->out->sector, &req->qiov, + req->qiov.size / 512, virtio_blk_rw_complete, req); + if (!acb) { + virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); + } } static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)