Bug 927160

Summary: bandwidth limit for block copy/pull will fail if the value reach to 17592186044415
Product: Red Hat Enterprise Linux 6 Reporter: yanbing du <ydu>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.4CC: cwei, dyuan, lsu, mzhan, rbalakri, zhwang, zpeng
Target Milestone: rcKeywords: Upstream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.10.2-32.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 927156 Environment:
Last Closed: 2014-10-14 04:15:18 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 927156    
Bug Blocks:    

Description yanbing du 2013-03-25 09:06:11 UTC
This bug also exist on rhel6, but error message is different:
# rpm -q libvirt
libvirt-0.10.2-18.el6_4.2.x86_64

# virsh blockcopy vm1 vda /tmp/vm1.img --wait --verbose --bandwidth 17592186044415
error: internal error unable to execute QEMU command '__com.redhat_drive-mirror': Could not open '/tmp/vm1.img': Device or resource busy


+++ This bug was initially created as a clone of Bug #927156 +++

Description of problem:
The limitation of copying bandwidth is 17592186044415, but when set the bandwidth value reach to 17592186044415, it will fail. And it bug affect blockcopy, blockpull and blockjob commands.

In libvirtd.log, it shows that after convert bandwidth MiB to bytes, the speed value is "-1048576".

2013-03-25 07:06:06.959+0000: 18195: debug : qemuMonitorDriveMirror:2890 : mon=0x7fab40000d00, device=drive-virtio-disk0, file=/dev/mapper/VG_test-lv_test1, format=qcow2, bandwidth=17592186044415, flags=0
...

2013-03-25 07:06:06.959+0000: 18195: debug : virJSONValueToString:1102 : result={"execute":"drive-mirror","arguments":{"device":"drive-virtio-disk0","target":"/dev/mapper/VG_test-lv_test1","speed":-1048576,"sync":"full","mode":"absolute-paths","format":"qcow2"},"id":"libvirt-7"}


Version-Release number of selected component (if applicable):
libvirt-1.0.3-1.el7.x86_64 

How reproducible:
100%

Steps to Reproduce:
1. Create a domain:
#virsh create vm1.xml
Domain vm1 created from vm1.xml


2. Do block copy for vda
#  # virsh blockcopy vm1 vda /dev/mapper/VG_test-lv_test1 --wait --verbose --finish --bandwidth 11111111111111111
error: numerical overflow: bandwidth must be less than 17592186044415

# virsh blockcopy vm1 vda /dev/mapper/VG_test-lv_test1 --wait --verbose --finish --bandwidth 17592186044415
error: internal error unable to execute QEMU command 'drive-mirror': Invalid parameter 'speed'

# virsh blockcopy vm1 vda /dev/mapper/VG_test-lv_test1 --wait --verbose --finish --bandwidth 17592186044411
error: internal error unable to execute QEMU command 'drive-mirror': Invalid parameter 'speed'

For blockjob,

# virsh blockjob vm1 vda --bandwidth 175921860444111
error: numerical overflow: bandwidth must be less than 17592186044415

# virsh blockjob vm1 vda --bandwidth 17592186044415
error: internal error Unexpected error

# virsh blockjob vm1 vda --bandwidth 17592186044414
error: internal error Unexpected error

  
Actual results:
bandwidth limit for block copy/pull will fail if the value reach to 17592186044415 

Expected results:
Fix this bug. 

Additional info:

Comment 1 Peter Krempa 2013-04-03 14:39:27 UTC
Fixed upstream with:

commit 24ca8fae64d6088cb10a424c4bc6a7eb16ddeb26
Author: Peter Krempa <pkrempa>
Date:   Wed Apr 3 10:36:03 2013 +0200

    qemu-blockjob: Fix limit of bandwidth for block jobs to supported value
    
    The JSON generator is able to represent only values less than LLONG_MAX, fix the
    bandwidth limit checks when converting to value to catch overflows before they
    reach the generator.

v1.0.4-26-g24ca8fa

Moving to POST

Comment 8 chhu 2014-04-25 08:32:17 UTC
Reproduced with libvirt-0.10.2-31.el6.x86_64,

Verified with the packages:
libvirt-0.10.2-33.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.423.el6.x86_64

Test steps:
1. Create a domain:
# virsh create r6-qcow2.xml 
Domain r6-qcow2 created from r6-qcow2.xml

2. Do block copy for vda
# virsh blockcopy r6-qcow2 vda /var/lib/libvirt/images/bak --wait --verbose --finish --bandwidth 11111111111111111
error: numerical overflow: bandwidth must be less than 8796093022207

# virsh blockcopy r6-qcow2 vda /var/lib/libvirt/images/bak --wait --verbose --finish --bandwidth 8796093022207
Block Copy: [100 %]
Successfully copied

3. For blockjob,
# virsh blockjob r6-qcow2 vda --bandwidth 175921860444111
error: numerical overflow: bandwidth must be less than 8796093022207

# virsh blockjob r6-qcow2 vda --bandwidth 8796093022207
# virsh blockjob r6-qcow2 vda
Block Copy: [ 50 %]    Bandwidth limit: 8796093022207 MiB/s

# virsh blockjob r6-qcow2 vda --bandwidth 879609302220
# virsh blockjob r6-qcow2 vda
Block Copy: [ 55 %]    Bandwidth limit: 879609302220 MiB/s

4. Do blockpull for vda
# virsh snapshot-create-as r6-qcow2 s1 --disk-only
Domain snapshot s1 created

# virsh snapshot-create-as r6-qcow2 s2 --disk-only
Domain snapshot s2 created

# virsh snapshot-create-as r6-qcow2  s3 --disk-only
Domain snapshot s3 created

# virsh domblklist r6-qcow2
Target     Source
------------------------------------------------
vda        /var/lib/libvirt/images/r6-qcow2.s3

# virsh blockpull r6-qcow2 vda 175921860444111 /var/lib/libvirt/images/r6-qcow2.s1
error: numerical overflow: bandwidth must be less than 8796093022207

# virsh blockpull r6-qcow2 vda 8796093022207 /var/lib/libvirt/images/r6-qcow2.s1 --wait --verbose
Block Pull: [100 %]
Pull complete

# virsh blockpull r6-qcow2 vda 8796093022207 --wait --verbose
Block Pull: [ 21 %]

# virsh blockjob r6-qcow2 vda 
Block Pull: [ 14 %]    Bandwidth limit: 8796093022207 MiB/s

# virsh blockjob r6-qcow2 vda 87960930

# virsh blockjob r6-qcow2 vda 
Block Pull: [ 17 %]    Bandwidth limit: 87960930 MiB/s

Test results:
1. blockcopy, blockjob work well.
2. blockpull work well.

Comment 10 errata-xmlrpc 2014-10-14 04:15:18 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1374.html