diff options
author | Fam Zheng <famz@redhat.com> | 2013-09-18 19:14:14 +0800 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2013-09-20 19:27:26 +0200 |
commit | bcb9d66e8590151967e1dbe3724eec7ec71392e0 (patch) | |
tree | 1e2d79ec373aa30aade110774e6df3f452d88201 /block.c | |
parent | 0f39ac9a07cc10278e37d87076b143008f28aa3b (diff) | |
download | qemu-bcb9d66e8590151967e1dbe3724eec7ec71392e0.zip qemu-bcb9d66e8590151967e1dbe3724eec7ec71392e0.tar.gz qemu-bcb9d66e8590151967e1dbe3724eec7ec71392e0.tar.bz2 |
block: don't lose data from last incomplete sector
To read the last sector that is not aligned to sector boundary, current
code for growable backends, since commit 893a8f6 "block: Produce zeros
when protocols reading beyond end of file", drops the data and directly
returns zeroes. That is incorrect.
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -2669,7 +2669,7 @@ static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs, goto out; } - total_sectors = len >> BDRV_SECTOR_BITS; + total_sectors = (len + BDRV_SECTOR_SIZE - 1) >> BDRV_SECTOR_BITS; max_nb_sectors = MAX(0, total_sectors - sector_num); if (max_nb_sectors > 0) { ret = drv->bdrv_co_readv(bs, sector_num, |