From patchwork Thu Mar 8 17:15:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [RFC,16/17] qemu-io: fix the alloc command Date: Thu, 08 Mar 2012 07:15:16 -0000 From: Paolo Bonzini X-Patchwork-Id: 145605 Message-Id: <1331226917-6658-17-git-send-email-pbonzini@redhat.com> To: qemu-devel@nongnu.org Signed-off-by: Paolo Bonzini --- qemu-io.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index bb5f7b8..c1bc053 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -1513,7 +1513,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; @@ -1534,8 +1534,10 @@ 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;