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