diff options
author | Eric Blake <eblake@redhat.com> | 2017-06-05 15:38:43 -0500 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-07-10 13:18:05 +0200 |
commit | 81c219ac6ce0d6182e35f3976f2caa4cefcaf9f0 (patch) | |
tree | a55fe72a3b42d3026d57cec604c5bedbb907622f /tests/qemu-iotests/177.out | |
parent | 64ebf556486af39024cc9e7a8c88303a7b37c465 (diff) | |
download | qemu-81c219ac6ce0d6182e35f3976f2caa4cefcaf9f0.zip qemu-81c219ac6ce0d6182e35f3976f2caa4cefcaf9f0.tar.gz qemu-81c219ac6ce0d6182e35f3976f2caa4cefcaf9f0.tar.bz2 |
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.out')
-rw-r--r-- | tests/qemu-iotests/177.out | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/qemu-iotests/177.out b/tests/qemu-iotests/177.out index e887542..fcfbfa3 100644 --- a/tests/qemu-iotests/177.out +++ b/tests/qemu-iotests/177.out @@ -45,5 +45,7 @@ read 30408704/30408704 bytes at offset 80740352 29 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 23068672/23068672 bytes at offset 111149056 22 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Offset Length File +0 0x8000000 json:{"image": {"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}}, "driver": "blkdebug", "align": "4k"} No errors were found on the image. *** done |