diff mbox

[3/4] iotests: Make some qemu-io commands read-only

Message ID 1405117387-25539-4-git-send-email-mreitz@redhat.com
State New
Headers show

Commit Message

Max Reitz July 11, 2014, 10:23 p.m. UTC
Test 072 (and 089 which copied some parts from it) tests image format
nesting. When opening the inner image, qemu now correctly emits a
warning because you should not attempt to write to the inner image of
such a constellation. An example would be:

1. Create a qcow2 image with some relatively large virtual size.
2. Interpret this qcow2 image as a raw image and convert it to a qcow2
   image.
3. This yields a qcow2 image whose virtual size is just enough to hold
   the original image's physical size; trying to grow the original (now
   inner) image would fail because the outer image cannot grow (without
   explicitly changing its size at least).

Therefore, the warnings are correct; but the tests do not attempt to
write to the inner image, they only read from it. Therefore, open it
read-only to get rid of the messages.

While at it, consciously add a check to test 072 that the warning is
actually emitted if the inner image is not opened read-only.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/072     | 9 ++++++++-
 tests/qemu-iotests/072.out | 1 +
 tests/qemu-iotests/089     | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072
index 58faa8b..1d39b16 100755
--- a/tests/qemu-iotests/072
+++ b/tests/qemu-iotests/072
@@ -55,7 +55,7 @@  $QEMU_IO -c 'write -P 42 0 512' -c 'write -P 23 512 512' \
 
 $QEMU_IMG convert -f raw -O $IMGFMT "$TEST_IMG.base" "$TEST_IMG"
 
-$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=$IMGFMT,file.file.filename=$TEST_IMG" \
+$QEMU_IO -c "open -r -o driver=$IMGFMT,file.driver=$IMGFMT,file.file.filename=$TEST_IMG" \
          -c 'read -P 42 0 512' -c 'read -P 23 512 512' \
          -c 'read -P 66 1024 512' | _filter_qemu_io
 
@@ -63,6 +63,13 @@  $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=$IMGFMT,file.file.filename=$TEST
 # should not work for any image formats with a header.
 $QEMU_IO -c 'read -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
 
+# This should emit a warning: Writes to the inner image might require it to grow
+# which it cannot because the outer image has a fixed virtual size. Therefore,
+# opening it non-read-only may result in I/O errors and this is why there should
+# be a warning.
+$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=$IMGFMT,file.file.filename=$TEST_IMG" \
+    2>&1 | _filter_imgfmt
+
 # success, all done
 echo "*** done"
 rm -f $seq.full
diff --git a/tests/qemu-iotests/072.out b/tests/qemu-iotests/072.out
index efe577c..11d6d81 100644
--- a/tests/qemu-iotests/072.out
+++ b/tests/qemu-iotests/072.out
@@ -18,4 +18,5 @@  read 512/512 bytes at offset 1024
 Pattern verification failed at offset 0, 512 bytes
 read 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Writes to the image '' in format 'IMGFMT' may require the file to grow which is not supported for this file; please open it read-only or try to export it in a different format over the protocol (e.g. use qemu-nbd instead of nbd-server)
 *** done
diff --git a/tests/qemu-iotests/089 b/tests/qemu-iotests/089
index dffc977..2f53735 100755
--- a/tests/qemu-iotests/089
+++ b/tests/qemu-iotests/089
@@ -66,7 +66,7 @@  $QEMU_IO -c 'write -P 42 0 512' -c 'write -P 23 512 512' \
 $QEMU_IMG convert -f raw -O $IMGFMT "$TEST_IMG.base" "$TEST_IMG"
 
 $QEMU_IO -c 'read -P 42 0 512' -c 'read -P 23 512 512' \
-         -c 'read -P 66 1024 512' "json:{
+         -c 'read -P 66 1024 512' -r "json:{
     \"driver\": \"$IMGFMT\",
     \"file\": {
         \"driver\": \"$IMGFMT\",