]>
Commit | Line | Data |
---|---|---|
11a82d14 | 1 | #!/usr/bin/env bash |
9dd003a9 | 2 | # group: rw migration quick |
fd040174 JC |
3 | # |
4 | # Live migration test | |
5 | # | |
6 | # Performs a migration from one VM to another via monitor commands | |
7 | # | |
8 | # Copyright (C) 2014 Red Hat, Inc. | |
9 | # | |
10 | # This program is free software; you can redistribute it and/or modify | |
11 | # it under the terms of the GNU General Public License as published by | |
12 | # the Free Software Foundation; either version 2 of the License, or | |
13 | # (at your option) any later version. | |
14 | # | |
15 | # This program is distributed in the hope that it will be useful, | |
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | # GNU General Public License for more details. | |
19 | # | |
20 | # You should have received a copy of the GNU General Public License | |
21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
22 | # | |
23 | ||
24 | # creator | |
42a5009d | 25 | [email protected] |
fd040174 JC |
26 | |
27 | seq=`basename $0` | |
28 | echo "QA output created by $seq" | |
29 | ||
fd040174 JC |
30 | status=1 # failure is the default! |
31 | ||
32 | MIG_FIFO="${TEST_DIR}/migrate" | |
33 | ||
34 | _cleanup() | |
35 | { | |
36 | rm -f "${MIG_FIFO}" | |
37 | _cleanup_qemu | |
38 | _cleanup_test_img | |
39 | } | |
40 | trap "_cleanup; exit \$status" 0 1 2 3 15 | |
41 | ||
42 | # get standard environment, filters and checks | |
43 | . ./common.rc | |
44 | . ./common.filter | |
45 | . ./common.qemu | |
46 | ||
47 | _supported_fmt qcow2 | |
57284d2a | 48 | _supported_proto file fuse |
fd040174 | 49 | _supported_os Linux |
755c5fe7 | 50 | _supported_cache_modes writethrough none writeback |
cfdca2b9 | 51 | _default_cache_mode none writeback |
fd040174 JC |
52 | |
53 | size=1G | |
54 | ||
55 | _make_test_img $size | |
56 | ||
57 | mkfifo "${MIG_FIFO}" | |
58 | ||
59 | echo | |
60 | echo === Starting QEMU VM1 === | |
61 | echo | |
62 | ||
63 | qemu_comm_method="monitor" | |
8dff69b9 | 64 | _launch_qemu -drive file="${TEST_IMG}",cache=${CACHEMODE},aio=${AIOMODE},id=disk |
fd040174 JC |
65 | h1=$QEMU_HANDLE |
66 | ||
67 | echo | |
68 | echo === Starting QEMU VM2 === | |
69 | echo | |
8dff69b9 | 70 | _launch_qemu -drive file="${TEST_IMG}",cache=${CACHEMODE},aio=${AIOMODE},id=disk \ |
fd040174 JC |
71 | -incoming "exec: cat '${MIG_FIFO}'" |
72 | h2=$QEMU_HANDLE | |
73 | ||
74 | echo | |
75 | echo === VM 1: Migrate from VM1 to VM2 === | |
76 | echo | |
77 | ||
78 | silent=yes | |
79 | _send_qemu_cmd $h1 'qemu-io disk "write -P 0x22 0 4M"' "(qemu)" | |
80 | echo "vm1: qemu-io disk write complete" | |
81 | _send_qemu_cmd $h1 "migrate \"exec: cat > '${MIG_FIFO}'\"" "(qemu)" | |
82 | echo "vm1: live migration started" | |
83 | qemu_cmd_repeat=20 _send_qemu_cmd $h1 "info migrate" "completed" | |
84 | echo "vm1: live migration completed" | |
85 | ||
86 | echo | |
87 | echo === VM 2: Post-migration, write to disk, verify running === | |
88 | echo | |
89 | ||
90 | _send_qemu_cmd $h2 'qemu-io disk "write 4M 1M"' "(qemu)" | |
91 | echo "vm2: qemu-io disk write complete" | |
92 | qemu_cmd_repeat=20 _send_qemu_cmd $h2 "info status" "running" | |
93 | echo "vm2: qemu process running successfully" | |
94 | ||
95 | echo "vm2: flush io, and quit" | |
96 | _send_qemu_cmd $h2 'qemu-io disk flush' "(qemu)" | |
97 | _send_qemu_cmd $h2 'quit' "" | |
8b084489 | 98 | _send_qemu_cmd $h1 'quit' "" |
fd040174 | 99 | |
b4a373bc HR |
100 | wait=yes _cleanup_qemu >/dev/null |
101 | ||
fd040174 JC |
102 | echo "Check image pattern" |
103 | ${QEMU_IO} -c "read -P 0x22 0 4M" "${TEST_IMG}" | _filter_testdir | _filter_qemu_io | |
104 | ||
105 | echo "Running 'qemu-img check -r all \$TEST_IMG'" | |
990f9bcc | 106 | _check_test_img -r all |
fd040174 JC |
107 | |
108 | echo "*** done" | |
109 | rm -f $seq.full | |
110 | status=0 |