From 14fb7e752b609602adafca082a2ecd09f7d034c3 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 15 Mar 2012 12:50:28 +0100 Subject: [PATCH 1/2] qemu-img: print error codes when convert fails RH-Author: Kevin Wolf Message-id: <1331815828-5671-1-git-send-email-kwolf@redhat.com> Patchwork-id: 38557 O-Subject: [RHEL-6.3 qemu-kvm PATCH] qemu-img: print error codes when convert fails Bugzilla: 803344 RH-Acked-by: Asias He RH-Acked-by: Paolo Bonzini RH-Acked-by: Jeffrey Cody From: Stefan Hajnoczi Bugzilla: 803344 Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf (cherry picked from commit 3fba9d8198a50f69e80aba8458d26cf1654e6e26) Conflicts: qemu-img.c Signed-off-by: Kevin Wolf --- qemu-img.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) Signed-off-by: Michal Novotny --- qemu-img.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 38de348..c5de0a1 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -899,7 +899,8 @@ static int img_convert(int argc, char **argv) ret = bdrv_read(bs[bs_i], bs_num, buf2, nlow); if (ret < 0) { - error("error while reading"); + error("error while reading sector %" PRId64 ": %s", + bs_num, strerror(-ret)); goto out; } @@ -917,8 +918,8 @@ static int img_convert(int argc, char **argv) ret = bdrv_write_compressed(out_bs, sector_num, buf, cluster_sectors); if (ret != 0) { - error("error while compressing sector %" PRId64, - sector_num); + error("error while compressing sector %" PRId64 + ": %s", sector_num, strerror(-ret)); goto out; } } @@ -981,7 +982,8 @@ static int img_convert(int argc, char **argv) ret = bdrv_read(bs[bs_i], sector_num - bs_offset, buf, n); if (ret < 0) { - error("error while reading"); + error("error while reading sector %" PRId64 ": %s", + sector_num - bs_offset, strerror(-ret)); goto out; } /* NOTE: at the same time we convert, we do not write zero @@ -1000,7 +1002,8 @@ static int img_convert(int argc, char **argv) is_allocated_sectors_min(buf1, n, &n1, min_sparse)) { ret = bdrv_write(out_bs, sector_num, buf1, n1); if (ret < 0) { - error("error while writing"); + error("error while writing sector %" PRId64 + ": %s", sector_num, strerror(-ret)); goto out; } } -- 1.7.7.6