Bug 1909185 - The error message of "qemu-img convert -r" should advertise the correct maximum number
Summary: The error message of "qemu-img convert -r" should advertise the correct maxim...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: qemu-kvm
Version: 8.4
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: 8.4
Assignee: Eric Blake
QA Contact: Tingting Mao
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-12-18 14:42 UTC by Xueqiang Wei
Modified: 2021-08-25 15:43 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-07-20 12:42:25 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Xueqiang Wei 2020-12-18 14:42:34 UTC
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.

Comment 1 John Ferlan 2020-12-20 16:36:50 UTC
Eric - looks perhaps related to commit 43d589b074370ebc9b340340b5f641b385da9df8 which you reviewed and had PULL'd.

Comment 2 Eric Blake 2021-02-22 20:17:20 UTC
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

Comment 3 Eric Blake 2021-03-11 20:28:25 UTC
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.

Comment 4 Tingting Mao 2021-07-20 03:33:44 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.