Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' into staging
[qemu/ar7.git] / tests / qemu-iotests / 181
blobe317e6342251653e24ff1e771e1ffb11dda84a28
1 #!/usr/bin/env bash
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/>.
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 _cleanup_test_img
35 _cleanup_qemu
37 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
40 . ./common.rc
41 . ./common.filter
42 . ./common.qemu
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
48 _supported_os Linux
50 size=64M
51 _make_test_img $size
53 echo
54 echo === Starting VMs ===
55 echo
57 qemu_comm_method="monitor"
59 if [ "$IMGOPTSSYNTAX" = "true" ]; then
60 _launch_qemu \
61 -drive "${TEST_IMG}",cache=${CACHEMODE},id=disk
62 else
63 _launch_qemu \
64 -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk
66 src=$QEMU_HANDLE
68 if [ "$IMGOPTSSYNTAX" = "true" ]; then
69 _launch_qemu \
70 -drive "${TEST_IMG}",cache=${CACHEMODE},id=disk \
71 -incoming "unix:${MIG_SOCKET}"
72 else
73 _launch_qemu \
74 -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk \
75 -incoming "unix:${MIG_SOCKET}"
77 dest=$QEMU_HANDLE
79 echo
80 echo === Write something on the source ===
81 echo
83 silent=
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"
89 echo
90 echo === Do postcopy migration to destination ===
91 echo
93 # Slow down migration so much that it definitely won't finish before we can
94 # switch to postcopy
95 # Enable postcopy-ram capability both on source and destination
96 silent=yes
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' ""
106 wait=1 _cleanup_qemu
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)"
120 echo
121 echo === Do some I/O on the destination ===
122 echo
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
127 silent=
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"
133 echo
134 echo === Shut down and check image ===
135 echo
137 _send_qemu_cmd $src 'quit' ""
138 _send_qemu_cmd $dest 'quit' ""
139 wait=1 _cleanup_qemu
141 _check_test_img
143 # success, all done
144 echo "*** done"
145 rm -f $seq.full
146 status=0