[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/3] virtio-blk: Treat read/write beyond end as
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH 3/3] virtio-blk: Treat read/write beyond end as invalid |
Date: |
Fri, 6 Jun 2014 11:21:05 +0800 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Thu, 06/05 14:15, Markus Armbruster wrote:
> The block layer fails such reads and writes just fine. However, they
> then get treated like valid operations that fail: the error action
> gets executed. Unwanted; reporting the error to the guest is the only
> sensible action.
>
> Reject them before passing them to the block layer. This bypasses the
> error action and I/O accounting.
>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> hw/block/virtio-blk.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 2c68d0d..0b38049 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -284,12 +284,19 @@ static void virtio_blk_handle_flush(VirtIOBlockReq
> *req, MultiReqBuffer *mrb)
> static bool virtio_blk_sect_range_ok(VirtIOBlock *dev,
> uint64_t sector, size_t size)
> {
> + uint64_t nb_sectors = size >> BDRV_SECTOR_BITS;
> + uint64_t total_sectors;
> +
> if (sector & dev->sector_mask) {
> return false;
> }
> if (size % dev->conf->logical_block_size) {
> return false;
> }
> + bdrv_get_geometry(dev->bs, &total_sectors);
> + if (sector > total_sectors || nb_sectors > total_sectors - sector) {
> + return false;
> + }
> return true;
> }
>
> --
> 1.9.3
>
>
Reviewed-by: Fam Zheng <address@hidden>
Re: [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end, Paolo Bonzini, 2014/06/06
Re: [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end, Markus Armbruster, 2014/06/26
Re: [Qemu-devel] [PATCH 0/3] virtio-blk: Suppress error action on r/w beyond end, Stefan Hajnoczi, 2014/06/27