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 958510 - virStorageVolCreateXML requires <capacity> even when <backingStore> is specified
Summary: virStorageVolCreateXML requires <capacity> even when <backingStore> is specified
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-05-01 17:21 UTC by Ian McLeod
Modified: 2016-04-26 14:08 UTC (History)
10 users (show)

Fixed In Version: libvirt-1.2.14-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 05:43:10 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1104862 0 unspecified CLOSED [RFE] Volume creation as external snapshot shouldn't require capacity 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHBA-2015:2202 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2015-11-19 08:17:58 UTC

Internal Links: 1104862

Description Ian McLeod 2013-05-01 17:21:42 UTC
Description of problem:

virStorageVolCreateXML() fails without a <capacity> element in the presence
of a <backingStorage> section that points to a file.

libvirt throws the following error:

"libvirt.libvirtError: XML error: missing capacity element"


This is on RHEL 6.4 with:

libvirt-0.10.2-18.el6.x86_64
libvirt-python-0.10.2-18.el6.x86_64

Per a brief chat with eblake, it would be nice to allow the capacity element to be omitted in situations where the volume is being created with backingStorage of known size (as with an existing raw or qcow2 image file), since qemu-img does not require a size when doing this type of create.

At present, I have to derive the capacity of the backing file (which may be either raw or qcow2 in this particular case) and then specify that as the capacity in the XML.

Comment 5 Jiri Denemark 2014-04-04 21:37:44 UTC
This bug was not selected to be addressed in Red Hat Enterprise Linux 6. We will look at it again within the Red Hat Enterprise Linux 7 product.

Comment 7 Ján Tomko 2015-02-19 15:23:33 UTC
Upstream patches:
https://www.redhat.com/archives/libvir-list/2015-February/msg00697.html

Comment 8 Ján Tomko 2015-03-02 07:45:34 UTC
Fixed upstream as of
commit 155ca616eb231181f6978efc9e3a1eb0eb60af8a
Author:     Ján Tomko <jtomko>
CommitDate: 2015-03-02 08:07:11 +0100

    Allow creating volumes with a backing store but no capacity
    
    The tool creating the image can get the capacity from the backing
    storage. Just refresh the volume afterwards.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=958510

git describe: v1.2.13-17-g155ca61

Comment 11 Yang Yang 2015-05-29 09:57:14 UTC
Verified on libvirt-1.2.15-2.el7.x86_64

Steps
1. test vol-create
# cat BZ958510 
<volume>
  <name>demo</name>
  <source>
  </source>
  <target>
    <format type='qcow2'/>
  </target>
  <backingStore>
    <path>/var/lib/libvirt/images/vm1.raw</path>
  </backingStore>
</volume>

# virsh vol-create default BZ958510 
Vol demo created from BZ958510

# virsh vol-info demo default
Name:           demo
Type:           file
Capacity:       5.00 GiB
Allocation:     196.00 KiB

# virsh vol-dumpxml demo default
<volume type='file'>
  <name>demo</name>
  <key>/var/lib/libvirt/images/demo</key>
  <source>
  </source>
  <capacity unit='bytes'>5368709120</capacity>
  <allocation unit='bytes'>200704</allocation>
  <target>
    <path>/var/lib/libvirt/images/demo</path>
    <format type='qcow2'/>
    <permissions>
      <mode>0600</mode>
      <owner>0</owner>
      <group>0</group>
      <label>system_u:object_r:virt_image_t:s0</label>
    </permissions>
    <timestamps>
      <atime>1432804118.667607029</atime>
      <mtime>1432804118.616607010</mtime>
      <ctime>1432804118.666607029</ctime>
    </timestamps>
  </target>
  <backingStore>
    <path>/var/lib/libvirt/images/vm1.raw</path>
    <format type='raw'/>
    <permissions>
      <mode>0644</mode>
      <owner>107</owner>
      <group>107</group>
      <label>system_u:object_r:svirt_image_t:s0:c469,c778</label>
    </permissions>
    <timestamps>
      <atime>1432804118.667607029</atime>
      <mtime>1432520901.532815217</mtime>
      <ctime>1432520901.532815217</ctime>
    </timestamps>
  </backingStore>
</volume>

start a vm with demo, it works well
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/demo'/>
      <backingStore type='file' index='1'>
        <format type='raw'/>
        <source file='/var/lib/libvirt/images/vm1.raw'/>
        <backingStore/>
      </backingStore>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </disk>

# virsh vol-delete demo default
Vol demo deleted

2. test vol-create-from
# cat BZ958510 
<volume>
  <name>demo</name>
  <source>
  </source>
  <target>
    <format type='qcow2'/>
  </target>
</volume>

# qemu-img info /var/lib/libvirt/images/vm1.raw 
image: /var/lib/libvirt/images/vm1.raw
file format: raw
virtual size: 5.0G (5368709120 bytes)
disk size: 1.3G

# virsh vol-create-from default BZ958510 --inputpool default vm1.raw
Vol demo created from input vol vm1.raw

# virsh vol-info demo default
Name:           demo
Type:           file
Capacity:       5.00 GiB
Allocation:     2.00 GiB

# qemu-img info /var/lib/libvirt/images/demo 
image: /var/lib/libvirt/images/demo
file format: qcow2
virtual size: 5.0G (5368709120 bytes)
disk size: 2.0G
cluster_size: 65536
Format specific information:
    compat: 0.10

start a vm with demo, it works well
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/demo'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </disk>

3. negative test: dir type vol with backing file
# cat BZ958510 
<volume type='dir'>
  <name>demo</name>
  <source>
  </source>
  <target>
    <format type='dir'/>
  </target>
<backingStore>
    <path>/var/lib/libvirt/images/vm1.raw</path>
  </backingStore>
</volume>

# virsh vol-create default BZ958510 
error: Failed to create vol from BZ958510
error: this function is not supported by the connection driver: backing storage not supported for directories volumes

4. negative test: raw type vol with backing file
# cat BZ958510 
<volume type='file'>
  <name>demo</name>
  <source>
  </source>
  <target>
    <format type='raw'/>
  </target>
<backingStore>
    <path>/var/lib/libvirt/images/vm1.raw</path>
  </backingStore>
</volume>

# virsh vol-create default BZ958510 
error: Failed to create vol from BZ958510
error: this function is not supported by the connection driver: backing storage not supported for raw volumes

5. negative test: lack of capacity in rbd pool
# cat BZ958510-RBD 
<volume type='network'>
  <name>demo</name>
  <source>
  </source>
</volume>

# virsh vol-create rbd BZ958510-RBD 
error: Failed to create vol from BZ958510-RBD
error: XML error: missing capacity element

6. negative test: vol with backing file in rbd pool. The issue is tracked in bz1223177

# cat BZ958510-RBD 
<volume type='network'>
  <name>demo</name>
  <source>
  </source>
<backingStore>
    <path>/var/lib/libvirt/images/vm1.raw</path>
  </backingStore>
</volume>

# virsh vol-create rbd BZ958510-RBD 
error: Failed to create vol from BZ958510-RBD
error: failed to remove volume 'libvirt-pool/demo': No such file or directory

# virsh vol-list rbd | grep demo
 demo                 libvirt-pool/demo 

# virsh vol-delete demo rbd
error: Failed to delete vol demo
error: failed to remove volume 'libvirt-pool/demo': No such file or directory

Comment 13 errata-xmlrpc 2015-11-19 05:43:10 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


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