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 Wolfstatus=1 # failure is the default! 280a8111e0SKevin Wolf 290a8111e0SKevin Wolf_cleanup() 300a8111e0SKevin Wolf{ 310a8111e0SKevin Wolf _cleanup_test_img 320a8111e0SKevin Wolf} 330a8111e0SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 340a8111e0SKevin Wolf 350a8111e0SKevin Wolf# get standard environment, filters and checks 360a8111e0SKevin Wolf. ./common.rc 370a8111e0SKevin Wolf. ./common.filter 380a8111e0SKevin Wolf 390a8111e0SKevin Wolf_supported_fmt qcow2 400a8111e0SKevin Wolf_supported_proto file 410a8111e0SKevin Wolf_supported_os Linux 420a8111e0SKevin Wolf 430a8111e0SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img 64M 440a8111e0SKevin Wolf_make_test_img -b "$TEST_IMG.base" 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 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 1030a8111e0SKevin Wolf# success, all done 1040a8111e0SKevin Wolfecho "*** done" 1050a8111e0SKevin Wolfrm -f $seq.full 1060a8111e0SKevin Wolfstatus=0 107