Bug 1297653

Summary: "qemu-img convert" can't create a fully allocated image passed a "-S 0" option
Product: Red Hat Enterprise Linux 6 Reporter: xiagao
Component: qemu-kvmAssignee: Hanna Czenczek <hreitz>
Status: CLOSED ERRATA QA Contact: Ping Li <pingl>
Severity: medium Docs Contact: Yehuda Zimmerman <yzimmerm>
Priority: medium    
Version: 6.8CC: ailan, chayang, famz, hreitz, juzhang, meyang, michen, mkenneth, ngu, rbalakri, shuang, tlavigne, virt-maint, xuwei, yiwei
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.495.el6 Doc Type: Bug Fix
Doc Text:
"-S 0" for "qemu-img convert" now works correctly Previously, specifying the "-S 0" option with "qemu-img convert" did not always explicitly write zeroes to all sparse areas in the output file. As a result, running "qemu-img convert -S 0" did not always result in a fully allocated output file. With this update, the command has been fixed, and running "qemu-img convert -S 0" always results in a fully allocated output file. Note that the qcow2 format offers a different preallocation option which can convert images to fully allocated output files faster than using the "-S 0" option. However, with other formats, this can only be achieved with the "-S 0" option.
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-21 09:36:30 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:
Bug Depends On:    
Bug Blocks: 1359965, 1364808    

Description xiagao 2016-01-12 06:27:15 UTC
Description of problem:
As summary, "qemu-img convert" can not to create a fully allocated image with a "-S 0" option


Version-Release number of selected component (if applicable):
qemu-kvm-rhev-0.12.1.2-2.483.el6.x86_64
kernel-2.6.32-595.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1.create a qcow2 image by default.
# qemu-img create -f qcow2 my-data-disk.qcow2 10G
Formatting 'my-data-disk.qcow2', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536

2.# qemu-img info my-data-disk.qcow2
image: my-data-disk.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 136K
cluster_size: 65536

3."qemu-img convert" can be passed a "-S 0" option to create a fully allocated image
# qemu-img convert -p -f qcow2 -O qcow2 **-S 0** my-data-disk.qcow2 dest.image
(100.00/100%)

4.# qemu-img info dest.image

Actual results:
# qemu-img info dest.image 
image: dest.image
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 136K
cluster_size: 65536


Expected results:
verify th disk size is the same to vritual size.
# qemu-img info dest.image
image: dest.image
file format: qcow2
virtual size: **10G** (10737418240 bytes)
**disk size: 10G**


Additional info:
1.this  issue can be reproduced on rhel6.7 release version and rhel7.2.z version
qemu-kvm-rhev-0.12.1.2-2.479.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.479.el6_7.3.x86_64
qemu-kvm-rhev-2.3.0-31.el7_2.5.x86_64

Comment 2 xiagao 2016-01-12 06:46:09 UTC
Test it on rhel7.2.z host.

version:
qemu-kvm-rhev-2.3.0-31.el7_2.5.x86_64

steps:
1.create a qcow2 image by default.
# qemu-img create -f qcow2 my-data-disk.qcow2 10G
Formatting 'my-data-disk.qcow2', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16

2.# qemu-img info my-data-disk.qcow2
image: my-data-disk.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 196K
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

3.# qemu-img convert -p -f qcow2 -O qcow2 -S 0 my-data-disk.qcow2 dest.image    (100.00/100%)

4.# qemu-img info dest.image
image: dest.image
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 2.1M
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

result:
The disk size is not the same with vritual size.

Comment 4 Yash Mankad 2016-10-27 20:33:01 UTC
Fix included in qemu-kvm-0.12.1.2-2.495.el6

Comment 6 Yiqian Wei 2016-10-28 03:29:54 UTC
Reproduce this bug
Host version:
  kernel-2.6.32-642.el6.x86_64
  qemu-kvm-0.12.1.2-2.490.el6.x86_64
Steps to Reproduce:
1.create a qcow2 image by default.
# qemu-img create -f qcow2 my-data-disk.qcow2 10G
Formatting 'my-data-disk.qcow2', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536

2.# qemu-img info my-data-disk.qcow2 
image: my-data-disk.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 196K
cluster_size: 65536

3.# qemu-img convert -p -f qcow2 -O qcow2 -S 0 my-data-disk.qcow2 dest.image
    (100.00/100%)

4.# qemu-img info dest.image 
image: dest.image
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 196K
cluster_size: 65536

Result:
The disk size is not the same with vritual size.
-------------------------------------------------
Verify this bug on "qemu-kvm-0.12.1.2-2.495.el6.x86_64" as same steps above.

Test results:The disk size is the same with vritual size.
# qemu-img info dest.image 
image: dest.image
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 10G
cluster_size: 65536

According to result above,this bug has been fixed.

Comment 7 Ping Li 2016-10-31 05:48:31 UTC
(In reply to Yiqian Wei from comment #6)
> Reproduce this bug
> Host version:
>   kernel-2.6.32-642.el6.x86_64
>   qemu-kvm-0.12.1.2-2.490.el6.x86_64
> Steps to Reproduce:
> 1.create a qcow2 image by default.
> # qemu-img create -f qcow2 my-data-disk.qcow2 10G
> Formatting 'my-data-disk.qcow2', fmt=qcow2 size=10737418240 encryption=off
> cluster_size=65536
> 
> 2.# qemu-img info my-data-disk.qcow2 
> image: my-data-disk.qcow2
> file format: qcow2
> virtual size: 10G (10737418240 bytes)
> disk size: 196K
> cluster_size: 65536
> 
> 3.# qemu-img convert -p -f qcow2 -O qcow2 -S 0 my-data-disk.qcow2 dest.image
>     (100.00/100%)
> 
> 4.# qemu-img info dest.image 
> image: dest.image
> file format: qcow2
> virtual size: 10G (10737418240 bytes)
> disk size: 196K
> cluster_size: 65536
> 
> Result:
> The disk size is not the same with vritual size.
> -------------------------------------------------
> Verify this bug on "qemu-kvm-0.12.1.2-2.495.el6.x86_64" as same steps above.
> 
> Test results:The disk size is the same with vritual size.
> # qemu-img info dest.image 
> image: dest.image
> file format: qcow2
> virtual size: 10G (10737418240 bytes)
> disk size: 10G
> cluster_size: 65536
> 
> According to result above,this bug has been fixed.

Thanks Yiqian.
Set this BZ as verified.

Comment 12 errata-xmlrpc 2017-03-21 09:36:30 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-2017-0621.html