]> Git Repo - qemu.git/blob - tests/qemu-iotests/183
Merge remote-tracking branch 'remotes/kraxel/tags/vga-20170717-pull-request' into...
[qemu.git] / tests / qemu-iotests / 183
1 #!/bin/bash
2 #
3 # Test old-style block migration (migrate -b)
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 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     rm -f "${TEST_IMG}.dest"
36     _cleanup_test_img
37     _cleanup_qemu
38 }
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 # get standard environment, filters and checks
42 . ./common.rc
43 . ./common.filter
44 . ./common.qemu
45
46 _supported_fmt qcow2 raw qed dmg quorum
47 _supported_proto file
48 _supported_os Linux
49
50 size=64M
51 _make_test_img $size
52 TEST_IMG="${TEST_IMG}.dest" _make_test_img $size
53
54 echo
55 echo === Starting VMs ===
56 echo
57
58 qemu_comm_method="qmp"
59
60 _launch_qemu \
61     -drive file="${TEST_IMG}",cache=$CACHEMODE,driver=$IMGFMT,id=disk
62 src=$QEMU_HANDLE
63 _send_qemu_cmd $src "{ 'execute': 'qmp_capabilities' }" 'return'
64
65 _launch_qemu \
66     -drive file="${TEST_IMG}.dest",cache=$CACHEMODE,driver=$IMGFMT,id=disk \
67     -incoming "unix:${MIG_SOCKET}"
68 dest=$QEMU_HANDLE
69 _send_qemu_cmd $dest "{ 'execute': 'qmp_capabilities' }" 'return'
70
71 echo
72 echo === Write something on the source ===
73 echo
74
75 _send_qemu_cmd $src \
76     "{ 'execute': 'human-monitor-command',
77        'arguments': { 'command-line':
78                       'qemu-io disk \"write -P 0x55 0 64k\"' } }" \
79     'return'
80 _send_qemu_cmd $src \
81     "{ 'execute': 'human-monitor-command',
82        'arguments': { 'command-line':
83                       'qemu-io disk \"read -P 0x55 0 64k\"' } }" \
84     'return'
85
86 echo
87 echo === Do block migration to destination ===
88 echo
89
90 reply="$(_send_qemu_cmd $src \
91     "{ 'execute': 'migrate',
92        'arguments': { 'uri': 'unix:${MIG_SOCKET}', 'blk': true } }" \
93     'return\|error')"
94 echo "$reply"
95 if echo "$reply" | grep "compiled without old-style" > /dev/null; then
96     _notrun "migrate -b support not compiled in"
97 fi
98
99 QEMU_COMM_TIMEOUT=0.1 qemu_cmd_repeat=50 silent=yes \
100     _send_qemu_cmd $src "{ 'execute': 'query-migrate' }" '"status": "completed"'
101 _send_qemu_cmd $src "{ 'execute': 'query-status' }" "return"
102
103 echo
104 echo === Do some I/O on the destination ===
105 echo
106
107 # It is important that we use the BlockBackend of the guest device here instead
108 # of the node name, which would create a new BlockBackend and not test whether
109 # the guest has the necessary permissions to access the image now
110 silent=yes _send_qemu_cmd $dest "" "100 %"
111 _send_qemu_cmd $dest "{ 'execute': 'query-status' }" "return"
112 _send_qemu_cmd $dest \
113     "{ 'execute': 'human-monitor-command',
114        'arguments': { 'command-line':
115                       'qemu-io disk \"read -P 0x55 0 64k\"' } }" \
116     'return'
117 _send_qemu_cmd $dest \
118     "{ 'execute': 'human-monitor-command',
119        'arguments': { 'command-line':
120                       'qemu-io disk \"write -P 0x66 1M 64k\"' } }" \
121     'return'
122
123 echo
124 echo === Shut down and check image ===
125 echo
126
127 _send_qemu_cmd $src '{"execute":"quit"}' 'return'
128 _send_qemu_cmd $dest '{"execute":"quit"}' 'return'
129 wait=1 _cleanup_qemu
130
131 _check_test_img
132 TEST_IMG="${TEST_IMG}.dest" _check_test_img
133
134 $QEMU_IO -c 'write -P 0x66 1M 64k' "$TEST_IMG" | _filter_qemu_io
135 $QEMU_IMG compare "$TEST_IMG.dest" "$TEST_IMG"
136
137 # success, all done
138 echo "*** done"
139 rm -f $seq.full
140 status=0
This page took 0.0321 seconds and 4 git commands to generate.