xref: /openbmc/qemu/tests/qemu-iotests/059 (revision 1f7bf7d0)
1ca6cbb65SFam Zheng#!/bin/bash
2ca6cbb65SFam Zheng#
3ca6cbb65SFam Zheng# Test case for vmdk
4ca6cbb65SFam Zheng#
5ca6cbb65SFam Zheng# Copyright (C) 2013 Red Hat, Inc.
6ca6cbb65SFam Zheng#
7ca6cbb65SFam Zheng# This program is free software; you can redistribute it and/or modify
8ca6cbb65SFam Zheng# it under the terms of the GNU General Public License as published by
9ca6cbb65SFam Zheng# the Free Software Foundation; either version 2 of the License, or
10ca6cbb65SFam Zheng# (at your option) any later version.
11ca6cbb65SFam Zheng#
12ca6cbb65SFam Zheng# This program is distributed in the hope that it will be useful,
13ca6cbb65SFam Zheng# but WITHOUT ANY WARRANTY; without even the implied warranty of
14ca6cbb65SFam Zheng# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15ca6cbb65SFam Zheng# GNU General Public License for more details.
16ca6cbb65SFam Zheng#
17ca6cbb65SFam Zheng# You should have received a copy of the GNU General Public License
18ca6cbb65SFam Zheng# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19ca6cbb65SFam Zheng#
20ca6cbb65SFam Zheng
21ca6cbb65SFam Zheng# creator
22ca6cbb65SFam Zhengowner=famz@redhat.com
23ca6cbb65SFam Zheng
24ca6cbb65SFam Zhengseq=`basename $0`
25ca6cbb65SFam Zhengecho "QA output created by $seq"
26ca6cbb65SFam Zheng
27ca6cbb65SFam Zhenghere=`pwd`
28ca6cbb65SFam Zhengtmp=/tmp/$$
29ca6cbb65SFam Zhengstatus=1	# failure is the default!
30ca6cbb65SFam Zheng
31ca6cbb65SFam Zheng_cleanup()
32ca6cbb65SFam Zheng{
33ca6cbb65SFam Zheng	_cleanup_test_img
34ca6cbb65SFam Zheng}
35ca6cbb65SFam Zhengtrap "_cleanup; exit \$status" 0 1 2 3 15
36ca6cbb65SFam Zheng
37ca6cbb65SFam Zheng# get standard environment, filters and checks
38ca6cbb65SFam Zheng. ./common.rc
39ca6cbb65SFam Zheng. ./common.filter
40ca6cbb65SFam Zheng
41ca6cbb65SFam Zheng# This tests vmdk-specific low-level functionality
42ca6cbb65SFam Zheng_supported_fmt vmdk
43*1f7bf7d0SPeter Lieven_supported_proto file
44ca6cbb65SFam Zheng_supported_os Linux
45d2329f27SFam Zheng_unsupported_imgopts "subformat=monolithicFlat" \
46d2329f27SFam Zheng                     "subformat=twoGbMaxExtentFlat" \
47d2329f27SFam Zheng                     "subformat=twoGbMaxExtentSparse"
48ca6cbb65SFam Zheng
492c43e43cSFam Zhengcapacity_offset=16
508aa1331cSFam Zhenggranularity_offset=20
51f8ce0403SFam Zhenggrain_table_size_offset=44
528aa1331cSFam Zheng
538aa1331cSFam Zhengecho
545dd75f9aSFam Zhengecho "=== Testing invalid granularity ==="
558aa1331cSFam Zheng_make_test_img 64M
568aa1331cSFam Zhengpoke_file "$TEST_IMG" "$granularity_offset" "\xff\xff\xff\xff\xff\xff\xff\xff"
57fef9c191SJeff Cody{ $QEMU_IO -c "read 0 512" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
58ca6cbb65SFam Zheng
59f8ce0403SFam Zhengecho
605dd75f9aSFam Zhengecho "=== Testing too big L2 table size ==="
61f8ce0403SFam Zheng_make_test_img 64M
62f8ce0403SFam Zhengpoke_file "$TEST_IMG" "$grain_table_size_offset" "\xff\xff\xff\xff"
63fef9c191SJeff Cody{ $QEMU_IO -c "read 0 512" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
64f8ce0403SFam Zheng
652c43e43cSFam Zhengecho
665dd75f9aSFam Zhengecho "=== Testing too big L1 table size ==="
672c43e43cSFam Zheng_make_test_img 64M
682c43e43cSFam Zhengpoke_file "$TEST_IMG" "$capacity_offset" "\xff\xff\xff\xff"
692c43e43cSFam Zhengpoke_file "$TEST_IMG" "$grain_table_size_offset" "\x01\x00\x00\x00"
70fef9c191SJeff Cody{ $QEMU_IO -c "read 0 512" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
712c43e43cSFam Zheng
722fe2e290SFam Zhengecho
735dd75f9aSFam Zhengecho "=== Testing monolithicFlat creation and opening ==="
742fe2e290SFam ZhengIMGOPTS="subformat=monolithicFlat" _make_test_img 2G
75f4c129a3SFam Zheng_img_info
762fe2e290SFam Zheng
7752c8d629SFam Zhengecho
7852c8d629SFam Zhengecho "=== Testing monolithicFlat with zeroed_grain ==="
7952c8d629SFam ZhengIMGOPTS="subformat=monolithicFlat,zeroed_grain=on" _make_test_img 2G
8052c8d629SFam Zheng
81981cbf59SFam Zhengecho
82af057fe7SFam Zhengecho "=== Testing big twoGbMaxExtentFlat ==="
83af057fe7SFam ZhengIMGOPTS="subformat=twoGbMaxExtentFlat" _make_test_img 1000G
84af057fe7SFam Zheng$QEMU_IMG info $TEST_IMG | _filter_testdir | sed -e 's/cid: [0-9]*/cid: XXXXXXXX/'
85af057fe7SFam Zheng
86af057fe7SFam Zhengecho
87b47053bdSFam Zhengecho "=== Testing malformed VMFS extent description line ==="
88b47053bdSFam Zhengcat >"$TEST_IMG" <<EOF
89b47053bdSFam Zheng# Disk DescriptorFile
90b47053bdSFam Zhengversion=1
91b47053bdSFam ZhengCID=58ab4847
92b47053bdSFam ZhengparentCID=ffffffff
93b47053bdSFam ZhengcreateType="vmfs"
94b47053bdSFam Zheng
95b47053bdSFam Zheng# Extent description
96b47053bdSFam ZhengRW 12582912 VMFS "dummy.vmdk" 1
97b47053bdSFam ZhengEOF
98b47053bdSFam Zheng_img_info
99b47053bdSFam Zheng
100b47053bdSFam Zhengecho
10134ceed81SFam Zhengecho "=== Testing truncated sparse ==="
10234ceed81SFam ZhengIMGOPTS="subformat=monolithicSparse" _make_test_img 100G
10334ceed81SFam Zhengtruncate -s 10M $TEST_IMG
10434ceed81SFam Zheng_img_info
10534ceed81SFam Zheng
10634ceed81SFam Zhengecho
107981cbf59SFam Zhengecho "=== Testing version 3 ==="
108981cbf59SFam Zheng_use_sample_img iotest-version3.vmdk.bz2
109981cbf59SFam Zheng_img_info
110981cbf59SFam Zheng
111585ea0c8SFam Zhengecho
112585ea0c8SFam Zhengecho "=== Testing 4TB monolithicFlat creation and IO ==="
113585ea0c8SFam ZhengIMGOPTS="subformat=monolithicFlat" _make_test_img 4T
114585ea0c8SFam Zheng_img_info
115585ea0c8SFam Zheng$QEMU_IO -c "write -P 0xa 900G 512" "$TEST_IMG" | _filter_qemu_io
116585ea0c8SFam Zheng$QEMU_IO -c "read -v 900G 1024" "$TEST_IMG" | _filter_qemu_io
117585ea0c8SFam Zheng
118ca6cbb65SFam Zheng# success, all done
119ca6cbb65SFam Zhengecho "*** done"
120ca6cbb65SFam Zhengrm -f $seq.full
121ca6cbb65SFam Zhengstatus=0
122