Bug 671104

Summary: virsh: vol-clone failed with the vol of allocation size with zero
Product: Red Hat Enterprise Linux 6 Reporter: Nan Zhang <nzhang>
Component: libvirtAssignee: Osier Yang <jyang>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 6.1CC: dallan, dyuan, eblake, llim, xen-maint, yoyzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-01-24 05:20:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Nan Zhang 2011-01-20 11:23:33 UTC
Description of problem:
Creating a volume and specify allocation size with zero, then failed to clone the volume with virsh vol-clone.

Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.129.el6.x86_64
libvirt-0.8.7-2.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
# virsh vol-create-as --pool default --name foo --capacity 6G --allocation 0 --format qcow2
Vol foo created

# virsh vol-info --pool default foo
Name:           foo
Type:           file
Capacity:       6.00 GB
Allocation:     140.00 KB
 
# virsh vol-clone --pool default --vol foo --newname foo1
error: Failed to clone vol from foo
error: Cannot run /usr/bin/qemu-img to create /var/lib/libvirt/images/foo1: Invalid argument
  
Actual results:
The error occurs.

Expected results:
The volume should be cloned successfully.

Additional info:
Successful case:
# virsh vol-create-as --pool default --name foo --capacity 6G --allocation 1G --format qcow2
Vol foo created

# virsh vol-clone --pool default --vol foo --newname foo1
Vol foo1 cloned from foo

Comment 1 Osier Yang 2011-01-22 04:22:18 UTC
What's the version of qemu-img?

And could you try to clone the vol from following qemu-img command? (/var/lib/libvirt/images/foo is the zero size vol you created.)

/usr/bin/qemu-img convert -f qcow2 -O qcow2 /var/lib/libvirt/images/foo /var/lib/libvirt/images/foo1

Comment 2 Osier Yang 2011-01-22 04:27:40 UTC
(In reply to comment #1)
> What's the version of qemu-img?
> 
> And could you try to clone the vol from following qemu-img command?
> (/var/lib/libvirt/images/foo is the zero size vol you created.)
> 
> /usr/bin/qemu-img convert -f qcow2 -O qcow2 /var/lib/libvirt/images/foo
> /var/lib/libvirt/images/foo1

Command above is what libvirt uses to clone the qcow2 vol, it works for me on
newer qemu-img.

[root@Osier ~]# /usr/bin/qemu-img convert -f qcow2 -O qcow2 /var/lib/libvirt/images/foo /var/lib/libvirt/images/foo1
[root@Osier ~]# echo $?
0

So, if it doesn't work on your qemu-img version, that's a bug of qemu-img, will reassign.

Comment 3 Osier Yang 2011-01-22 04:32:53 UTC
[root@Osier ~]# rpm -q qemu-img
qemu-img-0.13.0-1.fc14.x86_64

Comment 4 Nan Zhang 2011-01-24 05:20:53 UTC
I just tried both qemu-img and virsh command, it works well. It is curious that it can't be reproduced after rebooting my machine.