[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 24/42] block: do not use ->total_sectors in bdrv_co_i
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 24/42] block: do not use ->total_sectors in bdrv_co_is_allocated |
Date: |
Fri, 6 Sep 2013 17:38:55 +0200 |
From: Paolo Bonzini <address@hidden>
This is more robust when the device has removable media.
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index f27bab6..4a10fb1 100644
--- a/block.c
+++ b/block.c
@@ -3065,9 +3065,15 @@ static int coroutine_fn
bdrv_co_is_allocated(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum)
{
+ int64_t length;
int64_t n;
- if (sector_num >= bs->total_sectors) {
+ length = bdrv_getlength(bs);
+ if (length < 0) {
+ return length;
+ }
+
+ if (sector_num >= (length >> BDRV_SECTOR_BITS)) {
*pnum = 0;
return 0;
}
--
1.8.3.1
- [Qemu-devel] [PULL 41/42] qemu-iotests: Whitespace cleanup, (continued)
- [Qemu-devel] [PULL 41/42] qemu-iotests: Whitespace cleanup, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 42/42] qemu-iotests: Fixed test case 026, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 18/42] qmp: Documentation for BLOCK_IMAGE_CORRUPTED, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 20/42] cow: make writes go at a less indecent speed, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 16/42] nbd: use BlockDriverState refcnt, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 25/42] block: remove bdrv_is_allocated_above/bdrv_co_is_allocated_above distinction, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 26/42] block: expect errors from bdrv_co_is_allocated, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 22/42] block: keep bs->total_sectors up to date even for growable block devices, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 23/42] block: make bdrv_co_is_allocated static, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 21/42] cow: do not call bdrv_co_is_allocated, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 24/42] block: do not use ->total_sectors in bdrv_co_is_allocated,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 19/42] cow: make reads go at a decent speed, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 17/42] block: use BDS ref for block jobs, Stefan Hajnoczi, 2013/09/06