3 # Test postcopy live migration with shared storage
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/>.
22 owner
=kwolf@redhat.com
25 echo "QA output created by $seq"
27 status
=1 # failure is the default!
29 MIG_SOCKET
="${SOCK_DIR}/migrate"
37 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
44 _supported_fmt generic
45 # Formats that do not support live migration
46 _unsupported_fmt qcow vdi vhdx vmdk vpc vvfat parallels
47 _supported_proto generic
54 echo === Starting VMs
===
57 qemu_comm_method
="monitor"
59 if [ "$IMGOPTSSYNTAX" = "true" ]; then
61 -drive "${TEST_IMG}",cache
=${CACHEMODE},aio
=$AIOMODE,id
=disk
64 -drive file="${TEST_IMG}",cache
=${CACHEMODE},aio
=$AIOMODE,driver
=$IMGFMT,id
=disk
68 if [ "$IMGOPTSSYNTAX" = "true" ]; then
70 -drive "${TEST_IMG}",cache
=${CACHEMODE},aio
=$AIOMODE,id
=disk \
71 -incoming "unix:${MIG_SOCKET}"
74 -drive file="${TEST_IMG}",cache
=${CACHEMODE},aio
=$AIOMODE,driver
=$IMGFMT,id
=disk \
75 -incoming "unix:${MIG_SOCKET}"
80 echo === Write something on the
source ===
84 _send_qemu_cmd
$src 'qemu-io disk "write -P 0x55 0 64k"' "(qemu)"
85 _send_qemu_cmd
$src "" "ops/sec"
86 _send_qemu_cmd
$src 'qemu-io disk "read -P 0x55 0 64k"' "(qemu)"
87 _send_qemu_cmd
$src "" "ops/sec"
90 echo === Do postcopy migration to destination
===
93 # Slow down migration so much that it definitely won't finish before we can
95 # Enable postcopy-ram capability both on source and destination
97 _send_qemu_cmd
$dest 'migrate_set_capability postcopy-ram on' "(qemu)"
99 qemu_error_no_exit
=yes success_or_failure
=yes \
100 _send_qemu_cmd
$dest '' "(qemu)" "Postcopy is not supported"
101 if [ ${QEMU_STATUS[$dest]} -lt 0 ]; then
102 _send_qemu_cmd
$dest '' "(qemu)"
104 _send_qemu_cmd
$src 'quit' ""
105 _send_qemu_cmd
$dest 'quit' ""
108 _notrun
'Postcopy is not supported'
111 _send_qemu_cmd
$src 'migrate_set_speed 4k' "(qemu)"
112 _send_qemu_cmd
$src 'migrate_set_capability postcopy-ram on' "(qemu)"
113 _send_qemu_cmd
$src "migrate -d unix:${MIG_SOCKET}" "(qemu)"
114 _send_qemu_cmd
$src 'migrate_start_postcopy' "(qemu)"
116 QEMU_COMM_TIMEOUT
=1 qemu_cmd_repeat
=10 silent
=yes \
117 _send_qemu_cmd
$src "info migrate" "completed\|failed"
118 silent
=yes _send_qemu_cmd
$src "" "(qemu)"
121 echo === Do some I
/O on the destination
===
124 # It is important that we use the BlockBackend of the guest device here instead
125 # of the node name, which would create a new BlockBackend and not test whether
126 # the guest has the necessary permissions to access the image now
128 _send_qemu_cmd
$dest 'qemu-io disk "read -P 0x55 0 64k"' "(qemu)"
129 _send_qemu_cmd
$dest "" "ops/sec"
130 _send_qemu_cmd
$dest 'qemu-io disk "write -P 0x66 1M 64k"' "(qemu)"
131 _send_qemu_cmd
$dest "" "ops/sec"
134 echo === Shut down and check image
===
137 _send_qemu_cmd
$src 'quit' ""
138 _send_qemu_cmd
$dest 'quit' ""