]> Git Repo - qemu.git/blob - tests/qemu-iotests/181
iotests: ignore import warnings from pylint
[qemu.git] / tests / qemu-iotests / 181
1 #!/usr/bin/env bash
2 #
3 # Test postcopy live migration with shared storage
4 #
5 # Copyright (C) 2017 Red Hat, Inc.
6 #
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.
11 #
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.
16 #
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/>.
19 #
20
21 # creator
22 [email protected]
23
24 seq=`basename $0`
25 echo "QA output created by $seq"
26
27 status=1        # failure is the default!
28
29 MIG_SOCKET="${SOCK_DIR}/migrate"
30
31 _cleanup()
32 {
33     rm -f "${MIG_SOCKET}"
34         _cleanup_test_img
35     _cleanup_qemu
36 }
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 # get standard environment, filters and checks
40 . ./common.rc
41 . ./common.filter
42 . ./common.qemu
43
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
49
50 size=64M
51 _make_test_img $size
52
53 echo
54 echo === Starting VMs ===
55 echo
56
57 qemu_comm_method="monitor"
58
59 if [ "$IMGOPTSSYNTAX" = "true" ]; then
60     _launch_qemu \
61         -drive "${TEST_IMG}",cache=${CACHEMODE},aio=$AIOMODE,id=disk
62 else
63     _launch_qemu \
64         -drive file="${TEST_IMG}",cache=${CACHEMODE},aio=$AIOMODE,driver=$IMGFMT,id=disk
65 fi
66 src=$QEMU_HANDLE
67
68 if [ "$IMGOPTSSYNTAX" = "true" ]; then
69     _launch_qemu \
70         -drive "${TEST_IMG}",cache=${CACHEMODE},aio=$AIOMODE,id=disk \
71         -incoming "unix:${MIG_SOCKET}"
72 else
73     _launch_qemu \
74         -drive file="${TEST_IMG}",cache=${CACHEMODE},aio=$AIOMODE,driver=$IMGFMT,id=disk \
75         -incoming "unix:${MIG_SOCKET}"
76 fi
77 dest=$QEMU_HANDLE
78
79 echo
80 echo === Write something on the source ===
81 echo
82
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"
88
89 echo
90 echo === Do postcopy migration to destination ===
91 echo
92
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)"
98
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)"
103
104     _send_qemu_cmd $src 'quit' ""
105     _send_qemu_cmd $dest 'quit' ""
106     wait=1 _cleanup_qemu
107
108     _notrun 'Postcopy is not supported'
109 fi
110
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)"
115
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)"
119
120 echo
121 echo === Do some I/O on the destination ===
122 echo
123
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"
132
133 echo
134 echo === Shut down and check image ===
135 echo
136
137 _send_qemu_cmd $src 'quit' ""
138 _send_qemu_cmd $dest 'quit' ""
139 wait=1 _cleanup_qemu
140
141 _check_test_img
142
143 # success, all done
144 echo "*** done"
145 rm -f $seq.full
146 status=0
This page took 0.03171 seconds and 4 git commands to generate.