commit: Fix completion with extra reference
[qemu/kevin.git] / tests / qemu-iotests / 181
blobe969a2a94f7173c8c1ba47238ce0ff1c79e3a24f
1 #!/bin/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 here=`pwd`
28 status=1 # failure is the default!
30 MIG_SOCKET="${TEST_DIR}/migrate"
32 _cleanup()
34 rm -f "${MIG_SOCKET}"
35 _cleanup_test_img
36 _cleanup_qemu
38 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
41 . ./common.rc
42 . ./common.filter
43 . ./common.qemu
45 _supported_fmt generic
46 _supported_proto generic
47 _supported_os Linux
49 size=64M
50 _make_test_img $size
52 echo
53 echo === Starting VMs ===
54 echo
56 qemu_comm_method="monitor"
58 _launch_qemu \
59 -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk
60 src=$QEMU_HANDLE
62 _launch_qemu \
63 -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk \
64 -incoming "unix:${MIG_SOCKET}"
65 dest=$QEMU_HANDLE
67 echo
68 echo === Write something on the source ===
69 echo
71 silent=
72 _send_qemu_cmd $src 'qemu-io disk "write -P 0x55 0 64k"' "(qemu)"
73 _send_qemu_cmd $src "" "ops/sec"
74 _send_qemu_cmd $src 'qemu-io disk "read -P 0x55 0 64k"' "(qemu)"
75 _send_qemu_cmd $src "" "ops/sec"
77 echo
78 echo === Do postcopy migration to destination ===
79 echo
81 # Slow down migration so much that it definitely won't finish before we can
82 # switch to postcopy
83 silent=yes
84 _send_qemu_cmd $src 'migrate_set_speed 4k' "(qemu)"
85 _send_qemu_cmd $src 'migrate_set_capability postcopy-ram on' "(qemu)"
86 _send_qemu_cmd $src "migrate -d unix:${MIG_SOCKET}" "(qemu)"
87 _send_qemu_cmd $src 'migrate_start_postcopy' "(qemu)"
89 QEMU_COMM_TIMEOUT=1 qemu_cmd_repeat=10 silent=yes \
90 _send_qemu_cmd $src "info migrate" "completed\|failed"
91 silent=yes _send_qemu_cmd $src "" "(qemu)"
93 echo
94 echo === Do some I/O on the destination ===
95 echo
97 # It is important that we use the BlockBackend of the guest device here instead
98 # of the node name, which would create a new BlockBackend and not test whether
99 # the guest has the necessary permissions to access the image now
100 silent=
101 _send_qemu_cmd $dest 'qemu-io disk "read -P 0x55 0 64k"' "(qemu)"
102 _send_qemu_cmd $dest "" "ops/sec"
103 _send_qemu_cmd $dest 'qemu-io disk "write -P 0x66 1M 64k"' "(qemu)"
104 _send_qemu_cmd $dest "" "ops/sec"
106 echo
107 echo === Shut down and check image ===
108 echo
110 _send_qemu_cmd $src 'quit' ""
111 _send_qemu_cmd $dest 'quit' ""
112 wait=1 _cleanup_qemu
114 _check_test_img
116 # success, all done
117 echo "*** done"
118 rm -f $seq.full
119 status=0