diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2018-07-23 18:37:39 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2018-07-23 18:37:39 +0100 |
| commit | 5c29b203df6dc2416bffaee11d49f12b76662420 (patch) | |
| tree | a62f54dd08299904c309f9208f75b07977e50ee3 /qemu-img.c | |
| parent | e596be90393389405c96a5c9534c4c4e2e0b5675 (diff) | |
| parent | 3e31b4e17064d22e533071aaa57d3f01499ef910 (diff) | |
| download | focaccia-qemu-5c29b203df6dc2416bffaee11d49f12b76662420.tar.gz focaccia-qemu-5c29b203df6dc2416bffaee11d49f12b76662420.zip | |
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches: - vvfat: Disable debug message by default - qemu-iotests fixes - Fix typos in comments # gpg: Signature made Mon 23 Jul 2018 17:44:40 BST # gpg: using RSA key 7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: block/vvfat: Disable debug message by default iotests: Disallow compat=0.10 in 223 iotest: Fix filtering order in 226 iotests: remove LUKS support from test 226 qemu-img: avoid overflow of min_sparse parameter block: Fix typos in comments (found by codespell) qemu-iotests: Use host_device instead of file in 149 Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qemu-img.c')
| -rw-r--r-- | qemu-img.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/qemu-img.c b/qemu-img.c index 4a7ce43dc9..9b7506b8ae 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2005,6 +2005,8 @@ static int convert_do_copy(ImgConvertState *s) return s->ret; } +#define MAX_BUF_SECTORS 32768 + static int img_convert(int argc, char **argv) { int c, bs_i, flags, src_flags = 0; @@ -2100,8 +2102,12 @@ static int img_convert(int argc, char **argv) int64_t sval; sval = cvtnum(optarg); - if (sval < 0) { - error_report("Invalid minimum zero buffer size for sparse output specified"); + if (sval < 0 || sval & (BDRV_SECTOR_SIZE - 1) || + sval / BDRV_SECTOR_SIZE > MAX_BUF_SECTORS) { + error_report("Invalid buffer size for sparse output specified. " + "Valid sizes are multiples of %llu up to %llu. Select " + "0 to disable sparse detection (fully allocates output).", + BDRV_SECTOR_SIZE, MAX_BUF_SECTORS * BDRV_SECTOR_SIZE); goto fail_getopt; } @@ -2385,9 +2391,9 @@ static int img_convert(int argc, char **argv) } /* increase bufsectors from the default 4096 (2M) if opt_transfer - * or discard_alignment of the out_bs is greater. Limit to 32768 (16MB) - * as maximum. */ - s.buf_sectors = MIN(32768, + * or discard_alignment of the out_bs is greater. Limit to + * MAX_BUF_SECTORS as maximum which is currently 32768 (16MB). */ + s.buf_sectors = MIN(MAX_BUF_SECTORS, MAX(s.buf_sectors, MAX(out_bs->bl.opt_transfer >> BDRV_SECTOR_BITS, out_bs->bl.pdiscard_alignment >> |