On 27.04.2017 03:46, Eric Blake wrote: > For the 'alloc' command, accepting an offset in bytes but a length > in sectors, and reporting output in sectors, is confusing. Do > everything in bytes, and adjust the expected output accordingly. > > Signed-off-by: Eric Blake <ebl...@redhat.com> > Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org> > > --- > v10: rebase to code cleanup > v9: new patch > --- > qemu-io-cmds.c | 30 ++++++++++++++++++------------ > tests/qemu-iotests/019.out | 8 ++++---- > tests/qemu-iotests/common.pattern | 2 +- > 3 files changed, 23 insertions(+), 17 deletions(-) > > diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c > index fabc394..34f6707 100644 > --- a/qemu-io-cmds.c > +++ b/qemu-io-cmds.c > @@ -1760,7 +1760,7 @@ out: > static int alloc_f(BlockBackend *blk, int argc, char **argv) > { > BlockDriverState *bs = blk_bs(blk); > - int64_t offset, sector_num, nb_sectors, remaining; > + int64_t offset, sector_num, nb_sectors, remaining, bytes; > char s1[64]; > int num, ret; > int64_t sum_alloc; > @@ -1776,18 +1776,24 @@ static int alloc_f(BlockBackend *blk, int argc, char > **argv) > } > > if (argc == 3) { > - nb_sectors = cvtnum(argv[2]); > - if (nb_sectors < 0) { > - print_cvtnum_err(nb_sectors, argv[2]); > + bytes = cvtnum(argv[2]); > + if (bytes < 0) { > + print_cvtnum_err(bytes, argv[2]); > return 0; > - } else if (nb_sectors > INT_MAX) { > - printf("length argument cannot exceed %d, given %s\n", > - INT_MAX, argv[2]); > + } else if (bytes > INT_MAX * BDRV_SECTOR_SIZE) { > + printf("length argument cannot exceed %llu, given %s\n", > + INT_MAX * BDRV_SECTOR_SIZE, argv[2]); > return 0; > } > } else { > - nb_sectors = 1; > + bytes = BDRV_SECTOR_SIZE; > } > + if (!QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE)) { > + printf("bytes %" PRId64 " is not sector aligned\n",
This isn't real English. :-) With that fixed (somehow, you know better than me how to): Reviewed-by: Max Reitz <mre...@redhat.com> > + bytes); > + return 0; > + } > + nb_sectors = bytes >> BDRV_SECTOR_BITS; > > remaining = nb_sectors; > sum_alloc = 0;
signature.asc
Description: OpenPGP digital signature