[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 17/26] qemu-io: fix the alloc command
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 17/26] qemu-io: fix the alloc command |
Date: |
Thu, 12 Apr 2012 14:01:07 +0200 |
Because sector_num is not updated, the loop would either go on
forever or return garbage.
Signed-off-by: Paolo Bonzini <address@hidden>
---
qemu-io.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/qemu-io.c b/qemu-io.c
index 43643c8..27a0c3c 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1560,7 +1560,7 @@ out:
static int alloc_f(int argc, char **argv)
{
- int64_t offset;
+ int64_t offset, sector_num;
int nb_sectors, remaining;
char s1[64];
int num, sum_alloc;
@@ -1581,12 +1581,18 @@ static int alloc_f(int argc, char **argv)
remaining = nb_sectors;
sum_alloc = 0;
+ sector_num = offset >> 9;
while (remaining) {
- ret = bdrv_is_allocated(bs, offset >> 9, nb_sectors, &num);
+ ret = bdrv_is_allocated(bs, sector_num, remaining, &num);
+ sector_num += num;
remaining -= num;
if (ret) {
sum_alloc += num;
}
+ if (num == 0) {
+ nb_sectors -= remaining;
+ remaining = 0;
+ }
}
cvtstr(offset, s1, sizeof(s1));
--
1.7.9.3
- [Qemu-devel] [PATCH 10/26] block: fix snapshot on QED, (continued)
- [Qemu-devel] [PATCH 10/26] block: fix snapshot on QED, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 14/26] block: fix allocation size for dirty bitmap, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 12/26] block: update in-memory backing file and format, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 11/26] block: push bdrv_change_backing_file error checking up from drivers, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 13/26] block: open backing file as read-only when probing for size, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 22/26] stream: do not copy unallocated sectors from the base, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 23/26] block: implement is_allocated for raw, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 24/26] stream: tweak usage of bdrv_co_is_allocated, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 16/26] qemu-io: correctly print non-integer values as decimals, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 25/26] stream: move is_allocated_above to block.c, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 17/26] qemu-io: fix the alloc command,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 15/26] qemu-iotests: strip spaces from qemu-img/qemu-io/qemu command lines, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 21/26] stream: fix ratelimiting corner case, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 18/26] stream: fix sectors not allocated test, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 19/26] stream: add testcase for partial streaming, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 26/26] stream: move rate limiting to a separate header file, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 20/26] stream: pass new base image format to bdrv_change_backing_file, Paolo Bonzini, 2012/04/12
- [Qemu-devel] [PATCH 27/26] block: another bdrv_append fix, Paolo Bonzini, 2012/04/17