1c75203c8SKevin Wolf#!/bin/bash 2c75203c8SKevin Wolf# 3c75203c8SKevin Wolf# Test unsupported blockdev-add cases 4c75203c8SKevin Wolf# 5c75203c8SKevin Wolf# Copyright (C) 2014 Red Hat, Inc. 6c75203c8SKevin Wolf# 7c75203c8SKevin Wolf# This program is free software; you can redistribute it and/or modify 8c75203c8SKevin Wolf# it under the terms of the GNU General Public License as published by 9c75203c8SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 10c75203c8SKevin Wolf# (at your option) any later version. 11c75203c8SKevin Wolf# 12c75203c8SKevin Wolf# This program is distributed in the hope that it will be useful, 13c75203c8SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 14c75203c8SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15c75203c8SKevin Wolf# GNU General Public License for more details. 16c75203c8SKevin Wolf# 17c75203c8SKevin Wolf# You should have received a copy of the GNU General Public License 18c75203c8SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 19c75203c8SKevin Wolf# 20c75203c8SKevin Wolf 21c75203c8SKevin Wolf# creator 22c75203c8SKevin Wolfowner=kwolf@redhat.com 23c75203c8SKevin Wolf 24c75203c8SKevin Wolfseq=`basename $0` 25c75203c8SKevin Wolfecho "QA output created by $seq" 26c75203c8SKevin Wolf 27c75203c8SKevin Wolfhere=`pwd` 28c75203c8SKevin Wolfstatus=1 # failure is the default! 29c75203c8SKevin Wolf 30c75203c8SKevin Wolf# get standard environment, filters and checks 31c75203c8SKevin Wolf. ./common.rc 32c75203c8SKevin Wolf. ./common.filter 33c75203c8SKevin Wolf 34c75203c8SKevin Wolf_supported_fmt qcow2 35c75203c8SKevin Wolf_supported_proto file 36c75203c8SKevin Wolf_supported_os Linux 37c75203c8SKevin Wolf 38c75203c8SKevin Wolffunction do_run_qemu() 39c75203c8SKevin Wolf{ 40c75203c8SKevin Wolf echo Testing: "$@" 41c75203c8SKevin Wolf $QEMU -nographic -qmp stdio -serial none "$@" 42c75203c8SKevin Wolf echo 43c75203c8SKevin Wolf} 44c75203c8SKevin Wolf 45c75203c8SKevin Wolffunction run_qemu() 46c75203c8SKevin Wolf{ 47e6ff69bfSDaniel P. Berrange do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \ 48e6ff69bfSDaniel P. Berrange | _filter_qemu | _filter_imgfmt \ 494dd7b8d3SMax Reitz | sed -e 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g' 50c75203c8SKevin Wolf} 51c75203c8SKevin Wolf 52c75203c8SKevin Wolfsize=128M 53c75203c8SKevin Wolf 54c75203c8SKevin Wolf_make_test_img $size 55c75203c8SKevin Wolf 56c75203c8SKevin Wolfecho 57be4b67bcSMax Reitzecho === Missing ID and node-name === 58c75203c8SKevin Wolfecho 59c75203c8SKevin Wolf 60c75203c8SKevin Wolfrun_qemu <<EOF 61c75203c8SKevin Wolf{ "execute": "qmp_capabilities" } 62c75203c8SKevin Wolf{ "execute": "blockdev-add", 63c75203c8SKevin Wolf "arguments": { 64c75203c8SKevin Wolf "options": { 65c75203c8SKevin Wolf "driver": "$IMGFMT", 66c75203c8SKevin Wolf "file": { 67c75203c8SKevin Wolf "driver": "file", 68c75203c8SKevin Wolf "filename": "$TEST_IMG" 69c75203c8SKevin Wolf } 70c75203c8SKevin Wolf } 71c75203c8SKevin Wolf } 72c75203c8SKevin Wolf } 73c75203c8SKevin Wolf{ "execute": "quit" } 74c75203c8SKevin WolfEOF 75c75203c8SKevin Wolf 76c75203c8SKevin Wolfecho 77f2d953ecSKevin Wolfecho === Duplicate ID === 78f2d953ecSKevin Wolfecho 79f2d953ecSKevin Wolf 80*5feb08edSKevin Wolfrun_qemu -drive driver=$IMGFMT,id=disk,node-name=test-node,file="$TEST_IMG" <<EOF 81f2d953ecSKevin Wolf{ "execute": "qmp_capabilities" } 82f2d953ecSKevin Wolf{ "execute": "blockdev-add", 83f2d953ecSKevin Wolf "arguments": { 84f2d953ecSKevin Wolf "options": { 85f2d953ecSKevin Wolf "driver": "$IMGFMT", 8690d9d301SKevin Wolf "node-name": "disk", 8790d9d301SKevin Wolf "file": { 8890d9d301SKevin Wolf "driver": "file", 8990d9d301SKevin Wolf "filename": "$TEST_IMG" 9090d9d301SKevin Wolf } 9190d9d301SKevin Wolf } 9290d9d301SKevin Wolf } 9390d9d301SKevin Wolf } 9490d9d301SKevin Wolf{ "execute": "blockdev-add", 9590d9d301SKevin Wolf "arguments": { 9690d9d301SKevin Wolf "options": { 9790d9d301SKevin Wolf "driver": "$IMGFMT", 9890d9d301SKevin Wolf "node-name": "test-node", 9990d9d301SKevin Wolf "file": { 10090d9d301SKevin Wolf "driver": "file", 10190d9d301SKevin Wolf "filename": "$TEST_IMG" 10290d9d301SKevin Wolf } 10390d9d301SKevin Wolf } 10490d9d301SKevin Wolf } 10590d9d301SKevin Wolf } 106f2d953ecSKevin Wolf{ "execute": "quit" } 107f2d953ecSKevin WolfEOF 108f2d953ecSKevin Wolf 109f2d953ecSKevin Wolfecho 110c75203c8SKevin Wolfecho === aio=native without O_DIRECT === 111c75203c8SKevin Wolfecho 112c75203c8SKevin Wolf 113c75203c8SKevin Wolfrun_qemu <<EOF 114c75203c8SKevin Wolf{ "execute": "qmp_capabilities" } 115c75203c8SKevin Wolf{ "execute": "blockdev-add", 116c75203c8SKevin Wolf "arguments": { 117c75203c8SKevin Wolf "options": { 118c75203c8SKevin Wolf "driver": "$IMGFMT", 119*5feb08edSKevin Wolf "node-name": "disk", 120c75203c8SKevin Wolf "aio": "native", 121c75203c8SKevin Wolf "file": { 122c75203c8SKevin Wolf "driver": "file", 123c75203c8SKevin Wolf "filename": "$TEST_IMG" 124c75203c8SKevin Wolf } 125c75203c8SKevin Wolf } 126c75203c8SKevin Wolf } 127c75203c8SKevin Wolf } 128c75203c8SKevin Wolf{ "execute": "quit" } 129c75203c8SKevin WolfEOF 130c75203c8SKevin Wolf 131c75203c8SKevin Wolfecho 132c75203c8SKevin Wolfecho === Encrypted image === 133c75203c8SKevin Wolfecho 134c75203c8SKevin Wolf 135c75203c8SKevin Wolf_make_test_img -o encryption=on $size 136c3adb58fSMarkus Armbrusterrun_qemu -S <<EOF 137c3adb58fSMarkus Armbruster{ "execute": "qmp_capabilities" } 138c3adb58fSMarkus Armbruster{ "execute": "blockdev-add", 139c3adb58fSMarkus Armbruster "arguments": { 140c3adb58fSMarkus Armbruster "options": { 141c3adb58fSMarkus Armbruster "driver": "$IMGFMT", 142*5feb08edSKevin Wolf "node-name": "disk", 143c3adb58fSMarkus Armbruster "file": { 144c3adb58fSMarkus Armbruster "driver": "file", 145c3adb58fSMarkus Armbruster "filename": "$TEST_IMG" 146c3adb58fSMarkus Armbruster } 147c3adb58fSMarkus Armbruster } 148c3adb58fSMarkus Armbruster } 149c3adb58fSMarkus Armbruster } 150c3adb58fSMarkus Armbruster{ "execute": "quit" } 151c3adb58fSMarkus ArmbrusterEOF 152c3adb58fSMarkus Armbruster 153c75203c8SKevin Wolfrun_qemu <<EOF 154c75203c8SKevin Wolf{ "execute": "qmp_capabilities" } 155c75203c8SKevin Wolf{ "execute": "blockdev-add", 156c75203c8SKevin Wolf "arguments": { 157c75203c8SKevin Wolf "options": { 158c75203c8SKevin Wolf "driver": "$IMGFMT", 159*5feb08edSKevin Wolf "node-name": "disk", 160c75203c8SKevin Wolf "file": { 161c75203c8SKevin Wolf "driver": "file", 162c75203c8SKevin Wolf "filename": "$TEST_IMG" 163c75203c8SKevin Wolf } 164c75203c8SKevin Wolf } 165c75203c8SKevin Wolf } 166c75203c8SKevin Wolf } 167c75203c8SKevin Wolf{ "execute": "quit" } 168c75203c8SKevin WolfEOF 169c75203c8SKevin Wolf 170fe509ee2SFam Zhengecho 171fe509ee2SFam Zhengecho === Missing driver === 172fe509ee2SFam Zhengecho 173fe509ee2SFam Zheng 174fe509ee2SFam Zheng_make_test_img -o encryption=on $size 175fe509ee2SFam Zhengrun_qemu -S <<EOF 176fe509ee2SFam Zheng{ "execute": "qmp_capabilities" } 177fe509ee2SFam Zheng{ "execute": "blockdev-add", 178fe509ee2SFam Zheng "arguments": { 179fe509ee2SFam Zheng "options": { 180*5feb08edSKevin Wolf "node-name": "disk" 181fe509ee2SFam Zheng } 182fe509ee2SFam Zheng } 183fe509ee2SFam Zheng } 184fe509ee2SFam Zheng{ "execute": "quit" } 185fe509ee2SFam ZhengEOF 186fe509ee2SFam Zheng 187c75203c8SKevin Wolf# success, all done 188c75203c8SKevin Wolfecho "*** done" 189c75203c8SKevin Wolfrm -f $seq.full 190c75203c8SKevin Wolfstatus=0 191