[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 22/30] qemu-io: fix the alloc command
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 22/30] qemu-io: fix the alloc command |
Date: |
Thu, 10 May 2012 13:49:26 +0200 |
From: Paolo Bonzini <address@hidden>
Because sector_num is not updated, the loop would either go on
forever or return garbage.
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qemu-io.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/qemu-io.c b/qemu-io.c
index b48364f..5882067 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.6.5
- [Qemu-devel] [PATCH 13/30] block: do not reuse the backing file across bdrv_close/bdrv_open, (continued)
- [Qemu-devel] [PATCH 13/30] block: do not reuse the backing file across bdrv_close/bdrv_open, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 20/30] qemu-img: make "info" backing file output correct and easier to use, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 18/30] block: protect path_has_protocol from filenames with colons, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 11/30] block: fix snapshot on QED, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 15/30] block: add block_job_sleep_ns, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 16/30] block: wait for job callback in block_job_cancel_sync, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 23/30] stream: fix sectors not allocated test, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 19/30] block: move field reset from bdrv_open_common to bdrv_close, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 26/30] stream: fix HMP block_job_set_speed, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 27/30] stream: fix ratelimiting corner case, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 22/30] qemu-io: fix the alloc command,
Kevin Wolf <=
- [Qemu-devel] [PATCH 24/30] stream: add testcase for partial streaming, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 25/30] stream: pass new base image format to bdrv_change_backing_file, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 28/30] stream: do not copy unallocated sectors from the base, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 29/30] tests/Makefile: Add missing $(EXESUF), Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 30/30] declare ECANCELED on all machines, Kevin Wolf, 2012/05/10
- [Qemu-devel] [PATCH 21/30] qemu-io: correctly print non-integer values as decimals, Kevin Wolf, 2012/05/10
- Re: [Qemu-devel] [PULL 00/30] Block patches for 1.1, Anthony Liguori, 2012/05/14