Skip to contentSkip to conversation

qemu-img: print error codes when convert fails

PATCH Applied Stefan Hajnoczi 2 participants 3 messages Aug 17, 2011 – Aug 18, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-img: print error codes when convert fails

---
 qemu-img.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
qemu-img.c +8 -5
index b205e98..d9e6fc8 100644
@@ -890,7 +890,8 @@ static int img_convert(int argc, char **argv)
 
                 ret = bdrv_read(bs[bs_i], bs_num, buf2, nlow);
                 if (ret < 0) {
-                    error_report("error while reading");
+                    error_report("error while reading sector %" PRId64 ": %s",
+                                 bs_num, strerror(-ret));
                     goto out;
                 }
 
@@ -908,8 +909,8 @@ static int img_convert(int argc, char **argv)
                 ret = bdrv_write_compressed(out_bs, sector_num, buf,
                                             cluster_sectors);
                 if (ret != 0) {
-                    error_report("error while compressing sector %" PRId64,
-                          sector_num);
+                    error_report("error while compressing sector %" PRId64
+                                 ": %s", sector_num, strerror(-ret));
                     goto out;
                 }
             }
@@ -972,7 +973,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_report("error while reading");
+                error_report("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
@@ -991,7 +993,8 @@ static int img_convert(int argc, char **argv)
                     is_allocated_sectors(buf1, n, &n1)) {
                     ret = bdrv_write(out_bs, sector_num, buf1, n1);
                     if (ret < 0) {
-                        error_report("error while writing");
+                        error_report("error while writing sector %" PRId64
+                                     ": %s", sector_num, strerror(-ret));
                         goto out;
                     }
                 }
Signature · 1 line
1.7.5.4
Applied
#1 lore raw

Am 17.08.2011 18:41, schrieb Stefan Hajnoczi:

Quoted 1 line

Thanks, applied to the block branch.

(But is it really helpful to include sector numbers in the error message? Especially since we're not reading/writing single sectors)

Kevin

#2 lore raw
Quoted 7 lines · Kevin Wolf

Am 17.08.2011 18:41, schrieb Stefan Hajnoczi:

Quoted 1 line

Thanks, applied to the block branch.

(But is it really helpful to include sector numbers in the error message? Especially since we're not reading/writing single sectors)

The intention is that it would show suspicious sectors numbers, e.g. ~2 GB or ~4 GB.

In the best case it saves a round-trip on a bug report. In the worst case the sector number is a distraction :).

Stefan