2 # group: rw migration quick
4 # Test old-style block migration (migrate -b)
6 # Copyright (C) 2017 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/>.
23 owner=kwolf@redhat.com
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
30 MIG_SOCKET="${SOCK_DIR}/migrate"
35 _rm_test_img "${TEST_IMG}.dest"
39 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
46 _supported_os Linux FreeBSD NetBSD
47 _supported_fmt qcow2 raw qed quorum
48 _supported_proto file fuse
52 TEST_IMG="${TEST_IMG}.dest" _make_test_img $size
55 echo === Starting VMs ===
58 qemu_comm_method="qmp"
61 -drive file="${TEST_IMG}",cache=$CACHEMODE,aio=$AIOMODE,driver=$IMGFMT,id=disk
63 _send_qemu_cmd $src "{ 'execute': 'qmp_capabilities' }" 'return'
66 -drive file="${TEST_IMG}.dest",cache=$CACHEMODE,aio=$AIOMODE,driver=$IMGFMT,id=disk \
67 -incoming "unix:${MIG_SOCKET}"
69 _send_qemu_cmd $dest "{ 'execute': 'qmp_capabilities' }" 'return'
72 echo === Write something on the source ===
76 "{ 'execute': 'human-monitor-command',
77 'arguments': { 'command-line':
78 'qemu-io disk \"write -P 0x55 0 64k\"' } }" \
81 "{ 'execute': 'human-monitor-command',
82 'arguments': { 'command-line':
83 'qemu-io disk \"read -P 0x55 0 64k\"' } }" \
87 echo === Do block migration to destination ===
90 reply="$(_send_qemu_cmd $src \
91 "{ 'execute': 'migrate',
92 'arguments': { 'uri': 'unix:${MIG_SOCKET}', 'blk': true } }" \
93 'return\|error' | _filter_migration_block_deprecated)"
95 if echo "$reply" | grep "compiled without old-style" > /dev/null; then
96 _notrun "migrate -b support not compiled in"
99 timeout_comm=$QEMU_COMM_TIMEOUT
100 if [ "${VALGRIND_QEMU}" == "y" ]; then
103 QEMU_COMM_TIMEOUT=0.1
105 qemu_cmd_repeat=50 silent=yes \
106 _send_qemu_cmd $src "{ 'execute': 'query-migrate' }" '"status": "completed"'
107 QEMU_COMM_TIMEOUT=$timeout_comm
108 _send_qemu_cmd $src "{ 'execute': 'query-status' }" "return"
111 echo === Do some I/O on the destination ===
114 # It is important that we use the BlockBackend of the guest device here instead
115 # of the node name, which would create a new BlockBackend and not test whether
116 # the guest has the necessary permissions to access the image now
117 silent=yes _send_qemu_cmd $dest "" "100 %"
118 _send_qemu_cmd $dest "{ 'execute': 'query-status' }" "return"
119 _send_qemu_cmd $dest \
120 "{ 'execute': 'human-monitor-command',
121 'arguments': { 'command-line':
122 'qemu-io disk \"read -P 0x55 0 64k\"' } }" \
124 _send_qemu_cmd $dest \
125 "{ 'execute': 'human-monitor-command',
126 'arguments': { 'command-line':
127 'qemu-io disk \"write -P 0x66 1M 64k\"' } }" \
131 echo === Shut down and check image ===
134 _send_qemu_cmd $src '{"execute":"quit"}' 'return'
135 _send_qemu_cmd $dest '{"execute":"quit"}' 'return'
139 TEST_IMG="${TEST_IMG}.dest" _check_test_img
141 $QEMU_IO -c 'write -P 0x66 1M 64k' "$TEST_IMG" | _filter_qemu_io
142 $QEMU_IMG compare "$TEST_IMG.dest" "$TEST_IMG"