From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M1JSQ-0006W2-FU for qemu-devel@nongnu.org; Tue, 05 May 2009 08:09:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M1JSO-0006Vh-2f for qemu-devel@nongnu.org; Tue, 05 May 2009 08:09:10 -0400 Received: from [199.232.76.173] (port=33143 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M1JSN-0006Ve-RI for qemu-devel@nongnu.org; Tue, 05 May 2009 08:09:07 -0400 Received: from verein.lst.de ([213.95.11.210]:59222) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1M1JSN-0002ts-6i for qemu-devel@nongnu.org; Tue, 05 May 2009 08:09:07 -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 n45C95IF030794 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 5 May 2009 14:09:05 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-6.6) id n45C95Hj030792 for qemu-devel@nongnu.org; Tue, 5 May 2009 14:09:05 +0200 Date: Tue, 5 May 2009 14:09:05 +0200 From: Christoph Hellwig Message-ID: <20090505120905.GC30721@lst.de> References: <20090505120804.GA30651@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090505120804.GA30651@lst.de> Subject: [Qemu-devel] [PATCH 3/3] barriers: virtio List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Advertise the barriers feature to virtio guests if the underlying device supports it, and make sure to pass down the barrier flag on write requests to the block layer. Signed-off-by: Christoph Hellwig Index: qemu/hw/virtio-blk.c =================================================================== --- qemu.orig/hw/virtio-blk.c 2009-05-05 13:21:24.196784347 +0200 +++ qemu/hw/virtio-blk.c 2009-05-05 13:31:33.654786861 +0200 @@ -211,8 +211,14 @@ static void virtio_blk_handle_scsi(VirtI static void virtio_blk_handle_write(VirtIOBlockReq *req) { + + unsigned flags = 0; + + if (req->out->type & VIRTIO_BLK_T_BARRIER) + flags |= BDRV_IO_BARRIER; + bdrv_aio_writev(req->dev->bs, req->out->sector, &req->qiov, - req->qiov.size / 512, virtio_blk_rw_complete, req, 0); + req->qiov.size / 512, virtio_blk_rw_complete, req, flags); } static void virtio_blk_handle_read(VirtIOBlockReq *req) @@ -304,6 +310,7 @@ static void virtio_blk_update_config(Vir static uint32_t virtio_blk_get_features(VirtIODevice *vdev) { + VirtIOBlock *s = to_virtio_blk(vdev); uint32_t features = 0; features |= (1 << VIRTIO_BLK_F_SEG_MAX); @@ -312,6 +319,9 @@ static uint32_t virtio_blk_get_features( features |= (1 << VIRTIO_BLK_F_SCSI); #endif + if (s->bs->barrier_support) + features |= (1 << VIRTIO_BLK_F_BARRIER); + return features; }