Bug 1206479

Summary: libvirt should check the --granularity value if it is power of 2
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: dyuan, mprivozn, mzhan, rbalakri, shyu, yanyang
Target Milestone: rcKeywords: Upstream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.15-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:25:46 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:

Description Luyao Huang 2015-03-27 08:59:02 UTC
description of problem:
libvirt should check the --granularity value if it is power of 2

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

How reproducible:
100%

Steps to Reproduce:
1.# virsh blockcopy --help
...
    --granularity <number>  power-of-two granularity to use during the copy
    --buf-size <number>  maximum amount of in-flight data during the copy
...
 
2.prepare a transient vm and do blockcopy
# virsh blockcopy test3 hda --xml gluster.xml --granularity 513
error: internal error: unable to execute QEMU command 'drive-mirror': Parameter 'granularity' expects power of 2

Actual results:
qemu report error instead libvirt

Expected results:
we already know this value should be power of 2, i think libvirt should check the --granularity value if it is power of 2, and output error early.


Additional info:

Comment 1 Luyao Huang 2015-03-27 09:59:51 UTC
send a patch to upstream:

http://www.redhat.com/archives/libvir-list/2015-March/msg01429.html

Comment 2 Michal Privoznik 2015-04-02 10:39:40 UTC
I've pushed the patch upstream:

commit 20aca080f37b9f4ca23df8d210400a1f05390c86
Author:     Luyao Huang <lhuang>
AuthorDate: Fri Mar 27 17:56:30 2015 +0800
Commit:     Michal Privoznik <mprivozn>
CommitDate: Thu Apr 2 11:12:01 2015 +0200

    qemuDomainBlockCopy: Check @granularity to be a power of two
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1206479
    
    As described in virDomainBlockCopy() parameters description, the
    VIR_DOMAIN_BLOCK_COPY_GRANULARITY parameter may require the value to
    have some specific attributes (e.g. be a power of two or fall within a
    certain range). And in qemu, a power of two is required. However, our
    code does not check that and let qemu operation fail. Moreover, the
    virsh man page is not as exact as it could be in this respect.
    
    Signed-off-by: Luyao Huang <lhuang>
    Signed-off-by: Michal Privoznik <mprivozn>

v1.2.14-22-g20aca08

Comment 4 Shanzhi Yu 2015-06-16 10:47:03 UTC
We should also add check if the value of granularity is between 4096 and 65536. But it doesn't matter much, so I'd change this bug to verified status after test with libvirt-1.2.16-1.el7.x86_64.

Comment 6 errata-xmlrpc 2015-11-19 06:25:46 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.

https://rhn.redhat.com/errata/RHBA-2015-2202.html