Skip to contentSkip to conversation

parallels: additional iotests and a minor bugfix

PATCH Applied Denis V. Lunev 3 participants 7 messages Oct 8, 2014 – Oct 28, 2014 Block layer

lore
Share & tools
lore
#1 lore raw

PATCH 1/3 iotests: replace fake parallels image with authentic one

The image was generated using http://openvz.org/Ploop utility and properly filled with the same content as original one.

CC Jeff Cody <[email protected]>
CC Kevin Wolf <[email protected]>
CC Stefan Hajnoczi <[email protected]>
---
 tests/qemu-iotests/076                              |  10 +++++-----
 tests/qemu-iotests/076.out                          |   8 ++++----
 tests/qemu-iotests/sample_images/fake.parallels.bz2 | Bin 141 -> 0 bytes
 tests/qemu-iotests/sample_images/parallels-v1.bz2   | Bin 0 -> 147 bytes
 4 files changed, 9 insertions(+), 9 deletions(-)
 delete mode 100644 tests/qemu-iotests/sample_images/fake.parallels.bz2
 create mode 100644 tests/qemu-iotests/sample_images/parallels-v1.bz2
tests/qemu-iotests/076 +5 -5
index b614a7d..a300ee2 100755
@@ -47,26 +47,26 @@ catalog_entries_offset=$((0x20))
 nb_sectors_offset=$((0x24))
 
 echo
