xics/spapr: Detect old KVM XICS on POWER9 hosts
[qemu/ar7.git] / tests / qemu-iotests / 183
blobfbe5a99bebd512655abe9c582bc8a31208800611
1 #!/usr/bin/env bash
3 # Test old-style block migration (migrate -b)
5 # Copyright (C) 2017 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 # creator
22 owner=kwolf@redhat.com
24 seq=`basename $0`
25 echo "QA output created by $seq"
27 status=1 # failure is the default!
29 MIG_SOCKET="${TEST_DIR}/migrate"
31 _cleanup()
33 rm -f "${MIG_SOCKET}"
34 rm -f "${TEST_IMG}.dest"
35 _cleanup_test_img
36 _cleanup_qemu
38 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
41 . ./common.rc
42 . ./common.filter
43 . ./common.qemu
45 _supported_fmt qcow2 raw qed quorum
46 _supported_proto file
48 size=64M
49 _make_test_img $size
50 TEST_IMG="${TEST_IMG}.dest" _make_test_img $size
52 echo
53 echo === Starting VMs ===
54 echo
56 qemu_comm_method="qmp"
58 _launch_qemu \
59 -drive file="${TEST_IMG}",cache=$CACHEMODE,driver=$IMGFMT,id=disk
60 src=$QEMU_HANDLE
61 _send_qemu_cmd $src "{ 'execute': 'qmp_capabilities' }" 'return'
63 _launch_qemu \
64 -drive file="${TEST_IMG}.dest",cache=$CACHEMODE,driver=$IMGFMT,id=disk \
65 -incoming "unix:${MIG_SOCKET}"
66 dest=$QEMU_HANDLE
67 _send_qemu_cmd $dest "{ 'execute': 'qmp_capabilities' }" 'return'
69 echo
70 echo === Write something on the source ===
71 echo
73 _send_qemu_cmd $src \
74 "{ 'execute': 'human-monitor-command',
75 'arguments': { 'command-line':
76 'qemu-io disk \"write -P 0x55 0 64k\"' } }" \
77 'return'
78 _send_qemu_cmd $src \
79 "{ 'execute': 'human-monitor-command',
80 'arguments': { 'command-line':
81 'qemu-io disk \"read -P 0x55 0 64k\"' } }" \
82 'return'
84 echo
85 echo === Do block migration to destination ===
86 echo
88 reply="$(_send_qemu_cmd $src \
89 "{ 'execute': 'migrate',
90 'arguments': { 'uri': 'unix:${MIG_SOCKET}', 'blk': true } }" \
91 'return\|error')"
92 echo "$reply"
93 if echo "$reply" | grep "compiled without old-style" > /dev/null; then
94 _notrun "migrate -b support not compiled in"
97 QEMU_COMM_TIMEOUT=0.1 qemu_cmd_repeat=50 silent=yes \
98 _send_qemu_cmd $src "{ 'execute': 'query-migrate' }" '"status": "completed"'
99 _send_qemu_cmd $src "{ 'execute': 'query-status' }" "return"
101 echo
102 echo === Do some I/O on the destination ===
103 echo
105 # It is important that we use the BlockBackend of the guest device here instead
106 # of the node name, which would create a new BlockBackend and not test whether
107 # the guest has the necessary permissions to access the image now
108 silent=yes _send_qemu_cmd $dest "" "100 %"
109 _send_qemu_cmd $dest "{ 'execute': 'query-status' }" "return"
110 _send_qemu_cmd $dest \
111 "{ 'execute': 'human-monitor-command',
112 'arguments': { 'command-line':
113 'qemu-io disk \"read -P 0x55 0 64k\"' } }" \
114 'return'
115 _send_qemu_cmd $dest \
116 "{ 'execute': 'human-monitor-command',
117 'arguments': { 'command-line':
118 'qemu-io disk \"write -P 0x66 1M 64k\"' } }" \
119 'return'
121 echo
122 echo === Shut down and check image ===
123 echo
125 _send_qemu_cmd $src '{"execute":"quit"}' 'return'
126 _send_qemu_cmd $dest '{"execute":"quit"}' 'return'
127 wait=1 _cleanup_qemu
129 _check_test_img
130 TEST_IMG="${TEST_IMG}.dest" _check_test_img
132 $QEMU_IO -c 'write -P 0x66 1M 64k' "$TEST_IMG" | _filter_qemu_io
133 $QEMU_IMG compare "$TEST_IMG.dest" "$TEST_IMG"
135 # success, all done
136 echo "*** done"
137 rm -f $seq.full
138 status=0