From: Max Reitz <mreitz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH 3/4] iotests: Make some qemu-io commands read-only
Date: Sat, 12 Jul 2014 00:23:06 +0200 [thread overview]
Message-ID: <1405117387-25539-4-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1405117387-25539-1-git-send-email-mreitz@redhat.com>
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 --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\",
--
2.0.1
next prev parent reply other threads:[~2014-07-11 22:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-11 22:23 [Qemu-devel] [PATCH 0/4] block: Warn about usage of growing formats over non-growable protocols Max Reitz
2014-07-11 22:23 ` [Qemu-devel] [PATCH 1/4] block: Correct bs->growable Max Reitz
2014-08-20 11:40 ` Kevin Wolf
2014-08-20 19:13 ` Max Reitz
2014-08-21 8:19 ` Kevin Wolf
2014-08-22 13:26 ` Max Reitz
2014-09-04 20:01 ` Max Reitz
2014-09-05 10:01 ` Kevin Wolf
2014-09-05 12:46 ` Max Reitz
2014-09-05 13:13 ` Kevin Wolf
2014-07-11 22:23 ` [Qemu-devel] [PATCH 2/4] block: Introduce requires_growing_file Max Reitz
2014-07-11 22:23 ` Max Reitz [this message]
2014-07-11 22:23 ` [Qemu-devel] [PATCH 4/4] iotests: Skip read and write in 040 for length=0 Max Reitz
2014-08-15 15:23 ` [Qemu-devel] [PATCH 0/4] block: Warn about usage of growing formats over non-growable protocols Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1405117387-25539-4-git-send-email-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).