[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 26/32] block: Respect underlying file's EOF
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 26/32] block: Respect underlying file's EOF |
Date: |
Thu, 23 Oct 2014 22:42:33 +0200 |
From: Max Reitz <address@hidden>
When falling through to the underlying file in
bdrv_co_get_block_status(), if it returns that the query offset is
beyond the file end (by setting *pnum to 0), return the range to be
zero and do not let the number of sectors for which information could be
obtained be overwritten.
Signed-off-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index bbb04e7..88f6d9b 100644
--- a/block.c
+++ b/block.c
@@ -3954,13 +3954,24 @@ static int64_t coroutine_fn
bdrv_co_get_block_status(BlockDriverState *bs,
if (bs->file &&
(ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) &&
(ret & BDRV_BLOCK_OFFSET_VALID)) {
+ int file_pnum;
+
ret2 = bdrv_co_get_block_status(bs->file, ret >> BDRV_SECTOR_BITS,
- *pnum, pnum);
+ *pnum, &file_pnum);
if (ret2 >= 0) {
/* Ignore errors. This is just providing extra information, it
* is useful but not necessary.
*/
- ret |= (ret2 & BDRV_BLOCK_ZERO);
+ if (!file_pnum) {
+ /* !file_pnum indicates an offset at or beyond the EOF; it is
+ * perfectly valid for the format block driver to point to such
+ * offsets, so catch it and mark everything as zero */
+ ret |= BDRV_BLOCK_ZERO;
+ } else {
+ /* Limit request to the range reported by the protocol driver
*/
+ *pnum = file_pnum;
+ ret |= (ret2 & BDRV_BLOCK_ZERO);
+ }
}
}
--
1.8.3.1
- [Qemu-devel] [PULL 19/32] qcow2: Rebuild refcount structure during check, (continued)
- [Qemu-devel] [PULL 19/32] qcow2: Rebuild refcount structure during check, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 21/32] iotests: Fix test outputs, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 22/32] iotests: Add test for potentially damaging repairs, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 23/32] qcow2: Drop REFCOUNT_SHIFT, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 24/32] docs/qcow2: Correct refcount_block_entries, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 25/32] docs/qcow2: Limit refcount_order to [0, 6], Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 27/32] qemu-io: Respect early image end for map, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 28/32] iotests: Add test for map commands, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 30/32] iotests: Add test for qcow2 L1 table update, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 29/32] qcow2: Do not overflow when writing an L1 sector, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 26/32] block: Respect underlying file's EOF,
Kevin Wolf <=
- [Qemu-devel] [PULL 31/32] block: char devices on FreeBSD are not behind a pager, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 32/32] qemu-img: Print error if check failed, Kevin Wolf, 2014/10/23
- Re: [Qemu-devel] [PULL 00/32] Block patches, Peter Maydell, 2014/10/24