From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5gwr-0005VP-9J for qemu-devel@nongnu.org; Thu, 08 Mar 2012 12:16:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S5gwe-0004sz-5W for qemu-devel@nongnu.org; Thu, 08 Mar 2012 12:16:16 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:47906) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5gwd-0004n5-UJ for qemu-devel@nongnu.org; Thu, 08 Mar 2012 12:16:04 -0500 Received: by mail-iy0-f173.google.com with SMTP id j26so1015616iaf.4 for ; Thu, 08 Mar 2012 09:16:03 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 8 Mar 2012 18:15:16 +0100 Message-Id: <1331226917-6658-17-git-send-email-pbonzini@redhat.com> In-Reply-To: <1331226917-6658-1-git-send-email-pbonzini@redhat.com> References: <1331226917-6658-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [RFC PATCH 16/17] qemu-io: fix the alloc command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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; -- 1.7.7.6