xref: /qemu/tests/qemu-iotests/133 (revision 0a8111e0fbeccdf94ee011bc3b3013a45166a9a8)
1*0a8111e0SKevin Wolf#!/bin/bash
2*0a8111e0SKevin Wolf#
3*0a8111e0SKevin Wolf# Test for reopen
4*0a8111e0SKevin Wolf#
5*0a8111e0SKevin Wolf# Copyright (C) 2015 Red Hat, Inc.
6*0a8111e0SKevin Wolf#
7*0a8111e0SKevin Wolf# This program is free software; you can redistribute it and/or modify
8*0a8111e0SKevin Wolf# it under the terms of the GNU General Public License as published by
9*0a8111e0SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
10*0a8111e0SKevin Wolf# (at your option) any later version.
11*0a8111e0SKevin Wolf#
12*0a8111e0SKevin Wolf# This program is distributed in the hope that it will be useful,
13*0a8111e0SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*0a8111e0SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*0a8111e0SKevin Wolf# GNU General Public License for more details.
16*0a8111e0SKevin Wolf#
17*0a8111e0SKevin Wolf# You should have received a copy of the GNU General Public License
18*0a8111e0SKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*0a8111e0SKevin Wolf#
20*0a8111e0SKevin Wolf
21*0a8111e0SKevin Wolf# creator
22*0a8111e0SKevin Wolfowner=kwolf@redhat.com
23*0a8111e0SKevin Wolf
24*0a8111e0SKevin Wolfseq=`basename $0`
25*0a8111e0SKevin Wolfecho "QA output created by $seq"
26*0a8111e0SKevin Wolf
27*0a8111e0SKevin Wolfhere=`pwd`
28*0a8111e0SKevin Wolftmp=/tmp/$$
29*0a8111e0SKevin Wolfstatus=1	# failure is the default!
30*0a8111e0SKevin Wolf
31*0a8111e0SKevin Wolf_cleanup()
32*0a8111e0SKevin Wolf{
33*0a8111e0SKevin Wolf    _cleanup_test_img
34*0a8111e0SKevin Wolf}
35*0a8111e0SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
36*0a8111e0SKevin Wolf
37*0a8111e0SKevin Wolf# get standard environment, filters and checks
38*0a8111e0SKevin Wolf. ./common.rc
39*0a8111e0SKevin Wolf. ./common.filter
40*0a8111e0SKevin Wolf
41*0a8111e0SKevin Wolf_supported_fmt qcow2
42*0a8111e0SKevin Wolf_supported_proto file
43*0a8111e0SKevin Wolf_supported_os Linux
44*0a8111e0SKevin Wolf
45*0a8111e0SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img 64M
46*0a8111e0SKevin Wolf_make_test_img -b "$TEST_IMG.base"
47*0a8111e0SKevin Wolf
48*0a8111e0SKevin Wolfecho
49*0a8111e0SKevin Wolfecho "=== Check that node-name can't be changed ==="
50*0a8111e0SKevin Wolfecho
51*0a8111e0SKevin Wolf
52*0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o node-name=foo' $TEST_IMG
53*0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o file.node-name=foo' $TEST_IMG
54*0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o backing.node-name=foo' $TEST_IMG
55*0a8111e0SKevin Wolf
56*0a8111e0SKevin Wolfecho
57*0a8111e0SKevin Wolfecho "=== Check that unchanged node-name is okay ==="
58*0a8111e0SKevin Wolfecho
59*0a8111e0SKevin Wolf
60*0a8111e0SKevin Wolf# Explicitly repeated
61*0a8111e0SKevin Wolf$QEMU_IO -c "open -o node-name=foo $TEST_IMG" -c 'reopen -o node-name=foo'
62*0a8111e0SKevin Wolf$QEMU_IO -c "open -o file.node-name=foo $TEST_IMG" -c 'reopen -o file.node-name=foo'
63*0a8111e0SKevin Wolf$QEMU_IO -c "open -o backing.node-name=foo $TEST_IMG" -c 'reopen -o backing.node-name=foo'
64*0a8111e0SKevin Wolf
65*0a8111e0SKevin Wolf# Implicitly retained
66*0a8111e0SKevin Wolf$QEMU_IO -c "open -o node-name=foo $TEST_IMG" -c 'reopen'
67*0a8111e0SKevin Wolf$QEMU_IO -c "open -o file.node-name=foo $TEST_IMG" -c 'reopen'
68*0a8111e0SKevin Wolf$QEMU_IO -c "open -o backing.node-name=foo $TEST_IMG" -c 'reopen'
69*0a8111e0SKevin Wolf
70*0a8111e0SKevin Wolfecho
71*0a8111e0SKevin Wolfecho "=== Check that driver can't be changed ==="
72*0a8111e0SKevin Wolfecho
73*0a8111e0SKevin Wolf
74*0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o driver=raw' $TEST_IMG
75*0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o file.driver=qcow2' $TEST_IMG
76*0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o backing.driver=file' $TEST_IMG
77*0a8111e0SKevin Wolf
78*0a8111e0SKevin Wolfecho
79*0a8111e0SKevin Wolfecho "=== Check that unchanged driver is okay ==="
80*0a8111e0SKevin Wolfecho
81*0a8111e0SKevin Wolf
82*0a8111e0SKevin Wolf# Explicitly repeated (implicit case is covered in node-name test)
83*0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o driver=qcow2' $TEST_IMG
84*0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o file.driver=file' $TEST_IMG
85*0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o backing.driver=qcow2' $TEST_IMG
86*0a8111e0SKevin Wolf
87*0a8111e0SKevin Wolf# success, all done
88*0a8111e0SKevin Wolfecho "*** done"
89*0a8111e0SKevin Wolfrm -f $seq.full
90*0a8111e0SKevin Wolfstatus=0
91