xref: /openbmc/qemu/tests/qemu-iotests/146 (revision 7acafcfa)
1#!/usr/bin/env bash
2#
3# Test VHD image format creator detection and override
4#
5# Copyright (C) 2016 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=jcody@redhat.com
23
24seq=`basename $0`
25echo "QA output created by $seq"
26
27status=1    # failure is the default!
28
29_cleanup()
30{
31    _cleanup_qemu
32    _cleanup_test_img
33}
34trap "_cleanup; exit \$status" 0 1 2 3 15
35
36# get standard environment, filters and checks
37. ./common.rc
38. ./common.filter
39. ./common.qemu
40
41_supported_fmt vpc
42_supported_proto file
43_supported_os Linux
44
45
46qemu_comm_method="monitor"
47silent=
48
49echo
50echo === Testing VPC Autodetect ===
51echo
52_use_sample_img virtualpc-dynamic.vhd.bz2
53
54$QEMU_IMG map --output=json --image-opts \
55    "driver=vpc,file.filename=$TEST_IMG" \
56    | _filter_qemu_img_map
57
58echo
59echo === Testing VPC with current_size force ===
60echo
61
62$QEMU_IMG map --output=json --image-opts \
63    "driver=vpc,force_size_calc=current_size,file.filename=$TEST_IMG" \
64    | _filter_qemu_img_map
65
66echo
67echo === Testing VPC with chs force ===
68echo
69
70$QEMU_IMG map --output=json --image-opts \
71    "driver=vpc,force_size_calc=chs,file.filename=$TEST_IMG" \
72    | _filter_qemu_img_map
73
74_cleanup_test_img
75
76echo
77echo === Testing Hyper-V Autodetect ===
78echo
79_use_sample_img hyperv2012r2-dynamic.vhd.bz2
80
81$QEMU_IMG map --output=json --image-opts \
82    "driver=vpc,file.filename=$TEST_IMG" \
83    | _filter_qemu_img_map
84
85echo
86echo === Testing Hyper-V with current_size force ===
87echo
88
89$QEMU_IMG map --output=json --image-opts \
90    "driver=vpc,force_size_calc=current_size,file.filename=$TEST_IMG" \
91    | _filter_qemu_img_map
92
93echo
94echo === Testing Hyper-V with chs force ===
95echo
96
97$QEMU_IMG map --output=json --image-opts \
98    "driver=vpc,force_size_calc=chs,file.filename=$TEST_IMG" \
99    | _filter_qemu_img_map
100
101_cleanup_test_img
102
103echo
104echo === Testing d2v Autodetect ===
105echo
106_use_sample_img d2v-zerofilled.vhd.bz2
107
108$QEMU_IMG map --output=json --image-opts \
109    "driver=vpc,file.filename=$TEST_IMG" \
110    | _filter_qemu_img_map
111
112echo
113echo === Testing d2v with current_size force ===
114echo
115
116$QEMU_IMG map --output=json --image-opts \
117    "driver=vpc,force_size_calc=current_size,file.filename=$TEST_IMG" \
118    | _filter_qemu_img_map
119
120echo
121echo === Testing d2v with chs force ===
122echo
123
124$QEMU_IMG map --output=json --image-opts \
125    "driver=vpc,force_size_calc=chs,file.filename=$TEST_IMG" \
126    | _filter_qemu_img_map
127
128_cleanup_test_img
129
130echo
131echo === Testing Image create, default ===
132echo
133
134TEST_IMG="${TEST_DIR}/vpc-create-test.vpc"
135
136_make_test_img 4G
137
138echo
139echo === Read created image, default opts ====
140echo
141
142$QEMU_IMG map --output=json --image-opts \
143    "driver=vpc,file.filename=$TEST_IMG" \
144    | _filter_qemu_img_map
145
146echo
147echo === Read created image, force_size_calc=chs ====
148echo
149
150$QEMU_IMG map --output=json --image-opts \
151    "driver=vpc,force_size_calc=chs,file.filename=$TEST_IMG" \
152    | _filter_qemu_img_map
153
154echo
155echo === Read created image, force_size_calc=current_size ====
156echo
157
158$QEMU_IMG map --output=json --image-opts \
159    "driver=vpc,force_size_calc=current_size,file.filename=$TEST_IMG" \
160    | _filter_qemu_img_map
161
162echo
163echo === Testing Image create, force_size ===
164echo
165
166_make_test_img -o force_size 4G
167
168echo
169echo === Read created image, default opts ====
170echo
171
172$QEMU_IMG map --output=json --image-opts \
173    "driver=vpc,file.filename=$TEST_IMG" \
174    | _filter_qemu_img_map
175
176echo
177echo === Read created image, force_size_calc=chs ====
178echo
179
180$QEMU_IMG map --output=json --image-opts \
181    "driver=vpc,force_size_calc=chs,file.filename=$TEST_IMG" \
182    | _filter_qemu_img_map
183
184echo
185echo === Read created image, force_size_calc=current_size ====
186echo
187
188$QEMU_IMG map --output=json --image-opts \
189    "driver=vpc,force_size_calc=current_size,file.filename=$TEST_IMG" \
190    | _filter_qemu_img_map
191
192echo "*** done"
193rm -f $seq.full
194status=0
195