mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
iotests/081: Test rewrite-corrupted without WRITE
Test what happens when a rewrite-corrupted quorum node performs such a rewrite, while there is no parent that has taken the WRITE permission. Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <20201113211718.261671-4-mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
55f2c014d7
commit
c61c644f59
2 changed files with 81 additions and 0 deletions
|
@ -42,6 +42,7 @@ _supported_fmt raw
|
||||||
_supported_proto file
|
_supported_proto file
|
||||||
_supported_os Linux
|
_supported_os Linux
|
||||||
_require_drivers quorum
|
_require_drivers quorum
|
||||||
|
_require_devices virtio-scsi
|
||||||
|
|
||||||
do_run_qemu()
|
do_run_qemu()
|
||||||
{
|
{
|
||||||
|
@ -155,6 +156,59 @@ echo "== checking that quorum has corrected the corrupted file =="
|
||||||
|
|
||||||
$QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io
|
$QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "== using quorum rewrite corrupted mode without WRITE permission =="
|
||||||
|
|
||||||
|
# The same as above, but this time, do it on a quorum node whose only
|
||||||
|
# parent will not take the WRITE permission
|
||||||
|
|
||||||
|
echo '-- corrupting --'
|
||||||
|
# Only corrupt a portion: The guest device (scsi-hd on virtio-scsi)
|
||||||
|
# will read some data (looking for a partition table to guess the
|
||||||
|
# disk's geometry), which would trigger a quorum mismatch if the
|
||||||
|
# beginning of the image was corrupted. The subsequent
|
||||||
|
# QUORUM_REPORT_BAD event would be suppressed (because at that point,
|
||||||
|
# there cannot have been a qmp_capabilities on the monitor). Because
|
||||||
|
# that event is rate-limited, the next QUORUM_REPORT_BAD that happens
|
||||||
|
# thanks to our qemu-io read (which should trigger a mismatch) would
|
||||||
|
# then be delayed past the VM quit and not appear in the output.
|
||||||
|
# So we keep the first 1M intact to see a QUORUM_REPORT_BAD resulting
|
||||||
|
# from the qemu-io invocation.
|
||||||
|
$QEMU_IO -c "write -P 0x42 1M 1M" "$TEST_DIR/2.raw" | _filter_qemu_io
|
||||||
|
|
||||||
|
# Fix the corruption (on a read-only quorum node, i.e. without taking
|
||||||
|
# the WRITE permission on it -- its child nodes need to be R/W OTOH,
|
||||||
|
# so that rewrite-corrupted works)
|
||||||
|
echo
|
||||||
|
echo '-- running quorum --'
|
||||||
|
run_qemu \
|
||||||
|
-blockdev file,node-name=file1,filename="$TEST_DIR/1.raw" \
|
||||||
|
-blockdev file,node-name=file2,filename="$TEST_DIR/2.raw" \
|
||||||
|
-blockdev file,node-name=file3,filename="$TEST_DIR/3.raw" \
|
||||||
|
-blockdev '{
|
||||||
|
"driver": "quorum",
|
||||||
|
"node-name": "quorum",
|
||||||
|
"read-only": true,
|
||||||
|
"vote-threshold": 2,
|
||||||
|
"rewrite-corrupted": true,
|
||||||
|
"children": [ "file1", "file2", "file3" ]
|
||||||
|
}' \
|
||||||
|
-device virtio-scsi,id=scsi \
|
||||||
|
-device scsi-hd,id=quorum-drive,bus=scsi.0,drive=quorum \
|
||||||
|
<<EOF
|
||||||
|
{ "execute": "qmp_capabilities" }
|
||||||
|
{
|
||||||
|
"execute": "human-monitor-command",
|
||||||
|
"arguments": {
|
||||||
|
"command-line": 'qemu-io -d quorum-drive "read -P 0x32 0 $size"'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{ "execute": "quit" }
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo '-- checking that the image has been corrected --'
|
||||||
|
$QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "== breaking quorum =="
|
echo "== breaking quorum =="
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,33 @@ read 10485760/10485760 bytes at offset 0
|
||||||
read 10485760/10485760 bytes at offset 0
|
read 10485760/10485760 bytes at offset 0
|
||||||
10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||||
|
|
||||||
|
== using quorum rewrite corrupted mode without WRITE permission ==
|
||||||
|
-- corrupting --
|
||||||
|
wrote 1048576/1048576 bytes at offset 1048576
|
||||||
|
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||||
|
|
||||||
|
-- running quorum --
|
||||||
|
Testing: -blockdev file,node-name=file1,filename=TEST_DIR/1.IMGFMT -blockdev file,node-name=file2,filename=TEST_DIR/2.IMGFMT -blockdev file,node-name=file3,filename=TEST_DIR/3.IMGFMT -blockdev {
|
||||||
|
"driver": "quorum",
|
||||||
|
"node-name": "quorum",
|
||||||
|
"read-only": true,
|
||||||
|
"vote-threshold": 2,
|
||||||
|
"rewrite-corrupted": true,
|
||||||
|
"children": [ "file1", "file2", "file3" ]
|
||||||
|
} -device virtio-scsi,id=scsi -device scsi-hd,id=quorum-drive,bus=scsi.0,drive=quorum
|
||||||
|
QMP_VERSION
|
||||||
|
{"return": {}}
|
||||||
|
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "QUORUM_REPORT_BAD", "data": {"node-name": "file2", "sectors-count": 20480, "sector-num": 0, "type": "read"}}
|
||||||
|
read 10485760/10485760 bytes at offset 0
|
||||||
|
10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||||
|
{"return": ""}
|
||||||
|
{"return": {}}
|
||||||
|
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
|
||||||
|
|
||||||
|
-- checking that the image has been corrected --
|
||||||
|
read 10485760/10485760 bytes at offset 0
|
||||||
|
10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||||
|
|
||||||
== breaking quorum ==
|
== breaking quorum ==
|
||||||
wrote 10485760/10485760 bytes at offset 0
|
wrote 10485760/10485760 bytes at offset 0
|
||||||
10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue