summaryrefslogtreecommitdiffstats
path: root/tests/qemu-iotests/177
diff options
context:
space:
mode:
authorEric Blake2017-06-05 22:38:43 +0200
committerKevin Wolf2017-07-10 13:18:05 +0200
commit81c219ac6ce0d6182e35f3976f2caa4cefcaf9f0 (patch)
treea55fe72a3b42d3026d57cec604c5bedbb907622f /tests/qemu-iotests/177
parentqemu-io: Don't die on second open (diff)
downloadqemu-81c219ac6ce0d6182e35f3976f2caa4cefcaf9f0.tar.gz
qemu-81c219ac6ce0d6182e35f3976f2caa4cefcaf9f0.tar.xz
qemu-81c219ac6ce0d6182e35f3976f2caa4cefcaf9f0.zip
block: Guarantee that *file is set on bdrv_get_block_status()
We document that *file is valid if the return is not an error and includes BDRV_BLOCK_OFFSET_VALID, but forgot to obey this contract when a driver (such as blkdebug) lacks a callback. Messed up in commit 67a0fd2 (v2.6), when we added the file parameter. Enhance qemu-iotest 177 to cover this, using a sequence that would print garbage or even SEGV, because it was dererefencing through uninitialized memory. [The resulting test output shows that we have less-than-ideal block status from the blkdebug driver, but that's a separate fix coming up soon.] Setting *file on all paths that return BDRV_BLOCK_OFFSET_VALID is enough to fix the crash, but we can go one step further: always setting *file, even on error, means that a broken caller that blindly dereferences file without checking for error is now more likely to get a reliable SEGV instead of randomly acting on garbage, making it easier to diagnose such buggy callers. Adding an assertion that file is set where expected doesn't hurt either. CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/177')
-rwxr-xr-xtests/qemu-iotests/1773
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/qemu-iotests/177 b/tests/qemu-iotests/177
index 2005c174f2..f8ed8fb86b 100755
--- a/tests/qemu-iotests/177
+++ b/tests/qemu-iotests/177
@@ -43,6 +43,7 @@ _supported_proto file
CLUSTER_SIZE=1M
size=128M
options=driver=blkdebug,image.driver=qcow2
+nested_opts=image.file.driver=file,image.file.filename=$TEST_IMG
echo
echo "== setting up files =="
@@ -106,6 +107,8 @@ function verify_io()
}
verify_io | $QEMU_IO -r "$TEST_IMG" | _filter_qemu_io
+$QEMU_IMG map --image-opts "$options,$nested_opts,align=4k" \
+ | _filter_qemu_img_map
_check_test_img