]> Git Repo - qemu.git/blame - tests/qemu-iotests/223
iotests: Also test I/O over NBD TLS
[qemu.git] / tests / qemu-iotests / 223
CommitLineData
a1532a22
EB
1#!/bin/bash
2#
3# Test reading dirty bitmap over NBD
4#
5# Copyright (C) 2018 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
21seq="$(basename $0)"
22echo "QA output created by $seq"
23
a1532a22
EB
24status=1 # failure is the default!
25
26_cleanup()
27{
28 _cleanup_test_img
29 _cleanup_qemu
30 rm -f "$TEST_DIR/nbd"
31}
32trap "_cleanup; exit \$status" 0 1 2 3 15
33
34# get standard environment, filters and checks
35. ./common.rc
36. ./common.filter
37. ./common.qemu
38
39_supported_fmt qcow2
40_supported_proto file # uses NBD as well
41_supported_os Linux
092b9c40
HR
42# Persistent dirty bitmaps require compat=1.1
43_unsupported_imgopts 'compat=0.10'
a1532a22
EB
44
45function do_run_qemu()
46{
47 echo Testing: "$@"
48 $QEMU -nographic -qmp stdio -serial none "$@"
49 echo
50}
51
52function run_qemu()
53{
54 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
55 | _filter_qemu | _filter_imgfmt \
56 | _filter_actual_image_size
57}
58
59echo
60echo "=== Create partially sparse image, then add dirty bitmap ==="
61echo
62
63_make_test_img 4M
64$QEMU_IO -c 'w -P 0x11 1M 2M' "$TEST_IMG" | _filter_qemu_io
65run_qemu <<EOF
66{ "execute": "qmp_capabilities" }
67{ "execute": "blockdev-add",
68 "arguments": {
69 "driver": "$IMGFMT",
70 "node-name": "n",
71 "file": {
72 "driver": "file",
73 "filename": "$TEST_IMG"
74 }
75 }
76}
77{ "execute": "block-dirty-bitmap-add",
78 "arguments": {
79 "node": "n",
80 "name": "b",
81 "persistent": true
82 }
83}
84{ "execute": "quit" }
85EOF
86
87echo
88echo "=== Write part of the file under active bitmap ==="
89echo
90
91$QEMU_IO -c 'w -P 0x22 2M 2M' "$TEST_IMG" | _filter_qemu_io
92
93echo
94echo "=== End dirty bitmap, and start serving image over NBD ==="
95echo
96
97_launch_qemu 2> >(_filter_nbd)
98
99silent=
100_send_qemu_cmd $QEMU_HANDLE '{"execute":"qmp_capabilities"}' "return"
101_send_qemu_cmd $QEMU_HANDLE '{"execute":"blockdev-add",
102 "arguments":{"driver":"qcow2", "node-name":"n",
103 "file":{"driver":"file", "filename":"'"$TEST_IMG"'"}}}' "return"
104_send_qemu_cmd $QEMU_HANDLE '{"execute":"x-block-dirty-bitmap-disable",
105 "arguments":{"node":"n", "name":"b"}}' "return"
106_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-start",
107 "arguments":{"addr":{"type":"unix",
108 "data":{"path":"'"$TEST_DIR/nbd"'"}}}}' "return"
109_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
110 "arguments":{"device":"n"}}' "return"
111_send_qemu_cmd $QEMU_HANDLE '{"execute":"x-nbd-server-add-bitmap",
112 "arguments":{"name":"n", "bitmap":"b"}}' "return"
113
114echo
115echo "=== Contrast normal status with dirty-bitmap status ==="
116echo
117
118QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT
119IMG="driver=nbd,export=n,server.type=unix,server.path=$TEST_DIR/nbd"
120$QEMU_IO -r -c 'r -P 0 0 1m' -c 'r -P 0x11 1m 1m' \
121 -c 'r -P 0x22 2m 2m' --image-opts "$IMG" | _filter_qemu_io
122$QEMU_IMG map --output=json --image-opts \
123 "$IMG" | _filter_qemu_img_map
124$QEMU_IMG map --output=json --image-opts \
125 "$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b" | _filter_qemu_img_map
126
127echo
128echo "=== End NBD server ==="
129echo
130
131_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-remove",
132 "arguments":{"name":"n"}}' "return"
133_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-stop"}' "return"
134_send_qemu_cmd $QEMU_HANDLE '{"execute":"quit"}' "return"
135
136# success, all done
137echo '*** done'
138rm -f $seq.full
139status=0
This page took 0.075675 seconds and 4 git commands to generate.