mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
cutils: Use parse_uint in qemu_strtosz for negative rejection
Rather than open-coding two different ways to check for an unwanted negative sign, reuse the same code in both functions. That way, if we decide down the road to accept "-0" instead of rejecting it, we have fewer places to change. Also, it means we now get ERANGE instead of EINVAL for negative values in qemu_strtosz, which is reasonable for what it represents. This in turn changes the expected output of a couple of iotests. The change is not quite complete: negative fractional scaled values can trip us up. This will be fixed in a later patch addressing other issues with fractional scaled values. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Czenczek <hreitz@redhat.com> Message-Id: <20230522190441.64278-18-eblake@redhat.com>
This commit is contained in:
parent
3c5f246798
commit
b87ac96651
5 changed files with 9 additions and 19 deletions
|
@ -92,13 +92,10 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off comp
|
|||
== 3. Invalid sizes ==
|
||||
|
||||
qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- -1024
|
||||
qemu-img: Invalid image size specified. You may use k, M, G, T, P or E suffixes for
|
||||
qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes.
|
||||
qemu-img: Invalid image size specified. Must be between 0 and 9223372036854775807.
|
||||
|
||||
qemu-img create -f qcow2 -o size=-1024 TEST_DIR/t.qcow2
|
||||
qemu-img: TEST_DIR/t.qcow2: Parameter 'size' expects a non-negative number below 2^64
|
||||
Optional suffix k, M, G, T, P or E means kilo-, mega-, giga-, tera-, peta-
|
||||
and exabytes, respectively.
|
||||
qemu-img: TEST_DIR/t.qcow2: Value '-1024' is out of range for parameter 'size'
|
||||
|
||||
qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- -1k
|
||||
qemu-img: Invalid image size specified. You may use k, M, G, T, P or E suffixes for
|
||||
|
|
|
@ -13,8 +13,7 @@ qemu-img: Invalid option list: ,
|
|||
qemu-img: Invalid parameter 'snapshot.foo'
|
||||
qemu-img: Failed in parsing snapshot param 'snapshot.foo=bar'
|
||||
qemu-img: --output must be used with human or json as argument.
|
||||
qemu-img: Invalid image size specified. You may use k, M, G, T, P or E suffixes for
|
||||
qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes.
|
||||
qemu-img: Invalid image size specified. Must be between 0 and 9223372036854775807.
|
||||
qemu-img: Unknown file format 'foo'
|
||||
|
||||
== Size calculation for a new file (human) ==
|
||||
|
|
|
@ -13,8 +13,7 @@ qemu-img: Invalid option list: ,
|
|||
qemu-img: Invalid parameter 'snapshot.foo'
|
||||
qemu-img: Failed in parsing snapshot param 'snapshot.foo=bar'
|
||||
qemu-img: --output must be used with human or json as argument.
|
||||
qemu-img: Invalid image size specified. You may use k, M, G, T, P or E suffixes for
|
||||
qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes.
|
||||
qemu-img: Invalid image size specified. Must be between 0 and 9223372036854775807.
|
||||
qemu-img: Unknown file format 'foo'
|
||||
|
||||
== Size calculation for a new file (human) ==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue