From e076f3383b08a563d76c8beb9a716788a3987df9 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 29 Jun 2010 11:43:13 +0200 Subject: qemu-img check: Distinguish different kinds of errors People think that their images are corrupted when in fact there are just some leaked clusters. Differentiating several error cases should make the messages more comprehensible. Signed-off-by: Kevin Wolf --- block.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'block.c') diff --git a/block.c b/block.c index dd6dd76..b0ceef0 100644 --- a/block.c +++ b/block.c @@ -710,15 +710,19 @@ DeviceState *bdrv_get_attached(BlockDriverState *bs) /* * Run consistency checks on an image * - * Returns the number of errors or -errno when an internal error occurs + * Returns 0 if the check could be completed (it doesn't mean that the image is + * free of errors) or -errno when an internal error occured. The results of the + * check are stored in res. */ -int bdrv_check(BlockDriverState *bs) +int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res) { if (bs->drv->bdrv_check == NULL) { return -ENOTSUP; } - return bs->drv->bdrv_check(bs); + memset(res, 0, sizeof(*res)); + res->corruptions = bs->drv->bdrv_check(bs); + return res->corruptions < 0 ? res->corruptions : 0; } /* commit COW file into the raw image */ -- cgit v1.1