-echo "== Read from a valid (enough) image =="
-_use_sample_img fake.parallels.bz2
+echo "== Read from a valid v1 image =="
+_use_sample_img parallels-v1.bz2
 { $QEMU_IO -c "read -P 0x11 0 64k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
 
 echo
 echo "== Negative catalog size =="
-_use_sample_img fake.parallels.bz2
+_use_sample_img parallels-v1.bz2
 poke_file "$TEST_IMG" "$catalog_entries_offset" "\xff\xff\xff\xff"
 { $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
 
 echo
 echo "== Overflow in catalog allocation =="
-_use_sample_img fake.parallels.bz2
+_use_sample_img parallels-v1.bz2
 poke_file "$TEST_IMG" "$nb_sectors_offset" "\xff\xff\xff\xff"
 poke_file "$TEST_IMG" "$catalog_entries_offset" "\x01\x00\x00\x40"
 { $QEMU_IO -c "read 64M 64M" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
 
 echo
 echo "== Zero sectors per track =="
-_use_sample_img fake.parallels.bz2
+_use_sample_img parallels-v1.bz2
 poke_file "$TEST_IMG" "$tracks_offset" "\x00\x00\x00\x00"
 { $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
 
tests/qemu-iotests/076.out +4 -4
index f7745d8..fd26f3c 100644
@@ -1,18 +1,18 @@
 QA output created by 076
 
-== Read from a valid (enough) image ==
+== Read from a valid v1 image ==
 read 65536/65536 bytes at offset 0
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 
 == Negative catalog size ==
-qemu-io: can't open device TEST_DIR/fake.parallels: Catalog too large
+qemu-io: can't open device TEST_DIR/parallels-v1: Catalog too large
 no file open, try 'help open'
 
 == Overflow in catalog allocation ==
-qemu-io: can't open device TEST_DIR/fake.parallels: Catalog too large
+qemu-io: can't open device TEST_DIR/parallels-v1: Catalog too large
 no file open, try 'help open'
 
 == Zero sectors per track ==
-qemu-io: can't open device TEST_DIR/fake.parallels: Invalid image: Zero sectors per track
+qemu-io: can't open device TEST_DIR/parallels-v1: Invalid image: Zero sectors per track
 no file open, try 'help open'
 *** done
tests/qemu-iotests/sample_images/fake.parallels.bz2 deleted binary +0 -0
deleted file mode 100644
index ffb5f13bac31bc9ab6e1ea5c0cfa26786f2c4cc6..0000000000000000000000000000000000000000
GIT binary patch
tests/qemu-iotests/sample_images/parallels-v1.bz2 new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..d1ef14205401a8e010d1be68bffeee92ce137d39
GIT binary patch
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/3 iotests: add v2 parallels sample image and simple test for it

In reply to Denis V. Lunev

This is simple test image for the following commit made by me.

commit d25d59802021a747812472780d80a0e792078f40
Author: Denis V. Lunev <[email protected]>
Date: Mon Jul 28 20:23:55 2014 +0400
parallels: 2TB+ parallels images support

CC Jeff Cody <[email protected]>
CC Kevin Wolf <[email protected]>
CC Stefan Hajnoczi <[email protected]>
---
 tests/qemu-iotests/076                            |   5 +++++
 tests/qemu-iotests/076.out                        |   4 ++++
 tests/qemu-iotests/sample_images/parallels-v2.bz2 | Bin 0 -> 150 bytes
 3 files changed, 9 insertions(+)
 create mode 100644 tests/qemu-iotests/sample_images/parallels-v2.bz2
tests/qemu-iotests/076 +5 -0
index a300ee2..98d67b3 100755
@@ -70,6 +70,11 @@ _use_sample_img parallels-v1.bz2
 poke_file "$TEST_IMG" "$tracks_offset" "\x00\x00\x00\x00"
 { $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
 
+echo
+echo "== Read from a valid v2 image =="
+_use_sample_img parallels-v2.bz2
+{ $QEMU_IO -c "read -P 0x11 0 64k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
+
 # success, all done
 echo "*** done"
 rm -f $seq.full
tests/qemu-iotests/076.out +4 -0
index fd26f3c..32ade08 100644
@@ -15,4 +15,8 @@ no file open, try 'help open'
 == Zero sectors per track ==
 qemu-io: can't open device TEST_DIR/parallels-v1: Invalid image: Zero sectors per track
 no file open, try 'help open'
+
+== Read from a valid v2 image ==
+read 65536/65536 bytes at offset 0
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 *** done
tests/qemu-iotests/sample_images/parallels-v2.bz2 new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..fd8614d061172faae50a993ac7acd3173de9aa98
GIT binary patch
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/3 block/parallels: fix access to not initialized memory in catalog_bitmap

In reply to Denis V. Lunev

found by valgrind.

Command: ./qemu-img convert -f parallels -O qcow2 1.hds 1.img Invalid read of size 4
at 0x17D0EF: parallels_co_read (parallels.c:357) by 0x11FEE4: bdrv_aio_rw_vector (block.c:4640)
by 0x11FFBF: bdrv_aio_readv_em (block.c:4652)
by 0x11F55F: bdrv_co_readv_em (block.c:4862)
by 0x123428: bdrv_aligned_preadv (block.c:3056)
by 0x1239FA: bdrv_co_do_preadv (block.c:3162)
by 0x125424: bdrv_rw_co_entry (block.c:2706)
by 0x155DD9: coroutine_trampoline (coroutine-ucontext.c:118) by 0x6975B6F: ??? (in /lib/x86_64-linux-gnu/libc-2.19.so)

The problem is that s->catalog_bitmap is allocated/filled as gmalloc(s->catalog_size) thus index validity check must be inclusive, i.e. index >= s->catalog_size is invalid.

CC Jeff Cody <[email protected]>
CC Kevin Wolf <[email protected]>
CC Stefan Hajnoczi <[email protected]>
---
 block/parallels.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/parallels.c +1 -1
index 2a814f3..4f9cd8d 100644
@@ -155,7 +155,7 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
     offset = sector_num % s->tracks;
 
     /* not allocated */
-    if ((index > s->catalog_size) || (s->catalog_bitmap[index] == 0))
+    if ((index >= s->catalog_size) || (s->catalog_bitmap[index] == 0))
         return -1;
     return
         ((uint64_t)s->catalog_bitmap[index] * s->off_multiplier + offset) * 512;
Signature · 1 line
1.9.1
Reviewed-by on the v1 series
#4 lore raw
In reply to Denis V. Lunev

Il 08/10/2014 11:13, Denis V. Lunev ha scritto:

Quoted 11 lines

Pls find here test authentic test material, i.e. parallels images with "WithoutFreeSpace" and "WithouFreSpacExt" signatures created in authentic way + a minor bug fix for access to non-initialized memory found by valgrind.

CC Jeff Cody <[email protected]>
CC Kevin Wolf <[email protected]>
CC Stefan Hajnoczi <[email protected]>
#6 lore raw
In reply to Denis V. Lunev
Quoted 10 lines · Denis V. Lunev

Pls find here test authentic test material, i.e. parallels images with "WithoutFreeSpace" and "WithouFreSpacExt" signatures created in authentic way + a minor bug fix for access to non-initialized memory found by valgrind.

CC Jeff Cody <[email protected]>
CC Kevin Wolf <[email protected]>
CC Stefan Hajnoczi <[email protected]>

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan