From nobody Mon May 5 18:13:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541437809252715.548670765954; Mon, 5 Nov 2018 09:10:09 -0800 (PST) Received: from localhost ([::1]:36391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1gJiO2-0003bN-Sx for importer@patchew.org; Mon, 05 Nov 2018 12:10:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1gJhwt-000381-9B for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1gJhwn-000529-If for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56228) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1gJhwc-0005Rs-EU; Mon, 05 Nov 2018 11:41:44 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 564563001FD1; Mon, 5 Nov 2018 16:39:10 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com [10.36.117.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F5F760C5C; Mon, 5 Nov 2018 16:39:08 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Mon, 5 Nov 2018 17:37:37 +0100 Message-Id: <20181105163744.25139-30-kwolf@redhat.com> In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com> References: <20181105163744.25139-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 05 Nov 2018 16:39:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 29/36] qemu-iotests: Test auto-read-only with -drive and -blockdev X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> Content-Type: text/plain; charset="utf-8" Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> --- tests/qemu-iotests/232 | 147 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/232.out | 59 +++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 207 insertions(+) create mode 100755 tests/qemu-iotests/232 create mode 100644 tests/qemu-iotests/232.out diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232 new file mode 100755 index 0000000000..bc2972d124 --- /dev/null +++ b/tests/qemu-iotests/232 @@ -0,0 +1,147 @@ +#!/bin/bash +# +# Test for auto-read-only +# +# Copyright (C) 2018 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# creator +owner=3Dkwolf@redhat.com + +seq=3D`basename $0` +echo "QA output created by $seq" + +here=3D`pwd` +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img + rm -f $TEST_IMG.snap +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt generic +_supported_proto file +_supported_os Linux + +function do_run_qemu() +{ + echo Testing: "$@" + ( + if ! test -t 0; then + while read cmd; do + echo $cmd + done + fi + echo quit + ) | $QEMU -nographic -monitor stdio -nodefaults "$@" + echo +} + +function run_qemu() +{ + do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp | + _filter_generated_node_ids | _filter_imgfmt +} + +function run_qemu_info_block() +{ + echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG" +} + +size=3D128M + +_make_test_img $size + +echo +echo "=3D=3D=3D -drive with read-write image: read-only/auto-read-only com= binations =3D=3D=3D" +echo + +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read= -only=3Don,auto-read-only=3Doff +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read= -only=3Don,auto-read-only=3Don +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read= -only=3Don +echo +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read= -only=3Doff,auto-read-only=3Doff +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read= -only=3Doff,auto-read-only=3Don +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read= -only=3Doff +echo +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,auto= -read-only=3Doff +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,auto= -read-only=3Don +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone + +echo +echo "=3D=3D=3D -drive with read-only image: read-only/auto-read-only comb= inations =3D=3D=3D" +echo + +chmod a-w $TEST_IMG + +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read= -only=3Don,auto-read-only=3Doff +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read= -only=3Don,auto-read-only=3Don +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read= -only=3Don +echo +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read= -only=3Doff,auto-read-only=3Doff +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read= -only=3Doff,auto-read-only=3Don +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read= -only=3Doff +echo +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,auto= -read-only=3Doff +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,auto= -read-only=3Don +run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone + +echo +echo "=3D=3D=3D -blockdev with read-write image: read-only/auto-read-only = combinations =3D=3D=3D" +echo + +chmod a+w $TEST_IMG + +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,read-only=3Don,auto-read-only=3Doff +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,read-only=3Don,auto-read-only=3Don +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,read-only=3Don +echo +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,read-only=3Doff,auto-read-only=3Doff +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,read-only=3Doff,auto-read-only=3Don +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,read-only=3Doff +echo +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,auto-read-only=3Doff +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,auto-read-only=3Don +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0 + +echo +echo "=3D=3D=3D -blockdev with read-only image: read-only/auto-read-only c= ombinations =3D=3D=3D" +echo + +chmod a-w $TEST_IMG + +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,read-only=3Don,auto-read-only=3Doff +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,read-only=3Don,auto-read-only=3Don +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,read-only=3Don +echo +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,read-only=3Doff,auto-read-only=3Doff +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,read-only=3Doff,auto-read-only=3Don +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,read-only=3Doff +echo +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,auto-read-only=3Doff +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,auto-read-only=3Don +run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0 + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out new file mode 100644 index 0000000000..dcb683afa3 --- /dev/null +++ b/tests/qemu-iotests/232.out @@ -0,0 +1,59 @@ +QA output created by 232 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 + +=3D=3D=3D -drive with read-write image: read-only/auto-read-only combinati= ons =3D=3D=3D + +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) + +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) + +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) + +=3D=3D=3D -drive with read-only image: read-only/auto-read-only combinatio= ns =3D=3D=3D + +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) + +QEMU_PROG: -drive driver=3Dfile,file=3DTEST_DIR/t.IMGFMT,if=3Dnone,read-on= ly=3Doff,auto-read-only=3Doff: Could not open 'TEST_DIR/t.IMGFMT': Permissi= on denied +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) + +QEMU_PROG: -drive driver=3Dfile,file=3DTEST_DIR/t.IMGFMT,if=3Dnone,auto-re= ad-only=3Doff: Could not open 'TEST_DIR/t.IMGFMT': Permission denied +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) + +=3D=3D=3D -blockdev with read-write image: read-only/auto-read-only combin= ations =3D=3D=3D + +node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file, read-only) + +node0: TEST_DIR/t.IMGFMT (file) +node0: TEST_DIR/t.IMGFMT (file) +node0: TEST_DIR/t.IMGFMT (file) + +node0: TEST_DIR/t.IMGFMT (file) +node0: TEST_DIR/t.IMGFMT (file) +node0: TEST_DIR/t.IMGFMT (file) + +=3D=3D=3D -blockdev with read-only image: read-only/auto-read-only combina= tions =3D=3D=3D + +node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file, read-only) + +QEMU_PROG: -blockdev driver=3Dfile,filename=3DTEST_DIR/t.IMGFMT,node-name= =3Dnode0,read-only=3Doff,auto-read-only=3Doff: Could not open 'TEST_DIR/t.I= MGFMT': Permission denied +node0: TEST_DIR/t.IMGFMT (file, read-only) +QEMU_PROG: -blockdev driver=3Dfile,filename=3DTEST_DIR/t.IMGFMT,node-name= =3Dnode0,read-only=3Doff: Could not open 'TEST_DIR/t.IMGFMT': Permission de= nied + +QEMU_PROG: -blockdev driver=3Dfile,filename=3DTEST_DIR/t.IMGFMT,node-name= =3Dnode0,auto-read-only=3Doff: Could not open 'TEST_DIR/t.IMGFMT': Permissi= on denied +node0: TEST_DIR/t.IMGFMT (file, read-only) +QEMU_PROG: -blockdev driver=3Dfile,filename=3DTEST_DIR/t.IMGFMT,node-name= =3Dnode0: Could not open 'TEST_DIR/t.IMGFMT': Permission denied +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 31f6e77dcb..ebe4fe78bc 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -227,3 +227,4 @@ 227 auto quick 229 auto quick 231 auto quick +232 auto quick --=20 2.19.1