Skip to contentSkip to conversation

qcow2: Check that corrupted images can be repaired in iotest 060

PATCH Applied Alberto Garcia 3 participants 4 messages Nov 8, 2017 – Nov 10, 2017

lore
Share & tools
lore
#0 lore raw

cover qcow2: Check that corrupted images can be repaired in iotest 060

Hi,

I sent the 'Misc qcow2 corruption checks' series the other day, and Kevin suggested that we check that the corrupted images can be repaired using qemu-img.

This patch extends the tests that I wrote in order to do just that. Since the series is already in Max's branch I decided to write this as a follow-up patch, but if you prefer I can resend it instead.

Regards,

Berto

Alberto Garcia (1):
qcow2: Check that corrupted images can be repaired in iotest 060

 tests/qemu-iotests/060     | 10 ++++++++
 tests/qemu-iotests/060.out | 64 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/1 qcow2: Check that corrupted images can be repaired in iotest 060

We just fixed a few bugs that caused QEMU to crash when trying to write to corrupted qcow2 images, and iotest 060 was expanded to test all those scenarios.

In almost all cases the corrupted images can be repaired using qemu-img, so this patch verifies that.

---
 tests/qemu-iotests/060     | 10 ++++++++
 tests/qemu-iotests/060.out | 64 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)
tests/qemu-iotests/060 +10 -0
index 66a8fa4aea..fae08b03bf 100755
@@ -248,6 +248,8 @@ echo
 _make_test_img 64M
 poke_file "$TEST_IMG" "$rt_offset"        "\x00\x00\x00\x00\x00\x00\x00\x00"
 $QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io
+# Repair the image
+_check_test_img -r all
 
 echo
 echo "=== Testing empty refcount table with valid L1 and L2 tables ==="
@@ -259,6 +261,8 @@ poke_file "$TEST_IMG" "$rt_offset"        "\x00\x00\x00\x00\x00\x00\x00\x00"
 # allocation with an explicit offset (using qcow2_alloc_clusters_at())
 # causing a refcount block to be allocated at offset 0
 $QEMU_IO -c "write 0 128k" "$TEST_IMG" | _filter_qemu_io
+# Repair the image
+_check_test_img -r all
 
 echo
 echo "=== Testing empty refcount block ==="
@@ -266,6 +270,8 @@ echo
 _make_test_img 64M
 poke_file "$TEST_IMG" "$rb_offset"        "\x00\x00\x00\x00\x00\x00\x00\x00"
 $QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io
+# Repair the image
+_check_test_img -r all
 
 echo
 echo "=== Testing empty refcount block with compressed write ==="
@@ -276,6 +282,8 @@ poke_file "$TEST_IMG" "$rb_offset"        "\x00\x00\x00\x00\x00\x00\x00\x00"
 # The previous write already allocated an L2 table, so now this new
 # write will try to allocate a compressed data cluster at offset 0.
 $QEMU_IO -c "write -c 0k 64k" "$TEST_IMG" | _filter_qemu_io
+# Repair the image
+_check_test_img -r all
 
 echo
 echo "=== Testing zero refcount table size ==="
@@ -283,6 +291,8 @@ echo
 _make_test_img 64M
 poke_file "$TEST_IMG" "56"                "\x00\x00\x00\x00"
 $QEMU_IO -c "write 0 64k" "$TEST_IMG" 2>&1 | _filter_testdir | _filter_imgfmt
+# Repair the image
+_check_test_img -r all
 
 echo
 echo "=== Testing incorrect refcount table offset ==="
tests/qemu-iotests/060.out +64 -0

93 lines not on this page · raw message

Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#2 lore raw
Quoted 4 lines · Alberto Garcia

We just fixed a few bugs that caused QEMU to crash when trying to write to corrupted qcow2 images, and iotest 060 was expanded to test all those scenarios.

Quoted 8 lines

In almost all cases the corrupted images can be repaired using qemu-img, so this patch verifies that.

---
 tests/qemu-iotests/060     | 10 ++++++++
 tests/qemu-iotests/060.out | 64 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)

Just in case it matters to patchew:
Based-on: <[email protected]>

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Applied
#3 lore raw
In reply to Alberto Garcia
Quoted 6 lines · Alberto Garcia

Hi,

I sent the 'Misc qcow2 corruption checks' series the other day, and Kevin suggested that we check that the corrupted images can be repaired using qemu-img.

Quoted 7 lines

This patch extends the tests that I wrote in order to do just that. Since the series is already in Max's branch I decided to write this as a follow-up patch, but if you prefer I can resend it instead.

Regards,

Berto

Thanks, applied to my block branch:

https://github.com/XanClic/qemu/commits/block

Max