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"
28 status
=1 # failure is the default!
30 MIG_SOCKET
="${TEST_DIR}/migrate"
38 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
45 _supported_fmt generic
46 # Formats that do not support live migration
47 _unsupported_fmt qcow vdi vhdx vmdk vpc vvfat parallels
48 _supported_proto generic
55 echo === Starting VMs
===
58 qemu_comm_method
="monitor"
60 if [ "$IMGOPTSSYNTAX" = "true" ]; then
62 -drive "${TEST_IMG}",cache
=${CACHEMODE},id
=disk
65 -drive file="${TEST_IMG}",cache
=${CACHEMODE},driver
=$IMGFMT,id
=disk
69 if [ "$IMGOPTSSYNTAX" = "true" ]; then
71 -drive "${TEST_IMG}",cache
=${CACHEMODE},id
=disk \
72 -incoming "unix:${MIG_SOCKET}"
75 -drive file="${TEST_IMG}",cache
=${CACHEMODE},driver
=$IMGFMT,id
=disk \
76 -incoming "unix:${MIG_SOCKET}"
81 echo === Write something on the
source ===
85 _send_qemu_cmd
$src 'qemu-io disk "write -P 0x55 0 64k"' "(qemu)"
86 _send_qemu_cmd
$src "" "ops/sec"
87 _send_qemu_cmd
$src 'qemu-io disk "read -P 0x55 0 64k"' "(qemu)"
88 _send_qemu_cmd
$src "" "ops/sec"
91 echo === Do postcopy migration to destination
===
94 # Slow down migration so much that it definitely won't finish before we can
96 # Enable postcopy-ram capability both on source and destination
98 _send_qemu_cmd
$dest 'migrate_set_capability postcopy-ram on' "(qemu)"
100 qemu_error_no_exit
=yes success_or_failure
=yes \
101 _send_qemu_cmd
$dest '' "(qemu)" "Postcopy is not supported"
102 if [ ${QEMU_STATUS[$dest]} -lt 0 ]; then
103 _send_qemu_cmd
$dest '' "(qemu)"
105 _send_qemu_cmd
$src 'quit' ""
106 _send_qemu_cmd
$dest 'quit' ""
109 _notrun
'Postcopy is not supported'
112 _send_qemu_cmd
$src 'migrate_set_speed 4k' "(qemu)"
113 _send_qemu_cmd
$src 'migrate_set_capability postcopy-ram on' "(qemu)"
114 _send_qemu_cmd
$src "migrate -d unix:${MIG_SOCKET}" "(qemu)"
115 _send_qemu_cmd
$src 'migrate_start_postcopy' "(qemu)"
117 QEMU_COMM_TIMEOUT
=1 qemu_cmd_repeat
=10 silent
=yes \
118 _send_qemu_cmd
$src "info migrate" "completed\|failed"
119 silent
=yes _send_qemu_cmd
$src "" "(qemu)"
122 echo === Do some I
/O on the destination
===
125 # It is important that we use the BlockBackend of the guest device here instead
126 # of the node name, which would create a new BlockBackend and not test whether
127 # the guest has the necessary permissions to access the image now
129 _send_qemu_cmd
$dest 'qemu-io disk "read -P 0x55 0 64k"' "(qemu)"
130 _send_qemu_cmd
$dest "" "ops/sec"
131 _send_qemu_cmd
$dest 'qemu-io disk "write -P 0x66 1M 64k"' "(qemu)"
132 _send_qemu_cmd
$dest "" "ops/sec"
135 echo === Shut down and check image
===
138 _send_qemu_cmd
$src 'quit' ""
139 _send_qemu_cmd
$dest 'quit' ""