aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/060
diff options
context:
space:
mode:
authorAlberto Garcia <berto@igalia.com>2017-11-06 16:53:45 +0200
committerMax Reitz <mreitz@redhat.com>2017-11-21 14:54:02 +0100
commit50a3efb0f05bcfbe04201d4ebac0b96551a1b551 (patch)
treed11d2e71e3b1ed1a4e7cb4fd6a85584484cff825 /tests/qemu-iotests/060
parent70a5afedd64c3f0d3b5feae6b40b30f3e8d13e4b (diff)
downloadqemu-50a3efb0f05bcfbe04201d4ebac0b96551a1b551.zip
qemu-50a3efb0f05bcfbe04201d4ebac0b96551a1b551.tar.gz
qemu-50a3efb0f05bcfbe04201d4ebac0b96551a1b551.tar.bz2
block: Close a BlockDriverState completely even when bs->drv is NULL
bdrv_close() skips much of its logic when bs->drv is NULL. This is fine when we're closing a BlockDriverState that has just been created (because e.g the initialization process failed), but it's not enough in other cases. For example, when a valid qcow2 image is found to be corrupted then QEMU marks it as such in the file header and then sets bs->drv to NULL in order to make the BlockDriverState unusable. When that BDS is later closed then many of its data structures are not freed (leaking their memory) and none of its children are detached. This results in bdrv_close_all() failing to close all BDSs and making this assertion fail when QEMU is being shut down: bdrv_close_all: Assertion `QTAILQ_EMPTY(&all_bdrv_states)' failed. This patch makes bdrv_close() do the full uninitialization process in all cases. This fixes the problem with corrupted images and still works fine with freshly created BDSs. Signed-off-by: Alberto Garcia <berto@igalia.com> Message-id: 20171106145345.12038-1-berto@igalia.com Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/060')
-rwxr-xr-xtests/qemu-iotests/06013
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060
index 1eca094..14797dd 100755
--- a/tests/qemu-iotests/060
+++ b/tests/qemu-iotests/060
@@ -426,6 +426,19 @@ echo '--- Repairing ---'
_check_test_img -q -r all
_check_test_img -r all
+echo
+echo "=== Testing the QEMU shutdown with a corrupted image ==="
+echo
+_make_test_img 64M
+poke_file "$TEST_IMG" "$rt_offset" "\x00\x00\x00\x00\x00\x00\x00\x00"
+echo "{'execute': 'qmp_capabilities'}
+ {'execute': 'human-monitor-command',
+ 'arguments': {'command-line': 'qemu-io drive \"write 0 512\"'}}
+ {'execute': 'quit'}" \
+ | $QEMU -qmp stdio -nographic -nodefaults \
+ -drive if=none,node-name=drive,file="$TEST_IMG",driver=qcow2 \
+ | _filter_qmp | _filter_qemu_io
+
# success, all done
echo "*** done"
rm -f $seq.full