xref: /openbmc/qemu/tests/qemu-iotests/133 (revision 791cbccc9422f17ff907f33d5a689d88b8610cff)
10a8111e0SKevin Wolf#!/bin/bash
20a8111e0SKevin Wolf#
30a8111e0SKevin Wolf# Test for reopen
40a8111e0SKevin Wolf#
50a8111e0SKevin Wolf# Copyright (C) 2015 Red Hat, Inc.
60a8111e0SKevin Wolf#
70a8111e0SKevin Wolf# This program is free software; you can redistribute it and/or modify
80a8111e0SKevin Wolf# it under the terms of the GNU General Public License as published by
90a8111e0SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
100a8111e0SKevin Wolf# (at your option) any later version.
110a8111e0SKevin Wolf#
120a8111e0SKevin Wolf# This program is distributed in the hope that it will be useful,
130a8111e0SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
140a8111e0SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
150a8111e0SKevin Wolf# GNU General Public License for more details.
160a8111e0SKevin Wolf#
170a8111e0SKevin Wolf# You should have received a copy of the GNU General Public License
180a8111e0SKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
190a8111e0SKevin Wolf#
200a8111e0SKevin Wolf
210a8111e0SKevin Wolf# creator
220a8111e0SKevin Wolfowner=kwolf@redhat.com
230a8111e0SKevin Wolf
240a8111e0SKevin Wolfseq=`basename $0`
250a8111e0SKevin Wolfecho "QA output created by $seq"
260a8111e0SKevin Wolf
270a8111e0SKevin Wolfhere=`pwd`
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
410a8111e0SKevin Wolf_supported_proto file
420a8111e0SKevin Wolf_supported_os Linux
430a8111e0SKevin Wolf
440a8111e0SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img 64M
450a8111e0SKevin Wolf_make_test_img -b "$TEST_IMG.base"
460a8111e0SKevin Wolf
470a8111e0SKevin Wolfecho
480a8111e0SKevin Wolfecho "=== Check that node-name can't be changed ==="
490a8111e0SKevin Wolfecho
500a8111e0SKevin Wolf
510a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o node-name=foo' $TEST_IMG
520a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o file.node-name=foo' $TEST_IMG
530a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o backing.node-name=foo' $TEST_IMG
540a8111e0SKevin Wolf
550a8111e0SKevin Wolfecho
560a8111e0SKevin Wolfecho "=== Check that unchanged node-name is okay ==="
570a8111e0SKevin Wolfecho
580a8111e0SKevin Wolf
590a8111e0SKevin Wolf# Explicitly repeated
600a8111e0SKevin Wolf$QEMU_IO -c "open -o node-name=foo $TEST_IMG" -c 'reopen -o node-name=foo'
610a8111e0SKevin Wolf$QEMU_IO -c "open -o file.node-name=foo $TEST_IMG" -c 'reopen -o file.node-name=foo'
620a8111e0SKevin Wolf$QEMU_IO -c "open -o backing.node-name=foo $TEST_IMG" -c 'reopen -o backing.node-name=foo'
630a8111e0SKevin Wolf
640a8111e0SKevin Wolf# Implicitly retained
650a8111e0SKevin Wolf$QEMU_IO -c "open -o node-name=foo $TEST_IMG" -c 'reopen'
660a8111e0SKevin Wolf$QEMU_IO -c "open -o file.node-name=foo $TEST_IMG" -c 'reopen'
670a8111e0SKevin Wolf$QEMU_IO -c "open -o backing.node-name=foo $TEST_IMG" -c 'reopen'
680a8111e0SKevin Wolf
690a8111e0SKevin Wolfecho
700a8111e0SKevin Wolfecho "=== Check that driver can't be changed ==="
710a8111e0SKevin Wolfecho
720a8111e0SKevin Wolf
730a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o driver=raw' $TEST_IMG
740a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o file.driver=qcow2' $TEST_IMG
750a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o backing.driver=file' $TEST_IMG
760a8111e0SKevin Wolf
770a8111e0SKevin Wolfecho
780a8111e0SKevin Wolfecho "=== Check that unchanged driver is okay ==="
790a8111e0SKevin Wolfecho
800a8111e0SKevin Wolf
810a8111e0SKevin Wolf# Explicitly repeated (implicit case is covered in node-name test)
820a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o driver=qcow2' $TEST_IMG
830a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o file.driver=file' $TEST_IMG
840a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o backing.driver=qcow2' $TEST_IMG
850a8111e0SKevin Wolf
86*791cbcccSMax Reitzecho
87*791cbcccSMax Reitzecho "=== Check that reopening works with non-string options ==="
88*791cbcccSMax Reitzecho
89*791cbcccSMax Reitz
90*791cbcccSMax Reitz# Using the json: pseudo-protocol we can create non-string options
91*791cbcccSMax Reitz# (Invoke 'info' just so we get some output afterwards)
92*791cbcccSMax ReitzIMGOPTSSYNTAX=false $QEMU_IO -f null-co -c 'reopen' -c 'info' \
93*791cbcccSMax Reitz    "json:{'driver': 'null-co', 'size': 65536}"
94*791cbcccSMax Reitz
950a8111e0SKevin Wolf# success, all done
960a8111e0SKevin Wolfecho "*** done"
970a8111e0SKevin Wolfrm -f $seq.full
980a8111e0SKevin Wolfstatus=0
99