Bug 1083844

Summary: Original image checking get errors after commit back with lazy_refcounts=on+qcow2_v3
Product: Red Hat Enterprise Linux 7 Reporter: chuli
Component: qemu-kvm-rhevAssignee: Kevin Wolf <kwolf>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: areis, hhuang, juzhang, knoel, michen, rbalakri, sluo, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu 2.0 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 09:44:54 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:

Description chuli 2014-04-03 05:10:34 UTC
Description of problem:
1.create a image with qcow2_v3+lazy_refcounts=on
2.create a snapshot for original image
3.do sth in snapshot img guest 
4.commit back to original image
5.qemu-img check original image get errors

Version-Release number of selected component (if applicable):

Host info:
3.10.0-118.el7.x86_64 RHEL_7

qemu-kvm-1.5.3-60.el7.x86_64
qemu-kvm-common-1.5.3-60.el7.x86_64
qemu-kvm-debuginfo-1.5.3-60.el7.x86_64
qemu-img-1.5.3-60.el7.x86_64
qemu-kvm-tools-1.5.3-60.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
1.qemu-img create -f qcow2 -o lazy_refcounts=on /home/verify.qcow2 10G

2.issue below cmd to install guest
/usr/libexec/qemu-kvm -M pc -S -cpu SandyBridge,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff,hv_time -enable-kvm -m 4096 -smp 4,sockets=2,cores=2,threao-kvm-pit-reinjection -usb -device usb-mouse,id=input0 -name install-test-pxe -uuid 990ea161-6b67-47b2-b803-19fb01d10d11 -rtc base=localtime,clock=host,driftfix=slew -drive file=/home/verify.qcow2,if=none,id=drive-virtio-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop -device virtio-blk,drive=drive-virtio-disk,id=virtio-disk,bootindex=1 -k en-us -boot menu=on -qmp tcp:0:4444,server,nowait -serial unix:/tmp/ttyS0,server,nowait -vnc :1 -monitor stdio -netdev tap,id='f123' -device virtio-net,netdev=f123 -cdrom /home/RHEL-7.0-20140326.0-Server-x86_64-dvd1.iso 

3.after install finished,shutdown guest

4.create snapshot by
qemu-img create -f qcow2 -o lazy_refcounts=on -b /home/verify.qcow2 /home/verify-sp1.qcow2 10G

5.boot guest on snapshot
 /usr/libexec/qemu-kvm -M pc -S -cpu SandyBridge,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff,hv_time -enable-kvm -m 4096 -smp 4,sockets=2,cores=2,threao-kvm-pit-reinjection -usb -device usb-mouse,id=input0 -name install-test-pxe -uuid 990ea161-6b67-47b2-b803-19fb01d10d11 -rtc base=localtime,clock=host,driftfix=slew -drive file=/home/verify-sp1.qcow2,if=none,id=drive-virtio-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop -device virtio-blk,drive=drive-virtio-disk,id=virtio-disk,bootindex=1 -k en-us -boot menu=on -qmp tcp:0:4444,server,nowait -serial unix:/tmp/ttyS0,server,nowait -vnc :1 -monitor stdio -netdev tap,id='f123' -device virtio-net,netdev=f123 -cdrom /home/RHEL-7.0-20140326.0-Server-x86_64-dvd1.iso 

6.in the guest issue "dd if=/dev/urandom of=file1 bs=1M count=512" then shutdown guest

7.commit back 
qemu-img commit -t none -f qcow2 verify-sp1.qcow2 

8.qemu-img check verify.qcow2
Actual results:


Expected results:

after step 8 ,there are errors like

ERROR OFLAG_COPIED data cluster: l2_entry=8000000056780000 refcount=0
ERROR OFLAG_COPIED data cluster: l2_entry=8000000056790000 refcount=0

15212 errors were found on the image.
Data may be corrupted, or further writes to the image may corrupt it.
22125/163840 = 13.50% allocated, 8.58% fragmented, 0.00% compressed clusters
Image end offset: 1450835968
 
Please get the detail screen output from attachment check_err.log

Additional info:

I can not reproduce this issue when create original image without  lazy_refcounts=on

Comment 1 chuli 2014-04-03 06:57:47 UTC
I can reproduce this issue with 1.5.3-38, 1.5.3-50 and 1.5.3-57.so it looks like not a regression

Comment 2 Kevin Wolf 2014-04-03 13:50:10 UTC
Confirmed. This is not a big deal because the dirty flag remains set, so no
corruption will be caused by this. We'll want to fix it anyway. I sent a patch
for this upstream:

[PATCH] qcow2: Flush metadata during read-only reopen

Comment 5 Kevin Wolf 2014-07-17 13:58:24 UTC
Fixed in upstream commit 4c2e5f8f, which is in 2.0.

Comment 7 Sibiao Luo 2014-08-28 10:02:32 UTC
Reproduce this issue on qemu-kvm-rhev-1.5.3-60.el7ev.x86_64 with the same steps as comment #0.

host info:
# uname -r && rpm -q qemu-kvm
3.10.0-145.el7.x86_64
qemu-kvm-rhev-1.5.3-60.el7ev.x86_64

Results:
# qemu-img commit -t none -f qcow2 verify-sp1.qcow2 
Image committed.
# qemu-img check verify.qcow2
ERROR cluster 12509 refcount=0 reference=1
ERROR OFLAG_COPIED data cluster: l2_entry=8000000030dd0000 refcount=0

2 errors were found on the image.
Data may be corrupted, or further writes to the image may corrupt it.
12497/163840 = 7.63% allocated, 0.00% fragmented, 0.00% compressed clusters
Image end offset: 819855360

#############################################

Verify this issue on qemu-kvm-rhev-2.1.0-2.el7.x86_64 with the same steps as comment #0.
host info:
# uname -r && rpm -q qemu-kvm-rhev
3.10.0-145.el7.x86_64
qemu-kvm-rhev-2.1.0-2.el7.x86_64

# qemu-img commit -t none -f qcow2 verify-sp1.qcow2 
Image committed.
# qemu-img check verify.qcow2
No errors were found on the image.
12081/163840 = 7.37% allocated, 0.00% fragmented, 0.00% compressed clusters
Image end offset: 792592384

Base on above, this issue has been fixed correctly, move to VERIFIED status.

Best Regards,
sluo

Comment 9 errata-xmlrpc 2015-03-05 09:44:54 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-2015-0624.html