master
text 145 lines 3.64 KB
Raw
1 #!/usr/bin/env bash
2 # group: rw auto
3 #
4 # Test 'info block' with all kinds of configurations
5 #
6 # Copyright (C) 2017 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
23 owner=kwolf@redhat.com
24
25 seq=`basename $0`
26 echo "QA output created by $seq"
27
28 status=1 # failure is the default!
29
30 _cleanup()
31 {
32 _cleanup_test_img
33 }
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
39
40 _supported_fmt qcow2
41 _supported_proto file fuse
42 _require_drivers null-co
43 _require_devices virtio-scsi-pci
44 _require_hmp
45
46 if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
47 _notrun "Requires a PC machine"
48 fi
49
50 do_run_qemu()
51 {
52 echo Testing: "$@"
53
54 (
55 if ! test -t 0; then
56 while read cmd; do
57 echo $cmd
58 done
59 fi
60 echo quit
61 ) | $QEMU -S -display none -device virtio-scsi-pci -monitor stdio "$@" 2>&1
62 echo
63 }
64
65 check_info_block()
66 {
67 echo "info block" |
68 do_run_qemu "$@" | _filter_win32 | _filter_hmp | _filter_qemu |
69 _filter_generated_node_ids | _filter_qom_path
70 }
71
72
73 size=64M
74 _make_test_img $size
75
76 removable="floppy ide-cd scsi-cd"
77 fixed="ide-hd scsi-hd virtio-blk-pci"
78
79 echo
80 echo "=== Empty drives ==="
81 echo
82
83 for dev in $removable; do
84 check_info_block -device $dev
85 check_info_block -device $dev,id=qdev_id
86 done
87
88 echo
89 echo "=== -blockdev/-device=<node-name> ==="
90 echo
91
92 for dev in $fixed $removable; do
93 check_info_block -blockdev driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null
94 check_info_block -blockdev driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null,id=qdev_id
95 done
96
97 echo
98 echo "=== -drive if=none/-device=<node-name> ==="
99 echo
100
101 # This creates two BlockBackends that will show up in 'info block'!
102 # A monitor-owned one from -drive, and anonymous one from -device
103 for dev in $fixed $removable; do
104 check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null,id=qdev_id
105 done
106
107 echo
108 echo "=== -drive if=none/-device=<bb-name> (with medium) ==="
109 echo
110
111 for dev in $fixed $removable; do
112 check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=none0
113 check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=none0,id=qdev_id
114 done
115
116 echo
117 echo "=== -drive if=none/-device=<bb-name> (without medium) ==="
118 echo
119
120 check_info_block -drive if=none
121
122 for dev in $removable; do
123 check_info_block -drive if=none -device $dev,drive=none0
124 check_info_block -drive if=none -device $dev,drive=none0,id=qdev_id
125 done
126
127 echo
128 echo "=== -drive if=... ==="
129 echo
130
131 check_info_block -drive if=floppy
132 check_info_block -drive if=floppy,driver=null-co,read-zeroes=on
133
134 check_info_block -drive if=ide,driver=null-co,read-zeroes=on
135 check_info_block -drive if=ide,media=cdrom
136 check_info_block -drive if=ide,driver=null-co,read-zeroes=on,media=cdrom
137
138 check_info_block -drive if=virtio,driver=null-co,read-zeroes=on
139
140 check_info_block -drive if=pflash,driver=null-co,read-zeroes=on,size=1M
141
142 # success, all done
143 echo "*** done"
144 rm -f $seq.full
145 status=0