1 11a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 2 *9dd003a9SVladimir Sementsov-Ogievskiy# group: auto quick 3 0a8111e0SKevin Wolf# 4 0a8111e0SKevin Wolf# Test for reopen 5 0a8111e0SKevin Wolf# 6 0a8111e0SKevin Wolf# Copyright (C) 2015 Red Hat, Inc. 7 0a8111e0SKevin Wolf# 8 0a8111e0SKevin Wolf# This program is free software; you can redistribute it and/or modify 9 0a8111e0SKevin Wolf# it under the terms of the GNU General Public License as published by 10 0a8111e0SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 11 0a8111e0SKevin Wolf# (at your option) any later version. 12 0a8111e0SKevin Wolf# 13 0a8111e0SKevin Wolf# This program is distributed in the hope that it will be useful, 14 0a8111e0SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 15 0a8111e0SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 0a8111e0SKevin Wolf# GNU General Public License for more details. 17 0a8111e0SKevin Wolf# 18 0a8111e0SKevin Wolf# You should have received a copy of the GNU General Public License 19 0a8111e0SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 20 0a8111e0SKevin Wolf# 21 0a8111e0SKevin Wolf 22 0a8111e0SKevin Wolf# creator 23 0a8111e0SKevin Wolfowner=kwolf@redhat.com 24 0a8111e0SKevin Wolf 25 0a8111e0SKevin Wolfseq=`basename $0` 26 0a8111e0SKevin Wolfecho "QA output created by $seq" 27 0a8111e0SKevin Wolf 28 0a8111e0SKevin Wolfstatus=1 # failure is the default! 29 0a8111e0SKevin Wolf 30 0a8111e0SKevin Wolf_cleanup() 31 0a8111e0SKevin Wolf{ 32 0a8111e0SKevin Wolf _cleanup_test_img 33 0a8111e0SKevin Wolf} 34 0a8111e0SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 35 0a8111e0SKevin Wolf 36 0a8111e0SKevin Wolf# get standard environment, filters and checks 37 0a8111e0SKevin Wolf. ./common.rc 38 0a8111e0SKevin Wolf. ./common.filter 39 0a8111e0SKevin Wolf 40 0a8111e0SKevin Wolf_supported_fmt qcow2 41 57284d2aSMax Reitz_supported_proto file fuse 42 0a8111e0SKevin Wolf 43 0a8111e0SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img 64M 44 b66ff2c2SEric Blake_make_test_img -b "$TEST_IMG.base" -F $IMGFMT 45 0a8111e0SKevin Wolf 46 0a8111e0SKevin Wolfecho 47 0a8111e0SKevin Wolfecho "=== Check that node-name can't be changed ===" 48 0a8111e0SKevin Wolfecho 49 0a8111e0SKevin Wolf 50 0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o node-name=foo' $TEST_IMG 51 0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o file.node-name=foo' $TEST_IMG 52 0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o backing.node-name=foo' $TEST_IMG 53 0a8111e0SKevin Wolf 54 0a8111e0SKevin Wolfecho 55 0a8111e0SKevin Wolfecho "=== Check that unchanged node-name is okay ===" 56 0a8111e0SKevin Wolfecho 57 0a8111e0SKevin Wolf 58 0a8111e0SKevin Wolf# Explicitly repeated 59 0a8111e0SKevin Wolf$QEMU_IO -c "open -o node-name=foo $TEST_IMG" -c 'reopen -o node-name=foo' 60 0a8111e0SKevin Wolf$QEMU_IO -c "open -o file.node-name=foo $TEST_IMG" -c 'reopen -o file.node-name=foo' 61 0a8111e0SKevin Wolf$QEMU_IO -c "open -o backing.node-name=foo $TEST_IMG" -c 'reopen -o backing.node-name=foo' 62 0a8111e0SKevin Wolf 63 0a8111e0SKevin Wolf# Implicitly retained 64 0a8111e0SKevin Wolf$QEMU_IO -c "open -o node-name=foo $TEST_IMG" -c 'reopen' 65 0a8111e0SKevin Wolf$QEMU_IO -c "open -o file.node-name=foo $TEST_IMG" -c 'reopen' 66 0a8111e0SKevin Wolf$QEMU_IO -c "open -o backing.node-name=foo $TEST_IMG" -c 'reopen' 67 0a8111e0SKevin Wolf 68 0a8111e0SKevin Wolfecho 69 0a8111e0SKevin Wolfecho "=== Check that driver can't be changed ===" 70 0a8111e0SKevin Wolfecho 71 0a8111e0SKevin Wolf 72 0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o driver=raw' $TEST_IMG 73 0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o file.driver=qcow2' $TEST_IMG 74 0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o backing.driver=file' $TEST_IMG 75 0a8111e0SKevin Wolf 76 0a8111e0SKevin Wolfecho 77 0a8111e0SKevin Wolfecho "=== Check that unchanged driver is okay ===" 78 0a8111e0SKevin Wolfecho 79 0a8111e0SKevin Wolf 80 0a8111e0SKevin Wolf# Explicitly repeated (implicit case is covered in node-name test) 81 0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o driver=qcow2' $TEST_IMG 82 0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o file.driver=file' $TEST_IMG 83 0a8111e0SKevin Wolf$QEMU_IO -c 'reopen -o backing.driver=qcow2' $TEST_IMG 84 0a8111e0SKevin Wolf 85 791cbcccSMax Reitzecho 86 791cbcccSMax Reitzecho "=== Check that reopening works with non-string options ===" 87 791cbcccSMax Reitzecho 88 791cbcccSMax Reitz 89 791cbcccSMax Reitz# Using the json: pseudo-protocol we can create non-string options 90 791cbcccSMax Reitz# (Invoke 'info' just so we get some output afterwards) 91 791cbcccSMax ReitzIMGOPTSSYNTAX=false $QEMU_IO -f null-co -c 'reopen' -c 'info' \ 92 791cbcccSMax Reitz "json:{'driver': 'null-co', 'size': 65536}" 93 791cbcccSMax Reitz 94 dc900c35SAlberto Garciaecho 95 dc900c35SAlberto Garciaecho "=== Check that mixing -c/-r/-w and their corresponding options is forbidden ===" 96 dc900c35SAlberto Garciaecho 97 dc900c35SAlberto Garcia 98 dc900c35SAlberto Garcia$QEMU_IO -c 'reopen -r -o read-only=on' $TEST_IMG 99 dc900c35SAlberto Garcia$QEMU_IO -c 'reopen -w -o read-only=on' $TEST_IMG 100 dc900c35SAlberto Garcia$QEMU_IO -c 'reopen -c none -o cache.direct=on' $TEST_IMG 101 dc900c35SAlberto Garcia$QEMU_IO -c 'reopen -c writeback -o cache.direct=on' $TEST_IMG 102 dc900c35SAlberto Garcia$QEMU_IO -c 'reopen -c directsync -o cache.no-flush=on' $TEST_IMG 103 8eb4b07bSAlberto Garcia 104 8eb4b07bSAlberto Garciaecho 105 8eb4b07bSAlberto Garciaecho "=== Check that invalid options are handled correctly ===" 106 8eb4b07bSAlberto Garciaecho 107 8eb4b07bSAlberto Garcia 108 8eb4b07bSAlberto Garcia$QEMU_IO -c 'reopen -o read-only=foo' $TEST_IMG 109 8eb4b07bSAlberto Garcia$QEMU_IO -c 'reopen -o cache.no-flush=bar' $TEST_IMG 110 8eb4b07bSAlberto Garcia$QEMU_IO -c 'reopen -o cache.direct=baz' $TEST_IMG 111 8eb4b07bSAlberto Garcia$QEMU_IO -c 'reopen -o auto-read-only=qux' $TEST_IMG 112 0a8111e0SKevin Wolf# success, all done 113 0a8111e0SKevin Wolfecho "*** done" 114 0a8111e0SKevin Wolfrm -f $seq.full 115 0a8111e0SKevin Wolfstatus=0 116