]> Git Repo - qemu.git/blob - tests/qemu-iotests/183
iotests/041: drop self.assert_no_active_block_jobs()
[qemu.git] / tests / qemu-iotests / 183
1 #!/usr/bin/env 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 status=1 # failure is the default!
28
29 MIG_SOCKET="${SOCK_DIR}/migrate"
30
31 _cleanup()
32 {
33     rm -f "${MIG_SOCKET}"
34     _rm_test_img "${TEST_IMG}.dest"
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_os Linux FreeBSD NetBSD
46 _supported_fmt qcow2 raw qed quorum
47 _supported_proto file
48
49 size=64M
50 _make_test_img $size
51 TEST_IMG="${TEST_IMG}.dest" _make_test_img $size
52
53 echo
54 echo === Starting VMs ===
55 echo
56
57 qemu_comm_method="qmp"
58
59 _launch_qemu \
60     -drive file="${TEST_IMG}",cache=$CACHEMODE,aio=$AIOMODE,driver=$IMGFMT,id=disk
61 src=$QEMU_HANDLE
62 _send_qemu_cmd $src "{ 'execute': 'qmp_capabilities' }" 'return'
63
64 _launch_qemu \
65     -drive file="${TEST_IMG}.dest",cache=$CACHEMODE,aio=$AIOMODE,driver=$IMGFMT,id=disk \
66     -incoming "unix:${MIG_SOCKET}"
67 dest=$QEMU_HANDLE
68 _send_qemu_cmd $dest "{ 'execute': 'qmp_capabilities' }" 'return'
69
70 echo
71 echo === Write something on the source ===
72 echo
73
74 _send_qemu_cmd $src \
75     "{ 'execute': 'human-monitor-command',
76        'arguments': { 'command-line':
77                       'qemu-io disk \"write -P 0x55 0 64k\"' } }" \
78     'return'
79 _send_qemu_cmd $src \
80     "{ 'execute': 'human-monitor-command',
81        'arguments': { 'command-line':
82                       'qemu-io disk \"read -P 0x55 0 64k\"' } }" \
83     'return'
84
85 echo
86 echo === Do block migration to destination ===
87 echo
88
89 reply="$(_send_qemu_cmd $src \
90     "{ 'execute': 'migrate',
91        'arguments': { 'uri': 'unix:${MIG_SOCKET}', 'blk': true } }" \
92     'return\|error')"
93 echo "$reply"
94 if echo "$reply" | grep "compiled without old-style" > /dev/null; then
95     _notrun "migrate -b support not compiled in"
96 fi
97
98 timeout_comm=$QEMU_COMM_TIMEOUT
99 if [ "${VALGRIND_QEMU}" == "y" ]; then
100     QEMU_COMM_TIMEOUT=4
101 else
102     QEMU_COMM_TIMEOUT=0.1
103 fi
104 qemu_cmd_repeat=50 silent=yes \
105     _send_qemu_cmd $src "{ 'execute': 'query-migrate' }" '"status": "completed"'
106 QEMU_COMM_TIMEOUT=$timeout_comm
107 _send_qemu_cmd $src "{ 'execute': 'query-status' }" "return"
108
109 echo
110 echo === Do some I/O on the destination ===
111 echo
112
113 # It is important that we use the BlockBackend of the guest device here instead
114 # of the node name, which would create a new BlockBackend and not test whether
115 # the guest has the necessary permissions to access the image now
116 silent=yes _send_qemu_cmd $dest "" "100 %"
117 _send_qemu_cmd $dest "{ 'execute': 'query-status' }" "return"
118 _send_qemu_cmd $dest \
119     "{ 'execute': 'human-monitor-command',
120        'arguments': { 'command-line':
121                       'qemu-io disk \"read -P 0x55 0 64k\"' } }" \
122     'return'
123 _send_qemu_cmd $dest \
124     "{ 'execute': 'human-monitor-command',
125        'arguments': { 'command-line':
126                       'qemu-io disk \"write -P 0x66 1M 64k\"' } }" \
127     'return'
128
129 echo
130 echo === Shut down and check image ===
131 echo
132
133 _send_qemu_cmd $src '{"execute":"quit"}' 'return'
134 _send_qemu_cmd $dest '{"execute":"quit"}' 'return'
135 wait=1 _cleanup_qemu
136
137 _check_test_img
138 TEST_IMG="${TEST_IMG}.dest" _check_test_img
139
140 $QEMU_IO -c 'write -P 0x66 1M 64k' "$TEST_IMG" | _filter_qemu_io
141 $QEMU_IMG compare "$TEST_IMG.dest" "$TEST_IMG"
142
143 # success, all done
144 echo "*** done"
145 rm -f $seq.full
146 status=0
This page took 0.030342 seconds and 4 git commands to generate.