diff options
author | Fam Zheng <famz@redhat.com> | 2013-11-13 20:26:49 +0800 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-11-15 13:37:48 +0100 |
commit | 36452f12f877c60f004b34641287d74b14c96208 (patch) | |
tree | b6143061b2e8e840eea8a9769dae61feec456f5d /tests/qemu-iotests/048 | |
parent | a1144c0dbfa3f820916a135d2d3d6db5635adcc2 (diff) | |
download | qemu-36452f12f877c60f004b34641287d74b14c96208.tar.gz qemu-36452f12f877c60f004b34641287d74b14c96208.tar.bz2 qemu-36452f12f877c60f004b34641287d74b14c96208.zip |
qemu-img: Fix overwriting 'ret' before using
This patch moves ret assignment after reporting original error.
We were lucky to pass qemu-iotests 048 (qemu-img compare case) but when
I tried to run with TEST_DIR=/tmp (tmpfs), it fails with a "wrong"
mismatch offset. This fixes two bugs.
In the first if branch, setting ret to 1 before using it makes dead code
in the next line: pnum is never added to mismatch offset even if ret was
0.
In the other if branch, currently the output error is always -4:
strerror(-4) -> Unknown error -4
Added regression test in case 048.
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/048')
-rwxr-xr-x | tests/qemu-iotests/048 | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/qemu-iotests/048 b/tests/qemu-iotests/048 index 9b9d118ef3..9def7fcc8c 100755 --- a/tests/qemu-iotests/048 +++ b/tests/qemu-iotests/048 @@ -74,5 +74,39 @@ _compare io_pattern write 0 $CLUSTER_SIZE 0 1 123 _compare +# Test unaligned case of mismatch offsets in allocated clusters +_make_test_img $size +io_pattern write 0 512 0 1 100 +cp "$TEST_IMG" "$TEST_IMG2" +io_pattern write 512 512 0 1 101 +_compare + +# Test cluster allocated in one, with IO error +cat > "$TEST_DIR/blkdebug.conf"<<EOF +[inject-error] +event = "read_aio" +errno = "5" +once ="off" +EOF +_make_test_img $size +cp "$TEST_IMG" "$TEST_IMG2" +io_pattern write 512 512 0 1 102 +TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" _compare 2>&1 |\ + _filter_testdir | _filter_imgfmt + +# Test cluster allocated in one, with different sizes and IO error in the part +# that exists only in one image +cat > "$TEST_DIR/blkdebug.conf"<<EOF +[inject-error] +event = "read_aio" +errno = "5" +once ="off" +EOF +_make_test_img $size +TEST_IMG="$TEST_IMG2" _make_test_img 0 +io_pattern write 512 512 0 1 102 +TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" _compare 2>&1 |\ + _filter_testdir | _filter_imgfmt + # Cleanup status=0 |