Bug 1004347

Summary: Backport qcow2 corruption prevention patches
Product: Red Hat Enterprise Linux 7 Reporter: Kevin Wolf <kwolf>
Component: qemu-kvmAssignee: Hanna Czenczek <hreitz>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, chayang, hhuang, hreitz, huding, juzhang, michen, mrezanin, qzhang, sluo, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-1.5.3-34.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1004420 (view as bug list) Environment:
Last Closed: 2014-06-13 10:08:46 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: 1004420    

Description Kevin Wolf 2013-09-04 13:03:17 UTC
Upstream commits d4ca092a to ca0eca91 implements sanity checks for writes to a
qcow2 image as follows:

> If a qcow2 image file becomes corrupted, any write may inadvertently
> overwrite important metadata structures such as the L1 table. This
> series adds functionality for detecting, preventing and (to some extent)
> repairing such collisions.

This is something that we'll want to have in RHEL 7.

Comment 1 Miroslav Rezanina 2013-11-07 14:24:58 UTC
Fix included in qemu-kvm-1.5.3-16.el7

Comment 4 huiqingding 2013-12-23 06:30:26 UTC
Hi Max, 

Would you please answer the question of comment #3 ?

Best regards
Huiqing

Comment 6 juzhang 2014-01-03 09:17:25 UTC
Hi Huding,

Could you have a look and update the result in the bz?

Best Regards,
Junyi

Comment 9 Miroslav Rezanina 2014-01-08 12:43:46 UTC
Fix included in qemu-kvm-1.5.3-34.el7

Comment 10 huiqingding 2014-01-13 09:22:11 UTC
Reproduce this bug using the following version:
qemu-kvm-1.5.3-15.el7.x86_64
kernel-3.10.0-64.el7.x86_64

Run test 060 of qemu-iotests and the result is as following:
# ./check -qcow2 060
QEMU          -- /usr/libexec/qemu-kvm
QEMU_IMG      -- /usr/bin/qemu-img
QEMU_IO       -- /usr/bin/qemu-io 
IMGFMT        -- qcow2 (compat=1.1)
IMGPROTO      -- file
PLATFORM      -- Linux/x86_64 dhcp-8-151 3.10.0-64.el7.x86_64

060 1s ... - output mismatch (see 060.out.bad)
--- 060.out	2014-01-13 11:34:39.458489446 +0800
+++ 060.out.bad	2014-01-13 17:18:26.944998958 +0800
@@ -8,10 +8,13 @@
 1 errors were found on the image.
 Data may be corrupted, or further writes to the image may corrupt it.
 incompatible_features     0x0
-qcow2: Preventing invalid write on metadata (overlaps with active L1 table); image marked as corrupt.
-write failed: Input/output error
-incompatible_features     0x2
-qemu-io: can't open device TEST_DIR/t.IMGFMT: IMGFMT: Image is corrupt; cannot be opened read/write
+open: invalid option -- 'o'
+no file open, try 'help open'
+open [-Crsn] [path] -- open the file specified by path
+incompatible_features     0x0
+open: invalid option -- 'o'
+no file open, try 'help open'
+open [-Crsn] [path] -- open the file specified by path
 read 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 
@@ -24,58 +27,55 @@
 2 errors were found on the image.
 Data may be corrupted, or further writes to the image may corrupt it.
 incompatible_features     0x0
-qcow2: Preventing invalid write on metadata (overlaps with refcount block); image marked as corrupt.
-write failed: Input/output error
-incompatible_features     0x2
-Repairing refcount block 0 refcount=2
+open: invalid option -- 'o'
+no file open, try 'help open'
+open [-Crsn] [path] -- open the file specified by path
+incompatible_features     0x0
+ERROR refcount block 0 refcount=2
+Repairing cluster 2 refcount=1 reference=2
+ERROR OFLAG_COPIED: offset=8000000000020000 refcount=2
+ERROR refcount block 0 refcount=2
 The following inconsistencies were found and repaired:
 
     0 leaked clusters
     1 corruptions
 
 Double checking the fixed image now...
