]> git.proxmox.com Git - mirror_qemu.git/blame - tests/qemu-iotests/162
block: Declare blockdev-add and blockdev-del supported
[mirror_qemu.git] / tests / qemu-iotests / 162
CommitLineData
7d3e6936
HR
1#!/bin/bash
2#
3# Test case for specifying runtime options of the wrong type to some
4# block drivers
5#
6# Copyright (C) 2016 Red Hat, Inc.
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21
22# creator
23owner=mreitz@redhat.com
24
25seq="$(basename $0)"
26echo "QA output created by $seq"
27
28here="$PWD"
29status=1 # failure is the default!
30
31# get standard environment, filters and checks
32. ./common.rc
33. ./common.filter
34
35_supported_fmt generic
36_supported_os Linux
37
eaed0907
HR
38test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)')
39[ "$test_ssh" = "" ] && _notrun "ssh support required"
40
7d3e6936
HR
41echo
42echo '=== NBD ==='
43# NBD expects all of its arguments to be strings
44
45# So this should not crash
46$QEMU_IMG info 'json:{"driver": "nbd", "host": 42}'
47
48# And this should not treat @port as if it had not been specified
12ac9d9e
HR
49# (We need to set up a server here, because the error message for "Connection
50# refused" does not contain the destination port)
51
52# Launching qemu-nbd is done in a loop: We try to set up an NBD server on some
53# random port and continue until success, i.e. until we have found a port that
54# is not in use yet.
55while true; do
56 port=$((RANDOM + 32768))
57 if $QEMU_NBD -p $port -f raw --fork null-co:// 2> /dev/null; then
58 break
59 fi
60done
61
62$QEMU_IMG info "json:{'driver': 'nbd', 'host': 'localhost', 'port': $port}" \
63 | grep '^image' | sed -e "s/$port/PORT/"
7d3e6936
HR
64
65# This is a test for NBD's bdrv_refresh_filename() implementation: It expects
66# either host or path to be set, but it must not assume that they are set to
67# strings in the options QDict
668b4406 68$QEMU_NBD -k "$PWD/42" -f raw --fork null-co://
7d3e6936
HR
69$QEMU_IMG info 'json:{"driver": "nbd", "path": 42}' | grep '^image'
70rm -f 42
71
72
73echo
74echo '=== SSH ==='
75# SSH expects all of its arguments to be strings, except for @port, which is
76# expected to be an integer
77
78# So "0" should be converted to an integer here (instead of crashing)
79$QEMU_IMG info 'json:{"driver": "ssh", "host": "localhost", "port": "0", "path": "/foo"}'
80# The same, basically (all values for --image-opts are seen as strings in qemu)
81$QEMU_IMG info --image-opts \
82 driver=ssh,host=localhost,port=0,path=/foo
83
84# This, however, should fail because of the wrong type
85$QEMU_IMG info 'json:{"driver": "ssh", "host": "localhost", "port": 0.42, "path": "/foo"}'
86# Not really the same: Here, "0.42" will be passed instead of 0.42, but still,
87# qemu should not try to convert "0.42" to an integer
88$QEMU_IMG info --image-opts \
89 driver=ssh,host=localhost,port=0.42,path=/foo
90
91
92echo
93echo '=== blkdebug ==='
94# blkdebug expects all of its arguments to be strings, but its
95# bdrv_refresh_filename() implementation should not assume that they have been
96# passed as strings in the original options QDict.
97# So this should emit blkdebug:42:null-co:// as the filename:
98touch 42
99$QEMU_IMG info 'json:{"driver": "blkdebug", "config": 42,
100 "image.driver": "null-co"}' \
101 | grep '^image'
102rm -f 42
103
104
105# success, all done
106echo
107echo '*** done'
108rm -f $seq.full
109status=0