mirror of
https://github.com/qemu/qemu.git
synced 2024-12-09 11:43:38 +08:00
de38b5005e
Disk sizes close to INT64_MAX cause overflow, for some pretty ridiculous output: $ ./nbdkit -U - memory size=$((2**63 - 512)) --run 'qemu-img info $nbd' image: nbd+unix://?socket=/tmp/nbdkitHSAzNz/socket file format: raw virtual size: -8388607T (9223372036854775296 bytes) disk size: unavailable But there's no reason to have two separate implementations of integer to human-readable abbreviation, where one has overflow and stops at 'T', while the other avoids overflow and goes all the way to 'E'. With this patch, the output now claims 8EiB instead of -8388607T, which really is the correct rounding of largest file size supported by qemu (we could go 511 bytes larger if we used byte-accurate sizing instead of rounding up to the next sector boundary, but that wouldn't change the human-readable result). Quite a few iotests need updates to expected output to match. Reported-by: Richard W.M. Jones <rjones@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com> Tested-by: Richard W.M. Jones <rjones@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Tested-by: Max Reitz <mreitz@redhat.com>
232 lines
7.6 KiB
Plaintext
232 lines
7.6 KiB
Plaintext
=== Successful image creation (defaults) ===
|
|
|
|
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.luks", "size": 0}}}
|
|
{"return": {}}
|
|
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
|
|
{"return": {}}
|
|
|
|
{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.luks", "node-name": "imgfile"}}
|
|
{"return": {}}
|
|
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "luks", "file": "imgfile", "iter-time": 10, "key-secret": "keysec0", "size": 134217728}}}
|
|
{"return": {}}
|
|
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
|
|
{"return": {}}
|
|
|
|
image: json:{"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_IMG"}, "key-secret": "keysec0"}
|
|
file format: IMGFMT
|
|
virtual size: 128 MiB (134217728 bytes)
|
|
encrypted: yes
|
|
Format specific information:
|
|
ivgen alg: plain64
|
|
hash alg: sha256
|
|
cipher alg: aes-256
|
|
uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
cipher mode: xts
|
|
slots:
|
|
[0]:
|
|
active: true
|
|
iters: XXX
|
|
key offset: 4096
|
|
stripes: 4000
|
|
[1]:
|
|
active: false
|
|
key offset: 262144
|
|
[2]:
|
|
active: false
|
|
key offset: 520192
|
|
[3]:
|
|
active: false
|
|
key offset: 778240
|
|
[4]:
|
|
active: false
|
|
key offset: 1036288
|
|
[5]:
|
|
active: false
|
|
key offset: 1294336
|
|
[6]:
|
|
active: false
|
|
key offset: 1552384
|
|
[7]:
|
|
active: false
|
|
key offset: 1810432
|
|
payload offset: 2068480
|
|
master key iters: XXX
|
|
|
|
=== Successful image creation (with non-default options) ===
|
|
|
|
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.luks", "size": 0}}}
|
|
{"return": {}}
|
|
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
|
|
{"return": {}}
|
|
|
|
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"cipher-alg": "twofish-128", "cipher-mode": "ctr", "driver": "luks", "file": {"driver": "file", "filename": "TEST_DIR/PID-t.luks"}, "hash-alg": "sha1", "iter-time": 10, "ivgen-alg": "plain64", "ivgen-hash-alg": "md5", "key-secret": "keysec0", "size": 67108864}}}
|
|
{"return": {}}
|
|
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
|
|
{"return": {}}
|
|
|
|
image: json:{"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_IMG"}, "key-secret": "keysec0"}
|
|
file format: IMGFMT
|
|
virtual size: 64 MiB (67108864 bytes)
|
|
encrypted: yes
|
|
Format specific information:
|
|
ivgen alg: plain64
|
|
hash alg: sha1
|
|
cipher alg: twofish-128
|
|
uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
cipher mode: ctr
|
|
slots:
|
|
[0]:
|
|
active: true
|
|
iters: XXX
|
|
key offset: 4096
|
|
stripes: 4000
|
|
[1]:
|
|
active: false
|
|
key offset: 69632
|
|
[2]:
|
|
active: false
|
|
key offset: 135168
|
|
[3]:
|
|
active: false
|
|
key offset: 200704
|
|
[4]:
|
|
active: false
|
|
key offset: 266240
|
|
[5]:
|
|
active: false
|
|
key offset: 331776
|
|
[6]:
|
|
active: false
|
|
key offset: 397312
|
|
[7]:
|
|
active: false
|
|
key offset: 462848
|
|
payload offset: 528384
|
|
master key iters: XXX
|
|
|
|
=== Invalid BlockdevRef ===
|
|
|
|
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "luks", "file": "this doesn't exist", "size": 67108864}}}
|
|
{"return": {}}
|
|
Job failed: Cannot find device=this doesn't exist nor node_name=this doesn't exist
|
|
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
|
|
{"return": {}}
|
|
|
|
=== Zero size ===
|
|
|
|
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "luks", "file": "node0", "iter-time": 10, "key-secret": "keysec0", "size": 0}}}
|
|
{"return": {}}
|
|
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
|
|
{"return": {}}
|
|
|
|
image: json:{"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_IMG"}, "key-secret": "keysec0"}
|
|
file format: IMGFMT
|
|
virtual size: 0 B (0 bytes)
|
|
encrypted: yes
|
|
Format specific information:
|
|
ivgen alg: plain64
|
|
hash alg: sha256
|
|
cipher alg: aes-256
|
|
uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
cipher mode: xts
|
|
slots:
|
|
[0]:
|
|
active: true
|
|
iters: XXX
|
|
key offset: 4096
|
|
stripes: 4000
|
|
[1]:
|
|
active: false
|
|
key offset: 262144
|
|
[2]:
|
|
active: false
|
|
key offset: 520192
|
|
[3]:
|
|
active: false
|
|
key offset: 778240
|
|
[4]:
|
|
active: false
|
|
key offset: 1036288
|
|
[5]:
|
|
active: false
|
|
key offset: 1294336
|
|
[6]:
|
|
active: false
|
|
key offset: 1552384
|
|
[7]:
|
|
active: false
|
|
key offset: 1810432
|
|
payload offset: 2068480
|
|
master key iters: XXX
|
|
|
|
=== Invalid sizes ===
|
|
|
|
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "luks", "file": "node0", "key-secret": "keysec0", "size": 18446744073709551104}}}
|
|
{"return": {}}
|
|
Job failed: The requested file size is too large
|
|
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
|
|
{"return": {}}
|
|
|
|
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "luks", "file": "node0", "key-secret": "keysec0", "size": 9223372036854775808}}}
|
|
{"return": {}}
|
|
Job failed: The requested file size is too large
|
|
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
|
|
{"return": {}}
|
|
|
|
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "luks", "file": "node0", "key-secret": "keysec0", "size": 9223372036854775296}}}
|
|
{"return": {}}
|
|
Job failed: The requested file size is too large
|
|
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
|
|
{"return": {}}
|
|
|
|
=== Resize image with invalid sizes ===
|
|
|
|
{"execute": "block_resize", "arguments": {"node-name": "node1", "size": 9223372036854775296}}
|
|
{"error": {"class": "GenericError", "desc": "The requested file size is too large"}}
|
|
{"execute": "block_resize", "arguments": {"node-name": "node1", "size": 9223372036854775808}}
|
|
{"error": {"class": "GenericError", "desc": "Invalid parameter type for 'size', expected: integer"}}
|
|
{"execute": "block_resize", "arguments": {"node-name": "node1", "size": 18446744073709551104}}
|
|
{"error": {"class": "GenericError", "desc": "Invalid parameter type for 'size', expected: integer"}}
|
|
{"execute": "block_resize", "arguments": {"node-name": "node1", "size": -9223372036854775808}}
|
|
{"error": {"class": "GenericError", "desc": "Parameter 'size' expects a >0 size"}}
|
|
image: json:{"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_IMG"}, "key-secret": "keysec0"}
|
|
file format: IMGFMT
|
|
virtual size: 0 B (0 bytes)
|
|
encrypted: yes
|
|
Format specific information:
|
|
ivgen alg: plain64
|
|
hash alg: sha256
|
|
cipher alg: aes-256
|
|
uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
cipher mode: xts
|
|
slots:
|
|
[0]:
|
|
active: true
|
|
iters: XXX
|
|
key offset: 4096
|
|
stripes: 4000
|
|
[1]:
|
|
active: false
|
|
key offset: 262144
|
|
[2]:
|
|
active: false
|
|
key offset: 520192
|
|
[3]:
|
|
active: false
|
|
key offset: 778240
|
|
[4]:
|
|
active: false
|
|
key offset: 1036288
|
|
[5]:
|
|
active: false
|
|
key offset: 1294336
|
|
[6]:
|
|
active: false
|
|
key offset: 1552384
|
|
[7]:
|
|
active: false
|
|
key offset: 1810432
|
|
payload offset: 2068480
|
|
master key iters: XXX
|
|
|