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 "driver": "$IMGFMT", 65c75203c8SKevin Wolf "file": { 66c75203c8SKevin Wolf "driver": "file", 67c75203c8SKevin Wolf "filename": "$TEST_IMG" 68c75203c8SKevin Wolf } 69c75203c8SKevin Wolf } 70c75203c8SKevin Wolf } 71c75203c8SKevin Wolf{ "execute": "quit" } 72c75203c8SKevin WolfEOF 73c75203c8SKevin Wolf 74c75203c8SKevin Wolfecho 75f2d953ecSKevin Wolfecho === Duplicate ID === 76f2d953ecSKevin Wolfecho 77f2d953ecSKevin Wolf 785feb08edSKevin Wolfrun_qemu -drive driver=$IMGFMT,id=disk,node-name=test-node,file="$TEST_IMG" <<EOF 79f2d953ecSKevin Wolf{ "execute": "qmp_capabilities" } 80f2d953ecSKevin Wolf{ "execute": "blockdev-add", 81f2d953ecSKevin Wolf "arguments": { 82f2d953ecSKevin Wolf "driver": "$IMGFMT", 8390d9d301SKevin Wolf "node-name": "disk", 8490d9d301SKevin Wolf "file": { 85d5b8336aSFam Zheng "driver": "null-co" 8690d9d301SKevin Wolf } 8790d9d301SKevin Wolf } 8890d9d301SKevin Wolf } 8990d9d301SKevin Wolf{ "execute": "blockdev-add", 9090d9d301SKevin Wolf "arguments": { 9190d9d301SKevin Wolf "driver": "$IMGFMT", 9290d9d301SKevin Wolf "node-name": "test-node", 9390d9d301SKevin Wolf "file": { 94d5b8336aSFam Zheng "driver": "null-co" 9590d9d301SKevin Wolf } 9690d9d301SKevin Wolf } 9790d9d301SKevin Wolf } 98f2d953ecSKevin Wolf{ "execute": "quit" } 99f2d953ecSKevin WolfEOF 100f2d953ecSKevin Wolf 101f2d953ecSKevin Wolfecho 102c75203c8SKevin Wolfecho === aio=native without O_DIRECT === 103c75203c8SKevin Wolfecho 104c75203c8SKevin Wolf 105c75203c8SKevin Wolfrun_qemu <<EOF 106c75203c8SKevin Wolf{ "execute": "qmp_capabilities" } 107c75203c8SKevin Wolf{ "execute": "blockdev-add", 108c75203c8SKevin Wolf "arguments": { 109c75203c8SKevin Wolf "driver": "$IMGFMT", 1105feb08edSKevin Wolf "node-name": "disk", 111c75203c8SKevin Wolf "file": { 112c75203c8SKevin Wolf "driver": "file", 1130a4279d9SKevin Wolf "filename": "$TEST_IMG", 1140a4279d9SKevin Wolf "aio": "native" 115c75203c8SKevin Wolf } 116c75203c8SKevin Wolf } 117c75203c8SKevin Wolf } 118c75203c8SKevin Wolf{ "execute": "quit" } 119c75203c8SKevin WolfEOF 120c75203c8SKevin Wolf 121c75203c8SKevin Wolfecho 122c75203c8SKevin Wolfecho === Encrypted image === 123c75203c8SKevin Wolfecho 124c75203c8SKevin Wolf 125*b25b387fSDaniel P. Berrange_make_test_img --object secret,id=sec0,data=123456 -o encryption=on,encrypt.key-secret=sec0 $size 126c75203c8SKevin Wolfrun_qemu <<EOF 127c75203c8SKevin Wolf{ "execute": "qmp_capabilities" } 128*b25b387fSDaniel P. Berrange{ "execute": "object-add", 129*b25b387fSDaniel P. Berrange "arguments": { 130*b25b387fSDaniel P. Berrange "qom-type": "secret", 131*b25b387fSDaniel P. Berrange "id": "sec0", 132*b25b387fSDaniel P. Berrange "props": { 133*b25b387fSDaniel P. Berrange "data": "123456" 134*b25b387fSDaniel P. Berrange } 135*b25b387fSDaniel P. Berrange } 136*b25b387fSDaniel P. Berrange} 137c75203c8SKevin Wolf{ "execute": "blockdev-add", 138c75203c8SKevin Wolf "arguments": { 139c75203c8SKevin Wolf "driver": "$IMGFMT", 1405feb08edSKevin Wolf "node-name": "disk", 141c75203c8SKevin Wolf "file": { 142c75203c8SKevin Wolf "driver": "file", 143c75203c8SKevin Wolf "filename": "$TEST_IMG" 144*b25b387fSDaniel P. Berrange }, 145*b25b387fSDaniel P. Berrange "encrypt": { 146*b25b387fSDaniel P. Berrange "format": "aes", 147*b25b387fSDaniel P. Berrange "key-secret": "sec0" 148c75203c8SKevin Wolf } 149c75203c8SKevin Wolf } 150c75203c8SKevin Wolf } 151c75203c8SKevin Wolf{ "execute": "quit" } 152c75203c8SKevin WolfEOF 153c75203c8SKevin Wolf 154fe509ee2SFam Zhengecho 155fe509ee2SFam Zhengecho === Missing driver === 156fe509ee2SFam Zhengecho 157fe509ee2SFam Zheng 158*b25b387fSDaniel P. Berrange_make_test_img --object secret,id=sec0,data=123456 -o encryption=on,encrypt.key-secret=sec0 $size 159fe509ee2SFam Zhengrun_qemu -S <<EOF 160fe509ee2SFam Zheng{ "execute": "qmp_capabilities" } 161fe509ee2SFam Zheng{ "execute": "blockdev-add", 162fe509ee2SFam Zheng "arguments": { 1635feb08edSKevin Wolf "node-name": "disk" 164fe509ee2SFam Zheng } 165fe509ee2SFam Zheng } 166fe509ee2SFam Zheng{ "execute": "quit" } 167fe509ee2SFam ZhengEOF 168fe509ee2SFam Zheng 169c75203c8SKevin Wolf# success, all done 170c75203c8SKevin Wolfecho "*** done" 171c75203c8SKevin Wolfrm -f $seq.full 172c75203c8SKevin Wolfstatus=0 173