xref: /qemu/tests/qemu-iotests/133 (revision fef80ea073c4862bc9eaddb6ddb0ed970b8ad7c4)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
2*9dd003a9SVladimir Sementsov-Ogievskiy# group: auto quick
30a8111e0SKevin Wolf#
40a8111e0SKevin Wolf# Test for reopen
50a8111e0SKevin Wolf#
60a8111e0SKevin Wolf# Copyright (C) 2015 Red Hat, Inc.
70a8111e0SKevin Wolf#
80a8111e0SKevin Wolf# This program is free software; you can redistribute it and/or modify
90a8111e0SKevin Wolf# it under the terms of the GNU General Public License as published by
100a8111e0SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
110a8111e0SKevin Wolf# (at your option) any later version.
120a8111e0SKevin Wolf#
130a8111e0SKevin Wolf# This program is distributed in the hope that it will be useful,
140a8111e0SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
150a8111e0SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
160a8111e0SKevin Wolf# GNU General Public License for more details.
170a8111e0SKevin Wolf#
180a8111e0SKevin Wolf# You should have received a copy of the GNU General Public License
190a8111e0SKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
200a8111e0SKevin Wolf#
210a8111e0SKevin Wolf
220a8111e0SKevin Wolf# creator
230a8111e0SKevin Wolfowner=kwolf@redhat.com
240a8111e0SKevin Wolf
250a8111e0SKevin Wolfseq=`basename $0`
260a8111e0SKevin Wolfecho "QA output created by $seq"
270a8111e0SKevin Wolf
280a8111e0SKevin Wolfstatus=1	# failure is the default!
290a8111e0SKevin Wolf
300a8111e0SKevin Wolf_cleanup()
310a8111e0SKevin Wolf{
320a8111e0SKevin Wolf    _cleanup_test_img
330a8111e0SKevin Wolf}
340a8111e0SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
350a8111e0SKevin Wolf
360a8111e0SKevin Wolf# get standard environment, filters and checks
370a8111e0SKevin Wolf. ./common.rc
380a8111e0SKevin Wolf. ./common.filter
390a8111e0SKevin Wolf
400a8111e0SKevin Wolf_supported_fmt qcow2
4157284d2aSMax Reitz_supported_proto file fuse
420a8111e0SKevin Wolf
430a8111e0SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img 64M
44b66ff2c2SEric Blake_make_test_img -b "$TEST_IMG.base" -F $IMGFMT
450a8111e0SKevin Wolf
460a8111e0SKevin Wolfecho
470a8111e0SKevin Wolfecho "=== Check that node-name can't be changed ==="
480a8111e0SKevin Wolfecho
490a8111e0SKevin Wolf
500a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o node-name=foo' $TEST_IMG
510a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o file.node-name=foo' $TEST_IMG
520a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o backing.node-name=foo' $TEST_IMG
530a8111e0SKevin Wolf
540a8111e0SKevin Wolfecho
550a8111e0SKevin Wolfecho "=== Check that unchanged node-name is okay ==="
560a8111e0SKevin Wolfecho
570a8111e0SKevin Wolf
580a8111e0SKevin Wolf# Explicitly repeated
590a8111e0SKevin Wolf$QEMU_IO -c "open -o node-name=foo $TEST_IMG" -c 'reopen -o node-name=foo'
600a8111e0SKevin Wolf$QEMU_IO -c "open -o file.node-name=foo $TEST_IMG" -c 'reopen -o file.node-name=foo'
610a8111e0SKevin Wolf$QEMU_IO -c "open -o backing.node-name=foo $TEST_IMG" -c 'reopen -o backing.node-name=foo'
620a8111e0SKevin Wolf
630a8111e0SKevin Wolf# Implicitly retained
640a8111e0SKevin Wolf$QEMU_IO -c "open -o node-name=foo $TEST_IMG" -c 'reopen'
650a8111e0SKevin Wolf$QEMU_IO -c "open -o file.node-name=foo $TEST_IMG" -c 'reopen'
660a8111e0SKevin Wolf$QEMU_IO -c "open -o backing.node-name=foo $TEST_IMG" -c 'reopen'
670a8111e0SKevin Wolf
680a8111e0SKevin Wolfecho
690a8111e0SKevin Wolfecho "=== Check that driver can't be changed ==="
700a8111e0SKevin Wolfecho
710a8111e0SKevin Wolf
720a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o driver=raw' $TEST_IMG
730a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o file.driver=qcow2' $TEST_IMG
740a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o backing.driver=file' $TEST_IMG
750a8111e0SKevin Wolf
760a8111e0SKevin Wolfecho
770a8111e0SKevin Wolfecho "=== Check that unchanged driver is okay ==="
780a8111e0SKevin Wolfecho
790a8111e0SKevin Wolf
800a8111e0SKevin Wolf# Explicitly repeated (implicit case is covered in node-name test)
810a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o driver=qcow2' $TEST_IMG
820a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o file.driver=file' $TEST_IMG
830a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o backing.driver=qcow2' $TEST_IMG
840a8111e0SKevin Wolf
85791cbcccSMax Reitzecho
86791cbcccSMax Reitzecho "=== Check that reopening works with non-string options ==="
87791cbcccSMax Reitzecho
88791cbcccSMax Reitz
89791cbcccSMax Reitz# Using the json: pseudo-protocol we can create non-string options
90791cbcccSMax Reitz# (Invoke 'info' just so we get some output afterwards)
91791cbcccSMax ReitzIMGOPTSSYNTAX=false $QEMU_IO -f null-co -c 'reopen' -c 'info' \
92791cbcccSMax Reitz    "json:{'driver': 'null-co', 'size': 65536}"
93791cbcccSMax Reitz
94dc900c35SAlberto Garciaecho
95dc900c35SAlberto Garciaecho "=== Check that mixing -c/-r/-w and their corresponding options is forbidden ==="
96dc900c35SAlberto Garciaecho
97dc900c35SAlberto Garcia
98dc900c35SAlberto Garcia$QEMU_IO -c 'reopen -r -o read-only=on' $TEST_IMG
99dc900c35SAlberto Garcia$QEMU_IO -c 'reopen -w -o read-only=on' $TEST_IMG
100dc900c35SAlberto Garcia$QEMU_IO -c 'reopen -c none -o cache.direct=on' $TEST_IMG
101dc900c35SAlberto Garcia$QEMU_IO -c 'reopen -c writeback -o cache.direct=on' $TEST_IMG
102dc900c35SAlberto Garcia$QEMU_IO -c 'reopen -c directsync -o cache.no-flush=on' $TEST_IMG
1038eb4b07bSAlberto Garcia
1048eb4b07bSAlberto Garciaecho
1058eb4b07bSAlberto Garciaecho "=== Check that invalid options are handled correctly ==="
1068eb4b07bSAlberto Garciaecho
1078eb4b07bSAlberto Garcia
1088eb4b07bSAlberto Garcia$QEMU_IO -c 'reopen -o read-only=foo' $TEST_IMG
1098eb4b07bSAlberto Garcia$QEMU_IO -c 'reopen -o cache.no-flush=bar' $TEST_IMG
1108eb4b07bSAlberto Garcia$QEMU_IO -c 'reopen -o cache.direct=baz' $TEST_IMG
1118eb4b07bSAlberto Garcia$QEMU_IO -c 'reopen -o auto-read-only=qux' $TEST_IMG
1120a8111e0SKevin Wolf# success, all done
1130a8111e0SKevin Wolfecho "*** done"
1140a8111e0SKevin Wolfrm -f $seq.full
1150a8111e0SKevin Wolfstatus=0
116