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 1298065 - The size of raw image is incorect after clone without --nonsparse
Summary: The size of raw image is incorect after clone without --nonsparse
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.3
Hardware: x86_64
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-01-13 06:25 UTC by Xiaodai Wang
Modified: 2016-11-03 18:36 UTC (History)
7 users (show)

Fixed In Version: libvirt-1.3.1-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-03 18:36:10 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1130739 0 unspecified CLOSED cloned qcow2 image file has full size 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHSA-2016:2577 0 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2016-11-03 12:07:06 UTC

Internal Links: 1130739

Description Xiaodai Wang 2016-01-13 06:25:59 UTC
Description of problem:
The size of raw image is incorect after clone without --nonsparse

Version-Release number of selected component (if applicable):
# rpm -q libvirt virt-install
libvirt-1.2.17-13.el7.x86_64
virt-install-1.2.1-8.el7.noarch

How reproducible:
100%

Steps to Reproduce:
Prepare a guest with raw image and clone it with sparse.

# qemu-img info demo.img 
image: demo.img
file format: raw
virtual size: 5.0G (5368709120 bytes)
disk size: 2.4G

# virt-clone -o demo -f /var/lib/libvirt/images/demo-clone -n demo-clone
Allocating 'demo-clone'                                                                                                                               | 5.0 GB  00:00:40     

Clone 'demo-clone' created successfully.
# ll
-rw-------.  1 root root  5368709120 Jan 13 14:10 demo-clone
-rw-------.  1 root root  5368709120 Dec 11 17:13 demo.img

# qemu-img info demo-clone
image: demo-clone
file format: raw
virtual size: 5.0G (5368709120 bytes)
disk size: 5.0G

Actual results:
The size of the image is incorrect.

Expected results:
The size of the image should not be 5G and should be sparse.

Additional info:
These is a bug on upstream (https://bugzilla.redhat.com/show_bug.cgi?id=1130739), This bug is reported for tracking the problem on downstream.

Comment 2 Ján Tomko 2016-01-22 08:34:49 UTC
Fixed upstream by:
commit dd519a294b22646b8dab26627707a525556df4d4
Author:     Prerna Saxena <prerna.ibm.com>
CommitDate: 2015-07-10 08:54:10 +0200

    Fix cloning of raw, sparse volumes
    
    When virsh vol-clone is attempted on a raw file where capacity > allocation,
    the resulting cloned volume has a size that matches the virtual-size of
    the parent; in place of matching its actual, disk size.
    This patch fixes the cloned disk to have same _allocated_size_ as
    the parent file from which it was cloned.
    
    Ref: http://www.redhat.com/archives/libvir-list/2015-May/msg00050.html
    
    Also fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1130739
    
    Signed-off-by: Prerna Saxena <prerna.ibm.com>
    Signed-off-by: Ján Tomko <jtomko>

git describe: v1.2.17-74-gdd519a2 contains: v1.2.18-rc1~100

Comment 4 yisun 2016-02-23 10:05:53 UTC
Verified and PASSED

versions:
qemu-kvm-rhev-2.3.0-31.el7_2.7.x86_64
libvirt-1.3.1-1.el7.x86_64
virt-install-1.2.1-8.el7.noarch


prepare disks
In host:
# qemu-img create -f qcow2 /var/lib/libvirt/images/qcow2  10G
# qemu-img create -f raw /var/lib/libvirt/images/raw  5G

# virsh dumpxml vm1 | grep var -a2
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/rhel7.qcow2'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
--
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/qcow2'/>
      <target dev='hdb' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
--
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/raw'/>
      <target dev='hdc' bus='ide'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>

In guest:
#mkfs.xfs /dev/sdb; mkfs.xfs /dev/sdc
#mkdir /raw; mkdir /qcow2
#mount /dev/sdb /qcow2; mount /dev/sdc/raw
#dd if=/dev/urandom of=/raw/bigfile count=1000 bs=1M
#dd if=/dev/urandom of=/qcow2/bigfile count=2000 bs=1M

steps:
1. check original images' info 
# qemu-img info /var/lib/libvirt/images/qcow2 
image: /var/lib/libvirt/images/qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 2.0G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

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

2. use virt-clone to do the clone and check the new images' info
# virt-clone -o vm1 -f /var/lib/libvirt/images/rhel7-clone -f /tmp/qcow2-clone  -f /tmp/raw-clone -n JustATest

# qemu-img info /tmp/qcow2-clone 
image: /tmp/qcow2-clone
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 2.0G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true
    refcount bits: 16
    corrupt: false

# qemu-img info /tmp/raw-clone 
image: /tmp/raw-clone
file format: raw
virtual size: 5.0G (5368709120 bytes)
disk size: 1.0G

3. use virsh vol-clone to do the clone and check the new images' info
# virsh vol-clone --pool default --vol qcow2 qcow2-clone
Vol qcow2-clone cloned from qcow2

# virsh vol-clone --pool default --vol raw raw-clone
Vol raw-clone cloned from raw

# qemu-img info /var/lib/libvirt/images/qcow2-clone 
image: /var/lib/libvirt/images/qcow2-clone
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 2.0G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

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

Comment 6 errata-xmlrpc 2016-11-03 18:36: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/RHSA-2016-2577.html


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