From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XhPEN-0006eH-50 for qemu-devel@nongnu.org; Thu, 23 Oct 2014 16:43:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XhPEF-0002ig-JM for qemu-devel@nongnu.org; Thu, 23 Oct 2014 16:43:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XhPEF-0002iI-Cv for qemu-devel@nongnu.org; Thu, 23 Oct 2014 16:43:27 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9NKhQ2R009739 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 23 Oct 2014 16:43:26 -0400 From: Kevin Wolf Date: Thu, 23 Oct 2014 22:42:39 +0200 Message-Id: <1414096959-14682-33-git-send-email-kwolf@redhat.com> In-Reply-To: <1414096959-14682-1-git-send-email-kwolf@redhat.com> References: <1414096959-14682-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 32/32] qemu-img: Print error if check failed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com From: Max Reitz Currently, if bdrv_check() fails either by returning -errno or having check_errors set, qemu-img check just exits with 1 after having told the user that there were no errors on the image. This is bad. Instead of printing the check result if there were internal errors which were so bad that bdrv_check() could not even complete with 0 as a return value, qemu-img check should inform the user about the error. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Markus Armbruster --- qemu-img.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 09e7e72..731502c 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -687,16 +687,23 @@ static int img_check(int argc, char **argv) check->corruptions_fixed = corruptions_fixed; } - switch (output_format) { - case OFORMAT_HUMAN: - dump_human_image_check(check, quiet); - break; - case OFORMAT_JSON: - dump_json_image_check(check, quiet); - break; + if (!ret) { + switch (output_format) { + case OFORMAT_HUMAN: + dump_human_image_check(check, quiet); + break; + case OFORMAT_JSON: + dump_json_image_check(check, quiet); + break; + } } if (ret || check->check_errors) { + if (ret) { + error_report("Check failed: %s", strerror(-ret)); + } else { + error_report("Check failed"); + } ret = 1; goto fail; } -- 1.8.3.1