From patchwork Fri Jul 11 22:23:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 369258 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9472D1400DD for ; Sat, 12 Jul 2014 08:25:41 +1000 (EST) Received: from localhost ([::1]:46952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5jG7-0000UF-KQ for incoming@patchwork.ozlabs.org; Fri, 11 Jul 2014 18:25:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5jDs-0005Ez-46 for qemu-devel@nongnu.org; Fri, 11 Jul 2014 18:23:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X5jDl-0002RO-Ra for qemu-devel@nongnu.org; Fri, 11 Jul 2014 18:23:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28531) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5jDl-0002QQ-KS for qemu-devel@nongnu.org; Fri, 11 Jul 2014 18:23:13 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6BMND1q017257 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 11 Jul 2014 18:23:13 -0400 Received: from localhost (ovpn-116-38.ams2.redhat.com [10.36.116.38]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6BMN9UV010593 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Fri, 11 Jul 2014 18:23:11 -0400 From: Max Reitz To: qemu-devel@nongnu.org Date: Sat, 12 Jul 2014 00:23:06 +0200 Message-Id: <1405117387-25539-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1405117387-25539-1-git-send-email-mreitz@redhat.com> References: <1405117387-25539-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz Subject: [Qemu-devel] [PATCH 3/4] iotests: Make some qemu-io commands read-only X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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\",