diff options
author | Max Reitz <mreitz@redhat.com> | 2014-10-23 15:29:12 +0200 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2014-10-23 19:42:07 +0200 |
commit | 832390a5ed11e6c516db0986bf302d098e3ae36c (patch) | |
tree | 5bc56db7d132bb7007d7ee3c664e7e7c558275c3 /qemu-img.c | |
parent | 3cad83075c7b847fe0eb6e61316fdf50984d4570 (diff) | |
download | qemu-832390a5ed11e6c516db0986bf302d098e3ae36c.zip qemu-832390a5ed11e6c516db0986bf302d098e3ae36c.tar.gz qemu-832390a5ed11e6c516db0986bf302d098e3ae36c.tar.bz2 |
qemu-img: Print error if check failed
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 <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r-- | qemu-img.c | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -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; } |