From 636eacb641ce747cbc87c0c878d807cc09b4f905 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herv=C3=A9=20Poussineau?= Date: Mon, 22 May 2017 23:11:53 +0200 Subject: [PATCH] vvfat: fix qemu-img map and qemu-img convert MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - bs->total_sectors is the number of sectors of the whole disk - s->sector_count is the number of sectors of the FAT partition This fixes the following assert in qemu-img map: qemu-img.c:2641: get_block_status: Assertion `nb_sectors' failed. This also fixes an infinite loop in qemu-img convert. Fixes: 4480e0f924a42e1db8b8cfcac4d0634dd1bb27a0 Fixes: https://bugs.launchpad.net/qemu/+bug/1599539 Cc: qemu-stable@nongnu.org Signed-off-by: Hervé Poussineau Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf (cherry picked from commit 139921aaa77c435104308ad53b631a00c3b65ae8) Signed-off-by: Michael Roth --- block/vvfat.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 8b4e4ebe08..7d08f65547 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2958,8 +2958,7 @@ vvfat_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, static int64_t coroutine_fn vvfat_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *n, BlockDriverState **file) { - BDRVVVFATState* s = bs->opaque; - *n = s->sector_count - sector_num; + *n = bs->total_sectors - sector_num; if (*n > nb_sectors) { *n = nb_sectors; } else if (*n < 0) { -- 2.39.2