Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

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:
Embargoed:

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.