1#!/bin/bash 2# 3# Test unsupported blockdev-add cases 4# 5# Copyright (C) 2014 Red Hat, Inc. 6# 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 2 of the License, or 10# (at your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program. If not, see <http://www.gnu.org/licenses/>. 19# 20 21# creator 22owner=kwolf@redhat.com 23 24seq=`basename $0` 25echo "QA output created by $seq" 26 27here=`pwd` 28tmp=/tmp/$$ 29status=1 # failure is the default! 30 31# get standard environment, filters and checks 32. ./common.rc 33. ./common.filter 34 35_supported_fmt qcow2 36_supported_proto file 37_supported_os Linux 38 39function do_run_qemu() 40{ 41 echo Testing: "$@" 42 $QEMU -nographic -qmp stdio -serial none "$@" 43 echo 44} 45 46function run_qemu() 47{ 48 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | sed -e 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g' 49} 50 51size=128M 52 53_make_test_img $size 54 55echo 56echo === Missing ID === 57echo 58 59run_qemu <<EOF 60{ "execute": "qmp_capabilities" } 61{ "execute": "blockdev-add", 62 "arguments": { 63 "options": { 64 "driver": "$IMGFMT", 65 "file": { 66 "driver": "file", 67 "filename": "$TEST_IMG" 68 } 69 } 70 } 71 } 72{ "execute": "quit" } 73EOF 74 75echo 76echo === Duplicate ID === 77echo 78 79run_qemu <<EOF 80{ "execute": "qmp_capabilities" } 81{ "execute": "blockdev-add", 82 "arguments": { 83 "options": { 84 "driver": "$IMGFMT", 85 "id": "disk", 86 "file": { 87 "driver": "file", 88 "filename": "$TEST_IMG" 89 } 90 } 91 } 92 } 93{ "execute": "blockdev-add", 94 "arguments": { 95 "options": { 96 "driver": "$IMGFMT", 97 "id": "disk", 98 "file": { 99 "driver": "file", 100 "filename": "$TEST_IMG" 101 } 102 } 103 } 104 } 105{ "execute": "quit" } 106EOF 107 108echo 109echo === aio=native without O_DIRECT === 110echo 111 112run_qemu <<EOF 113{ "execute": "qmp_capabilities" } 114{ "execute": "blockdev-add", 115 "arguments": { 116 "options": { 117 "driver": "$IMGFMT", 118 "id": "disk", 119 "aio": "native", 120 "file": { 121 "driver": "file", 122 "filename": "$TEST_IMG" 123 } 124 } 125 } 126 } 127{ "execute": "quit" } 128EOF 129 130echo 131echo === Encrypted image === 132echo 133 134_make_test_img -o encryption=on $size 135run_qemu -S <<EOF 136{ "execute": "qmp_capabilities" } 137{ "execute": "blockdev-add", 138 "arguments": { 139 "options": { 140 "driver": "$IMGFMT", 141 "id": "disk", 142 "file": { 143 "driver": "file", 144 "filename": "$TEST_IMG" 145 } 146 } 147 } 148 } 149{ "execute": "quit" } 150EOF 151 152run_qemu <<EOF 153{ "execute": "qmp_capabilities" } 154{ "execute": "blockdev-add", 155 "arguments": { 156 "options": { 157 "driver": "$IMGFMT", 158 "id": "disk", 159 "file": { 160 "driver": "file", 161 "filename": "$TEST_IMG" 162 } 163 } 164 } 165 } 166{ "execute": "quit" } 167EOF 168 169# success, all done 170echo "*** done" 171rm -f $seq.full 172status=0 173