tests/avocado/machine_m68k_nextcube: Fix the download URL for the ROM image
[qemu/ar7.git] / tests / qemu-iotests / 156
bloba9540bd80d2fd901810c611e524467f835f6b0ff
1 #!/usr/bin/env bash
2 # group: rw auto quick
4 # Tests oVirt-like storage migration:
5 # - Create snapshot
6 # - Create target image with (not yet existing) target backing chain
7 # (i.e. just write the name of a soon-to-be-copied-over backing file into it)
8 # - drive-mirror the snapshot to the target with mode=existing and sync=top
9 # - In the meantime, copy the original source files to the destination via
10 # conventional means (i.e. outside of qemu)
11 # - Complete the drive-mirror job
12 # - Delete all source images
14 # Copyright (C) 2016 Red Hat, Inc.
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program. If not, see <http://www.gnu.org/licenses/>.
30 # creator
31 owner=hreitz@redhat.com
33 seq="$(basename $0)"
34 echo "QA output created by $seq"
36 status=1 # failure is the default!
38 _cleanup()
40 _cleanup_qemu
41 for img in "$TEST_IMG"{,.target}{,.backing,.overlay}; do
42 _rm_test_img "$img"
43 done
45 trap "_cleanup; exit \$status" 0 1 2 3 15
47 # get standard environment, filters and checks
48 . ./common.rc
49 . ./common.filter
50 . ./common.qemu
52 _supported_fmt qcow2 qed
53 _supported_proto generic
54 # Copying files around with cp does not work with external data files
55 _unsupported_imgopts data_file
57 # Create source disk
58 TEST_IMG="$TEST_IMG.backing" _make_test_img 1M
59 _make_test_img -b "$TEST_IMG.backing" -F $IMGFMT 1M
61 $QEMU_IO -c 'write -P 1 0 256k' "$TEST_IMG.backing" | _filter_qemu_io
62 $QEMU_IO -c 'write -P 2 64k 192k' "$TEST_IMG" | _filter_qemu_io
64 _launch_qemu -drive if=none,id=source,file="$TEST_IMG"
66 _send_qemu_cmd $QEMU_HANDLE \
67 "{ 'execute': 'qmp_capabilities' }" \
68 'return'
70 # Create snapshot
71 TEST_IMG="$TEST_IMG.overlay" _make_test_img -u -b "$TEST_IMG" -F $IMGFMT 1M
72 _send_qemu_cmd $QEMU_HANDLE \
73 "{ 'execute': 'blockdev-snapshot-sync',
74 'arguments': { 'device': 'source',
75 'snapshot-file': '$TEST_IMG.overlay',
76 'format': '$IMGFMT',
77 'mode': 'existing' } }" \
78 'return'
80 # Write something to the snapshot
81 _send_qemu_cmd $QEMU_HANDLE \
82 "{ 'execute': 'human-monitor-command',
83 'arguments': { 'command-line':
84 'qemu-io source \"write -P 3 128k 128k\"' } }" \
85 'return'
87 # Create target image
88 TEST_IMG="$TEST_IMG.target.overlay" _make_test_img -u -b "$TEST_IMG.target" \
89 -F $IMGFMT 1M
91 # Mirror snapshot
92 _send_qemu_cmd $QEMU_HANDLE \
93 "{ 'execute': 'drive-mirror',
94 'arguments': { 'device': 'source',
95 'target': '$TEST_IMG.target.overlay',
96 'mode': 'existing',
97 'sync': 'top' } }" \
98 'return'
100 # Wait for convergence
101 _send_qemu_cmd $QEMU_HANDLE \
102 '' \
103 'BLOCK_JOB_READY'
105 # Write some more
106 _send_qemu_cmd $QEMU_HANDLE \
107 "{ 'execute': 'human-monitor-command',
108 'arguments': { 'command-line':
109 'qemu-io source \"write -P 4 192k 64k\"' } }" \
110 'return'
112 # Copy source backing chain to the target before completing the job
113 cp "$TEST_IMG.backing" "$TEST_IMG.target.backing"
114 cp "$TEST_IMG" "$TEST_IMG.target"
115 $QEMU_IMG rebase -u -b "$TEST_IMG.target.backing" -F $IMGFMT "$TEST_IMG.target"
117 # Complete block job
118 _send_qemu_cmd $QEMU_HANDLE \
119 "{ 'execute': 'block-job-complete',
120 'arguments': { 'device': 'source' } }" \
123 _send_qemu_cmd $QEMU_HANDLE \
124 '' \
125 '"status": "null"'
127 # Remove the source images
128 for img in "$TEST_IMG{,.backing,.overlay}"; do
129 _rm_test_img "$img"
130 done
132 echo
134 # Check online disk contents
135 _send_qemu_cmd $QEMU_HANDLE \
136 "{ 'execute': 'human-monitor-command',
137 'arguments': { 'command-line':
138 'qemu-io source \"read -P 1 0k 64k\"' } }" \
139 'return'
141 _send_qemu_cmd $QEMU_HANDLE \
142 "{ 'execute': 'human-monitor-command',
143 'arguments': { 'command-line':
144 'qemu-io source \"read -P 2 64k 64k\"' } }" \
145 'return'
147 _send_qemu_cmd $QEMU_HANDLE \
148 "{ 'execute': 'human-monitor-command',
149 'arguments': { 'command-line':
150 'qemu-io source \"read -P 3 128k 64k\"' } }" \
151 'return'
153 _send_qemu_cmd $QEMU_HANDLE \
154 "{ 'execute': 'human-monitor-command',
155 'arguments': { 'command-line':
156 'qemu-io source \"read -P 4 192k 64k\"' } }" \
157 'return'
159 echo
161 _send_qemu_cmd $QEMU_HANDLE \
162 "{ 'execute': 'quit' }" \
163 'return'
165 wait=1 _cleanup_qemu
167 echo
169 # Check offline disk contents
170 $QEMU_IO -c 'read -P 1 0k 64k' \
171 -c 'read -P 2 64k 64k' \
172 -c 'read -P 3 128k 64k' \
173 -c 'read -P 4 192k 64k' \
174 "$TEST_IMG.target.overlay" | _filter_qemu_io
176 echo
178 # success, all done
179 echo '*** done'
180 rm -f $seq.full
181 status=0