virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event
[qemu/kevin.git] / tests / qemu-iotests / 049
blobed12fa49d7f5dfeb253d095a301eb56a280fa7b3
1 #!/usr/bin/env bash
2 # group: rw auto
4 # Check qemu-img option parsing
6 # Copyright (C) 2013 Red Hat, Inc.
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.
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.
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/>.
22 # creator
23 owner=kwolf@redhat.com
25 seq=`basename $0`
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
30 _cleanup()
32 _cleanup_test_img
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
40 _supported_fmt qcow2
41 _supported_proto file
43 filter_test_dir()
45 sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
46 -e "s#$TEST_DIR#TEST_DIR#g"
49 test_qemu_img()
51 echo qemu-img "$@" | filter_test_dir
52 $QEMU_IMG "$@" 2>&1 | filter_test_dir
53 echo
56 echo "=== Check correct interpretation of suffixes for image size ==="
57 echo
58 sizes="1024 1024b 1k 1K 1M 1G 1T "
59 sizes+="1024.0 1024.0b 1.5k 1.5K 1.5M 1.5G 1.5T"
61 echo "== 1. Traditional size parameter =="
62 echo
63 for s in $sizes; do
64 test_qemu_img create -f $IMGFMT "$TEST_IMG" $s
65 done
67 echo "== 2. Specifying size via -o =="
68 echo
69 for s in $sizes; do
70 test_qemu_img create -f $IMGFMT -o size=$s "$TEST_IMG"
71 done
73 echo "== 3. Invalid sizes =="
74 echo
75 sizes="-1024 -1k 1kilobyte foobar"
77 for s in $sizes; do
78 test_qemu_img create -f $IMGFMT "$TEST_IMG" -- $s
79 test_qemu_img create -f $IMGFMT -o size=$s "$TEST_IMG"
80 done
82 echo "== 4. Specify size twice (-o and traditional parameter) =="
83 echo
85 test_qemu_img create -f $IMGFMT -o size=10M "$TEST_IMG" 20M
87 echo "== Check correct interpretation of suffixes for cluster size =="
88 echo
89 sizes="1024 1024b 1k 1K 1M "
90 sizes+="1024.0 1024.0b 0.5k 0.5K 0.5M"
92 for s in $sizes; do
93 test_qemu_img create -f $IMGFMT -o cluster_size=$s "$TEST_IMG" 64M
94 done
96 echo "== Check compat level option =="
97 echo
98 test_qemu_img create -f $IMGFMT -o compat=0.10 "$TEST_IMG" 64M
99 test_qemu_img create -f $IMGFMT -o compat=1.1 "$TEST_IMG" 64M
101 test_qemu_img create -f $IMGFMT -o compat=0.42 "$TEST_IMG" 64M
102 test_qemu_img create -f $IMGFMT -o compat=foobar "$TEST_IMG" 64M
104 echo "== Check preallocation option =="
105 echo
106 test_qemu_img create -f $IMGFMT -o preallocation=off "$TEST_IMG" 64M
107 test_qemu_img create -f $IMGFMT -o preallocation=metadata "$TEST_IMG" 64M
108 test_qemu_img create -f $IMGFMT -o preallocation=1234 "$TEST_IMG" 64M
110 echo "== Check encryption option =="
111 echo
112 test_qemu_img create -f $IMGFMT -o encryption=off "$TEST_IMG" 64M
113 test_qemu_img create -f $IMGFMT --object secret,id=sec0,data=123456 -o encryption=on,encrypt.key-secret=sec0 "$TEST_IMG" 64M
115 echo "== Check lazy_refcounts option (only with v3) =="
116 echo
117 test_qemu_img create -f $IMGFMT -o compat=1.1,lazy_refcounts=off "$TEST_IMG" 64M
118 test_qemu_img create -f $IMGFMT -o compat=1.1,lazy_refcounts=on "$TEST_IMG" 64M
120 test_qemu_img create -f $IMGFMT -o compat=0.10,lazy_refcounts=off "$TEST_IMG" 64M
121 test_qemu_img create -f $IMGFMT -o compat=0.10,lazy_refcounts=on "$TEST_IMG" 64M
123 echo "== Expect error when backing file name is empty string =="
124 echo
125 test_qemu_img create -f $IMGFMT -b '' $TEST_IMG 1M
127 # success, all done
128 echo "*** done"
129 rm -f $seq.full
130 status=0