-No errors were found on the image.
+
+2 errors were found on the image.
+Data may be corrupted, or further writes to the image may corrupt it.
 incompatible_features     0x0
-wrote 512/512 bytes at offset 0
-512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+open: invalid option -- 'o'
+no file open, try 'help open'
+open [-Crsn] [path] -- open the file specified by path
 incompatible_features     0x0
 
 === Testing cluster data reference into inactive L2 table ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 
-wrote 512/512 bytes at offset 0
-512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-wrote 512/512 bytes at offset 0
-512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-ERROR cluster 4 refcount=1 reference=2
-Leaked cluster 9 refcount=1 reference=0
-
-1 errors were found on the image.
-Data may be corrupted, or further writes to the image may corrupt it.
-
-1 leaked clusters were found on the image.
-This means waste of disk space, but no harm to data.
+open: invalid option -- 'o'
+no file open, try 'help open'
+open [-Crsn] [path] -- open the file specified by path
+open: invalid option -- 'o'
+no file open, try 'help open'
+open [-Crsn] [path] -- open the file specified by path
+No errors were found on the image.
+incompatible_features     0x0
+open: invalid option -- 'o'
+no file open, try 'help open'
+open [-Crsn] [path] -- open the file specified by path
 incompatible_features     0x0
-qcow2: Preventing invalid write on metadata (overlaps with inactive L2 table); image marked as corrupt.
-write failed: Input/output error
-incompatible_features     0x2
-Repairing cluster 4 refcount=1 reference=2
-Repairing cluster 9 refcount=1 reference=0
-Repairing OFLAG_COPIED data cluster: l2_entry=8000000000040000 refcount=2
-The following inconsistencies were found and repaired:
-
-    1 leaked clusters
-    2 corruptions
-
-Double checking the fixed image now...
 No errors were found on the image.
 incompatible_features     0x0
-wrote 512/512 bytes at offset 0
-512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+open: invalid option -- 'o'
+no file open, try 'help open'
+open [-Crsn] [path] -- open the file specified by path
 incompatible_features     0x0
+Pattern verification failed at offset 0, 512 bytes
 read 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 No errors were found on the image.
+Pattern verification failed at offset 0, 512 bytes
 read 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 *** done
Failures: 060
Failed 1 of 1 tests

Comment 11 huiqingding 2014-01-13 09:25:37 UTC
Reproduce this bug using the following version:
qemu-kvm-1.5.3-35.el7.x86_64
kernel-3.10.0-64.el7.x86_64

Run test 060 of qemu-iotests and the result is as following:
# ./check -qcow2 060
QEMU          -- /usr/libexec/qemu-kvm
QEMU_IMG      -- /usr/bin/qemu-img
QEMU_IO       -- /usr/bin/qemu-io 
IMGFMT        -- qcow2 (compat=1.1)
IMGPROTO      -- file
PLATFORM      -- Linux/x86_64 dhcp-8-151 3.10.0-64.el7.x86_64

060 1s ...
Passed all 1 tests

Based on the above result, I think this bug is fixed.

Comment 12 huiqingding 2014-01-21 03:21:22 UTC
(In reply to huiqingding from comment #11)
> Reproduce this bug using the following version:

Sorry, it should "Verify this bug using the following version"

> qemu-kvm-1.5.3-35.el7.x86_64
> kernel-3.10.0-64.el7.x86_64
> 
> Run test 060 of qemu-iotests and the result is as following:
> # ./check -qcow2 060
> QEMU          -- /usr/libexec/qemu-kvm
> QEMU_IMG      -- /usr/bin/qemu-img
> QEMU_IO       -- /usr/bin/qemu-io 
> IMGFMT        -- qcow2 (compat=1.1)
> IMGPROTO      -- file
> PLATFORM      -- Linux/x86_64 dhcp-8-151 3.10.0-64.el7.x86_64
> 
> 060 1s ...
> Passed all 1 tests
> 
> Based on the above result, I think this bug is fixed.

Comment 14 Ludek Smid 2014-06-13 10:08:46 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.