]>
Commit | Line | Data |
---|---|---|
0065c455 AG |
1 | #!/bin/bash |
2 | # | |
6bd858b3 | 3 | # Test reopening a backing image after block-stream and block-commit |
0065c455 AG |
4 | # |
5 | # Copyright (C) 2018 Igalia, S.L. | |
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 | _cleanup() | |
31 | { | |
32 | _cleanup_test_img | |
33 | rm -f "$TEST_IMG.base" | |
34 | rm -f "$TEST_IMG.int" | |
35 | } | |
36 | trap "_cleanup; exit \$status" 0 1 2 3 15 | |
37 | ||
38 | # get standard environment, filters and checks | |
39 | . ./common.rc | |
40 | . ./common.filter | |
41 | . ./common.qemu | |
42 | ||
43 | # Any format implementing BlockDriver.bdrv_change_backing_file | |
44 | _supported_fmt qcow2 qed | |
45 | _supported_proto file | |
46 | _supported_os Linux | |
47 | ||
48 | IMG_SIZE=1M | |
49 | ||
50 | # Create the images | |
51 | TEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE | _filter_imgfmt | |
52 | TEST_IMG="$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" | _filter_imgfmt | |
53 | _make_test_img -b "$TEST_IMG.int" | _filter_imgfmt | |
54 | ||
55 | # First test: reopen $TEST.IMG changing the detect-zeroes option on | |
56 | # its backing file ($TEST_IMG.int). | |
57 | echo | |
58 | echo "*** Change an option on the backing file" | |
59 | echo | |
60 | _launch_qemu -drive if=none,file="${TEST_IMG}" | |
61 | _send_qemu_cmd $QEMU_HANDLE \ | |
62 | "{ 'execute': 'qmp_capabilities' }" \ | |
63 | 'return' | |
64 | ||
65 | _send_qemu_cmd $QEMU_HANDLE \ | |
66 | "{ 'execute': 'human-monitor-command', | |
67 | 'arguments': { 'command-line': | |
68 | 'qemu-io none0 \"reopen -o backing.detect-zeroes=on\"' } }" \ | |
69 | "return" | |
70 | ||
71 | _cleanup_qemu | |
72 | ||
73 | # Second test: stream $TEST_IMG.base into $TEST_IMG.int and then | |
74 | # reopen $TEST.IMG changing the detect-zeroes option on its new | |
75 | # backing file ($TEST_IMG.base). | |
76 | echo | |
77 | echo "*** Stream and then change an option on the backing file" | |
78 | echo | |
79 | _launch_qemu -drive if=none,file="${TEST_IMG}" | |
80 | _send_qemu_cmd $QEMU_HANDLE \ | |
81 | "{ 'execute': 'qmp_capabilities' }" \ | |
82 | 'return' | |
83 | ||
84 | _send_qemu_cmd $QEMU_HANDLE \ | |
85 | "{ 'execute': 'block-stream', \ | |
86 | 'arguments': { 'device': 'none0', | |
87 | 'base': '${TEST_IMG}.base' } }" \ | |
88 | 'return' | |
89 | ||
90 | # Wait for block-stream to finish | |
91 | sleep 0.5 | |
92 | ||
93 | _send_qemu_cmd $QEMU_HANDLE \ | |
94 | "{ 'execute': 'human-monitor-command', | |
95 | 'arguments': { 'command-line': | |
96 | 'qemu-io none0 \"reopen -o backing.detect-zeroes=on\"' } }" \ | |
97 | "return" | |
98 | ||
99 | _cleanup_qemu | |
100 | ||
6bd858b3 AG |
101 | # Third test: commit $TEST_IMG.int into $TEST_IMG.base and then reopen |
102 | # $TEST.IMG changing the detect-zeroes option on its new backing file | |
103 | # ($TEST_IMG.base). | |
104 | echo | |
105 | echo "*** Commit and then change an option on the backing file" | |
106 | echo | |
107 | # Create the images again | |
108 | TEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE | _filter_imgfmt | |
109 | TEST_IMG="$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" | _filter_imgfmt | |
110 | _make_test_img -b "$TEST_IMG.int" | _filter_imgfmt | |
111 | ||
112 | _launch_qemu -drive if=none,file="${TEST_IMG}" | |
113 | _send_qemu_cmd $QEMU_HANDLE \ | |
114 | "{ 'execute': 'qmp_capabilities' }" \ | |
115 | 'return' | |
116 | ||
117 | _send_qemu_cmd $QEMU_HANDLE \ | |
118 | "{ 'execute': 'block-commit', \ | |
119 | 'arguments': { 'device': 'none0', | |
120 | 'top': '${TEST_IMG}.int' } }" \ | |
121 | 'return' | |
122 | ||
123 | # Wait for block-commit to finish | |
124 | sleep 0.5 | |
125 | ||
126 | _send_qemu_cmd $QEMU_HANDLE \ | |
127 | "{ 'execute': 'human-monitor-command', | |
128 | 'arguments': { 'command-line': | |
129 | 'qemu-io none0 \"reopen -o backing.detect-zeroes=on\"' } }" \ | |
130 | "return" | |
131 | ||
132 | _cleanup_qemu | |
133 | ||
0065c455 AG |
134 | # success, all done |
135 | echo "*** done" | |
136 | rm -f $seq.full | |
137 | status=0 |