spapr_pci: fix MSI/MSIX selection
[qemu.git] / tests / qemu-iotests / 156
blobe75dc4d7433daa7df840b8ad538bc8d7fac7f1d7
1 #!/bin/bash
3 # Tests oVirt-like storage migration:
4 # - Create snapshot
5 # - Create target image with (not yet existing) target backing chain
6 # (i.e. just write the name of a soon-to-be-copied-over backing file into it)
7 # - drive-mirror the snapshot to the target with mode=existing and sync=top
8 # - In the meantime, copy the original source files to the destination via
9 # conventional means (i.e. outside of qemu)
10 # - Complete the drive-mirror job
11 # - Delete all source images
13 # Copyright (C) 2016 Red Hat, Inc.
15 # This program is free software; you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation; either version 2 of the License, or
18 # (at your option) any later version.
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program. If not, see <http://www.gnu.org/licenses/>.
29 # creator
30 owner=mreitz@redhat.com
32 seq="$(basename $0)"
33 echo "QA output created by $seq"
35 here="$PWD"
36 status=1 # failure is the default!
38 _cleanup()
40 _cleanup_qemu
41 rm -f "$TEST_IMG"{,.target}{,.backing,.overlay}
43 trap "_cleanup; exit \$status" 0 1 2 3 15
45 # get standard environment, filters and checks
46 . ./common.rc
47 . ./common.filter
48 . ./common.qemu
50 _supported_fmt qcow2 qed
51 _supported_proto generic
52 _unsupported_proto vxhs
53 _supported_os Linux
55 # Create source disk
56 TEST_IMG="$TEST_IMG.backing" _make_test_img 1M
57 _make_test_img -b "$TEST_IMG.backing" 1M
59 $QEMU_IO -c 'write -P 1 0 256k' "$TEST_IMG.backing" | _filter_qemu_io
60 $QEMU_IO -c 'write -P 2 64k 192k' "$TEST_IMG" | _filter_qemu_io
62 _launch_qemu -drive if=none,id=source,file="$TEST_IMG"
64 _send_qemu_cmd $QEMU_HANDLE \
65 "{ 'execute': 'qmp_capabilities' }" \
66 'return'
68 # Create snapshot
69 TEST_IMG="$TEST_IMG.overlay" _make_test_img -u -b "$TEST_IMG" 1M
70 _send_qemu_cmd $QEMU_HANDLE \
71 "{ 'execute': 'blockdev-snapshot-sync',
72 'arguments': { 'device': 'source',
73 'snapshot-file': '$TEST_IMG.overlay',
74 'format': '$IMGFMT',
75 'mode': 'existing' } }" \
76 'return'
78 # Write something to the snapshot
79 _send_qemu_cmd $QEMU_HANDLE \
80 "{ 'execute': 'human-monitor-command',
81 'arguments': { 'command-line':
82 'qemu-io source \"write -P 3 128k 128k\"' } }" \
83 'return'
85 # Create target image
86 TEST_IMG="$TEST_IMG.target.overlay" _make_test_img -u -b "$TEST_IMG.target" 1M
88 # Mirror snapshot
89 _send_qemu_cmd $QEMU_HANDLE \
90 "{ 'execute': 'drive-mirror',
91 'arguments': { 'device': 'source',
92 'target': '$TEST_IMG.target.overlay',
93 'mode': 'existing',
94 'sync': 'top' } }" \
95 'return'
97 # Wait for convergence
98 _send_qemu_cmd $QEMU_HANDLE \
99 '' \
100 'BLOCK_JOB_READY'
102 # Write some more
103 _send_qemu_cmd $QEMU_HANDLE \
104 "{ 'execute': 'human-monitor-command',
105 'arguments': { 'command-line':
106 'qemu-io source \"write -P 4 192k 64k\"' } }" \
107 'return'
109 # Copy source backing chain to the target before completing the job
110 cp "$TEST_IMG.backing" "$TEST_IMG.target.backing"
111 cp "$TEST_IMG" "$TEST_IMG.target"
112 $QEMU_IMG rebase -u -b "$TEST_IMG.target.backing" "$TEST_IMG.target"
114 # Complete block job
115 _send_qemu_cmd $QEMU_HANDLE \
116 "{ 'execute': 'block-job-complete',
117 'arguments': { 'device': 'source' } }" \
120 _send_qemu_cmd $QEMU_HANDLE \
121 '' \
122 'BLOCK_JOB_COMPLETED'
124 # Remove the source images
125 rm -f "$TEST_IMG{,.backing,.overlay}"
127 echo
129 # Check online disk contents
130 _send_qemu_cmd $QEMU_HANDLE \
131 "{ 'execute': 'human-monitor-command',
132 'arguments': { 'command-line':
133 'qemu-io source \"read -P 1 0k 64k\"' } }" \
134 'return'
136 _send_qemu_cmd $QEMU_HANDLE \
137 "{ 'execute': 'human-monitor-command',
138 'arguments': { 'command-line':
139 'qemu-io source \"read -P 2 64k 64k\"' } }" \
140 'return'
142 _send_qemu_cmd $QEMU_HANDLE \
143 "{ 'execute': 'human-monitor-command',
144 'arguments': { 'command-line':
145 'qemu-io source \"read -P 3 128k 64k\"' } }" \
146 'return'
148 _send_qemu_cmd $QEMU_HANDLE \
149 "{ 'execute': 'human-monitor-command',
150 'arguments': { 'command-line':
151 'qemu-io source \"read -P 4 192k 64k\"' } }" \
152 'return'
154 echo
156 _send_qemu_cmd $QEMU_HANDLE \
157 "{ 'execute': 'quit' }" \
158 'return'
160 wait=1 _cleanup_qemu
162 echo
164 # Check offline disk contents
165 $QEMU_IO -c 'read -P 1 0k 64k' \
166 -c 'read -P 2 64k 64k' \
167 -c 'read -P 3 128k 64k' \
168 -c 'read -P 4 192k 64k' \
169 "$TEST_IMG.target.overlay" | _filter_qemu_io
171 echo
173 # success, all done
174 echo '*** done'
175 rm -f $seq.full
176 status=0