Skip to contentSkip to conversation

qemu-img: Report convert errors by bytes, not sectors

PATCH Applied Eric Blake 3 participants 3 messages Apr 2, 2020 – Apr 3, 2020

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH v3 1/1 qemu-img: Report convert errors by bytes, not sectors

Various qemu-img commands are inconsistent on whether they report status/errors in terms of bytes or sector offsets. The latter is confusing (especially as more places move to 4k block sizes), so let's switch everything to just use bytes everywhere. One iotest is impacted.

---

v3: Fix affected iotest [patchew]

 qemu-img.c                 | 8 ++++----
 tests/qemu-iotests/244.out | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
qemu-img.c +4 -4
index b167376bd72e..821cbf610e5f 100644
@@ -1924,8 +1924,8 @@ retry:
         if (status == BLK_DATA && !copy_range) {
             ret = convert_co_read(s, sector_num, n, buf);
             if (ret < 0) {
-                error_report("error while reading sector %" PRId64
-                             ": %s", sector_num, strerror(-ret));
+                error_report("error while reading at byte %lld: %s",
+                             sector_num * BDRV_SECTOR_SIZE, strerror(-ret));
                 s->ret = ret;
             }
         } else if (!s->min_sparse && status == BLK_ZERO) {
@@ -1953,8 +1953,8 @@ retry:
                 ret = convert_co_write(s, sector_num, n, buf, status);
             }
             if (ret < 0) {
-                error_report("error while writing sector %" PRId64
-                             ": %s", sector_num, strerror(-ret));
+                error_report("error while writing at byte %lld: %s",
+                             sector_num * BDRV_SECTOR_SIZE, strerror(-ret));
                 s->ret = ret;
             }
         }
tests/qemu-iotests/244.out +1 -1
index e6f4dc79934b..56329deb4b9f 100644
@@ -33,7 +33,7 @@ Convert to compressed target with data file:
 Formatting 'TEST_DIR/t.IMGFMT.src', fmt=IMGFMT size=67108864
 wrote 1048576/1048576 bytes at offset 0
 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: error while writing sector 0: Operation not supported
+qemu-img: error while writing at byte 0: Operation not supported
 
 Convert uncompressed, then write compressed data manually:
 Images are identical.
Signature · 1 line
2.26.0.rc2
Reviewed-by on v3 1/1
#1 lore raw
Quoted 48 lines · Eric Blake

Various qemu-img commands are inconsistent on whether they report status/errors in terms of bytes or sector offsets. The latter is confusing (especially as more places move to 4k block sizes), so let's switch everything to just use bytes everywhere. One iotest is impacted.

---

v3: Fix affected iotest [patchew]

  qemu-img.c                 | 8 ++++----
  tests/qemu-iotests/244.out | 2 +-
  2 files changed, 5 insertions(+), 5 deletions(-)
qemu-img.c +4 -4
index b167376bd72e..821cbf610e5f 100644
@@ -1924,8 +1924,8 @@ retry:
          if (status == BLK_DATA && !copy_range) {
              ret = convert_co_read(s, sector_num, n, buf);
              if (ret < 0) {
-                error_report("error while reading sector %" PRId64
-                             ": %s", sector_num, strerror(-ret));
+                error_report("error while reading at byte %lld: %s",
+                             sector_num * BDRV_SECTOR_SIZE, strerror(-ret));
                  s->ret = ret;
              }
          } else if (!s->min_sparse && status == BLK_ZERO) {
@@ -1953,8 +1953,8 @@ retry:
                  ret = convert_co_write(s, sector_num, n, buf, status);
              }
              if (ret < 0) {
-                error_report("error while writing sector %" PRId64
-                             ": %s", sector_num, strerror(-ret));
+                error_report("error while writing at byte %lld: %s",
+                             sector_num * BDRV_SECTOR_SIZE, strerror(-ret));
                  s->ret = ret;
              }
          }
tests/qemu-iotests/244.out +0 -0
index e6f4dc79934b..56329deb4b9f 100644

tests/qemu-iotests/244.out Convert to compressed target with data file: · line 39

Quoted 8 lines
tests/qemu-iotests/244.out +1 -1
@@ -33,7 +33,7 @@ Convert to compressed target with data file:
  Formatting 'TEST_DIR/t.IMGFMT.src', fmt=IMGFMT size=67108864
  wrote 1048576/1048576 bytes at offset 0
  1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-qemu-img: error while writing sector 0: Operation not supported
+qemu-img: error while writing at byte 0: Operation not supported
 
  Convert uncompressed, then write compressed data manually:
  Images are identical.
Applied
#2 lore raw
In reply to Eric Blake
Quoted 8 lines · Eric Blake

Various qemu-img commands are inconsistent on whether they report status/errors in terms of bytes or sector offsets. The latter is confusing (especially as more places move to 4k block sizes), so let's switch everything to just use bytes everywhere. One iotest is impacted.

Quoted 7 lines

---

v3: Fix affected iotest [patchew]

 qemu-img.c                 | 8 ++++----
 tests/qemu-iotests/244.out | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

Thanks, applied to my block branch:

https://git.xanclic.moe/XanClic/qemu/commits/branch/block

Max