[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 27/32] qemu-io: Respect early image end for map
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 27/32] qemu-io: Respect early image end for map |
Date: |
Thu, 23 Oct 2014 22:42:34 +0200 |
From: Max Reitz <address@hidden>
bdrv_is_allocated() may report zero clusters which most probably means
the image (file) is shorter than expected. Respect this case in order to
avoid an infinite loop.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: BenoƮt Canet <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qemu-io-cmds.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index b224ede..d94fb1e 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -1900,7 +1900,7 @@ static int map_is_allocated(BlockDriverState *bs, int64_t
sector_num,
num_checked = MIN(nb_sectors, INT_MAX);
ret = bdrv_is_allocated(bs, sector_num, num_checked, &num);
- if (ret == firstret) {
+ if (ret == firstret && num) {
*pnum += num;
} else {
break;
@@ -1927,6 +1927,9 @@ static int map_f(BlockDriverState *bs, int argc, char
**argv)
if (ret < 0) {
error_report("Failed to get allocation status: %s",
strerror(-ret));
return 0;
+ } else if (!num) {
+ error_report("Unexpected end of image");
+ return 0;
}
retstr = ret ? " allocated" : "not allocated";
--
1.8.3.1
- [Qemu-devel] [PULL 15/32] qcow2: Let inc_refcounts() resize the reftable, (continued)
- [Qemu-devel] [PULL 15/32] qcow2: Let inc_refcounts() resize the reftable, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 17/32] qcow2: Fix refcount blocks beyond image end, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 18/32] qcow2: Do not perform potentially damaging repairs, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 20/32] qcow2: Clean up after refcount rebuild, Kevin Wolf, 2014/10/23
- [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 <=
- [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, 2014/10/23
- [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