Skip to content

Commit

Permalink
qemu-img: Report convert errors by bytes, not sectors
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200402135717.476398-1-eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
  • Loading branch information
ebblake authored and XanClic committed Apr 7, 2020
1 parent 80f5c01 commit 39f77cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions qemu-img.c
Expand Up @@ -1924,8 +1924,8 @@ static void coroutine_fn convert_co_do_copy(void *opaque)
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) {
Expand Down Expand Up @@ -1953,8 +1953,8 @@ static void coroutine_fn convert_co_do_copy(void *opaque)
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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/qemu-iotests/244.out
Expand Up @@ -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.
Expand Down

0 comments on commit 39f77cb

Please sign in to comment.