From d663640c04f2aab810915c556390211d75457704 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 4 Sep 2013 19:00:25 +0200 Subject: block: expect errors from bdrv_co_is_allocated Some bdrv_is_allocated callers do not expect errors, but the fallback in qcow2.c might make other callers trip on assertion failures or infinite loops. Fix the callers to always look for errors. Cc: qemu-stable@nongnu.org Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini Signed-off-by: Stefan Hajnoczi --- block.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'block.c') diff --git a/block.c b/block.c index c6404ebbf8..5df17de5a4 100644 --- a/block.c +++ b/block.c @@ -1857,8 +1857,11 @@ int bdrv_commit(BlockDriverState *bs) buf = g_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE); for (sector = 0; sector < total_sectors; sector += n) { - if (bdrv_is_allocated(bs, sector, COMMIT_BUF_SECTORS, &n)) { - + ret = bdrv_is_allocated(bs, sector, COMMIT_BUF_SECTORS, &n); + if (ret < 0) { + goto ro_cleanup; + } + if (ret) { if (bdrv_read(bs, sector, buf, n) != 0) { ret = -EIO; goto ro_cleanup; -- cgit v1.2.1