Bug 598488

Summary: qcow2 corruption bug in refcount table growth
Product: Red Hat Enterprise Linux 5 Reporter: Kevin Wolf <kwolf>
Component: kvmAssignee: Kevin Wolf <kwolf>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 5.5CC: cpelland, llim, qzhang, szhou, tburke, virt-maint, ykaul
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: kvm-83-182.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 598407 Environment:
Last Closed: 2011-01-13 23:35:40 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:
Bug Depends On:    
Bug Blocks: 602363    

Description Kevin Wolf 2010-06-01 13:48:53 UTC
The same bug exists in RHEL 5.5/5.6.

+++ This bug was initially created as a clone of Bug #598407 +++

A bug in rarely used code path in the refcount table growth code of qcow2 can lead to inconsistencies in the metadata, which can cause real data corruption later on.

This bug can be reproduced like this:

[rhel6/master] kwolf@dhcp-5-188:~/source/qemu-kvm-rhel6$ ./qemu-img create -f qcow2 -ocluster_size=512 /tmp/test.qcow2 1G
Formatting '/tmp/test.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=512 
[rhel6/master] kwolf@dhcp-5-188:~/source/qemu-kvm-rhel6$ ./qemu-io /tmp/test.qcow2 
qemu-io> write -b 0 64M
wrote 67108864/67108864 bytes at offset 0
64 MiB, 1 ops; 0:00:11.00 (5.791 MiB/sec and 0.0905 ops/sec)
qemu-io> [rhel6/master] kwolf@dhcp-5-188:~/source/qemu-kvm-rhel6$ ./qemu-img check /tmp/test.qcow2 
ERROR cluster 768 refcount=0 reference=1
ERROR cluster 773 refcount=2 reference=1
ERROR cluster 774 refcount=2 reference=1
ERROR cluster 1024 refcount=0 reference=1
ERROR cluster 1029 refcount=2 reference=1
ERROR cluster 1030 refcount=2 reference=1
ERROR cluster 1031 refcount=2 reference=1
7 errors were found on the image.

Comment 5 Qunfang Zhang 2010-06-11 03:55:13 UTC
Reproduced on kvm-83-181.el5, and verified pass on kvm-83-182.el5

Steps:
1.Create a disk on *RHEL6* host
#qemu-img create -f qcow2 -ocluster_size=512 test.qcow2 1G
2.Copy this disk to RHEL5 host
#/usr/libexec/qemu-kvm test.qcow2 -monitor stdio -vnc :10
(qemu)savevm aaa
(qemu)savevm bbb
(qemu)info snapshots
(qemu)quit
3.#qemu-img check test.qcow2

On kvm-83-181.el5:
[root@dhcp-91-161 home]# qemu-img check test.qcow2 
ERROR cluster 768 refcount=0 reference=1
ERROR cluster 773 refcount=2 reference=1
ERROR cluster 774 refcount=2 reference=1
ERROR cluster 1024 refcount=0 reference=1
ERROR cluster 1029 refcount=2 reference=1
ERROR cluster 1030 refcount=2 reference=1
ERROR cluster 1031 refcount=2 reference=1
ERROR cluster 2304 refcount=0 reference=1
ERROR cluster 2371 refcount=2 reference=1
ERROR cluster 2372 refcount=2 reference=1
ERROR cluster 2560 refcount=0 reference=1
ERROR cluster 2627 refcount=2 reference=1
ERROR cluster 2628 refcount=2 reference=1
ERROR cluster 2629 refcount=2 reference=1
ERROR cluster 4352 refcount=0 reference=1
ERROR cluster 4428 refcount=2 reference=1
ERROR cluster 4429 refcount=2 reference=1
ERROR cluster 4608 refcount=0 reference=1
ERROR cluster 4684 refcount=2 reference=1
ERROR cluster 4685 refcount=2 reference=1
ERROR cluster 4686 refcount=2 reference=1
21 errors were found on the image.

On kvm-83-182.el5
[root@dhcp-91-161 home]# qemu-img check test.qcow2 
No errors were found on the image.

Comment 7 Shirley Zhou 2010-11-02 05:23:11 UTC
Re-verify this bug with package kvm-83-207.el5 as comment 5 steps, after step3, then check image, no error shows.
Change bug to verified.

Comment 9 errata-xmlrpc 2011-01-13 23:35:40 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0028.html