sm501: Ignore no-op blits
[qemu/ar7.git] / tests / qemu-iotests / 291
blob28e4fb9b4d1557e57561f8864fd40697f2341dea
1 #!/usr/bin/env bash
3 # Test qemu-img bitmap handling
5 # Copyright (C) 2018-2020 Red Hat, Inc.
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.
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.
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/>.
21 seq="$(basename $0)"
22 echo "QA output created by $seq"
24 status=1 # failure is the default!
26 _cleanup()
28 _cleanup_test_img
29 nbd_server_stop
31 trap "_cleanup; exit \$status" 0 1 2 3 15
33 # get standard environment, filters and checks
34 . ./common.rc
35 . ./common.filter
36 . ./common.nbd
38 _supported_fmt qcow2
39 _supported_proto file
40 _supported_os Linux
41 _require_command QEMU_NBD
42 # compat=0.10 does not support bitmaps
43 _unsupported_imgopts 'compat=0.10'
45 echo
46 echo "=== Initial image setup ==="
47 echo
49 # Create backing image with one bitmap
50 TEST_IMG="$TEST_IMG.base" _make_test_img 10M
51 $QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG.base" b0
52 $QEMU_IO -c 'w 3M 1M' -f $IMGFMT "$TEST_IMG.base" | _filter_qemu_io
54 # Create initial image and populate two bitmaps: one active, one inactive.
55 ORIG_IMG=$TEST_IMG
56 TEST_IMG=$TEST_IMG.orig
57 _make_test_img -b "$ORIG_IMG.base" -F $IMGFMT 10M
58 $QEMU_IO -c 'w 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
59 $QEMU_IMG bitmap --add -g 512k -f $IMGFMT "$TEST_IMG" b1
60 $QEMU_IMG bitmap --add --disable -f $IMGFMT "$TEST_IMG" b2
61 $QEMU_IO -c 'w 3M 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
62 $QEMU_IMG bitmap --clear -f $IMGFMT "$TEST_IMG" b1
63 $QEMU_IO -c 'w 1M 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
64 $QEMU_IMG bitmap --disable -f $IMGFMT "$TEST_IMG" b1
65 $QEMU_IMG bitmap --enable -f $IMGFMT "$TEST_IMG" b2
66 $QEMU_IO -c 'w 2M 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
67 echo "Check resulting qcow2 header extensions:"
68 $PYTHON qcow2.py "$TEST_IMG" dump-header-exts
70 echo
71 echo "=== Bitmap preservation not possible to non-qcow2 ==="
72 echo
74 TEST_IMG=$ORIG_IMG
75 $QEMU_IMG convert --bitmaps -O raw "$TEST_IMG.orig" "$TEST_IMG" &&
76 echo "unexpected success"
78 echo
79 echo "=== Convert with bitmap preservation ==="
80 echo
82 # Only bitmaps from the active layer are copied
83 $QEMU_IMG convert --bitmaps -O qcow2 "$TEST_IMG.orig" "$TEST_IMG"
84 _img_info --format-specific
85 # But we can also merge in bitmaps from other layers. This test is a bit
86 # contrived to cover more code paths, in reality, you could merge directly
87 # into b0 without going through tmp
88 $QEMU_IMG bitmap --add --disable -f $IMGFMT "$TEST_IMG" b0
89 $QEMU_IMG bitmap --add --merge b0 -b "$TEST_IMG.base" -F $IMGFMT \
90 -f $IMGFMT "$TEST_IMG" tmp
91 $QEMU_IMG bitmap --merge tmp -f $IMGFMT "$TEST_IMG" b0
92 $QEMU_IMG bitmap --remove --image-opts \
93 driver=$IMGFMT,file.driver=file,file.filename="$TEST_IMG" tmp
94 _img_info --format-specific
95 echo "Check resulting qcow2 header extensions:"
96 $PYTHON qcow2.py "$TEST_IMG" dump-header-exts
98 echo
99 echo "=== Check bitmap contents ==="
100 echo
102 # x-dirty-bitmap is a hack for reading bitmaps; it abuses block status to
103 # report "data":false for portions of the bitmap which are set
104 IMG="driver=nbd,server.type=unix,server.path=$nbd_unix_socket"
105 nbd_server_start_unix_socket -r -f qcow2 -B b0 "$TEST_IMG"
106 $QEMU_IMG map --output=json --image-opts \
107 "$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b0" | _filter_qemu_img_map
108 nbd_server_start_unix_socket -r -f qcow2 -B b1 "$TEST_IMG"
109 $QEMU_IMG map --output=json --image-opts \
110 "$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b1" | _filter_qemu_img_map
111 nbd_server_start_unix_socket -r -f qcow2 -B b2 "$TEST_IMG"
112 $QEMU_IMG map --output=json --image-opts \
113 "$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b2" | _filter_qemu_img_map
115 # success, all done
116 echo '*** done'
117 rm -f $seq.full
118 status=0