]>
Commit | Line | Data |
---|---|---|
312758e2 KW |
1 | #!/bin/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 | owner=kwolf@redhat.com | |
23 | ||
24 | seq=`basename $0` | |
25 | echo "QA output created by $seq" | |
26 | ||
27 | here=`pwd` | |
28 | status=1 # failure is the default! | |
29 | ||
30 | MIG_SOCKET="${TEST_DIR}/migrate" | |
31 | ||
32 | _cleanup() | |
33 | { | |
34 | rm -f "${MIG_SOCKET}" | |
35 | _cleanup_test_img | |
36 | _cleanup_qemu | |
37 | } | |
38 | trap "_cleanup; exit \$status" 0 1 2 3 15 | |
39 | ||
40 | # get standard environment, filters and checks | |
41 | . ./common.rc | |
42 | . ./common.filter | |
43 | . ./common.qemu | |
44 | ||
45 | _supported_fmt generic | |
a9ed6a91 HR |
46 | # Formats that do not support live migration |
47 | _unsupported_fmt qcow vdi vhdx vmdk vpc vvfat | |
312758e2 KW |
48 | _supported_proto generic |
49 | _supported_os Linux | |
50 | ||
51 | size=64M | |
52 | _make_test_img $size | |
53 | ||
54 | echo | |
55 | echo === Starting VMs === | |
56 | echo | |
57 | ||
58 | qemu_comm_method="monitor" | |
59 | ||
13a1d4a7 DB |
60 | if [ "$IMGOPTSSYNTAX" = "true" ]; then |
61 | _launch_qemu \ | |
62 | -drive "${TEST_IMG}",cache=${CACHEMODE},id=disk | |
63 | else | |
64 | _launch_qemu \ | |
65 | -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk | |
66 | fi | |
312758e2 KW |
67 | src=$QEMU_HANDLE |
68 | ||
13a1d4a7 DB |
69 | if [ "$IMGOPTSSYNTAX" = "true" ]; then |
70 | _launch_qemu \ | |
71 | -drive "${TEST_IMG}",cache=${CACHEMODE},id=disk \ | |
72 | -incoming "unix:${MIG_SOCKET}" | |
73 | else | |
74 | _launch_qemu \ | |
75 | -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk \ | |
76 | -incoming "unix:${MIG_SOCKET}" | |
77 | fi | |
312758e2 KW |
78 | dest=$QEMU_HANDLE |
79 | ||
80 | echo | |
81 | echo === Write something on the source === | |
82 | echo | |
83 | ||
84 | silent= | |
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" | |
89 | ||
90 | echo | |
91 | echo === Do postcopy migration to destination === | |
92 | echo | |
93 | ||
94 | # Slow down migration so much that it definitely won't finish before we can | |
95 | # switch to postcopy | |
96 | silent=yes | |
97 | _send_qemu_cmd $src 'migrate_set_speed 4k' "(qemu)" | |
98 | _send_qemu_cmd $src 'migrate_set_capability postcopy-ram on' "(qemu)" | |
99 | _send_qemu_cmd $src "migrate -d unix:${MIG_SOCKET}" "(qemu)" | |
100 | _send_qemu_cmd $src 'migrate_start_postcopy' "(qemu)" | |
101 | ||
102 | QEMU_COMM_TIMEOUT=1 qemu_cmd_repeat=10 silent=yes \ | |
103 | _send_qemu_cmd $src "info migrate" "completed\|failed" | |
104 | silent=yes _send_qemu_cmd $src "" "(qemu)" | |
105 | ||
106 | echo | |
107 | echo === Do some I/O on the destination === | |
108 | echo | |
109 | ||
110 | # It is important that we use the BlockBackend of the guest device here instead | |
111 | # of the node name, which would create a new BlockBackend and not test whether | |
112 | # the guest has the necessary permissions to access the image now | |
113 | silent= | |
114 | _send_qemu_cmd $dest 'qemu-io disk "read -P 0x55 0 64k"' "(qemu)" | |
115 | _send_qemu_cmd $dest "" "ops/sec" | |
116 | _send_qemu_cmd $dest 'qemu-io disk "write -P 0x66 1M 64k"' "(qemu)" | |
117 | _send_qemu_cmd $dest "" "ops/sec" | |
118 | ||
119 | echo | |
120 | echo === Shut down and check image === | |
121 | echo | |
122 | ||
123 | _send_qemu_cmd $src 'quit' "" | |
124 | _send_qemu_cmd $dest 'quit' "" | |
125 | wait=1 _cleanup_qemu | |
126 | ||
127 | _check_test_img | |
128 | ||
129 | # success, all done | |
130 | echo "*** done" | |
131 | rm -f $seq.full | |
132 | status=0 |