Description of problem: The error message of "qemu-img convert -r" should advertise the correct maximum number. It advertises a larger maximum number than is allowed. Version-Release number of selected component (if applicable): kernel-4.18.0-259.el8.x86_64 qemu-kvm-5.2.0-1.module+el8.4.0+9091+650b220a How reproducible: 5/5 Steps to Reproduce: 1. convert a image with -r -1, getting the value must be between 0 and 9223372036854775807. # qemu-img convert -f qcow2 -O qcow2 /home/RHEL.8.4-virtio-scsi.qcow2 tgt.qcow2 -r -1 -p qemu-img: Invalid rate limit specified. Must be between 0 and 9223372036854775807. 2. Tested with -r 0, it works well. # qemu-img convert -f qcow2 -O qcow2 /home/RHEL.8.4-virtio-scsi.qcow2 tgt.qcow2 -r 0 -p (100.00/100%) 3. Tested with -r 9223372036854775807, it doesn't work. # qemu-img convert -f qcow2 -O qcow2 /home/RHEL.8.4-virtio-scsi.qcow2 tgt.qcow2 -r 9223372036854775807 qemu-img: Invalid rate limit specified. Must be between 0 and 9223372036854775807. Actual results: after step 3, failed to convert a image with -r 9223372036854775807. It advertises a larger maximum number than is allowed in the error message. Expected results: The error message of "qemu-img convert -r" should advertise the correct maximum number. Additional info: Tested with "qemu-img commit -r", also hit it.
Eric - looks perhaps related to commit 43d589b074370ebc9b340340b5f641b385da9df8 which you reviewed and had PULL'd.
This bug is due to qemu_strtosz() mishandling more than 53 bits of precision, and will be fixed once this lands upstream: https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg04160.html [PATCH v2 0/4] improve do_strtosz precision
Note that the patches mentioned in comment 2 are now upstream, but introduced a rounding regression where 12.345M produces 12344999 bytes in a context using 1000 as the scaling base. Followup patch proposed: https://lists.gnu.org/archive/html/qemu-devel/2021-03/msg04143.html [PATCH] utils: Reduce chance of rounding inaccuracy in qemu_strtosz.
Tried with latest qemu package, the bugs seems fixed. Tested with: qemu-kvm-6.0.0-7.el9 kernel-modules-5.13.0-1.el9.x86_64 Steps: # qemu-img convert -f qcow2 -O qcow2 test.qcow2 tgt.qcow2 -r -1 -p qemu-img: Invalid rate limit specified. You may use k, M, G, T, P or E suffixes for qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes. # qemu-img convert -f qcow2 -O qcow2 test.qcow2 tgt.qcow2 -r 0 -p (100.00/100%) # qemu-img convert -f qcow2 -O qcow2 test.qcow2 tgt.qcow2 -r 9223372036854775807 -p --------------------------> The maximum number works now. (100.00/100%) # qemu-img convert -f qcow2 -O qcow2 test.qcow2 tgt.qcow2 -r 9223372036854775808 -p qemu-img: Invalid rate limit specified. Must be between 0 and 9223372036854775807.