1
The following changes since commit 07f426c35eddd79388a23d11cb278600d7e3831d:
1
The following changes since commit c4e0780ed1ffd056f205348d387a61b4136a45df:
2
2
3
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180926' into staging (2018-09-28 18:56:09 +0100)
3
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-4.0-pull-request' into staging (2019-03-07 18:40:43 +0000)
4
4
5
are available in the git repository at:
5
are available in the Git repository at:
6
6
7
git://repo.or.cz/qemu/kevin.git tags/for-upstream
7
git://repo.or.cz/qemu/kevin.git tags/for-upstream
8
8
9
for you to fetch changes up to dd353157942a59c21da07da5ac8749a871f7c3ed:
9
for you to fetch changes up to e88153ea9a40009a8ae7648282c0eac1b7f5494f:
10
10
11
tests/test-bdrv-drain: Fix too late qemu_event_reset() (2018-10-01 19:13:55 +0200)
11
qcow2 spec: Describe string header extensions (2019-03-08 12:26:46 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block layer patches:
14
Block layer patches:
15
15
16
- qcow2 cache option default changes (Linux: 32 MB maximum, limited by
16
- qcow2: Support for external data files
17
whatever cache size can be made use of with the specific image;
17
- qcow2: Default to 4KB for the qcow2 cache entry size
18
default cache-clean-interval of 10 minutes)
18
- Apply block driver whitelist for -drive format=help
19
- reopen: Allow specifying unchanged child node references, and changing
19
- Several qemu-iotests improvements
20
a few generic options (discard, detect-zeroes)
21
- Fix werror/rerror defaults for -device drive=<node-name>
22
- Test case fixes
23
20
24
----------------------------------------------------------------
21
----------------------------------------------------------------
25
Alberto Garcia (9):
22
Alberto Garcia (1):
26
qemu-io: Fix writethrough check in reopen
23
qcow2: Default to 4KB for the qcow2 cache entry size
27
file-posix: x-check-cache-dropped should default to false on reopen
24
28
block: Remove child references from bs->{options,explicit_options}
25
Andrey Shinkevich (4):
29
block: Don't look for child references in append_open_options()
26
iotests: open notrun files in text mode
30
block: Allow child references on reopen
27
block: iterate_format with account of whitelisting
31
block: Forbid trying to change unsupported options during reopen
28
iotests: ask QEMU for supported formats
32
file-posix: Forbid trying to change unsupported options during reopen
29
iotests: check whitelisted formats
33
block: Allow changing 'discard' on reopen
30
34
block: Allow changing 'detect-zeroes' on reopen
31
Kevin Wolf (21):
35
32
qemu-iotests: Test qcow2 preallocation modes
36
Fam Zheng (1):
33
qcow2: Simplify preallocation code
37
file-posix: Include filename in locking error message
34
qcow2: Extend spec for external data files
38
35
qcow2: Basic definitions for external data files
39
Kevin Wolf (3):
36
qcow2: Pass bs to qcow2_get_cluster_type()
40
block-backend: Set werror/rerror defaults in blk_new()
37
qcow2: Prepare qcow2_get_cluster_type() for external data file
41
test-replication: Lock AioContext around blk_unref()
38
qcow2: Prepare count_contiguous_clusters() for external data file
42
tests/test-bdrv-drain: Fix too late qemu_event_reset()
39
qcow2: Don't assume 0 is an invalid cluster offset
43
40
qcow2: Return 0/-errno in qcow2_alloc_compressed_cluster_offset()
44
Leonid Bloch (10):
41
qcow2: Prepare qcow2_co_block_status() for data file
45
qcow2: Options' documentation fixes
42
qcow2: External file I/O
46
include: Add a lookup table of sizes
43
qcow2: Return error for snapshot operation with data file
47
qcow2: Make sizes more humanly readable
44
qcow2: Support external data file in qemu-img check
48
qcow2: Avoid duplication in setting the refcount cache size
45
qcow2: Add basic data-file infrastructure
49
qcow2: Assign the L2 cache relatively to the image size
46
qcow2: Creating images with external data file
50
qcow2: Increase the default upper limit on the L2 cache size
47
qcow2: Store data file name in the image
51
qcow2: Resize the cache upon image resizing
48
qcow2: Implement data-file-raw create option
52
qcow2: Set the default cache-clean-interval to 10 minutes
49
qemu-iotests: Preallocation with external data file
53
qcow2: Explicit number replaced by a constant
50
qemu-iotests: General tests for qcow2 with external data file
54
qcow2: Fix cache-clean-interval documentation
51
qemu-iotests: amend with external data file
55
52
qcow2 spec: Describe string header extensions
56
qapi/block-core.json | 4 +-
53
57
docs/qcow2-cache.txt | 59 ++++++++++++--------
54
Philippe Mathieu-Daudé (6):
58
block/qcow2.h | 19 ++++---
55
tests/multiboot: Improve portability by searching bash in the $PATH
59
include/block/block.h | 1 +
56
tests/bios-tables: Improve portability by searching bash in the $PATH
60
include/qemu/units.h | 55 ++++++++++++++++++
57
qemu-iotests: Improve portability by searching bash in the $PATH
61
block.c | 135 +++++++++++++++++++++++++++++----------------
58
qemu-iotests: Ensure GNU sed is used
62
block/block-backend.c | 3 +
59
ahci-test: Add dependency to qemu-img tool
63
block/file-posix.c | 19 +++++--
60
qemu-iotests: Add dependency to qemu-nbd tool
64
block/qcow2.c | 43 +++++++++------
61
65
qemu-io-cmds.c | 2 +-
62
Stefan Hajnoczi (1):
66
tests/test-bdrv-drain.c | 4 +-
63
iotests: use iotests.VM in 238
67
tests/test-replication.c | 11 ++++
64
68
qemu-options.hx | 12 ++--
65
qapi/block-core.json | 26 ++-
69
tests/qemu-iotests/067.out | 1 +
66
docs/interop/qcow2.txt | 54 +++++-
70
tests/qemu-iotests/137 | 8 ++-
67
docs/qcow2-cache.txt | 17 +-
71
tests/qemu-iotests/137.out | 4 +-
68
block/qcow2.h | 66 +++++--
72
tests/qemu-iotests/153.out | 76 ++++++++++++-------------
69
include/block/block.h | 2 +-
73
tests/qemu-iotests/182.out | 2 +-
70
include/block/block_int.h | 2 +
74
18 files changed, 307 insertions(+), 151 deletions(-)
71
block.c | 23 ++-
75
72
block/qcow2-bitmap.c | 7 +-
73
block/qcow2-cache.c | 6 +-
74
block/qcow2-cluster.c | 182 +++++++++++-------
75
block/qcow2-refcount.c | 88 ++++++---
76
block/qcow2-snapshot.c | 22 ++-
77
block/qcow2.c | 326 +++++++++++++++++++++++++++-----
78
blockdev.c | 4 +-
79
qemu-img.c | 2 +-
80
tests/Makefile.include | 4 +-
81
tests/data/acpi/rebuild-expected-aml.sh | 2 +-
82
tests/multiboot/run_test.sh | 2 +-
83
tests/qemu-iotests/001 | 2 +-
84
tests/qemu-iotests/002 | 2 +-
85
tests/qemu-iotests/003 | 2 +-
86
tests/qemu-iotests/004 | 2 +-
87
tests/qemu-iotests/005 | 2 +-
88
tests/qemu-iotests/007 | 2 +-
89
tests/qemu-iotests/008 | 2 +-
90
tests/qemu-iotests/009 | 2 +-
91
tests/qemu-iotests/010 | 2 +-
92
tests/qemu-iotests/011 | 2 +-
93
tests/qemu-iotests/012 | 2 +-
94
tests/qemu-iotests/013 | 2 +-
95
tests/qemu-iotests/014 | 2 +-
96
tests/qemu-iotests/015 | 2 +-
97
tests/qemu-iotests/017 | 2 +-
98
tests/qemu-iotests/018 | 2 +-
99
tests/qemu-iotests/019 | 2 +-
100
tests/qemu-iotests/020 | 2 +-
101
tests/qemu-iotests/021 | 2 +-
102
tests/qemu-iotests/022 | 2 +-
103
tests/qemu-iotests/023 | 2 +-
104
tests/qemu-iotests/024 | 2 +-
105
tests/qemu-iotests/025 | 2 +-
106
tests/qemu-iotests/026 | 2 +-
107
tests/qemu-iotests/027 | 2 +-
108
tests/qemu-iotests/028 | 2 +-
109
tests/qemu-iotests/029 | 2 +-
110
tests/qemu-iotests/031 | 2 +-
111
tests/qemu-iotests/031.out | 8 +-
112
tests/qemu-iotests/032 | 2 +-
113
tests/qemu-iotests/033 | 2 +-
114
tests/qemu-iotests/034 | 2 +-
115
tests/qemu-iotests/035 | 2 +-
116
tests/qemu-iotests/036 | 2 +-
117
tests/qemu-iotests/036.out | 4 +-
118
tests/qemu-iotests/037 | 2 +-
119
tests/qemu-iotests/038 | 2 +-
120
tests/qemu-iotests/039 | 2 +-
121
tests/qemu-iotests/042 | 2 +-
122
tests/qemu-iotests/043 | 2 +-
123
tests/qemu-iotests/046 | 2 +-
124
tests/qemu-iotests/047 | 2 +-
125
tests/qemu-iotests/048 | 2 +-
126
tests/qemu-iotests/049 | 2 +-
127
tests/qemu-iotests/050 | 2 +-
128
tests/qemu-iotests/051 | 2 +-
129
tests/qemu-iotests/052 | 2 +-
130
tests/qemu-iotests/053 | 2 +-
131
tests/qemu-iotests/054 | 2 +-
132
tests/qemu-iotests/058 | 2 +-
133
tests/qemu-iotests/059 | 2 +-
134
tests/qemu-iotests/060 | 2 +-
135
tests/qemu-iotests/061 | 47 ++++-
136
tests/qemu-iotests/061.out | 103 +++++++++-
137
tests/qemu-iotests/062 | 2 +-
138
tests/qemu-iotests/063 | 2 +-
139
tests/qemu-iotests/064 | 2 +-
140
tests/qemu-iotests/066 | 2 +-
141
tests/qemu-iotests/067 | 2 +-
142
tests/qemu-iotests/068 | 2 +-
143
tests/qemu-iotests/069 | 2 +-
144
tests/qemu-iotests/070 | 2 +-
145
tests/qemu-iotests/071 | 2 +-
146
tests/qemu-iotests/072 | 2 +-
147
tests/qemu-iotests/073 | 2 +-
148
tests/qemu-iotests/074 | 2 +-
149
tests/qemu-iotests/075 | 2 +-
150
tests/qemu-iotests/076 | 2 +-
151
tests/qemu-iotests/077 | 2 +-
152
tests/qemu-iotests/078 | 2 +-
153
tests/qemu-iotests/079 | 2 +-
154
tests/qemu-iotests/080 | 2 +-
155
tests/qemu-iotests/081 | 2 +-
156
tests/qemu-iotests/082 | 2 +-
157
tests/qemu-iotests/082.out | 54 ++++++
158
tests/qemu-iotests/083 | 2 +-
159
tests/qemu-iotests/084 | 2 +-
160
tests/qemu-iotests/085 | 2 +-
161
tests/qemu-iotests/086 | 2 +-
162
tests/qemu-iotests/087 | 2 +-
163
tests/qemu-iotests/088 | 2 +-
164
tests/qemu-iotests/089 | 2 +-
165
tests/qemu-iotests/090 | 2 +-
166
tests/qemu-iotests/091 | 2 +-
167
tests/qemu-iotests/092 | 2 +-
168
tests/qemu-iotests/094 | 2 +-
169
tests/qemu-iotests/095 | 2 +-
170
tests/qemu-iotests/097 | 2 +-
171
tests/qemu-iotests/098 | 2 +-
172
tests/qemu-iotests/099 | 2 +-
173
tests/qemu-iotests/101 | 2 +-
174
tests/qemu-iotests/102 | 2 +-
175
tests/qemu-iotests/103 | 2 +-
176
tests/qemu-iotests/104 | 2 +-
177
tests/qemu-iotests/105 | 2 +-
178
tests/qemu-iotests/106 | 2 +-
179
tests/qemu-iotests/107 | 2 +-
180
tests/qemu-iotests/108 | 2 +-
181
tests/qemu-iotests/109 | 2 +-
182
tests/qemu-iotests/110 | 2 +-
183
tests/qemu-iotests/111 | 2 +-
184
tests/qemu-iotests/112 | 2 +-
185
tests/qemu-iotests/113 | 2 +-
186
tests/qemu-iotests/114 | 2 +-
187
tests/qemu-iotests/115 | 2 +-
188
tests/qemu-iotests/116 | 2 +-
189
tests/qemu-iotests/117 | 2 +-
190
tests/qemu-iotests/119 | 2 +-
191
tests/qemu-iotests/120 | 2 +-
192
tests/qemu-iotests/121 | 2 +-
193
tests/qemu-iotests/122 | 2 +-
194
tests/qemu-iotests/123 | 2 +-
195
tests/qemu-iotests/125 | 2 +-
196
tests/qemu-iotests/126 | 2 +-
197
tests/qemu-iotests/127 | 2 +-
198
tests/qemu-iotests/128 | 2 +-
199
tests/qemu-iotests/130 | 2 +-
200
tests/qemu-iotests/131 | 2 +-
201
tests/qemu-iotests/133 | 2 +-
202
tests/qemu-iotests/134 | 2 +-
203
tests/qemu-iotests/135 | 2 +-
204
tests/qemu-iotests/137 | 2 +-
205
tests/qemu-iotests/138 | 2 +-
206
tests/qemu-iotests/139 | 3 +
207
tests/qemu-iotests/140 | 2 +-
208
tests/qemu-iotests/141 | 2 +-
209
tests/qemu-iotests/142 | 2 +-
210
tests/qemu-iotests/143 | 2 +-
211
tests/qemu-iotests/144 | 2 +-
212
tests/qemu-iotests/145 | 2 +-
213
tests/qemu-iotests/146 | 2 +-
214
tests/qemu-iotests/150 | 2 +-
215
tests/qemu-iotests/153 | 2 +-
216
tests/qemu-iotests/154 | 2 +-
217
tests/qemu-iotests/156 | 2 +-
218
tests/qemu-iotests/157 | 2 +-
219
tests/qemu-iotests/158 | 2 +-
220
tests/qemu-iotests/159 | 2 +-
221
tests/qemu-iotests/160 | 2 +-
222
tests/qemu-iotests/161 | 2 +-
223
tests/qemu-iotests/162 | 2 +-
224
tests/qemu-iotests/170 | 2 +-
225
tests/qemu-iotests/171 | 2 +-
226
tests/qemu-iotests/172 | 2 +-
227
tests/qemu-iotests/173 | 2 +-
228
tests/qemu-iotests/174 | 2 +-
229
tests/qemu-iotests/175 | 2 +-
230
tests/qemu-iotests/176 | 2 +-
231
tests/qemu-iotests/177 | 2 +-
232
tests/qemu-iotests/178 | 2 +-
233
tests/qemu-iotests/179 | 2 +-
234
tests/qemu-iotests/181 | 2 +-
235
tests/qemu-iotests/182 | 2 +-
236
tests/qemu-iotests/183 | 2 +-
237
tests/qemu-iotests/184 | 2 +-
238
tests/qemu-iotests/185 | 2 +-
239
tests/qemu-iotests/186 | 2 +-
240
tests/qemu-iotests/187 | 2 +-
241
tests/qemu-iotests/188 | 2 +-
242
tests/qemu-iotests/189 | 2 +-
243
tests/qemu-iotests/190 | 2 +-
244
tests/qemu-iotests/191 | 2 +-
245
tests/qemu-iotests/192 | 2 +-
246
tests/qemu-iotests/195 | 2 +-
247
tests/qemu-iotests/197 | 2 +-
248
tests/qemu-iotests/198 | 2 +-
249
tests/qemu-iotests/200 | 2 +-
250
tests/qemu-iotests/201 | 2 +-
251
tests/qemu-iotests/204 | 2 +-
252
tests/qemu-iotests/214 | 2 +-
253
tests/qemu-iotests/215 | 2 +-
254
tests/qemu-iotests/217 | 2 +-
255
tests/qemu-iotests/220 | 2 +-
256
tests/qemu-iotests/220.out | 2 +-
257
tests/qemu-iotests/221 | 2 +-
258
tests/qemu-iotests/223 | 2 +-
259
tests/qemu-iotests/225 | 2 +-
260
tests/qemu-iotests/226 | 2 +-
261
tests/qemu-iotests/227 | 2 +-
262
tests/qemu-iotests/229 | 2 +-
263
tests/qemu-iotests/231 | 2 +-
264
tests/qemu-iotests/232 | 2 +-
265
tests/qemu-iotests/233 | 2 +-
266
tests/qemu-iotests/238 | 7 +-
267
tests/qemu-iotests/243 | 85 +++++++++
268
tests/qemu-iotests/243.out | 58 ++++++
269
tests/qemu-iotests/244 | 200 ++++++++++++++++++++
270
tests/qemu-iotests/244.out | 125 ++++++++++++
271
tests/qemu-iotests/check | 15 +-
272
tests/qemu-iotests/common.config | 2 +-
273
tests/qemu-iotests/common.filter | 38 ++--
274
tests/qemu-iotests/common.nbd | 2 +-
275
tests/qemu-iotests/common.pattern | 2 +-
276
tests/qemu-iotests/common.qemu | 2 +-
277
tests/qemu-iotests/common.rc | 15 +-
278
tests/qemu-iotests/common.tls | 2 +-
279
tests/qemu-iotests/group | 2 +
280
tests/qemu-iotests/iotests.py | 45 ++++-
281
216 files changed, 1585 insertions(+), 423 deletions(-)
282
create mode 100755 tests/qemu-iotests/243
283
create mode 100644 tests/qemu-iotests/243.out
284
create mode 100755 tests/qemu-iotests/244
285
create mode 100644 tests/qemu-iotests/244.out
286
diff view generated by jsdifflib
New patch
1
From: Stefan Hajnoczi <stefanha@redhat.com>
1
2
3
Test 238 does not require the kvm accelerator. Using the qtest
4
accelerator allows the test to run in both non-kvm and non-tcg
5
environments.
6
7
iotests.VM implicitly uses the qtest accelerator and is really the class
8
that this test should be using. Switch to that instead of
9
qemu.QEMUMachine.
10
11
Suggested-by: Thomas Huth <thuth@redhat.com>
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14
---
15
tests/qemu-iotests/238 | 7 +------
16
1 file changed, 1 insertion(+), 6 deletions(-)
17
18
diff --git a/tests/qemu-iotests/238 b/tests/qemu-iotests/238
19
index XXXXXXX..XXXXXXX 100755
20
--- a/tests/qemu-iotests/238
21
+++ b/tests/qemu-iotests/238
22
@@ -XXX,XX +XXX,XX @@ import os
23
import iotests
24
from iotests import log
25
26
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
27
-
28
-from qemu import QEMUMachine
29
-
30
if iotests.qemu_default_machine == 's390-ccw-virtio':
31
virtio_scsi_device = 'virtio-scsi-ccw'
32
else:
33
virtio_scsi_device = 'virtio-scsi-pci'
34
35
-vm = QEMUMachine(iotests.qemu_prog)
36
-vm.add_args('-machine', 'accel=kvm')
37
+vm = iotests.VM()
38
vm.launch()
39
40
log(vm.qmp('blockdev-add', node_name='hd0', driver='null-co'))
41
--
42
2.20.1
43
44
diff view generated by jsdifflib
1
From: Leonid Bloch <lbloch@janustech.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
Sufficient L2 cache can noticeably improve the performance when using
3
QEMU 2.12 (commit 1221fe6f636754ab5f2c1c87caa77633e9123622) introduced
4
large images with frequent I/O.
4
a new setting called l2-cache-entry-size that allows making entries on
5
the qcow2 L2 cache smaller than the cluster size.
5
6
6
Previously, unless 'cache-size' was specified and was large enough, the
7
I have been performing several tests with different cluster and entry
7
L2 cache was set to a certain size without taking the virtual image size
8
sizes and all of them show that reducing the entry size (aka L2 slice)
8
into account.
9
consistently improves I/O performance, notably during random I/O (all
10
tests done with sequential I/O show similar results). This is to be
11
expected because loading and evicting an L2 slice is more expensive
12
the larger the slice is.
9
13
10
Now, the L2 cache assignment is aware of the virtual size of the image,
14
Here are some numbers on fully populated 40GB qcow2 images. The
11
and will cover the entire image, unless the cache size needed for that is
15
rightmost column represents the maximum L2 cache size in both cases.
12
larger than a certain maximum. This maximum is set to 1 MB by default
13
(enough to cover an 8 GB image with the default cluster size) but can
14
be increased or decreased using the 'l2-cache-size' option. This option
15
was previously documented as the *maximum* L2 cache size, and this patch
16
makes it behave as such, instead of as a constant size. Also, the
17
existing option 'cache-size' can limit the sum of both L2 and refcount
18
caches, as previously.
19
16
20
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
17
Cluster size = 64 KB
21
Reviewed-by: Alberto Garcia <berto@igalia.com>
18
|-------------+--------------+--------------+--------------|
22
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
19
| | 1MB L2 cache | 3MB L2 cache | 5MB L2 cache |
20
|-------------+--------------+--------------+--------------|
21
| 4KB slices | 6545 IOPS | 12045 IOPS | 55680 IOPS |
22
| 16KB slices | 5177 IOPS | 9798 IOPS | 56278 IOPS |
23
| 64KB slices | 2718 IOPS | 5326 IOPS | 57355 IOPS |
24
|-------------+--------------+--------------+--------------|
25
26
Cluster size = 256 KB
27
|--------------+----------------+--------------+-----------------|
28
| | 512KB L2 cache | 1MB L2 cache | 1280KB L2 cache |
29
|--------------+----------------+--------------+-----------------|
30
| 4KB slices | 8539 IOPS | 21071 IOPS | 55417 IOPS |
31
| 64KB slices | 3598 IOPS | 9772 IOPS | 57687 IOPS |
32
| 256KB slices | 1415 IOPS | 4120 IOPS | 58001 IOPS |
33
|--------------+----------------+--------------+-----------------|
34
35
As can be seen in the numbers, the only exception to the rule is when
36
the cache is large enough to hold all L2 tables. This is also to be
37
expected because in this case no cache entry is ever evicted so
38
reducing its size doesn't bring any benefit.
39
40
This patch sets the default L2 cache entry size to 4KB except when the
41
cache is large enough for the whole disk.
42
43
Signed-off-by: Alberto Garcia <berto@igalia.com>
23
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
44
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
24
---
45
---
25
docs/qcow2-cache.txt | 15 ++++++++++-----
46
docs/qcow2-cache.txt | 17 +++++++++++------
26
block/qcow2.h | 4 +---
47
block/qcow2.c | 12 ++++++++++++
27
block/qcow2.c | 21 +++++++++------------
48
2 files changed, 23 insertions(+), 6 deletions(-)
28
qemu-options.hx | 6 +++---
29
tests/qemu-iotests/137 | 8 +++++++-
30
tests/qemu-iotests/137.out | 4 +++-
31
6 files changed, 33 insertions(+), 25 deletions(-)
32
49
33
diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt
50
diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt
34
index XXXXXXX..XXXXXXX 100644
51
index XXXXXXX..XXXXXXX 100644
35
--- a/docs/qcow2-cache.txt
52
--- a/docs/qcow2-cache.txt
36
+++ b/docs/qcow2-cache.txt
53
+++ b/docs/qcow2-cache.txt
37
@@ -XXX,XX +XXX,XX @@ There are a few things that need to be taken into account:
54
@@ -XXX,XX +XXX,XX @@ refcount cache is as small as possible unless overridden by the user.
38
- Both caches must have a size that is a multiple of the cluster size
55
39
(or the cache entry size: see "Using smaller cache sizes" below).
56
Using smaller cache entries
40
57
---------------------------
41
- - The default L2 cache size is 8 clusters or 1MB (whichever is more),
58
-The qcow2 L2 cache stores complete tables by default. This means that
42
- and the minimum is 2 clusters (or 2 cache entries, see below).
59
-if QEMU needs an entry from an L2 table then the whole table is read
43
+ - The maximum L2 cache size is 1 MB by default (enough for full coverage
60
-from disk and is kept in the cache. If the cache is full then a
44
+ of 8 GB images, with the default cluster size). This value can be
61
-complete table needs to be evicted first.
45
+ modified using the "l2-cache-size" option. QEMU will not use more memory
62
+The qcow2 L2 cache can store complete tables. This means that if QEMU
46
+ than needed to hold all of the image's L2 tables, regardless of this max.
63
+needs an entry from an L2 table then the whole table is read from disk
47
+ value. The minimal L2 cache size is 2 clusters (or 2 cache entries, see
64
+and is kept in the cache. If the cache is full then a complete table
48
+ below).
65
+needs to be evicted first.
49
66
50
- The default (and minimum) refcount cache size is 4 clusters.
67
This can be inefficient with large cluster sizes since it results in
51
68
more disk I/O and wastes more cache memory.
69
@@ -XXX,XX +XXX,XX @@ it smaller than the cluster size. This can be configured using the
70
71
-drive file=hd.qcow2,l2-cache-size=2097152,l2-cache-entry-size=4096
72
73
+Since QEMU 4.0 the value of l2-cache-entry-size defaults to 4KB (or
74
+the cluster size if it's smaller).
75
+
76
Some things to take into account:
77
78
- The L2 cache entry size has the same restrictions as the cluster
52
@@ -XXX,XX +XXX,XX @@ Some things to take into account:
79
@@ -XXX,XX +XXX,XX @@ Some things to take into account:
80
81
- Try different entry sizes to see which one gives faster performance
82
in your case. The block size of the host filesystem is generally a
83
- good default (usually 4096 bytes in the case of ext4).
84
+ good default (usually 4096 bytes in the case of ext4, hence the
85
+ default).
86
87
- Only the L2 cache can be configured this way. The refcount cache
53
always uses the cluster size as the entry size.
88
always uses the cluster size as the entry size.
54
89
@@ -XXX,XX +XXX,XX @@ Some things to take into account:
55
- If the L2 cache is big enough to hold all of the image's L2 tables
90
(as explained in the "Choosing the right cache sizes" and "How to
56
- (as explained in the "Choosing the right cache sizes" section
91
configure the cache sizes" sections in this document) then none of
57
- earlier in this document) then none of this is necessary and you
92
this is necessary and you can omit the "l2-cache-entry-size"
58
- can omit the "l2-cache-entry-size" parameter altogether.
93
- parameter altogether.
59
+ (as explained in the "Choosing the right cache sizes" and "How to
94
+ parameter altogether. In this case QEMU makes the entry size
60
+ configure the cache sizes" sections in this document) then none of
95
+ equal to the cluster size by default.
61
+ this is necessary and you can omit the "l2-cache-entry-size"
62
+ parameter altogether.
63
96
64
97
65
Reducing the memory usage
98
Reducing the memory usage
66
diff --git a/block/qcow2.h b/block/qcow2.h
67
index XXXXXXX..XXXXXXX 100644
68
--- a/block/qcow2.h
69
+++ b/block/qcow2.h
70
@@ -XXX,XX +XXX,XX @@
71
/* Must be at least 4 to cover all cases of refcount table growth */
72
#define MIN_REFCOUNT_CACHE_SIZE 4 /* clusters */
73
74
-/* Whichever is more */
75
-#define DEFAULT_L2_CACHE_CLUSTERS 8 /* clusters */
76
-#define DEFAULT_L2_CACHE_SIZE S_1MiB
77
+#define DEFAULT_L2_CACHE_MAX_SIZE S_1MiB
78
79
#define DEFAULT_CLUSTER_SIZE S_64KiB
80
81
diff --git a/block/qcow2.c b/block/qcow2.c
99
diff --git a/block/qcow2.c b/block/qcow2.c
82
index XXXXXXX..XXXXXXX 100644
100
index XXXXXXX..XXXXXXX 100644
83
--- a/block/qcow2.c
101
--- a/block/qcow2.c
84
+++ b/block/qcow2.c
102
+++ b/block/qcow2.c
85
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
103
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
86
uint64_t *refcount_cache_size, Error **errp)
87
{
88
BDRVQcow2State *s = bs->opaque;
104
BDRVQcow2State *s = bs->opaque;
89
- uint64_t combined_cache_size;
105
uint64_t combined_cache_size, l2_cache_max_setting;
90
+ uint64_t combined_cache_size, l2_cache_max_setting;
91
bool l2_cache_size_set, refcount_cache_size_set, combined_cache_size_set;
106
bool l2_cache_size_set, refcount_cache_size_set, combined_cache_size_set;
107
+ bool l2_cache_entry_size_set;
92
int min_refcount_cache = MIN_REFCOUNT_CACHE_SIZE * s->cluster_size;
108
int min_refcount_cache = MIN_REFCOUNT_CACHE_SIZE * s->cluster_size;
93
+ uint64_t virtual_disk_size = bs->total_sectors * BDRV_SECTOR_SIZE;
109
uint64_t virtual_disk_size = bs->total_sectors * BDRV_SECTOR_SIZE;
94
+ uint64_t max_l2_cache = virtual_disk_size / (s->cluster_size / 8);
110
uint64_t max_l2_cache = virtual_disk_size / (s->cluster_size / 8);
95
111
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
96
combined_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_CACHE_SIZE);
112
combined_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_CACHE_SIZE);
97
l2_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_L2_CACHE_SIZE);
113
l2_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_L2_CACHE_SIZE);
98
refcount_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_REFCOUNT_CACHE_SIZE);
114
refcount_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_REFCOUNT_CACHE_SIZE);
115
+ l2_cache_entry_size_set = qemu_opt_get(opts, QCOW2_OPT_L2_CACHE_ENTRY_SIZE);
99
116
100
combined_cache_size = qemu_opt_get_size(opts, QCOW2_OPT_CACHE_SIZE, 0);
117
combined_cache_size = qemu_opt_get_size(opts, QCOW2_OPT_CACHE_SIZE, 0);
101
- *l2_cache_size = qemu_opt_get_size(opts, QCOW2_OPT_L2_CACHE_SIZE, 0);
118
l2_cache_max_setting = qemu_opt_get_size(opts, QCOW2_OPT_L2_CACHE_SIZE,
102
+ l2_cache_max_setting = qemu_opt_get_size(opts, QCOW2_OPT_L2_CACHE_SIZE,
103
+ DEFAULT_L2_CACHE_MAX_SIZE);
104
*refcount_cache_size = qemu_opt_get_size(opts,
105
QCOW2_OPT_REFCOUNT_CACHE_SIZE, 0);
106
107
*l2_cache_entry_size = qemu_opt_get_size(
108
opts, QCOW2_OPT_L2_CACHE_ENTRY_SIZE, s->cluster_size);
109
110
+ *l2_cache_size = MIN(max_l2_cache, l2_cache_max_setting);
111
+
112
if (combined_cache_size_set) {
113
if (l2_cache_size_set && refcount_cache_size_set) {
114
error_setg(errp, QCOW2_OPT_CACHE_SIZE ", " QCOW2_OPT_L2_CACHE_SIZE
115
" and " QCOW2_OPT_REFCOUNT_CACHE_SIZE " may not be set "
116
"at the same time");
117
return;
118
- } else if (*l2_cache_size > combined_cache_size) {
119
+ } else if (l2_cache_size_set &&
120
+ (l2_cache_max_setting > combined_cache_size)) {
121
error_setg(errp, QCOW2_OPT_L2_CACHE_SIZE " may not exceed "
122
QCOW2_OPT_CACHE_SIZE);
123
return;
124
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
119
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
125
} else if (refcount_cache_size_set) {
126
*l2_cache_size = combined_cache_size - *refcount_cache_size;
127
} else {
128
- uint64_t virtual_disk_size = bs->total_sectors * BDRV_SECTOR_SIZE;
129
- uint64_t max_l2_cache = virtual_disk_size / (s->cluster_size / 8);
130
-
131
/* Assign as much memory as possible to the L2 cache, and
132
* use the remainder for the refcount cache */
133
if (combined_cache_size >= max_l2_cache + min_refcount_cache) {
134
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
135
*l2_cache_size = combined_cache_size - *refcount_cache_size;
136
}
120
}
137
}
121
}
138
- } else {
139
- if (!l2_cache_size_set) {
140
- *l2_cache_size = MAX(DEFAULT_L2_CACHE_SIZE,
141
- (uint64_t)DEFAULT_L2_CACHE_CLUSTERS
142
- * s->cluster_size);
143
- }
144
}
122
}
123
+
124
+ /*
125
+ * If the L2 cache is not enough to cover the whole disk then
126
+ * default to 4KB entries. Smaller entries reduce the cost of
127
+ * loads and evictions and increase I/O performance.
128
+ */
129
+ if (*l2_cache_size < max_l2_cache && !l2_cache_entry_size_set) {
130
+ *l2_cache_entry_size = MIN(s->cluster_size, 4096);
131
+ }
132
+
145
/* l2_cache_size and refcount_cache_size are ensured to have at least
133
/* l2_cache_size and refcount_cache_size are ensured to have at least
146
* their minimum values in qcow2_update_options_prepare() */
134
* their minimum values in qcow2_update_options_prepare() */
147
diff --git a/qemu-options.hx b/qemu-options.hx
148
index XXXXXXX..XXXXXXX 100644
149
--- a/qemu-options.hx
150
+++ b/qemu-options.hx
151
@@ -XXX,XX +XXX,XX @@ The maximum total size of the L2 table and refcount block caches in bytes
152
153
@item l2-cache-size
154
The maximum size of the L2 table cache in bytes
155
-(default: if cache-size is not defined - 1048576 bytes or 8 clusters, whichever
156
-is larger; otherwise, as large as possible or needed within the cache-size,
157
-while permitting the requested or the minimal refcount cache size)
158
+(default: if cache-size is not specified - 1M; otherwise, as large as possible
159
+within the cache-size, while permitting the requested or the minimal refcount
160
+cache size)
161
162
@item refcount-cache-size
163
The maximum size of the refcount block cache in bytes
164
diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137
165
index XXXXXXX..XXXXXXX 100755
166
--- a/tests/qemu-iotests/137
167
+++ b/tests/qemu-iotests/137
168
@@ -XXX,XX +XXX,XX @@ $QEMU_IO \
169
-c "reopen -o cache-size=1M,l2-cache-size=64k,refcount-cache-size=64k" \
170
-c "reopen -o cache-size=1M,l2-cache-size=2M" \
171
-c "reopen -o cache-size=1M,refcount-cache-size=2M" \
172
- -c "reopen -o l2-cache-size=256T" \
173
-c "reopen -o l2-cache-entry-size=33k" \
174
-c "reopen -o l2-cache-entry-size=128k" \
175
-c "reopen -o refcount-cache-size=256T" \
176
@@ -XXX,XX +XXX,XX @@ $QEMU_IO \
177
-c "reopen -o cache-clean-interval=-1" \
178
"$TEST_IMG" | _filter_qemu_io
179
180
+IMGOPTS="cluster_size=256k" _make_test_img 32P
181
+$QEMU_IO \
182
+ -c "reopen -o l2-cache-entry-size=512,l2-cache-size=1T" \
183
+ "$TEST_IMG" | _filter_qemu_io
184
+
185
+_make_test_img 64M
186
+
187
echo
188
echo === Test transaction semantics ===
189
echo
190
diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out
191
index XXXXXXX..XXXXXXX 100644
192
--- a/tests/qemu-iotests/137.out
193
+++ b/tests/qemu-iotests/137.out
194
@@ -XXX,XX +XXX,XX @@ Parameter 'lazy-refcounts' expects 'on' or 'off'
195
cache-size, l2-cache-size and refcount-cache-size may not be set at the same time
196
l2-cache-size may not exceed cache-size
197
refcount-cache-size may not exceed cache-size
198
-L2 cache size too big
199
L2 cache entry size must be a power of two between 512 and the cluster size (65536)
200
L2 cache entry size must be a power of two between 512 and the cluster size (65536)
201
Refcount cache size too big
202
@@ -XXX,XX +XXX,XX @@ Conflicting values for qcow2 options 'overlap-check' ('constant') and 'overlap-c
203
Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all
204
Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all
205
Cache clean interval too big
206
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=36028797018963968
207
+L2 cache size too big
208
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
209
210
=== Test transaction semantics ===
211
135
212
--
136
--
213
2.13.6
137
2.20.1
214
138
215
139
diff view generated by jsdifflib
New patch
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
1
2
3
Replace the binary mode with the default text one when *.notrun
4
files are opened for skipped tests. That change is made for the
5
compatibility with Python 3 which returns error otherwise.
6
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
---
11
tests/qemu-iotests/iotests.py | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
14
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
15
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/qemu-iotests/iotests.py
17
+++ b/tests/qemu-iotests/iotests.py
18
@@ -XXX,XX +XXX,XX @@ def notrun(reason):
19
# Each test in qemu-iotests has a number ("seq")
20
seq = os.path.basename(sys.argv[0])
21
22
- open('%s/%s.notrun' % (output_dir, seq), 'wb').write(reason + '\n')
23
+ open('%s/%s.notrun' % (output_dir, seq), 'w').write(reason + '\n')
24
print('%s not run: %s' % (seq, reason))
25
sys.exit(0)
26
27
--
28
2.20.1
29
30
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
2
2
3
'detect-zeroes' is one of the basic BlockdevOptions available for all
3
bdrv_iterate_format (which is currently only used for printing out the
4
drivers, but it's not handled by bdrv_reopen_prepare(), so any attempt
4
formats supported by the block layer) doesn't take format whitelisting
5
to change it results in an error:
5
into account.
6
6
7
(qemu) qemu-io virtio0 "reopen -o detect-zeroes=on"
7
This creates a problem for tests: they enumerate supported formats to
8
Cannot change the option 'detect-zeroes'
8
decide which tests to enable, but then discover that QEMU doesn't let
9
them actually use some of those formats.
9
10
10
Since there's no reason why we shouldn't allow changing it and the
11
To avoid that, exclude formats that are not whitelisted from
11
implementation is simple let's just do it.
12
enumeration, if whitelisting is in use. Since we have separate
13
whitelists for r/w and r/o, take this a parameter to
14
bdrv_iterate_format, and print two lists of supported formats (r/w and
15
r/o) in main qemu.
12
16
13
Signed-off-by: Alberto Garcia <berto@igalia.com>
17
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
18
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
14
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
19
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
15
---
20
---
16
include/block/block.h | 1 +
21
include/block/block.h | 2 +-
17
block.c | 64 ++++++++++++++++++++++++++++++++-------------------
22
block.c | 23 +++++++++++++++++++----
18
2 files changed, 41 insertions(+), 24 deletions(-)
23
blockdev.c | 4 +++-
24
qemu-img.c | 2 +-
25
4 files changed, 24 insertions(+), 7 deletions(-)
19
26
20
diff --git a/include/block/block.h b/include/block/block.h
27
diff --git a/include/block/block.h b/include/block/block.h
21
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
22
--- a/include/block/block.h
29
--- a/include/block/block.h
23
+++ b/include/block/block.h
30
+++ b/include/block/block.h
24
@@ -XXX,XX +XXX,XX @@ typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue;
31
@@ -XXX,XX +XXX,XX @@ void bdrv_next_cleanup(BdrvNextIterator *it);
25
typedef struct BDRVReopenState {
32
BlockDriverState *bdrv_next_monitor_owned(BlockDriverState *bs);
26
BlockDriverState *bs;
33
bool bdrv_is_encrypted(BlockDriverState *bs);
27
int flags;
34
void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
28
+ BlockdevDetectZeroesOptions detect_zeroes;
35
- void *opaque);
29
uint64_t perm, shared_perm;
36
+ void *opaque, bool read_only);
30
QDict *options;
37
const char *bdrv_get_node_name(const BlockDriverState *bs);
31
QDict *explicit_options;
38
const char *bdrv_get_device_name(const BlockDriverState *bs);
39
const char *bdrv_get_device_or_node_name(const BlockDriverState *bs);
32
diff --git a/block.c b/block.c
40
diff --git a/block.c b/block.c
33
index XXXXXXX..XXXXXXX 100644
41
index XXXXXXX..XXXXXXX 100644
34
--- a/block.c
42
--- a/block.c
35
+++ b/block.c
43
+++ b/block.c
36
@@ -XXX,XX +XXX,XX @@ static void bdrv_join_options(BlockDriverState *bs, QDict *options,
44
@@ -XXX,XX +XXX,XX @@ BlockDriver *bdrv_find_format(const char *format_name)
45
return bdrv_do_find_format(format_name);
46
}
47
48
-int bdrv_is_whitelisted(BlockDriver *drv, bool read_only)
49
+static int bdrv_format_is_whitelisted(const char *format_name, bool read_only)
50
{
51
static const char *whitelist_rw[] = {
52
CONFIG_BDRV_RW_WHITELIST
53
@@ -XXX,XX +XXX,XX @@ int bdrv_is_whitelisted(BlockDriver *drv, bool read_only)
37
}
54
}
55
56
for (p = whitelist_rw; *p; p++) {
57
- if (!strcmp(drv->format_name, *p)) {
58
+ if (!strcmp(format_name, *p)) {
59
return 1;
60
}
61
}
62
if (read_only) {
63
for (p = whitelist_ro; *p; p++) {
64
- if (!strcmp(drv->format_name, *p)) {
65
+ if (!strcmp(format_name, *p)) {
66
return 1;
67
}
68
}
69
@@ -XXX,XX +XXX,XX @@ int bdrv_is_whitelisted(BlockDriver *drv, bool read_only)
70
return 0;
38
}
71
}
39
72
40
+static BlockdevDetectZeroesOptions bdrv_parse_detect_zeroes(QemuOpts *opts,
73
+int bdrv_is_whitelisted(BlockDriver *drv, bool read_only)
41
+ int open_flags,
42
+ Error **errp)
43
+{
74
+{
44
+ Error *local_err = NULL;
75
+ return bdrv_format_is_whitelisted(drv->format_name, read_only);
45
+ char *value = qemu_opt_get_del(opts, "detect-zeroes");
46
+ BlockdevDetectZeroesOptions detect_zeroes =
47
+ qapi_enum_parse(&BlockdevDetectZeroesOptions_lookup, value,
48
+ BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF, &local_err);
49
+ g_free(value);
50
+ if (local_err) {
51
+ error_propagate(errp, local_err);
52
+ return detect_zeroes;
53
+ }
54
+
55
+ if (detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&
56
+ !(open_flags & BDRV_O_UNMAP))
57
+ {
58
+ error_setg(errp, "setting detect-zeroes to unmap is not allowed "
59
+ "without setting discard operation to unmap");
60
+ }
61
+
62
+ return detect_zeroes;
63
+}
76
+}
64
+
77
+
65
/**
78
bool bdrv_uses_whitelist(void)
66
* Set open flags for a given discard mode
79
{
67
*
80
return use_bdrv_whitelist;
68
@@ -XXX,XX +XXX,XX @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
81
@@ -XXX,XX +XXX,XX @@ static int qsort_strcmp(const void *a, const void *b)
69
const char *driver_name = NULL;
82
}
70
const char *node_name = NULL;
83
71
const char *discard;
84
void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
72
- const char *detect_zeroes;
85
- void *opaque)
73
QemuOpts *opts;
86
+ void *opaque, bool read_only)
87
{
74
BlockDriver *drv;
88
BlockDriver *drv;
75
Error *local_err = NULL;
89
int count = 0;
76
@@ -XXX,XX +XXX,XX @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
90
@@ -XXX,XX +XXX,XX @@ void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
91
if (drv->format_name) {
92
bool found = false;
93
int i = count;
94
+
95
+ if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, read_only)) {
96
+ continue;
97
+ }
98
+
99
while (formats && i && !found) {
100
found = !strcmp(formats[--i], drv->format_name);
101
}
102
@@ -XXX,XX +XXX,XX @@ void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
103
bool found = false;
104
int j = count;
105
106
+ if (use_bdrv_whitelist &&
107
+ !bdrv_format_is_whitelisted(format_name, read_only)) {
108
+ continue;
109
+ }
110
+
111
while (formats && j && !found) {
112
found = !strcmp(formats[--j], format_name);
113
}
114
diff --git a/blockdev.c b/blockdev.c
115
index XXXXXXX..XXXXXXX 100644
116
--- a/blockdev.c
117
+++ b/blockdev.c
118
@@ -XXX,XX +XXX,XX @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
119
if ((buf = qemu_opt_get(opts, "format")) != NULL) {
120
if (is_help_option(buf)) {
121
error_printf("Supported formats:");
122
- bdrv_iterate_format(bdrv_format_print, NULL);
123
+ bdrv_iterate_format(bdrv_format_print, NULL, false);
124
+ error_printf("\nSupported formats (read-only):");
125
+ bdrv_iterate_format(bdrv_format_print, NULL, true);
126
error_printf("\n");
127
goto early_err;
77
}
128
}
78
}
129
diff --git a/qemu-img.c b/qemu-img.c
79
130
index XXXXXXX..XXXXXXX 100644
80
- detect_zeroes = qemu_opt_get(opts, "detect-zeroes");
131
--- a/qemu-img.c
81
- if (detect_zeroes) {
132
+++ b/qemu-img.c
82
- BlockdevDetectZeroesOptions value =
133
@@ -XXX,XX +XXX,XX @@ static void QEMU_NORETURN help(void)
83
- qapi_enum_parse(&BlockdevDetectZeroesOptions_lookup,
134
" 'skip=N' skip N bs-sized blocks at the start of input\n";
84
- detect_zeroes,
135
85
- BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF,
136
printf("%s\nSupported formats:", help_msg);
86
- &local_err);
137
- bdrv_iterate_format(format_print, NULL);
87
- if (local_err) {
138
+ bdrv_iterate_format(format_print, NULL, false);
88
- error_propagate(errp, local_err);
139
printf("\n\n" QEMU_HELP_BOTTOM "\n");
89
- ret = -EINVAL;
140
exit(EXIT_SUCCESS);
90
- goto fail_opts;
141
}
91
- }
92
-
93
- if (value == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&
94
- !(bs->open_flags & BDRV_O_UNMAP))
95
- {
96
- error_setg(errp, "setting detect-zeroes to unmap is not allowed "
97
- "without setting discard operation to unmap");
98
- ret = -EINVAL;
99
- goto fail_opts;
100
- }
101
-
102
- bs->detect_zeroes = value;
103
+ bs->detect_zeroes =
104
+ bdrv_parse_detect_zeroes(opts, bs->open_flags, &local_err);
105
+ if (local_err) {
106
+ error_propagate(errp, local_err);
107
+ ret = -EINVAL;
108
+ goto fail_opts;
109
}
110
111
if (filename != NULL) {
112
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
113
}
114
}
115
116
+ reopen_state->detect_zeroes =
117
+ bdrv_parse_detect_zeroes(opts, reopen_state->flags, &local_err);
118
+ if (local_err) {
119
+ error_propagate(errp, local_err);
120
+ ret = -EINVAL;
121
+ goto error;
122
+ }
123
+
124
/* All other options (including node-name and driver) must be unchanged.
125
* Put them back into the QDict, so that they are checked at the end
126
* of this function. */
127
@@ -XXX,XX +XXX,XX @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
128
bs->options = reopen_state->options;
129
bs->open_flags = reopen_state->flags;
130
bs->read_only = !(reopen_state->flags & BDRV_O_RDWR);
131
+ bs->detect_zeroes = reopen_state->detect_zeroes;
132
133
/* Remove child references from bs->options and bs->explicit_options.
134
* Child options were already removed in bdrv_reopen_queue_child() */
135
--
142
--
136
2.13.6
143
2.20.1
137
144
138
145
diff view generated by jsdifflib
New patch
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
1
2
3
Supported formats listed by 'qemu' may differ from those listed by
4
'qemu-img' due to whitelists. Some test cases require specific formats
5
that may be used with qemu. They can be inquired directly by running
6
'qemu -drive format=help'. The response takes whitelists into account.
7
The method supported_formats() serves for that. The method decorator
8
skip_if_unsupported() checks if all requested formats are whitelisted.
9
If not, the test case will be skipped. That has been implemented in
10
the 'check' file in the way similar to the 'test notrun' mechanism.
11
12
Suggested-by: Roman Kagan <rkagan@virtuozzo.com>
13
Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
14
Suggested-by: Kevin Wolf <kwolf@redhat.com>
15
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
16
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
17
---
18
tests/qemu-iotests/check | 13 ++++++++++-
19
tests/qemu-iotests/iotests.py | 43 +++++++++++++++++++++++++++++++++++
20
2 files changed, 55 insertions(+), 1 deletion(-)
21
22
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
23
index XXXXXXX..XXXXXXX 100755
24
--- a/tests/qemu-iotests/check
25
+++ b/tests/qemu-iotests/check
26
@@ -XXX,XX +XXX,XX @@ try=0
27
n_bad=0
28
bad=""
29
notrun=""
30
+casenotrun=""
31
interrupt=true
32
33
# by default don't output timestamps
34
@@ -XXX,XX +XXX,XX @@ END { if (NR > 0) {
35
echo "Not run:$notrun"
36
echo "Not run:$notrun" >>check.log
37
fi
38
+ if [ ! -z "$casenotrun" ]
39
+ then
40
+ echo "Some cases not run in:$casenotrun"
41
+ echo "Some cases not run in:$casenotrun" >>check.log
42
+ fi
43
if [ ! -z "$n_bad" -a $n_bad != 0 ]
44
then
45
echo "Failures:$bad"
46
@@ -XXX,XX +XXX,XX @@ do
47
printf " " # prettier output with timestamps.
48
fi
49
rm -f core $seq.notrun
50
+ rm -f $seq.casenotrun
51
52
start=$(_wallclock)
53
$timestamp && printf %s " [$(date "+%T")]"
54
@@ -XXX,XX +XXX,XX @@ do
55
fi
56
fi
57
fi
58
-
59
+ if [ -f $seq.casenotrun ]
60
+ then
61
+ cat $seq.casenotrun
62
+ casenotrun="$casenotrun $seq"
63
+ fi
64
fi
65
66
# come here for each test, except when $showme is true
67
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
68
index XXXXXXX..XXXXXXX 100644
69
--- a/tests/qemu-iotests/iotests.py
70
+++ b/tests/qemu-iotests/iotests.py
71
@@ -XXX,XX +XXX,XX @@ def notrun(reason):
72
print('%s not run: %s' % (seq, reason))
73
sys.exit(0)
74
75
+def case_notrun(reason):
76
+ '''Skip this test case'''
77
+ # Each test in qemu-iotests has a number ("seq")
78
+ seq = os.path.basename(sys.argv[0])
79
+
80
+ open('%s/%s.casenotrun' % (output_dir, seq), 'a').write(
81
+ ' [case not run] ' + reason + '\n')
82
+
83
def verify_image_format(supported_fmts=[], unsupported_fmts=[]):
84
assert not (supported_fmts and unsupported_fmts)
85
86
@@ -XXX,XX +XXX,XX @@ def verify_quorum():
87
if not supports_quorum():
88
notrun('quorum support missing')
89
90
+def qemu_pipe(*args):
91
+ '''Run qemu with an option to print something and exit (e.g. a help option),
92
+ and return its output'''
93
+ args = [qemu_prog] + qemu_opts + list(args)
94
+ subp = subprocess.Popen(args, stdout=subprocess.PIPE,
95
+ stderr=subprocess.STDOUT,
96
+ universal_newlines=True)
97
+ exitcode = subp.wait()
98
+ if exitcode < 0:
99
+ sys.stderr.write('qemu received signal %i: %s\n' % (-exitcode,
100
+ ' '.join(args)))
101
+ return subp.communicate()[0]
102
+
103
+def supported_formats(read_only=False):
104
+ '''Set 'read_only' to True to check ro-whitelist
105
+ Otherwise, rw-whitelist is checked'''
106
+ format_message = qemu_pipe("-drive", "format=help")
107
+ line = 1 if read_only else 0
108
+ return format_message.splitlines()[line].split(":")[1].split()
109
+
110
+def skip_if_unsupported(required_formats=[], read_only=False):
111
+ '''Skip Test Decorator
112
+ Runs the test if all the required formats are whitelisted'''
113
+ def skip_test_decorator(func):
114
+ def func_wrapper(*args, **kwargs):
115
+ usf_list = list(set(required_formats) -
116
+ set(supported_formats(read_only)))
117
+ if usf_list:
118
+ case_notrun('{}: formats {} are not whitelisted'.format(
119
+ args[0], usf_list))
120
+ else:
121
+ return func(*args, **kwargs)
122
+ return func_wrapper
123
+ return skip_test_decorator
124
+
125
def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[],
126
unsupported_fmts=[]):
127
'''Run tests'''
128
--
129
2.20.1
130
131
diff view generated by jsdifflib
New patch
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
1
2
3
Some test cases require specific formats. The method decorator
4
skip_if_unsupported() checks if requested formats are whitelisted.
5
The test #139 was selected for a sample output, after running
6
$ ./check -qcow2 131-140
7
8
137 3s ...
9
138 0s ...
10
139 2s ...
11
[case not run] testBlkDebug (__main__.TestBlockdevDel): formats ['blkdebug'] are not whitelisted
12
[case not run] testBlkVerify (__main__.TestBlockdevDel): formats ['blkverify'] are not whitelisted
13
[case not run] testQuorum (__main__.TestBlockdevDel): formats ['quorum'] are not whitelisted
14
140 0s ...
15
Not run: 131 135 136
16
Some cases not run in: 139
17
Passed all 7 tests
18
19
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
20
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
21
---
22
tests/qemu-iotests/139 | 3 +++
23
1 file changed, 3 insertions(+)
24
25
diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139
26
index XXXXXXX..XXXXXXX 100755
27
--- a/tests/qemu-iotests/139
28
+++ b/tests/qemu-iotests/139
29
@@ -XXX,XX +XXX,XX @@ class TestBlockdevDel(iotests.QMPTestCase):
30
# FIXME mirror0 disappears, drive-mirror doesn't take a reference
31
#self.delBlockDriverState('mirror0')
32
33
+ @iotests.skip_if_unsupported(['blkdebug'])
34
def testBlkDebug(self):
35
self.addBlkDebug('debug0', 'node0')
36
# 'node0' is used by the blkdebug node
37
@@ -XXX,XX +XXX,XX @@ class TestBlockdevDel(iotests.QMPTestCase):
38
self.delBlockDriverState('debug0')
39
self.checkBlockDriverState('node0', False)
40
41
+ @iotests.skip_if_unsupported(['blkverify'])
42
def testBlkVerify(self):
43
self.addBlkVerify('verify0', 'node0', 'node1')
44
# We cannot remove the children of a blkverify device
45
@@ -XXX,XX +XXX,XX @@ class TestBlockdevDel(iotests.QMPTestCase):
46
self.checkBlockDriverState('node0', False)
47
self.checkBlockDriverState('node1', False)
48
49
+ @iotests.skip_if_unsupported(['quorum'])
50
def testQuorum(self):
51
if not iotests.supports_quorum():
52
return
53
--
54
2.20.1
55
56
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Bash is not always installed as /bin/bash. In particular on OpenBSD,
4
the package installs it in /usr/local/bin.
5
Use the 'env' shebang to search bash in the $PATH.
6
7
Reviewed-by: Kamil Rytarowski <n54@gmx.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
---
12
tests/multiboot/run_test.sh | 2 +-
13
1 file changed, 1 insertion(+), 1 deletion(-)
14
15
diff --git a/tests/multiboot/run_test.sh b/tests/multiboot/run_test.sh
16
index XXXXXXX..XXXXXXX 100755
17
--- a/tests/multiboot/run_test.sh
18
+++ b/tests/multiboot/run_test.sh
19
@@ -XXX,XX +XXX,XX @@
20
-#!/bin/bash
21
+#!/usr/bin/env bash
22
23
# Copyright (c) 2013 Kevin Wolf <kwolf@redhat.com>
24
#
25
--
26
2.20.1
27
28
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Bash is not always installed as /bin/bash. In particular on OpenBSD,
4
the package installs it in /usr/local/bin.
5
Use the 'env' shebang to search bash in the $PATH.
6
7
Reviewed-by: Kamil Rytarowski <n54@gmx.com>
8
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
9
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Acked-by: Thomas Huth <thuth@redhat.com>
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13
---
14
tests/data/acpi/rebuild-expected-aml.sh | 2 +-
15
1 file changed, 1 insertion(+), 1 deletion(-)
16
17
diff --git a/tests/data/acpi/rebuild-expected-aml.sh b/tests/data/acpi/rebuild-expected-aml.sh
18
index XXXXXXX..XXXXXXX 100755
19
--- a/tests/data/acpi/rebuild-expected-aml.sh
20
+++ b/tests/data/acpi/rebuild-expected-aml.sh
21
@@ -XXX,XX +XXX,XX @@
22
-#! /bin/bash
23
+#!/usr/bin/env bash
24
25
#
26
# Rebuild expected AML files for acpi unit-test
27
--
28
2.20.1
29
30
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Bash is not always installed as /bin/bash. In particular on OpenBSD,
4
the package installs it in /usr/local/bin.
5
Use the 'env' shebang to search bash in the $PATH.
6
7
Patch created mechanically by running:
8
9
$ git grep -lE '#! ?/bin/bash' -- tests/qemu-iotests \
10
| while read f; do \
11
sed -i 's|^#!.\?/bin/bash$|#!/usr/bin/env bash|' $f; \
12
done
13
14
Reviewed-by: Eric Blake <eblake@redhat.com>
15
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
16
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
17
---
18
tests/qemu-iotests/001 | 2 +-
19
tests/qemu-iotests/002 | 2 +-
20
tests/qemu-iotests/003 | 2 +-
21
tests/qemu-iotests/004 | 2 +-
22
tests/qemu-iotests/005 | 2 +-
23
tests/qemu-iotests/007 | 2 +-
24
tests/qemu-iotests/008 | 2 +-
25
tests/qemu-iotests/009 | 2 +-
26
tests/qemu-iotests/010 | 2 +-
27
tests/qemu-iotests/011 | 2 +-
28
tests/qemu-iotests/012 | 2 +-
29
tests/qemu-iotests/013 | 2 +-
30
tests/qemu-iotests/014 | 2 +-
31
tests/qemu-iotests/015 | 2 +-
32
tests/qemu-iotests/017 | 2 +-
33
tests/qemu-iotests/018 | 2 +-
34
tests/qemu-iotests/019 | 2 +-
35
tests/qemu-iotests/020 | 2 +-
36
tests/qemu-iotests/021 | 2 +-
37
tests/qemu-iotests/022 | 2 +-
38
tests/qemu-iotests/023 | 2 +-
39
tests/qemu-iotests/024 | 2 +-
40
tests/qemu-iotests/025 | 2 +-
41
tests/qemu-iotests/026 | 2 +-
42
tests/qemu-iotests/027 | 2 +-
43
tests/qemu-iotests/028 | 2 +-
44
tests/qemu-iotests/029 | 2 +-
45
tests/qemu-iotests/031 | 2 +-
46
tests/qemu-iotests/032 | 2 +-
47
tests/qemu-iotests/033 | 2 +-
48
tests/qemu-iotests/034 | 2 +-
49
tests/qemu-iotests/035 | 2 +-
50
tests/qemu-iotests/036 | 2 +-
51
tests/qemu-iotests/037 | 2 +-
52
tests/qemu-iotests/038 | 2 +-
53
tests/qemu-iotests/039 | 2 +-
54
tests/qemu-iotests/042 | 2 +-
55
tests/qemu-iotests/043 | 2 +-
56
tests/qemu-iotests/046 | 2 +-
57
tests/qemu-iotests/047 | 2 +-
58
tests/qemu-iotests/048 | 2 +-
59
tests/qemu-iotests/049 | 2 +-
60
tests/qemu-iotests/050 | 2 +-
61
tests/qemu-iotests/051 | 2 +-
62
tests/qemu-iotests/052 | 2 +-
63
tests/qemu-iotests/053 | 2 +-
64
tests/qemu-iotests/054 | 2 +-
65
tests/qemu-iotests/058 | 2 +-
66
tests/qemu-iotests/059 | 2 +-
67
tests/qemu-iotests/060 | 2 +-
68
tests/qemu-iotests/061 | 2 +-
69
tests/qemu-iotests/062 | 2 +-
70
tests/qemu-iotests/063 | 2 +-
71
tests/qemu-iotests/064 | 2 +-
72
tests/qemu-iotests/066 | 2 +-
73
tests/qemu-iotests/067 | 2 +-
74
tests/qemu-iotests/068 | 2 +-
75
tests/qemu-iotests/069 | 2 +-
76
tests/qemu-iotests/070 | 2 +-
77
tests/qemu-iotests/071 | 2 +-
78
tests/qemu-iotests/072 | 2 +-
79
tests/qemu-iotests/073 | 2 +-
80
tests/qemu-iotests/074 | 2 +-
81
tests/qemu-iotests/075 | 2 +-
82
tests/qemu-iotests/076 | 2 +-
83
tests/qemu-iotests/077 | 2 +-
84
tests/qemu-iotests/078 | 2 +-
85
tests/qemu-iotests/079 | 2 +-
86
tests/qemu-iotests/080 | 2 +-
87
tests/qemu-iotests/081 | 2 +-
88
tests/qemu-iotests/082 | 2 +-
89
tests/qemu-iotests/083 | 2 +-
90
tests/qemu-iotests/084 | 2 +-
91
tests/qemu-iotests/085 | 2 +-
92
tests/qemu-iotests/086 | 2 +-
93
tests/qemu-iotests/087 | 2 +-
94
tests/qemu-iotests/088 | 2 +-
95
tests/qemu-iotests/089 | 2 +-
96
tests/qemu-iotests/090 | 2 +-
97
tests/qemu-iotests/091 | 2 +-
98
tests/qemu-iotests/092 | 2 +-
99
tests/qemu-iotests/094 | 2 +-
100
tests/qemu-iotests/095 | 2 +-
101
tests/qemu-iotests/097 | 2 +-
102
tests/qemu-iotests/098 | 2 +-
103
tests/qemu-iotests/099 | 2 +-
104
tests/qemu-iotests/101 | 2 +-
105
tests/qemu-iotests/102 | 2 +-
106
tests/qemu-iotests/103 | 2 +-
107
tests/qemu-iotests/104 | 2 +-
108
tests/qemu-iotests/105 | 2 +-
109
tests/qemu-iotests/106 | 2 +-
110
tests/qemu-iotests/107 | 2 +-
111
tests/qemu-iotests/108 | 2 +-
112
tests/qemu-iotests/109 | 2 +-
113
tests/qemu-iotests/110 | 2 +-
114
tests/qemu-iotests/111 | 2 +-
115
tests/qemu-iotests/112 | 2 +-
116
tests/qemu-iotests/113 | 2 +-
117
tests/qemu-iotests/114 | 2 +-
118
tests/qemu-iotests/115 | 2 +-
119
tests/qemu-iotests/116 | 2 +-
120
tests/qemu-iotests/117 | 2 +-
121
tests/qemu-iotests/119 | 2 +-
122
tests/qemu-iotests/120 | 2 +-
123
tests/qemu-iotests/121 | 2 +-
124
tests/qemu-iotests/122 | 2 +-
125
tests/qemu-iotests/123 | 2 +-
126
tests/qemu-iotests/125 | 2 +-
127
tests/qemu-iotests/126 | 2 +-
128
tests/qemu-iotests/127 | 2 +-
129
tests/qemu-iotests/128 | 2 +-
130
tests/qemu-iotests/130 | 2 +-
131
tests/qemu-iotests/131 | 2 +-
132
tests/qemu-iotests/133 | 2 +-
133
tests/qemu-iotests/134 | 2 +-
134
tests/qemu-iotests/135 | 2 +-
135
tests/qemu-iotests/137 | 2 +-
136
tests/qemu-iotests/138 | 2 +-
137
tests/qemu-iotests/140 | 2 +-
138
tests/qemu-iotests/141 | 2 +-
139
tests/qemu-iotests/142 | 2 +-
140
tests/qemu-iotests/143 | 2 +-
141
tests/qemu-iotests/144 | 2 +-
142
tests/qemu-iotests/145 | 2 +-
143
tests/qemu-iotests/146 | 2 +-
144
tests/qemu-iotests/150 | 2 +-
145
tests/qemu-iotests/153 | 2 +-
146
tests/qemu-iotests/154 | 2 +-
147
tests/qemu-iotests/156 | 2 +-
148
tests/qemu-iotests/157 | 2 +-
149
tests/qemu-iotests/158 | 2 +-
150
tests/qemu-iotests/159 | 2 +-
151
tests/qemu-iotests/160 | 2 +-
152
tests/qemu-iotests/161 | 2 +-
153
tests/qemu-iotests/162 | 2 +-
154
tests/qemu-iotests/170 | 2 +-
155
tests/qemu-iotests/171 | 2 +-
156
tests/qemu-iotests/172 | 2 +-
157
tests/qemu-iotests/173 | 2 +-
158
tests/qemu-iotests/174 | 2 +-
159
tests/qemu-iotests/175 | 2 +-
160
tests/qemu-iotests/176 | 2 +-
161
tests/qemu-iotests/177 | 2 +-
162
tests/qemu-iotests/178 | 2 +-
163
tests/qemu-iotests/179 | 2 +-
164
tests/qemu-iotests/181 | 2 +-
165
tests/qemu-iotests/182 | 2 +-
166
tests/qemu-iotests/183 | 2 +-
167
tests/qemu-iotests/184 | 2 +-
168
tests/qemu-iotests/185 | 2 +-
169
tests/qemu-iotests/186 | 2 +-
170
tests/qemu-iotests/187 | 2 +-
171
tests/qemu-iotests/188 | 2 +-
172
tests/qemu-iotests/189 | 2 +-
173
tests/qemu-iotests/190 | 2 +-
174
tests/qemu-iotests/191 | 2 +-
175
tests/qemu-iotests/192 | 2 +-
176
tests/qemu-iotests/195 | 2 +-
177
tests/qemu-iotests/197 | 2 +-
178
tests/qemu-iotests/198 | 2 +-
179
tests/qemu-iotests/200 | 2 +-
180
tests/qemu-iotests/201 | 2 +-
181
tests/qemu-iotests/204 | 2 +-
182
tests/qemu-iotests/214 | 2 +-
183
tests/qemu-iotests/215 | 2 +-
184
tests/qemu-iotests/217 | 2 +-
185
tests/qemu-iotests/220 | 2 +-
186
tests/qemu-iotests/221 | 2 +-
187
tests/qemu-iotests/223 | 2 +-
188
tests/qemu-iotests/225 | 2 +-
189
tests/qemu-iotests/226 | 2 +-
190
tests/qemu-iotests/227 | 2 +-
191
tests/qemu-iotests/229 | 2 +-
192
tests/qemu-iotests/231 | 2 +-
193
tests/qemu-iotests/232 | 2 +-
194
tests/qemu-iotests/233 | 2 +-
195
tests/qemu-iotests/check | 2 +-
196
tests/qemu-iotests/common.config | 2 +-
197
tests/qemu-iotests/common.filter | 2 +-
198
tests/qemu-iotests/common.nbd | 2 +-
199
tests/qemu-iotests/common.pattern | 2 +-
200
tests/qemu-iotests/common.qemu | 2 +-
201
tests/qemu-iotests/common.rc | 2 +-
202
tests/qemu-iotests/common.tls | 2 +-
203
185 files changed, 185 insertions(+), 185 deletions(-)
204
205
diff --git a/tests/qemu-iotests/001 b/tests/qemu-iotests/001
206
index XXXXXXX..XXXXXXX 100755
207
--- a/tests/qemu-iotests/001
208
+++ b/tests/qemu-iotests/001
209
@@ -XXX,XX +XXX,XX @@
210
-#!/bin/bash
211
+#!/usr/bin/env bash
212
#
213
# Test simple read/write using plain bdrv_read/bdrv_write
214
#
215
diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002
216
index XXXXXXX..XXXXXXX 100755
217
--- a/tests/qemu-iotests/002
218
+++ b/tests/qemu-iotests/002
219
@@ -XXX,XX +XXX,XX @@
220
-#!/bin/bash
221
+#!/usr/bin/env bash
222
#
223
# Test simple read/write using plain bdrv_pread/bdrv_pwrite
224
#
225
diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003
226
index XXXXXXX..XXXXXXX 100755
227
--- a/tests/qemu-iotests/003
228
+++ b/tests/qemu-iotests/003
229
@@ -XXX,XX +XXX,XX @@
230
-#!/bin/bash
231
+#!/usr/bin/env bash
232
#
233
# Test simple read/write using bdrv_aio_readv/bdrv_aio_writev
234
#
235
diff --git a/tests/qemu-iotests/004 b/tests/qemu-iotests/004
236
index XXXXXXX..XXXXXXX 100755
237
--- a/tests/qemu-iotests/004
238
+++ b/tests/qemu-iotests/004
239
@@ -XXX,XX +XXX,XX @@
240
-#!/bin/bash
241
+#!/usr/bin/env bash
242
#
243
# Make sure we can't read and write outside of the image size.
244
#
245
diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005
246
index XXXXXXX..XXXXXXX 100755
247
--- a/tests/qemu-iotests/005
248
+++ b/tests/qemu-iotests/005
249
@@ -XXX,XX +XXX,XX @@
250
-#!/bin/bash
251
+#!/usr/bin/env bash
252
#
253
# Make sure qemu-img can create 5TB images
254
#
255
diff --git a/tests/qemu-iotests/007 b/tests/qemu-iotests/007
256
index XXXXXXX..XXXXXXX 100755
257
--- a/tests/qemu-iotests/007
258
+++ b/tests/qemu-iotests/007
259
@@ -XXX,XX +XXX,XX @@
260
-#!/bin/bash
261
+#!/usr/bin/env bash
262
#
263
# Check for one possible case of qcow2 refcount corruption.
264
#
265
diff --git a/tests/qemu-iotests/008 b/tests/qemu-iotests/008
266
index XXXXXXX..XXXXXXX 100755
267
--- a/tests/qemu-iotests/008
268
+++ b/tests/qemu-iotests/008
269
@@ -XXX,XX +XXX,XX @@
270
-#!/bin/bash
271
+#!/usr/bin/env bash
272
#
273
# Test simple asynchronous read/write operations.
274
#
275
diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009
276
index XXXXXXX..XXXXXXX 100755
277
--- a/tests/qemu-iotests/009
278
+++ b/tests/qemu-iotests/009
279
@@ -XXX,XX +XXX,XX @@
280
-#!/bin/bash
281
+#!/usr/bin/env bash
282
#
283
# Nolan I qcow2 corruption - incorrectly reports free clusters
284
#
285
diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010
286
index XXXXXXX..XXXXXXX 100755
287
--- a/tests/qemu-iotests/010
288
+++ b/tests/qemu-iotests/010
289
@@ -XXX,XX +XXX,XX @@
290
-#!/bin/bash
291
+#!/usr/bin/env bash
292
#
293
# Nolan II qcow2 corruption - wrong used cluster
294
#
295
diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011
296
index XXXXXXX..XXXXXXX 100755
297
--- a/tests/qemu-iotests/011
298
+++ b/tests/qemu-iotests/011
299
@@ -XXX,XX +XXX,XX @@
300
-#!/bin/bash
301
+#!/usr/bin/env bash
302
#
303
# Test for AIO allocation on the same cluster
304
#
305
diff --git a/tests/qemu-iotests/012 b/tests/qemu-iotests/012
306
index XXXXXXX..XXXXXXX 100755
307
--- a/tests/qemu-iotests/012
308
+++ b/tests/qemu-iotests/012
309
@@ -XXX,XX +XXX,XX @@
310
-#!/bin/bash
311
+#!/usr/bin/env bash
312
#
313
# Make sure we can open read-only images
314
#
315
diff --git a/tests/qemu-iotests/013 b/tests/qemu-iotests/013
316
index XXXXXXX..XXXXXXX 100755
317
--- a/tests/qemu-iotests/013
318
+++ b/tests/qemu-iotests/013
319
@@ -XXX,XX +XXX,XX @@
320
-#!/bin/bash
321
+#!/usr/bin/env bash
322
#
323
# qcow2 pattern test, empty and compressed image - 4k cluster patterns
324
#
325
diff --git a/tests/qemu-iotests/014 b/tests/qemu-iotests/014
326
index XXXXXXX..XXXXXXX 100755
327
--- a/tests/qemu-iotests/014
328
+++ b/tests/qemu-iotests/014
329
@@ -XXX,XX +XXX,XX @@
330
-#!/bin/bash
331
+#!/usr/bin/env bash
332
#
333
# qcow2 pattern test, complex patterns including compression and snapshots
334
# Using patterns for 4k cluster size.
335
diff --git a/tests/qemu-iotests/015 b/tests/qemu-iotests/015
336
index XXXXXXX..XXXXXXX 100755
337
--- a/tests/qemu-iotests/015
338
+++ b/tests/qemu-iotests/015
339
@@ -XXX,XX +XXX,XX @@
340
-#!/bin/bash
341
+#!/usr/bin/env bash
342
#
343
# Combined test to grow the refcount table and test snapshots.
344
#
345
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
346
index XXXXXXX..XXXXXXX 100755
347
--- a/tests/qemu-iotests/017
348
+++ b/tests/qemu-iotests/017
349
@@ -XXX,XX +XXX,XX @@
350
-#!/bin/bash
351
+#!/usr/bin/env bash
352
#
353
# Simple backing file reads
354
#
355
diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018
356
index XXXXXXX..XXXXXXX 100755
357
--- a/tests/qemu-iotests/018
358
+++ b/tests/qemu-iotests/018
359
@@ -XXX,XX +XXX,XX @@
360
-#!/bin/bash
361
+#!/usr/bin/env bash
362
#
363
# Merge backing file into test image when converting the image
364
#
365
diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
366
index XXXXXXX..XXXXXXX 100755
367
--- a/tests/qemu-iotests/019
368
+++ b/tests/qemu-iotests/019
369
@@ -XXX,XX +XXX,XX @@
370
-#!/bin/bash
371
+#!/usr/bin/env bash
372
#
373
# When using a backing file for the output image in qemu-img convert,
374
# the backing file clusters must not copied. The data must still be
375
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
376
index XXXXXXX..XXXXXXX 100755
377
--- a/tests/qemu-iotests/020
378
+++ b/tests/qemu-iotests/020
379
@@ -XXX,XX +XXX,XX @@
380
-#!/bin/bash
381
+#!/usr/bin/env bash
382
#
383
# Commit changes to backing file
384
#
385
diff --git a/tests/qemu-iotests/021 b/tests/qemu-iotests/021
386
index XXXXXXX..XXXXXXX 100755
387
--- a/tests/qemu-iotests/021
388
+++ b/tests/qemu-iotests/021
389
@@ -XXX,XX +XXX,XX @@
390
-#!/bin/bash
391
+#!/usr/bin/env bash
392
#
393
# Test handling of invalid patterns arguments to qemu-io
394
#
395
diff --git a/tests/qemu-iotests/022 b/tests/qemu-iotests/022
396
index XXXXXXX..XXXXXXX 100755
397
--- a/tests/qemu-iotests/022
398
+++ b/tests/qemu-iotests/022
399
@@ -XXX,XX +XXX,XX @@
400
-#!/bin/bash
401
+#!/usr/bin/env bash
402
#
403
# Test bdrv_load/save_vmstate using the usual patterns
404
#
405
diff --git a/tests/qemu-iotests/023 b/tests/qemu-iotests/023
406
index XXXXXXX..XXXXXXX 100755
407
--- a/tests/qemu-iotests/023
408
+++ b/tests/qemu-iotests/023
409
@@ -XXX,XX +XXX,XX @@
410
-#!/bin/bash
411
+#!/usr/bin/env bash
412
#
413
# qcow2 pattern test with various cluster sizes
414
#
415
diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024
416
index XXXXXXX..XXXXXXX 100755
417
--- a/tests/qemu-iotests/024
418
+++ b/tests/qemu-iotests/024
419
@@ -XXX,XX +XXX,XX @@
420
-#!/bin/bash
421
+#!/usr/bin/env bash
422
#
423
# Rebasing COW images
424
#
425
diff --git a/tests/qemu-iotests/025 b/tests/qemu-iotests/025
426
index XXXXXXX..XXXXXXX 100755
427
--- a/tests/qemu-iotests/025
428
+++ b/tests/qemu-iotests/025
429
@@ -XXX,XX +XXX,XX @@
430
-#!/bin/bash
431
+#!/usr/bin/env bash
432
#
433
# Resizing images
434
#
435
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
436
index XXXXXXX..XXXXXXX 100755
437
--- a/tests/qemu-iotests/026
438
+++ b/tests/qemu-iotests/026
439
@@ -XXX,XX +XXX,XX @@
440
-#!/bin/bash
441
+#!/usr/bin/env bash
442
#
443
# qcow2 error path testing
444
#
445
diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027
446
index XXXXXXX..XXXXXXX 100755
447
--- a/tests/qemu-iotests/027
448
+++ b/tests/qemu-iotests/027
449
@@ -XXX,XX +XXX,XX @@
450
-#!/bin/bash
451
+#!/usr/bin/env bash
452
#
453
# Test that sub-cluster allocating writes zero the rest of the cluster
454
#
455
diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028
456
index XXXXXXX..XXXXXXX 100755
457
--- a/tests/qemu-iotests/028
458
+++ b/tests/qemu-iotests/028
459
@@ -XXX,XX +XXX,XX @@
460
-#!/bin/bash
461
+#!/usr/bin/env bash
462
#
463
# Test that backing files can be smaller than the image
464
#
465
diff --git a/tests/qemu-iotests/029 b/tests/qemu-iotests/029
466
index XXXXXXX..XXXXXXX 100755
467
--- a/tests/qemu-iotests/029
468
+++ b/tests/qemu-iotests/029
469
@@ -XXX,XX +XXX,XX @@
470
-#!/bin/bash
471
+#!/usr/bin/env bash
472
#
473
# qcow2 internal snapshots/VM state tests
474
#
475
diff --git a/tests/qemu-iotests/031 b/tests/qemu-iotests/031
476
index XXXXXXX..XXXXXXX 100755
477
--- a/tests/qemu-iotests/031
478
+++ b/tests/qemu-iotests/031
479
@@ -XXX,XX +XXX,XX @@
480
-#!/bin/bash
481
+#!/usr/bin/env bash
482
#
483
# Test that all qcow2 header extensions survive a header rewrite
484
#
485
diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032
486
index XXXXXXX..XXXXXXX 100755
487
--- a/tests/qemu-iotests/032
488
+++ b/tests/qemu-iotests/032
489
@@ -XXX,XX +XXX,XX @@
490
-#!/bin/bash
491
+#!/usr/bin/env bash
492
#
493
# Test that AIO requests are drained before an image is closed. This used
494
# to segfault because the request coroutine kept running even after the
495
diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033
496
index XXXXXXX..XXXXXXX 100755
497
--- a/tests/qemu-iotests/033
498
+++ b/tests/qemu-iotests/033
499
@@ -XXX,XX +XXX,XX @@
500
-#!/bin/bash
501
+#!/usr/bin/env bash
502
#
503
# Test aligned and misaligned write zeroes operations.
504
#
505
diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034
506
index XXXXXXX..XXXXXXX 100755
507
--- a/tests/qemu-iotests/034
508
+++ b/tests/qemu-iotests/034
509
@@ -XXX,XX +XXX,XX @@
510
-#!/bin/bash
511
+#!/usr/bin/env bash
512
#
513
# Test bdrv_pwrite_zeroes with backing files (see also 154)
514
#
515
diff --git a/tests/qemu-iotests/035 b/tests/qemu-iotests/035
516
index XXXXXXX..XXXXXXX 100755
517
--- a/tests/qemu-iotests/035
518
+++ b/tests/qemu-iotests/035
519
@@ -XXX,XX +XXX,XX @@
520
-#!/bin/bash
521
+#!/usr/bin/env bash
522
#
523
# Let a few AIO requests run in parallel and have them access different L2
524
# tables so that the cache has a chance to get used up.
525
diff --git a/tests/qemu-iotests/036 b/tests/qemu-iotests/036
526
index XXXXXXX..XXXXXXX 100755
527
--- a/tests/qemu-iotests/036
528
+++ b/tests/qemu-iotests/036
529
@@ -XXX,XX +XXX,XX @@
530
-#!/bin/bash
531
+#!/usr/bin/env bash
532
#
533
# Test qcow2 feature bits
534
#
535
diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037
536
index XXXXXXX..XXXXXXX 100755
537
--- a/tests/qemu-iotests/037
538
+++ b/tests/qemu-iotests/037
539
@@ -XXX,XX +XXX,XX @@
540
-#!/bin/bash
541
+#!/usr/bin/env bash
542
#
543
# Test COW from backing files
544
#
545
diff --git a/tests/qemu-iotests/038 b/tests/qemu-iotests/038
546
index XXXXXXX..XXXXXXX 100755
547
--- a/tests/qemu-iotests/038
548
+++ b/tests/qemu-iotests/038
549
@@ -XXX,XX +XXX,XX @@
550
-#!/bin/bash
551
+#!/usr/bin/env bash
552
#
553
# Test COW from backing files with AIO
554
#
555
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
556
index XXXXXXX..XXXXXXX 100755
557
--- a/tests/qemu-iotests/039
558
+++ b/tests/qemu-iotests/039
559
@@ -XXX,XX +XXX,XX @@
560
-#!/bin/bash
561
+#!/usr/bin/env bash
562
#
563
# Test qcow2 lazy refcounts
564
#
565
diff --git a/tests/qemu-iotests/042 b/tests/qemu-iotests/042
566
index XXXXXXX..XXXXXXX 100755
567
--- a/tests/qemu-iotests/042
568
+++ b/tests/qemu-iotests/042
569
@@ -XXX,XX +XXX,XX @@
570
-#!/bin/bash
571
+#!/usr/bin/env bash
572
#
573
# Test qemu-img operation on zero size images
574
#
575
diff --git a/tests/qemu-iotests/043 b/tests/qemu-iotests/043
576
index XXXXXXX..XXXXXXX 100755
577
--- a/tests/qemu-iotests/043
578
+++ b/tests/qemu-iotests/043
579
@@ -XXX,XX +XXX,XX @@
580
-#!/bin/bash
581
+#!/usr/bin/env bash
582
#
583
# Test that qemu-img info --backing-chain detects infinite loops
584
#
585
diff --git a/tests/qemu-iotests/046 b/tests/qemu-iotests/046
586
index XXXXXXX..XXXXXXX 100755
587
--- a/tests/qemu-iotests/046
588
+++ b/tests/qemu-iotests/046
589
@@ -XXX,XX +XXX,XX @@
590
-#!/bin/bash
591
+#!/usr/bin/env bash
592
#
593
# Test concurrent cluster allocations
594
#
595
diff --git a/tests/qemu-iotests/047 b/tests/qemu-iotests/047
596
index XXXXXXX..XXXXXXX 100755
597
--- a/tests/qemu-iotests/047
598
+++ b/tests/qemu-iotests/047
599
@@ -XXX,XX +XXX,XX @@
600
-#!/bin/bash
601
+#!/usr/bin/env bash
602
#
603
# Regression test for commit b7ab0fea (which was a corruption fix,
604
# despite the commit message claiming otherwise)
605
diff --git a/tests/qemu-iotests/048 b/tests/qemu-iotests/048
606
index XXXXXXX..XXXXXXX 100755
607
--- a/tests/qemu-iotests/048
608
+++ b/tests/qemu-iotests/048
609
@@ -XXX,XX +XXX,XX @@
610
-#!/bin/bash
611
+#!/usr/bin/env bash
612
##
613
## qemu-img compare test
614
##
615
diff --git a/tests/qemu-iotests/049 b/tests/qemu-iotests/049
616
index XXXXXXX..XXXXXXX 100755
617
--- a/tests/qemu-iotests/049
618
+++ b/tests/qemu-iotests/049
619
@@ -XXX,XX +XXX,XX @@
620
-#!/bin/bash
621
+#!/usr/bin/env bash
622
#
623
# Check qemu-img option parsing
624
#
625
diff --git a/tests/qemu-iotests/050 b/tests/qemu-iotests/050
626
index XXXXXXX..XXXXXXX 100755
627
--- a/tests/qemu-iotests/050
628
+++ b/tests/qemu-iotests/050
629
@@ -XXX,XX +XXX,XX @@
630
-#!/bin/bash
631
+#!/usr/bin/env bash
632
#
633
# Test qemu-img rebase with zero clusters
634
#
635
diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051
636
index XXXXXXX..XXXXXXX 100755
637
--- a/tests/qemu-iotests/051
638
+++ b/tests/qemu-iotests/051
639
@@ -XXX,XX +XXX,XX @@
640
-#!/bin/bash
641
+#!/usr/bin/env bash
642
#
643
# Test command line configuration of block devices and driver-specific options
644
#
645
diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052
646
index XXXXXXX..XXXXXXX 100755
647
--- a/tests/qemu-iotests/052
648
+++ b/tests/qemu-iotests/052
649
@@ -XXX,XX +XXX,XX @@
650
-#!/bin/bash
651
+#!/usr/bin/env bash
652
#
653
# Test bdrv_read/bdrv_write using BDRV_O_SNAPSHOT
654
#
655
diff --git a/tests/qemu-iotests/053 b/tests/qemu-iotests/053
656
index XXXXXXX..XXXXXXX 100755
657
--- a/tests/qemu-iotests/053
658
+++ b/tests/qemu-iotests/053
659
@@ -XXX,XX +XXX,XX @@
660
-#!/bin/bash
661
+#!/usr/bin/env bash
662
#
663
# Test qemu-img convert when image length is not a multiple of cluster size
664
#
665
diff --git a/tests/qemu-iotests/054 b/tests/qemu-iotests/054
666
index XXXXXXX..XXXXXXX 100755
667
--- a/tests/qemu-iotests/054
668
+++ b/tests/qemu-iotests/054
669
@@ -XXX,XX +XXX,XX @@
670
-#!/bin/bash
671
+#!/usr/bin/env bash
672
#
673
# Test huge qcow2 images
674
#
675
diff --git a/tests/qemu-iotests/058 b/tests/qemu-iotests/058
676
index XXXXXXX..XXXXXXX 100755
677
--- a/tests/qemu-iotests/058
678
+++ b/tests/qemu-iotests/058
679
@@ -XXX,XX +XXX,XX @@
680
-#!/bin/bash
681
+#!/usr/bin/env bash
682
#
683
# Test export internal snapshot by qemu-nbd, convert it by qemu-img.
684
#
685
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
686
index XXXXXXX..XXXXXXX 100755
687
--- a/tests/qemu-iotests/059
688
+++ b/tests/qemu-iotests/059
689
@@ -XXX,XX +XXX,XX @@
690
-#!/bin/bash
691
+#!/usr/bin/env bash
692
#
693
# Test case for vmdk
694
#
695
diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060
696
index XXXXXXX..XXXXXXX 100755
697
--- a/tests/qemu-iotests/060
698
+++ b/tests/qemu-iotests/060
699
@@ -XXX,XX +XXX,XX @@
700
-#!/bin/bash
701
+#!/usr/bin/env bash
702
#
703
# Test case for image corruption (overlapping data structures) in qcow2
704
#
705
diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061
706
index XXXXXXX..XXXXXXX 100755
707
--- a/tests/qemu-iotests/061
708
+++ b/tests/qemu-iotests/061
709
@@ -XXX,XX +XXX,XX @@
710
-#!/bin/bash
711
+#!/usr/bin/env bash
712
#
713
# Test case for image option amendment in qcow2.
714
#
715
diff --git a/tests/qemu-iotests/062 b/tests/qemu-iotests/062
716
index XXXXXXX..XXXXXXX 100755
717
--- a/tests/qemu-iotests/062
718
+++ b/tests/qemu-iotests/062
719
@@ -XXX,XX +XXX,XX @@
720
-#!/bin/bash
721
+#!/usr/bin/env bash
722
#
723
# Test case for snapshotting images with unallocated zero clusters in
724
# qcow2
725
diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
726
index XXXXXXX..XXXXXXX 100755
727
--- a/tests/qemu-iotests/063
728
+++ b/tests/qemu-iotests/063
729
@@ -XXX,XX +XXX,XX @@
730
-#!/bin/bash
731
+#!/usr/bin/env bash
732
#
733
# test of qemu-img convert -n - convert without creation
734
#
735
diff --git a/tests/qemu-iotests/064 b/tests/qemu-iotests/064
736
index XXXXXXX..XXXXXXX 100755
737
--- a/tests/qemu-iotests/064
738
+++ b/tests/qemu-iotests/064
739
@@ -XXX,XX +XXX,XX @@
740
-#!/bin/bash
741
+#!/usr/bin/env bash
742
#
743
# Test VHDX read/write from a sample image created with Hyper-V
744
#
745
diff --git a/tests/qemu-iotests/066 b/tests/qemu-iotests/066
746
index XXXXXXX..XXXXXXX 100755
747
--- a/tests/qemu-iotests/066
748
+++ b/tests/qemu-iotests/066
749
@@ -XXX,XX +XXX,XX @@
750
-#!/bin/bash
751
+#!/usr/bin/env bash
752
#
753
# Test case for preallocated zero clusters in qcow2
754
#
755
diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067
756
index XXXXXXX..XXXXXXX 100755
757
--- a/tests/qemu-iotests/067
758
+++ b/tests/qemu-iotests/067
759
@@ -XXX,XX +XXX,XX @@
760
-#!/bin/bash
761
+#!/usr/bin/env bash
762
#
763
# Test automatic deletion of BDSes created by -drive/drive_add
764
#
765
diff --git a/tests/qemu-iotests/068 b/tests/qemu-iotests/068
766
index XXXXXXX..XXXXXXX 100755
767
--- a/tests/qemu-iotests/068
768
+++ b/tests/qemu-iotests/068
769
@@ -XXX,XX +XXX,XX @@
770
-#!/bin/bash
771
+#!/usr/bin/env bash
772
#
773
# Test case for loading a saved VM state from a qcow2 image
774
#
775
diff --git a/tests/qemu-iotests/069 b/tests/qemu-iotests/069
776
index XXXXXXX..XXXXXXX 100755
777
--- a/tests/qemu-iotests/069
778
+++ b/tests/qemu-iotests/069
779
@@ -XXX,XX +XXX,XX @@
780
-#!/bin/bash
781
+#!/usr/bin/env bash
782
#
783
# Test case for deleting a backing file
784
#
785
diff --git a/tests/qemu-iotests/070 b/tests/qemu-iotests/070
786
index XXXXXXX..XXXXXXX 100755
787
--- a/tests/qemu-iotests/070
788
+++ b/tests/qemu-iotests/070
789
@@ -XXX,XX +XXX,XX @@
790
-#!/bin/bash
791
+#!/usr/bin/env bash
792
#
793
# Test VHDX log replay from an image with a journal that needs to be
794
# replayed
795
diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071
796
index XXXXXXX..XXXXXXX 100755
797
--- a/tests/qemu-iotests/071
798
+++ b/tests/qemu-iotests/071
799
@@ -XXX,XX +XXX,XX @@
800
-#!/bin/bash
801
+#!/usr/bin/env bash
802
#
803
# Test case for the QMP blkdebug and blkverify interfaces
804
#
805
diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072
806
index XXXXXXX..XXXXXXX 100755
807
--- a/tests/qemu-iotests/072
808
+++ b/tests/qemu-iotests/072
809
@@ -XXX,XX +XXX,XX @@
810
-#!/bin/bash
811
+#!/usr/bin/env bash
812
#
813
# Test case for nested image formats
814
#
815
diff --git a/tests/qemu-iotests/073 b/tests/qemu-iotests/073
816
index XXXXXXX..XXXXXXX 100755
817
--- a/tests/qemu-iotests/073
818
+++ b/tests/qemu-iotests/073
819
@@ -XXX,XX +XXX,XX @@
820
-#!/bin/bash
821
+#!/usr/bin/env bash
822
#
823
# Test count_contiguous_clusters in qcow2
824
#
825
diff --git a/tests/qemu-iotests/074 b/tests/qemu-iotests/074
826
index XXXXXXX..XXXXXXX 100755
827
--- a/tests/qemu-iotests/074
828
+++ b/tests/qemu-iotests/074
829
@@ -XXX,XX +XXX,XX @@
830
-#!/bin/bash
831
+#!/usr/bin/env bash
832
##
833
## qemu-img compare test (qcow2 only ones)
834
##
835
diff --git a/tests/qemu-iotests/075 b/tests/qemu-iotests/075
836
index XXXXXXX..XXXXXXX 100755
837
--- a/tests/qemu-iotests/075
838
+++ b/tests/qemu-iotests/075
839
@@ -XXX,XX +XXX,XX @@
840
-#!/bin/bash
841
+#!/usr/bin/env bash
842
#
843
# cloop format input validation tests
844
#
845
diff --git a/tests/qemu-iotests/076 b/tests/qemu-iotests/076
846
index XXXXXXX..XXXXXXX 100755
847
--- a/tests/qemu-iotests/076
848
+++ b/tests/qemu-iotests/076
849
@@ -XXX,XX +XXX,XX @@
850
-#!/bin/bash
851
+#!/usr/bin/env bash
852
#
853
# parallels format input validation tests
854
#
855
diff --git a/tests/qemu-iotests/077 b/tests/qemu-iotests/077
856
index XXXXXXX..XXXXXXX 100755
857
--- a/tests/qemu-iotests/077
858
+++ b/tests/qemu-iotests/077
859
@@ -XXX,XX +XXX,XX @@
860
-#!/bin/bash
861
+#!/usr/bin/env bash
862
#
863
# Test concurrent pread/pwrite
864
#
865
diff --git a/tests/qemu-iotests/078 b/tests/qemu-iotests/078
866
index XXXXXXX..XXXXXXX 100755
867
--- a/tests/qemu-iotests/078
868
+++ b/tests/qemu-iotests/078
869
@@ -XXX,XX +XXX,XX @@
870
-#!/bin/bash
871
+#!/usr/bin/env bash
872
#
873
# bochs format input validation tests
874
#
875
diff --git a/tests/qemu-iotests/079 b/tests/qemu-iotests/079
876
index XXXXXXX..XXXXXXX 100755
877
--- a/tests/qemu-iotests/079
878
+++ b/tests/qemu-iotests/079
879
@@ -XXX,XX +XXX,XX @@
880
-#!/bin/bash
881
+#!/usr/bin/env bash
882
#
883
# Test qcow2 preallocation with different cluster_sizes
884
#
885
diff --git a/tests/qemu-iotests/080 b/tests/qemu-iotests/080
886
index XXXXXXX..XXXXXXX 100755
887
--- a/tests/qemu-iotests/080
888
+++ b/tests/qemu-iotests/080
889
@@ -XXX,XX +XXX,XX @@
890
-#!/bin/bash
891
+#!/usr/bin/env bash
892
#
893
# qcow2 format input validation tests
894
#
895
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
896
index XXXXXXX..XXXXXXX 100755
897
--- a/tests/qemu-iotests/081
898
+++ b/tests/qemu-iotests/081
899
@@ -XXX,XX +XXX,XX @@
900
-#!/bin/bash
901
+#!/usr/bin/env bash
902
#
903
# Test Quorum block driver
904
#
905
diff --git a/tests/qemu-iotests/082 b/tests/qemu-iotests/082
906
index XXXXXXX..XXXXXXX 100755
907
--- a/tests/qemu-iotests/082
908
+++ b/tests/qemu-iotests/082
909
@@ -XXX,XX +XXX,XX @@
910
-#!/bin/bash
911
+#!/usr/bin/env bash
912
#
913
# Test qemu-img command line parsing
914
#
915
diff --git a/tests/qemu-iotests/083 b/tests/qemu-iotests/083
916
index XXXXXXX..XXXXXXX 100755
917
--- a/tests/qemu-iotests/083
918
+++ b/tests/qemu-iotests/083
919
@@ -XXX,XX +XXX,XX @@
920
-#!/bin/bash
921
+#!/usr/bin/env bash
922
#
923
# Test NBD client unexpected disconnect
924
#
925
diff --git a/tests/qemu-iotests/084 b/tests/qemu-iotests/084
926
index XXXXXXX..XXXXXXX 100755
927
--- a/tests/qemu-iotests/084
928
+++ b/tests/qemu-iotests/084
929
@@ -XXX,XX +XXX,XX @@
930
-#!/bin/bash
931
+#!/usr/bin/env bash
932
#
933
# Test case for VDI header corruption; image too large, and too many blocks.
934
# Also simple test for creating dynamic and static VDI images.
935
diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085
936
index XXXXXXX..XXXXXXX 100755
937
--- a/tests/qemu-iotests/085
938
+++ b/tests/qemu-iotests/085
939
@@ -XXX,XX +XXX,XX @@
940
-#!/bin/bash
941
+#!/usr/bin/env bash
942
#
943
# Live snapshot tests
944
#
945
diff --git a/tests/qemu-iotests/086 b/tests/qemu-iotests/086
946
index XXXXXXX..XXXXXXX 100755
947
--- a/tests/qemu-iotests/086
948
+++ b/tests/qemu-iotests/086
949
@@ -XXX,XX +XXX,XX @@
950
-#!/bin/bash
951
+#!/usr/bin/env bash
952
#
953
# Test qemu-img progress output
954
#
955
diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087
956
index XXXXXXX..XXXXXXX 100755
957
--- a/tests/qemu-iotests/087
958
+++ b/tests/qemu-iotests/087
959
@@ -XXX,XX +XXX,XX @@
960
-#!/bin/bash
961
+#!/usr/bin/env bash
962
#
963
# Test unsupported blockdev-add cases
964
#
965
diff --git a/tests/qemu-iotests/088 b/tests/qemu-iotests/088
966
index XXXXXXX..XXXXXXX 100755
967
--- a/tests/qemu-iotests/088
968
+++ b/tests/qemu-iotests/088
969
@@ -XXX,XX +XXX,XX @@
970
-#!/bin/bash
971
+#!/usr/bin/env bash
972
#
973
# vpc (VHD) format input validation tests
974
#
975
diff --git a/tests/qemu-iotests/089 b/tests/qemu-iotests/089
976
index XXXXXXX..XXXXXXX 100755
977
--- a/tests/qemu-iotests/089
978
+++ b/tests/qemu-iotests/089
979
@@ -XXX,XX +XXX,XX @@
980
-#!/bin/bash
981
+#!/usr/bin/env bash
982
#
983
# Test case for support of JSON filenames
984
#
985
diff --git a/tests/qemu-iotests/090 b/tests/qemu-iotests/090
986
index XXXXXXX..XXXXXXX 100755
987
--- a/tests/qemu-iotests/090
988
+++ b/tests/qemu-iotests/090
989
@@ -XXX,XX +XXX,XX @@
990
-#!/bin/bash
991
+#!/usr/bin/env bash
992
#
993
# Test for discarding compressed clusters on qcow2 images
994
#
995
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
996
index XXXXXXX..XXXXXXX 100755
997
--- a/tests/qemu-iotests/091
998
+++ b/tests/qemu-iotests/091
999
@@ -XXX,XX +XXX,XX @@
1000
-#!/bin/bash
1001
+#!/usr/bin/env bash
1002
#
1003
# Live migration test
1004
#
1005
diff --git a/tests/qemu-iotests/092 b/tests/qemu-iotests/092
1006
index XXXXXXX..XXXXXXX 100755
1007
--- a/tests/qemu-iotests/092
1008
+++ b/tests/qemu-iotests/092
1009
@@ -XXX,XX +XXX,XX @@
1010
-#!/bin/bash
1011
+#!/usr/bin/env bash
1012
#
1013
# qcow1 format input validation tests
1014
#
1015
diff --git a/tests/qemu-iotests/094 b/tests/qemu-iotests/094
1016
index XXXXXXX..XXXXXXX 100755
1017
--- a/tests/qemu-iotests/094
1018
+++ b/tests/qemu-iotests/094
1019
@@ -XXX,XX +XXX,XX @@
1020
-#!/bin/bash
1021
+#!/usr/bin/env bash
1022
#
1023
# Test case for drive-mirror to NBD
1024
#
1025
diff --git a/tests/qemu-iotests/095 b/tests/qemu-iotests/095
1026
index XXXXXXX..XXXXXXX 100755
1027
--- a/tests/qemu-iotests/095
1028
+++ b/tests/qemu-iotests/095
1029
@@ -XXX,XX +XXX,XX @@
1030
-#!/bin/bash
1031
+#!/usr/bin/env bash
1032
#
1033
# Test for commit of larger active layer
1034
#
1035
diff --git a/tests/qemu-iotests/097 b/tests/qemu-iotests/097
1036
index XXXXXXX..XXXXXXX 100755
1037
--- a/tests/qemu-iotests/097
1038
+++ b/tests/qemu-iotests/097
1039
@@ -XXX,XX +XXX,XX @@
1040
-#!/bin/bash
1041
+#!/usr/bin/env bash
1042
#
1043
# Commit changes into backing chains and empty the top image if the
1044
# backing image is not explicitly specified
1045
diff --git a/tests/qemu-iotests/098 b/tests/qemu-iotests/098
1046
index XXXXXXX..XXXXXXX 100755
1047
--- a/tests/qemu-iotests/098
1048
+++ b/tests/qemu-iotests/098
1049
@@ -XXX,XX +XXX,XX @@
1050
-#!/bin/bash
1051
+#!/usr/bin/env bash
1052
#
1053
# Test qcow2's bdrv_make_empty for images without internal snapshots
1054
#
1055
diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099
1056
index XXXXXXX..XXXXXXX 100755
1057
--- a/tests/qemu-iotests/099
1058
+++ b/tests/qemu-iotests/099
1059
@@ -XXX,XX +XXX,XX @@
1060
-#!/bin/bash
1061
+#!/usr/bin/env bash
1062
#
1063
# Test valid filenames for blkdebug and blkverify representatively for
1064
# other protocols (such as NBD) when queried
1065
diff --git a/tests/qemu-iotests/101 b/tests/qemu-iotests/101
1066
index XXXXXXX..XXXXXXX 100755
1067
--- a/tests/qemu-iotests/101
1068
+++ b/tests/qemu-iotests/101
1069
@@ -XXX,XX +XXX,XX @@
1070
-#!/bin/bash
1071
+#!/usr/bin/env bash
1072
#
1073
# Test short file I/O
1074
#
1075
diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102
1076
index XXXXXXX..XXXXXXX 100755
1077
--- a/tests/qemu-iotests/102
1078
+++ b/tests/qemu-iotests/102
1079
@@ -XXX,XX +XXX,XX @@
1080
-#!/bin/bash
1081
+#!/usr/bin/env bash
1082
#
1083
# Test case for qemu-io -c map and qemu-img map
1084
#
1085
diff --git a/tests/qemu-iotests/103 b/tests/qemu-iotests/103
1086
index XXXXXXX..XXXXXXX 100755
1087
--- a/tests/qemu-iotests/103
1088
+++ b/tests/qemu-iotests/103
1089
@@ -XXX,XX +XXX,XX @@
1090
-#!/bin/bash
1091
+#!/usr/bin/env bash
1092
#
1093
# Test case for qcow2 metadata cache size specification
1094
#
1095
diff --git a/tests/qemu-iotests/104 b/tests/qemu-iotests/104
1096
index XXXXXXX..XXXXXXX 100755
1097
--- a/tests/qemu-iotests/104
1098
+++ b/tests/qemu-iotests/104
1099
@@ -XXX,XX +XXX,XX @@
1100
-#!/bin/bash
1101
+#!/usr/bin/env bash
1102
#
1103
# Test image creation with aligned and unaligned sizes
1104
#
1105
diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105
1106
index XXXXXXX..XXXXXXX 100755
1107
--- a/tests/qemu-iotests/105
1108
+++ b/tests/qemu-iotests/105
1109
@@ -XXX,XX +XXX,XX @@
1110
-#!/bin/bash
1111
+#!/usr/bin/env bash
1112
#
1113
# Create, read, write big image
1114
#
1115
diff --git a/tests/qemu-iotests/106 b/tests/qemu-iotests/106
1116
index XXXXXXX..XXXXXXX 100755
1117
--- a/tests/qemu-iotests/106
1118
+++ b/tests/qemu-iotests/106
1119
@@ -XXX,XX +XXX,XX @@
1120
-#!/bin/bash
1121
+#!/usr/bin/env bash
1122
#
1123
# Test preallocated resize of raw images
1124
#
1125
diff --git a/tests/qemu-iotests/107 b/tests/qemu-iotests/107
1126
index XXXXXXX..XXXXXXX 100755
1127
--- a/tests/qemu-iotests/107
1128
+++ b/tests/qemu-iotests/107
1129
@@ -XXX,XX +XXX,XX @@
1130
-#!/bin/bash
1131
+#!/usr/bin/env bash
1132
#
1133
# Tests updates of the qcow2 L1 table
1134
#
1135
diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108
1136
index XXXXXXX..XXXXXXX 100755
1137
--- a/tests/qemu-iotests/108
1138
+++ b/tests/qemu-iotests/108
1139
@@ -XXX,XX +XXX,XX @@
1140
-#!/bin/bash
1141
+#!/usr/bin/env bash
1142
#
1143
# Test case for repairing qcow2 images which cannot be repaired using
1144
# the on-disk refcount structures
1145
diff --git a/tests/qemu-iotests/109 b/tests/qemu-iotests/109
1146
index XXXXXXX..XXXXXXX 100755
1147
--- a/tests/qemu-iotests/109
1148
+++ b/tests/qemu-iotests/109
1149
@@ -XXX,XX +XXX,XX @@
1150
-#!/bin/bash
1151
+#!/usr/bin/env bash
1152
#
1153
# Test writing image headers of other formats into raw images
1154
#
1155
diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110
1156
index XXXXXXX..XXXXXXX 100755
1157
--- a/tests/qemu-iotests/110
1158
+++ b/tests/qemu-iotests/110
1159
@@ -XXX,XX +XXX,XX @@
1160
-#!/bin/bash
1161
+#!/usr/bin/env bash
1162
#
1163
# Test case for relative backing file names in complex BDS trees
1164
#
1165
diff --git a/tests/qemu-iotests/111 b/tests/qemu-iotests/111
1166
index XXXXXXX..XXXXXXX 100755
1167
--- a/tests/qemu-iotests/111
1168
+++ b/tests/qemu-iotests/111
1169
@@ -XXX,XX +XXX,XX @@
1170
-#!/bin/bash
1171
+#!/usr/bin/env bash
1172
#
1173
# Test case for non-existing backing file when creating a qcow2 image
1174
# and not specifying the size
1175
diff --git a/tests/qemu-iotests/112 b/tests/qemu-iotests/112
1176
index XXXXXXX..XXXXXXX 100755
1177
--- a/tests/qemu-iotests/112
1178
+++ b/tests/qemu-iotests/112
1179
@@ -XXX,XX +XXX,XX @@
1180
-#!/bin/bash
1181
+#!/usr/bin/env bash
1182
#
1183
# Test cases for different refcount_bits values
1184
#
1185
diff --git a/tests/qemu-iotests/113 b/tests/qemu-iotests/113
1186
index XXXXXXX..XXXXXXX 100755
1187
--- a/tests/qemu-iotests/113
1188
+++ b/tests/qemu-iotests/113
1189
@@ -XXX,XX +XXX,XX @@
1190
-#!/bin/bash
1191
+#!/usr/bin/env bash
1192
#
1193
# Test case for accessing creation options on image formats and
1194
# protocols not supporting image creation
1195
diff --git a/tests/qemu-iotests/114 b/tests/qemu-iotests/114
1196
index XXXXXXX..XXXXXXX 100755
1197
--- a/tests/qemu-iotests/114
1198
+++ b/tests/qemu-iotests/114
1199
@@ -XXX,XX +XXX,XX @@
1200
-#!/bin/bash
1201
+#!/usr/bin/env bash
1202
#
1203
# Test invalid backing file format in qcow2 images
1204
#
1205
diff --git a/tests/qemu-iotests/115 b/tests/qemu-iotests/115
1206
index XXXXXXX..XXXXXXX 100755
1207
--- a/tests/qemu-iotests/115
1208
+++ b/tests/qemu-iotests/115
1209
@@ -XXX,XX +XXX,XX @@
1210
-#!/bin/bash
1211
+#!/usr/bin/env bash
1212
#
1213
# Test case for non-self-referential qcow2 refcount blocks
1214
#
1215
diff --git a/tests/qemu-iotests/116 b/tests/qemu-iotests/116
1216
index XXXXXXX..XXXXXXX 100755
1217
--- a/tests/qemu-iotests/116
1218
+++ b/tests/qemu-iotests/116
1219
@@ -XXX,XX +XXX,XX @@
1220
-#!/bin/bash
1221
+#!/usr/bin/env bash
1222
#
1223
# Test error code paths for invalid QED images
1224
#
1225
diff --git a/tests/qemu-iotests/117 b/tests/qemu-iotests/117
1226
index XXXXXXX..XXXXXXX 100755
1227
--- a/tests/qemu-iotests/117
1228
+++ b/tests/qemu-iotests/117
1229
@@ -XXX,XX +XXX,XX @@
1230
-#!/bin/bash
1231
+#!/usr/bin/env bash
1232
#
1233
# Test case for shared BDS between backend trees
1234
#
1235
diff --git a/tests/qemu-iotests/119 b/tests/qemu-iotests/119
1236
index XXXXXXX..XXXXXXX 100755
1237
--- a/tests/qemu-iotests/119
1238
+++ b/tests/qemu-iotests/119
1239
@@ -XXX,XX +XXX,XX @@
1240
-#!/bin/bash
1241
+#!/usr/bin/env bash
1242
#
1243
# NBD test case for overriding BDRV_O_PROTOCOL by explicitly specifying
1244
# a driver
1245
diff --git a/tests/qemu-iotests/120 b/tests/qemu-iotests/120
1246
index XXXXXXX..XXXXXXX 100755
1247
--- a/tests/qemu-iotests/120
1248
+++ b/tests/qemu-iotests/120
1249
@@ -XXX,XX +XXX,XX @@
1250
-#!/bin/bash
1251
+#!/usr/bin/env bash
1252
#
1253
# Non-NBD test cases for overriding BDRV_O_PROTOCOL by explicitly
1254
# specifying a driver
1255
diff --git a/tests/qemu-iotests/121 b/tests/qemu-iotests/121
1256
index XXXXXXX..XXXXXXX 100755
1257
--- a/tests/qemu-iotests/121
1258
+++ b/tests/qemu-iotests/121
1259
@@ -XXX,XX +XXX,XX @@
1260
-#!/bin/bash
1261
+#!/usr/bin/env bash
1262
#
1263
# Test cases for qcow2 refcount table growth
1264
#
1265
diff --git a/tests/qemu-iotests/122 b/tests/qemu-iotests/122
1266
index XXXXXXX..XXXXXXX 100755
1267
--- a/tests/qemu-iotests/122
1268
+++ b/tests/qemu-iotests/122
1269
@@ -XXX,XX +XXX,XX @@
1270
-#!/bin/bash
1271
+#!/usr/bin/env bash
1272
#
1273
# Test some qemu-img convert cases
1274
#
1275
diff --git a/tests/qemu-iotests/123 b/tests/qemu-iotests/123
1276
index XXXXXXX..XXXXXXX 100755
1277
--- a/tests/qemu-iotests/123
1278
+++ b/tests/qemu-iotests/123
1279
@@ -XXX,XX +XXX,XX @@
1280
-#!/bin/bash
1281
+#!/usr/bin/env bash
1282
#
1283
# Test case for qemu-img convert to NBD
1284
#
1285
diff --git a/tests/qemu-iotests/125 b/tests/qemu-iotests/125
1286
index XXXXXXX..XXXXXXX 100755
1287
--- a/tests/qemu-iotests/125
1288
+++ b/tests/qemu-iotests/125
1289
@@ -XXX,XX +XXX,XX @@
1290
-#!/bin/bash
1291
+#!/usr/bin/env bash
1292
#
1293
# Test preallocated growth of qcow2 images
1294
#
1295
diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
1296
index XXXXXXX..XXXXXXX 100755
1297
--- a/tests/qemu-iotests/126
1298
+++ b/tests/qemu-iotests/126
1299
@@ -XXX,XX +XXX,XX @@
1300
-#!/bin/bash
1301
+#!/usr/bin/env bash
1302
#
1303
# Tests handling of colons in filenames (which may be confused with protocol
1304
# prefixes)
1305
diff --git a/tests/qemu-iotests/127 b/tests/qemu-iotests/127
1306
index XXXXXXX..XXXXXXX 100755
1307
--- a/tests/qemu-iotests/127
1308
+++ b/tests/qemu-iotests/127
1309
@@ -XXX,XX +XXX,XX @@
1310
-#!/bin/bash
1311
+#!/usr/bin/env bash
1312
#
1313
# Test case for mirroring with dataplane
1314
#
1315
diff --git a/tests/qemu-iotests/128 b/tests/qemu-iotests/128
1316
index XXXXXXX..XXXXXXX 100755
1317
--- a/tests/qemu-iotests/128
1318
+++ b/tests/qemu-iotests/128
1319
@@ -XXX,XX +XXX,XX @@
1320
-#!/bin/bash
1321
+#!/usr/bin/env bash
1322
#
1323
# Test that opening O_DIRECT succeeds when image file I/O produces EIO
1324
#
1325
diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130
1326
index XXXXXXX..XXXXXXX 100755
1327
--- a/tests/qemu-iotests/130
1328
+++ b/tests/qemu-iotests/130
1329
@@ -XXX,XX +XXX,XX @@
1330
-#!/bin/bash
1331
+#!/usr/bin/env bash
1332
#
1333
# Test that temporary backing file overrides (on the command line or in
1334
# blockdev-add) don't replace the original path stored in the image during
1335
diff --git a/tests/qemu-iotests/131 b/tests/qemu-iotests/131
1336
index XXXXXXX..XXXXXXX 100755
1337
--- a/tests/qemu-iotests/131
1338
+++ b/tests/qemu-iotests/131
1339
@@ -XXX,XX +XXX,XX @@
1340
-#!/bin/bash
1341
+#!/usr/bin/env bash
1342
#
1343
# parallels format validation tests (created by QEMU)
1344
#
1345
diff --git a/tests/qemu-iotests/133 b/tests/qemu-iotests/133
1346
index XXXXXXX..XXXXXXX 100755
1347
--- a/tests/qemu-iotests/133
1348
+++ b/tests/qemu-iotests/133
1349
@@ -XXX,XX +XXX,XX @@
1350
-#!/bin/bash
1351
+#!/usr/bin/env bash
1352
#
1353
# Test for reopen
1354
#
1355
diff --git a/tests/qemu-iotests/134 b/tests/qemu-iotests/134
1356
index XXXXXXX..XXXXXXX 100755
1357
--- a/tests/qemu-iotests/134
1358
+++ b/tests/qemu-iotests/134
1359
@@ -XXX,XX +XXX,XX @@
1360
-#!/bin/bash
1361
+#!/usr/bin/env bash
1362
#
1363
# Test encrypted read/write using plain bdrv_read/bdrv_write
1364
#
1365
diff --git a/tests/qemu-iotests/135 b/tests/qemu-iotests/135
1366
index XXXXXXX..XXXXXXX 100755
1367
--- a/tests/qemu-iotests/135
1368
+++ b/tests/qemu-iotests/135
1369
@@ -XXX,XX +XXX,XX @@
1370
-#!/bin/bash
1371
+#!/usr/bin/env bash
1372
#
1373
# Test VPC open of image with large Max Table Entries value.
1374
#
1375
diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137
1376
index XXXXXXX..XXXXXXX 100755
1377
--- a/tests/qemu-iotests/137
1378
+++ b/tests/qemu-iotests/137
1379
@@ -XXX,XX +XXX,XX @@
1380
-#!/bin/bash
1381
+#!/usr/bin/env bash
1382
#
1383
# Test qcow2 reopen
1384
#
1385
diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138
1386
index XXXXXXX..XXXXXXX 100755
1387
--- a/tests/qemu-iotests/138
1388
+++ b/tests/qemu-iotests/138
1389
@@ -XXX,XX +XXX,XX @@
1390
-#!/bin/bash
1391
+#!/usr/bin/env bash
1392
#
1393
# General test case for qcow2's image check
1394
#
1395
diff --git a/tests/qemu-iotests/140 b/tests/qemu-iotests/140
1396
index XXXXXXX..XXXXXXX 100755
1397
--- a/tests/qemu-iotests/140
1398
+++ b/tests/qemu-iotests/140
1399
@@ -XXX,XX +XXX,XX @@
1400
-#!/bin/bash
1401
+#!/usr/bin/env bash
1402
#
1403
# Test case for ejecting a BlockBackend with an NBD server attached to it
1404
#
1405
diff --git a/tests/qemu-iotests/141 b/tests/qemu-iotests/141
1406
index XXXXXXX..XXXXXXX 100755
1407
--- a/tests/qemu-iotests/141
1408
+++ b/tests/qemu-iotests/141
1409
@@ -XXX,XX +XXX,XX @@
1410
-#!/bin/bash
1411
+#!/usr/bin/env bash
1412
#
1413
# Test case for ejecting BDSs with block jobs still running on them
1414
#
1415
diff --git a/tests/qemu-iotests/142 b/tests/qemu-iotests/142
1416
index XXXXXXX..XXXXXXX 100755
1417
--- a/tests/qemu-iotests/142
1418
+++ b/tests/qemu-iotests/142
1419
@@ -XXX,XX +XXX,XX @@
1420
-#!/bin/bash
1421
+#!/usr/bin/env bash
1422
#
1423
# Test for configuring cache modes of arbitrary nodes (requires O_DIRECT)
1424
#
1425
diff --git a/tests/qemu-iotests/143 b/tests/qemu-iotests/143
1426
index XXXXXXX..XXXXXXX 100755
1427
--- a/tests/qemu-iotests/143
1428
+++ b/tests/qemu-iotests/143
1429
@@ -XXX,XX +XXX,XX @@
1430
-#!/bin/bash
1431
+#!/usr/bin/env bash
1432
#
1433
# Test case for connecting to a non-existing NBD export name
1434
#
1435
diff --git a/tests/qemu-iotests/144 b/tests/qemu-iotests/144
1436
index XXXXXXX..XXXXXXX 100755
1437
--- a/tests/qemu-iotests/144
1438
+++ b/tests/qemu-iotests/144
1439
@@ -XXX,XX +XXX,XX @@
1440
-#!/bin/bash
1441
+#!/usr/bin/env bash
1442
# Check live snapshot, followed by active commit, and another snapshot.
1443
#
1444
# This test is to catch the error case of BZ #1300209:
1445
diff --git a/tests/qemu-iotests/145 b/tests/qemu-iotests/145
1446
index XXXXXXX..XXXXXXX 100755
1447
--- a/tests/qemu-iotests/145
1448
+++ b/tests/qemu-iotests/145
1449
@@ -XXX,XX +XXX,XX @@
1450
-#!/bin/bash
1451
+#!/usr/bin/env bash
1452
#
1453
# Test the combination of -incoming and snapshot=on
1454
#
1455
diff --git a/tests/qemu-iotests/146 b/tests/qemu-iotests/146
1456
index XXXXXXX..XXXXXXX 100755
1457
--- a/tests/qemu-iotests/146
1458
+++ b/tests/qemu-iotests/146
1459
@@ -XXX,XX +XXX,XX @@
1460
-#!/bin/bash
1461
+#!/usr/bin/env bash
1462
#
1463
# Test VHD image format creator detection and override
1464
#
1465
diff --git a/tests/qemu-iotests/150 b/tests/qemu-iotests/150
1466
index XXXXXXX..XXXXXXX 100755
1467
--- a/tests/qemu-iotests/150
1468
+++ b/tests/qemu-iotests/150
1469
@@ -XXX,XX +XXX,XX @@
1470
-#!/bin/bash
1471
+#!/usr/bin/env bash
1472
#
1473
# Test that qemu-img convert -S 0 fully allocates the target image
1474
#
1475
diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153
1476
index XXXXXXX..XXXXXXX 100755
1477
--- a/tests/qemu-iotests/153
1478
+++ b/tests/qemu-iotests/153
1479
@@ -XXX,XX +XXX,XX @@
1480
-#!/bin/bash
1481
+#!/usr/bin/env bash
1482
#
1483
# Test image locking
1484
#
1485
diff --git a/tests/qemu-iotests/154 b/tests/qemu-iotests/154
1486
index XXXXXXX..XXXXXXX 100755
1487
--- a/tests/qemu-iotests/154
1488
+++ b/tests/qemu-iotests/154
1489
@@ -XXX,XX +XXX,XX @@
1490
-#!/bin/bash
1491
+#!/usr/bin/env bash
1492
#
1493
# qcow2 specific bdrv_pwrite_zeroes tests with backing files (complements 034)
1494
#
1495
diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156
1496
index XXXXXXX..XXXXXXX 100755
1497
--- a/tests/qemu-iotests/156
1498
+++ b/tests/qemu-iotests/156
1499
@@ -XXX,XX +XXX,XX @@
1500
-#!/bin/bash
1501
+#!/usr/bin/env bash
1502
#
1503
# Tests oVirt-like storage migration:
1504
# - Create snapshot
1505
diff --git a/tests/qemu-iotests/157 b/tests/qemu-iotests/157
1506
index XXXXXXX..XXXXXXX 100755
1507
--- a/tests/qemu-iotests/157
1508
+++ b/tests/qemu-iotests/157
1509
@@ -XXX,XX +XXX,XX @@
1510
-#!/bin/bash
1511
+#!/usr/bin/env bash
1512
#
1513
# Test command line configuration of block devices with qdev
1514
#
1515
diff --git a/tests/qemu-iotests/158 b/tests/qemu-iotests/158
1516
index XXXXXXX..XXXXXXX 100755
1517
--- a/tests/qemu-iotests/158
1518
+++ b/tests/qemu-iotests/158
1519
@@ -XXX,XX +XXX,XX @@
1520
-#!/bin/bash
1521
+#!/usr/bin/env bash
1522
#
1523
# Test encrypted read/write using backing files
1524
#
1525
diff --git a/tests/qemu-iotests/159 b/tests/qemu-iotests/159
1526
index XXXXXXX..XXXXXXX 100755
1527
--- a/tests/qemu-iotests/159
1528
+++ b/tests/qemu-iotests/159
1529
@@ -XXX,XX +XXX,XX @@
1530
-#! /bin/bash
1531
+#!/usr/bin/env bash
1532
#
1533
# qemu-img dd test with different block sizes
1534
#
1535
diff --git a/tests/qemu-iotests/160 b/tests/qemu-iotests/160
1536
index XXXXXXX..XXXXXXX 100755
1537
--- a/tests/qemu-iotests/160
1538
+++ b/tests/qemu-iotests/160
1539
@@ -XXX,XX +XXX,XX @@
1540
-#! /bin/bash
1541
+#!/usr/bin/env bash
1542
#
1543
# qemu-img dd test for the skip option
1544
#
1545
diff --git a/tests/qemu-iotests/161 b/tests/qemu-iotests/161
1546
index XXXXXXX..XXXXXXX 100755
1547
--- a/tests/qemu-iotests/161
1548
+++ b/tests/qemu-iotests/161
1549
@@ -XXX,XX +XXX,XX @@
1550
-#!/bin/bash
1551
+#!/usr/bin/env bash
1552
#
1553
# Test reopening a backing image after block-stream and block-commit
1554
#
1555
diff --git a/tests/qemu-iotests/162 b/tests/qemu-iotests/162
1556
index XXXXXXX..XXXXXXX 100755
1557
--- a/tests/qemu-iotests/162
1558
+++ b/tests/qemu-iotests/162
1559
@@ -XXX,XX +XXX,XX @@
1560
-#!/bin/bash
1561
+#!/usr/bin/env bash
1562
#
1563
# Test case for specifying runtime options of the wrong type to some
1564
# block drivers
1565
diff --git a/tests/qemu-iotests/170 b/tests/qemu-iotests/170
1566
index XXXXXXX..XXXXXXX 100755
1567
--- a/tests/qemu-iotests/170
1568
+++ b/tests/qemu-iotests/170
1569
@@ -XXX,XX +XXX,XX @@
1570
-#! /bin/bash
1571
+#!/usr/bin/env bash
1572
#
1573
# qemu-img dd test
1574
#
1575
diff --git a/tests/qemu-iotests/171 b/tests/qemu-iotests/171
1576
index XXXXXXX..XXXXXXX 100755
1577
--- a/tests/qemu-iotests/171
1578
+++ b/tests/qemu-iotests/171
1579
@@ -XXX,XX +XXX,XX @@
1580
-#!/bin/bash
1581
+#!/usr/bin/env bash
1582
#
1583
# Test 'offset' and 'size' options of the raw driver. Make sure we can't
1584
# (or can) read and write outside of the image size.
1585
diff --git a/tests/qemu-iotests/172 b/tests/qemu-iotests/172
1586
index XXXXXXX..XXXXXXX 100755
1587
--- a/tests/qemu-iotests/172
1588
+++ b/tests/qemu-iotests/172
1589
@@ -XXX,XX +XXX,XX @@
1590
-#!/bin/bash
1591
+#!/usr/bin/env bash
1592
#
1593
# Test floppy configuration
1594
#
1595
diff --git a/tests/qemu-iotests/173 b/tests/qemu-iotests/173
1596
index XXXXXXX..XXXXXXX 100755
1597
--- a/tests/qemu-iotests/173
1598
+++ b/tests/qemu-iotests/173
1599
@@ -XXX,XX +XXX,XX @@
1600
-#!/bin/bash
1601
+#!/usr/bin/env bash
1602
#
1603
# Test QAPI commands looking up protocol based images with relative
1604
# filename backing strings
1605
diff --git a/tests/qemu-iotests/174 b/tests/qemu-iotests/174
1606
index XXXXXXX..XXXXXXX 100755
1607
--- a/tests/qemu-iotests/174
1608
+++ b/tests/qemu-iotests/174
1609
@@ -XXX,XX +XXX,XX @@
1610
-#!/bin/bash
1611
+#!/usr/bin/env bash
1612
#
1613
# Test that qemu-io fail with non-zero exit code
1614
#
1615
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
1616
index XXXXXXX..XXXXXXX 100755
1617
--- a/tests/qemu-iotests/175
1618
+++ b/tests/qemu-iotests/175
1619
@@ -XXX,XX +XXX,XX @@
1620
-#!/bin/bash
1621
+#!/usr/bin/env bash
1622
#
1623
# Test creating raw image preallocation mode
1624
#
1625
diff --git a/tests/qemu-iotests/176 b/tests/qemu-iotests/176
1626
index XXXXXXX..XXXXXXX 100755
1627
--- a/tests/qemu-iotests/176
1628
+++ b/tests/qemu-iotests/176
1629
@@ -XXX,XX +XXX,XX @@
1630
-#!/bin/bash
1631
+#!/usr/bin/env bash
1632
#
1633
# Commit changes into backing chains and empty the top image if the
1634
# backing image is not explicitly specified.
1635
diff --git a/tests/qemu-iotests/177 b/tests/qemu-iotests/177
1636
index XXXXXXX..XXXXXXX 100755
1637
--- a/tests/qemu-iotests/177
1638
+++ b/tests/qemu-iotests/177
1639
@@ -XXX,XX +XXX,XX @@
1640
-#!/bin/bash
1641
+#!/usr/bin/env bash
1642
#
1643
# Test corner cases with unusual block geometries
1644
#
1645
diff --git a/tests/qemu-iotests/178 b/tests/qemu-iotests/178
1646
index XXXXXXX..XXXXXXX 100755
1647
--- a/tests/qemu-iotests/178
1648
+++ b/tests/qemu-iotests/178
1649
@@ -XXX,XX +XXX,XX @@
1650
-#!/bin/bash
1651
+#!/usr/bin/env bash
1652
#
1653
# qemu-img measure sub-command tests
1654
#
1655
diff --git a/tests/qemu-iotests/179 b/tests/qemu-iotests/179
1656
index XXXXXXX..XXXXXXX 100755
1657
--- a/tests/qemu-iotests/179
1658
+++ b/tests/qemu-iotests/179
1659
@@ -XXX,XX +XXX,XX @@
1660
-#!/bin/bash
1661
+#!/usr/bin/env bash
1662
#
1663
# Test case for write zeroes with unmap
1664
#
1665
diff --git a/tests/qemu-iotests/181 b/tests/qemu-iotests/181
1666
index XXXXXXX..XXXXXXX 100755
1667
--- a/tests/qemu-iotests/181
1668
+++ b/tests/qemu-iotests/181
1669
@@ -XXX,XX +XXX,XX @@
1670
-#!/bin/bash
1671
+#!/usr/bin/env bash
1672
#
1673
# Test postcopy live migration with shared storage
1674
#
1675
diff --git a/tests/qemu-iotests/182 b/tests/qemu-iotests/182
1676
index XXXXXXX..XXXXXXX 100755
1677
--- a/tests/qemu-iotests/182
1678
+++ b/tests/qemu-iotests/182
1679
@@ -XXX,XX +XXX,XX @@
1680
-#!/bin/bash
1681
+#!/usr/bin/env bash
1682
#
1683
# Test image locking for POSIX locks
1684
#
1685
diff --git a/tests/qemu-iotests/183 b/tests/qemu-iotests/183
1686
index XXXXXXX..XXXXXXX 100755
1687
--- a/tests/qemu-iotests/183
1688
+++ b/tests/qemu-iotests/183
1689
@@ -XXX,XX +XXX,XX @@
1690
-#!/bin/bash
1691
+#!/usr/bin/env bash
1692
#
1693
# Test old-style block migration (migrate -b)
1694
#
1695
diff --git a/tests/qemu-iotests/184 b/tests/qemu-iotests/184
1696
index XXXXXXX..XXXXXXX 100755
1697
--- a/tests/qemu-iotests/184
1698
+++ b/tests/qemu-iotests/184
1699
@@ -XXX,XX +XXX,XX @@
1700
-#!/bin/bash
1701
+#!/usr/bin/env bash
1702
#
1703
# Test I/O throttle block filter driver interface
1704
#
1705
diff --git a/tests/qemu-iotests/185 b/tests/qemu-iotests/185
1706
index XXXXXXX..XXXXXXX 100755
1707
--- a/tests/qemu-iotests/185
1708
+++ b/tests/qemu-iotests/185
1709
@@ -XXX,XX +XXX,XX @@
1710
-#!/bin/bash
1711
+#!/usr/bin/env bash
1712
#
1713
# Test exiting qemu while jobs are still running
1714
#
1715
diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186
1716
index XXXXXXX..XXXXXXX 100755
1717
--- a/tests/qemu-iotests/186
1718
+++ b/tests/qemu-iotests/186
1719
@@ -XXX,XX +XXX,XX @@
1720
-#!/bin/bash
1721
+#!/usr/bin/env bash
1722
#
1723
# Test 'info block' with all kinds of configurations
1724
#
1725
diff --git a/tests/qemu-iotests/187 b/tests/qemu-iotests/187
1726
index XXXXXXX..XXXXXXX 100755
1727
--- a/tests/qemu-iotests/187
1728
+++ b/tests/qemu-iotests/187
1729
@@ -XXX,XX +XXX,XX @@
1730
-#!/bin/bash
1731
+#!/usr/bin/env bash
1732
#
1733
# Test switching between read-only and read-write
1734
#
1735
diff --git a/tests/qemu-iotests/188 b/tests/qemu-iotests/188
1736
index XXXXXXX..XXXXXXX 100755
1737
--- a/tests/qemu-iotests/188
1738
+++ b/tests/qemu-iotests/188
1739
@@ -XXX,XX +XXX,XX @@
1740
-#!/bin/bash
1741
+#!/usr/bin/env bash
1742
#
1743
# Test encrypted read/write using plain bdrv_read/bdrv_write
1744
#
1745
diff --git a/tests/qemu-iotests/189 b/tests/qemu-iotests/189
1746
index XXXXXXX..XXXXXXX 100755
1747
--- a/tests/qemu-iotests/189
1748
+++ b/tests/qemu-iotests/189
1749
@@ -XXX,XX +XXX,XX @@
1750
-#!/bin/bash
1751
+#!/usr/bin/env bash
1752
#
1753
# Test encrypted read/write using backing files
1754
#
1755
diff --git a/tests/qemu-iotests/190 b/tests/qemu-iotests/190
1756
index XXXXXXX..XXXXXXX 100755
1757
--- a/tests/qemu-iotests/190
1758
+++ b/tests/qemu-iotests/190
1759
@@ -XXX,XX +XXX,XX @@
1760
-#!/bin/bash
1761
+#!/usr/bin/env bash
1762
#
1763
# qemu-img measure sub-command tests on huge qcow2 files
1764
#
1765
diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191
1766
index XXXXXXX..XXXXXXX 100755
1767
--- a/tests/qemu-iotests/191
1768
+++ b/tests/qemu-iotests/191
1769
@@ -XXX,XX +XXX,XX @@
1770
-#!/bin/bash
1771
+#!/usr/bin/env bash
1772
#
1773
# Test commit block job where top has two parents
1774
#
1775
diff --git a/tests/qemu-iotests/192 b/tests/qemu-iotests/192
1776
index XXXXXXX..XXXXXXX 100755
1777
--- a/tests/qemu-iotests/192
1778
+++ b/tests/qemu-iotests/192
1779
@@ -XXX,XX +XXX,XX @@
1780
-#!/bin/bash
1781
+#!/usr/bin/env bash
1782
#
1783
# Test NBD export with -incoming (non-shared storage migration use case from
1784
# libvirt)
1785
diff --git a/tests/qemu-iotests/195 b/tests/qemu-iotests/195
1786
index XXXXXXX..XXXXXXX 100755
1787
--- a/tests/qemu-iotests/195
1788
+++ b/tests/qemu-iotests/195
1789
@@ -XXX,XX +XXX,XX @@
1790
-#!/bin/bash
1791
+#!/usr/bin/env bash
1792
#
1793
# Test change-backing-file command
1794
#
1795
diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197
1796
index XXXXXXX..XXXXXXX 100755
1797
--- a/tests/qemu-iotests/197
1798
+++ b/tests/qemu-iotests/197
1799
@@ -XXX,XX +XXX,XX @@
1800
-#!/bin/bash
1801
+#!/usr/bin/env bash
1802
#
1803
# Test case for copy-on-read into qcow2
1804
#
1805
diff --git a/tests/qemu-iotests/198 b/tests/qemu-iotests/198
1806
index XXXXXXX..XXXXXXX 100755
1807
--- a/tests/qemu-iotests/198
1808
+++ b/tests/qemu-iotests/198
1809
@@ -XXX,XX +XXX,XX @@
1810
-#!/bin/bash
1811
+#!/usr/bin/env bash
1812
#
1813
# Test commit of encrypted qcow2 files
1814
#
1815
diff --git a/tests/qemu-iotests/200 b/tests/qemu-iotests/200
1816
index XXXXXXX..XXXXXXX 100755
1817
--- a/tests/qemu-iotests/200
1818
+++ b/tests/qemu-iotests/200
1819
@@ -XXX,XX +XXX,XX @@
1820
-#!/bin/bash
1821
+#!/usr/bin/env bash
1822
#
1823
# Block job co-routine race condition test.
1824
#
1825
diff --git a/tests/qemu-iotests/201 b/tests/qemu-iotests/201
1826
index XXXXXXX..XXXXXXX 100755
1827
--- a/tests/qemu-iotests/201
1828
+++ b/tests/qemu-iotests/201
1829
@@ -XXX,XX +XXX,XX @@
1830
-#!/bin/bash
1831
+#!/usr/bin/env bash
1832
#
1833
# Test savevm and loadvm after live migration with postcopy flag
1834
#
1835
diff --git a/tests/qemu-iotests/204 b/tests/qemu-iotests/204
1836
index XXXXXXX..XXXXXXX 100755
1837
--- a/tests/qemu-iotests/204
1838
+++ b/tests/qemu-iotests/204
1839
@@ -XXX,XX +XXX,XX @@
1840
-#!/bin/bash
1841
+#!/usr/bin/env bash
1842
#
1843
# Test corner cases with unusual block geometries
1844
#
1845
diff --git a/tests/qemu-iotests/214 b/tests/qemu-iotests/214
1846
index XXXXXXX..XXXXXXX 100755
1847
--- a/tests/qemu-iotests/214
1848
+++ b/tests/qemu-iotests/214
1849
@@ -XXX,XX +XXX,XX @@
1850
-#!/bin/bash
1851
+#!/usr/bin/env bash
1852
#
1853
# Test qcow2 image compression
1854
#
1855
diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215
1856
index XXXXXXX..XXXXXXX 100755
1857
--- a/tests/qemu-iotests/215
1858
+++ b/tests/qemu-iotests/215
1859
@@ -XXX,XX +XXX,XX @@
1860
-#!/bin/bash
1861
+#!/usr/bin/env bash
1862
#
1863
# Test case for copy-on-read into qcow2, using the COR filter driver
1864
#
1865
diff --git a/tests/qemu-iotests/217 b/tests/qemu-iotests/217
1866
index XXXXXXX..XXXXXXX 100755
1867
--- a/tests/qemu-iotests/217
1868
+++ b/tests/qemu-iotests/217
1869
@@ -XXX,XX +XXX,XX @@
1870
-#!/bin/bash
1871
+#!/usr/bin/env bash
1872
#
1873
# I/O errors when working with internal qcow2 snapshots, and repairing
1874
# the result
1875
diff --git a/tests/qemu-iotests/220 b/tests/qemu-iotests/220
1876
index XXXXXXX..XXXXXXX 100755
1877
--- a/tests/qemu-iotests/220
1878
+++ b/tests/qemu-iotests/220
1879
@@ -XXX,XX +XXX,XX @@
1880
-#!/bin/bash
1881
+#!/usr/bin/env bash
1882
#
1883
# max limits on compression in huge qcow2 files
1884
#
1885
diff --git a/tests/qemu-iotests/221 b/tests/qemu-iotests/221
1886
index XXXXXXX..XXXXXXX 100755
1887
--- a/tests/qemu-iotests/221
1888
+++ b/tests/qemu-iotests/221
1889
@@ -XXX,XX +XXX,XX @@
1890
-#!/bin/bash
1891
+#!/usr/bin/env bash
1892
#
1893
# Test qemu-img vs. unaligned images
1894
#
1895
diff --git a/tests/qemu-iotests/223 b/tests/qemu-iotests/223
1896
index XXXXXXX..XXXXXXX 100755
1897
--- a/tests/qemu-iotests/223
1898
+++ b/tests/qemu-iotests/223
1899
@@ -XXX,XX +XXX,XX @@
1900
-#!/bin/bash
1901
+#!/usr/bin/env bash
1902
#
1903
# Test reading dirty bitmap over NBD
1904
#
1905
diff --git a/tests/qemu-iotests/225 b/tests/qemu-iotests/225
1906
index XXXXXXX..XXXXXXX 100755
1907
--- a/tests/qemu-iotests/225
1908
+++ b/tests/qemu-iotests/225
1909
@@ -XXX,XX +XXX,XX @@
1910
-#!/bin/bash
1911
+#!/usr/bin/env bash
1912
#
1913
# Test vmdk backing file correlation
1914
#
1915
diff --git a/tests/qemu-iotests/226 b/tests/qemu-iotests/226
1916
index XXXXXXX..XXXXXXX 100755
1917
--- a/tests/qemu-iotests/226
1918
+++ b/tests/qemu-iotests/226
1919
@@ -XXX,XX +XXX,XX @@
1920
-#!/bin/bash
1921
+#!/usr/bin/env bash
1922
#
1923
# This test covers expected filetypes for the file, host_cdrom and
1924
# host_device drivers.
1925
diff --git a/tests/qemu-iotests/227 b/tests/qemu-iotests/227
1926
index XXXXXXX..XXXXXXX 100755
1927
--- a/tests/qemu-iotests/227
1928
+++ b/tests/qemu-iotests/227
1929
@@ -XXX,XX +XXX,XX @@
1930
-#!/bin/bash
1931
+#!/usr/bin/env bash
1932
#
1933
# Test query-blockstats with different ways to create a BB
1934
#
1935
diff --git a/tests/qemu-iotests/229 b/tests/qemu-iotests/229
1936
index XXXXXXX..XXXXXXX 100755
1937
--- a/tests/qemu-iotests/229
1938
+++ b/tests/qemu-iotests/229
1939
@@ -XXX,XX +XXX,XX @@
1940
-#!/bin/bash
1941
+#!/usr/bin/env bash
1942
#
1943
# Test for force canceling a running blockjob that is paused in
1944
# an error state.
1945
diff --git a/tests/qemu-iotests/231 b/tests/qemu-iotests/231
1946
index XXXXXXX..XXXXXXX 100755
1947
--- a/tests/qemu-iotests/231
1948
+++ b/tests/qemu-iotests/231
1949
@@ -XXX,XX +XXX,XX @@
1950
-#!/bin/bash
1951
+#!/usr/bin/env bash
1952
#
1953
# Test legacy and modern option parsing for rbd/ceph. This will not
1954
# actually connect to a ceph server, but rather looks for the appropriate
1955
diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232
1956
index XXXXXXX..XXXXXXX 100755
1957
--- a/tests/qemu-iotests/232
1958
+++ b/tests/qemu-iotests/232
1959
@@ -XXX,XX +XXX,XX @@
1960
-#!/bin/bash
1961
+#!/usr/bin/env bash
1962
#
1963
# Test for auto-read-only
1964
#
1965
diff --git a/tests/qemu-iotests/233 b/tests/qemu-iotests/233
1966
index XXXXXXX..XXXXXXX 100755
1967
--- a/tests/qemu-iotests/233
1968
+++ b/tests/qemu-iotests/233
1969
@@ -XXX,XX +XXX,XX @@
1970
-#!/bin/bash
1971
+#!/usr/bin/env bash
1972
#
1973
# Test NBD TLS certificate / authorization integration
1974
#
1975
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
1976
index XXXXXXX..XXXXXXX 100755
1977
--- a/tests/qemu-iotests/check
1978
+++ b/tests/qemu-iotests/check
1979
@@ -XXX,XX +XXX,XX @@
1980
-#!/bin/bash
1981
+#!/usr/bin/env bash
1982
#
1983
# Copyright (C) 2009 Red Hat, Inc.
1984
# Copyright (c) 2000-2002,2006 Silicon Graphics, Inc. All Rights Reserved.
1985
diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
1986
index XXXXXXX..XXXXXXX 100644
1987
--- a/tests/qemu-iotests/common.config
1988
+++ b/tests/qemu-iotests/common.config
1989
@@ -XXX,XX +XXX,XX @@
1990
-#!/bin/bash
1991
+#!/usr/bin/env bash
1992
#
1993
# Copyright (C) 2009 Red Hat, Inc.
1994
# Copyright (c) 2000-2003,2006 Silicon Graphics, Inc. All Rights Reserved.
1995
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
1996
index XXXXXXX..XXXXXXX 100644
1997
--- a/tests/qemu-iotests/common.filter
1998
+++ b/tests/qemu-iotests/common.filter
1999
@@ -XXX,XX +XXX,XX @@
2000
-#!/bin/bash
2001
+#!/usr/bin/env bash
2002
#
2003
# Copyright (C) 2009 Red Hat, Inc.
2004
# Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
2005
diff --git a/tests/qemu-iotests/common.nbd b/tests/qemu-iotests/common.nbd
2006
index XXXXXXX..XXXXXXX 100644
2007
--- a/tests/qemu-iotests/common.nbd
2008
+++ b/tests/qemu-iotests/common.nbd
2009
@@ -XXX,XX +XXX,XX @@
2010
-#!/bin/bash
2011
+#!/usr/bin/env bash
2012
# -*- shell-script-mode -*-
2013
#
2014
# Helpers for NBD server related config
2015
diff --git a/tests/qemu-iotests/common.pattern b/tests/qemu-iotests/common.pattern
2016
index XXXXXXX..XXXXXXX 100644
2017
--- a/tests/qemu-iotests/common.pattern
2018
+++ b/tests/qemu-iotests/common.pattern
2019
@@ -XXX,XX +XXX,XX @@
2020
-#!/bin/bash
2021
+#!/usr/bin/env bash
2022
#
2023
# Copyright (C) 2009 Red Hat, Inc.
2024
#
2025
diff --git a/tests/qemu-iotests/common.qemu b/tests/qemu-iotests/common.qemu
2026
index XXXXXXX..XXXXXXX 100644
2027
--- a/tests/qemu-iotests/common.qemu
2028
+++ b/tests/qemu-iotests/common.qemu
2029
@@ -XXX,XX +XXX,XX @@
2030
-#!/bin/bash
2031
+#!/usr/bin/env bash
2032
#
2033
# This allows for launching of multiple QEMU instances, with independent
2034
# communication possible to each instance.
2035
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
2036
index XXXXXXX..XXXXXXX 100644
2037
--- a/tests/qemu-iotests/common.rc
2038
+++ b/tests/qemu-iotests/common.rc
2039
@@ -XXX,XX +XXX,XX @@
2040
-#!/bin/bash
2041
+#!/usr/bin/env bash
2042
#
2043
# Copyright (C) 2009 Red Hat, Inc.
2044
# Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
2045
diff --git a/tests/qemu-iotests/common.tls b/tests/qemu-iotests/common.tls
2046
index XXXXXXX..XXXXXXX 100644
2047
--- a/tests/qemu-iotests/common.tls
2048
+++ b/tests/qemu-iotests/common.tls
2049
@@ -XXX,XX +XXX,XX @@
2050
-#!/bin/bash
2051
+#!/usr/bin/env bash
2052
#
2053
# Helpers for TLS related config
2054
#
2055
--
2056
2.20.1
2057
2058
diff view generated by jsdifflib
1
Recently, the test case has started failing because some job related
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
functions want to drop the AioContext lock even though it hasn't been
3
taken:
4
2
5
(gdb) bt
3
Various sed regexp from common.filter use sed GNU extensions.
6
#0 0x00007f51c067c9fb in raise () from /lib64/libc.so.6
4
Instead of spending time to write these regex to be POSIX compliant,
7
#1 0x00007f51c067e77d in abort () from /lib64/libc.so.6
5
verify the GNU sed is available and use it.
8
#2 0x0000558c9d5dde7b in error_exit (err=<optimized out>, msg=msg@entry=0x558c9d6fe120 <__func__.18373> "qemu_mutex_unlock_impl") at util/qemu-thread-posix.c:36
9
#3 0x0000558c9d6b5263 in qemu_mutex_unlock_impl (mutex=mutex@entry=0x558c9f3999a0, file=file@entry=0x558c9d6fd36f "util/async.c", line=line@entry=516) at util/qemu-thread-posix.c:96
10
#4 0x0000558c9d6b0565 in aio_context_release (ctx=ctx@entry=0x558c9f399940) at util/async.c:516
11
#5 0x0000558c9d5eb3da in job_completed_txn_abort (job=0x558c9f68e640) at job.c:738
12
#6 0x0000558c9d5eb227 in job_finish_sync (job=0x558c9f68e640, finish=finish@entry=0x558c9d5eb8d0 <job_cancel_err>, errp=errp@entry=0x0) at job.c:986
13
#7 0x0000558c9d5eb8ee in job_cancel_sync (job=<optimized out>) at job.c:941
14
#8 0x0000558c9d64d853 in replication_close (bs=<optimized out>) at block/replication.c:148
15
#9 0x0000558c9d5e5c9f in bdrv_close (bs=0x558c9f41b020) at block.c:3420
16
#10 bdrv_delete (bs=0x558c9f41b020) at block.c:3629
17
#11 bdrv_unref (bs=0x558c9f41b020) at block.c:4685
18
#12 0x0000558c9d62a3f3 in blk_remove_bs (blk=blk@entry=0x558c9f42a7c0) at block/block-backend.c:783
19
#13 0x0000558c9d62a667 in blk_delete (blk=0x558c9f42a7c0) at block/block-backend.c:402
20
#14 blk_unref (blk=0x558c9f42a7c0) at block/block-backend.c:457
21
#15 0x0000558c9d5dfcea in test_secondary_stop () at tests/test-replication.c:478
22
#16 0x00007f51c1f13178 in g_test_run_suite_internal () from /lib64/libglib-2.0.so.0
23
#17 0x00007f51c1f1337b in g_test_run_suite_internal () from /lib64/libglib-2.0.so.0
24
#18 0x00007f51c1f1337b in g_test_run_suite_internal () from /lib64/libglib-2.0.so.0
25
#19 0x00007f51c1f13552 in g_test_run_suite () from /lib64/libglib-2.0.so.0
26
#20 0x00007f51c1f13571 in g_test_run () from /lib64/libglib-2.0.so.0
27
#21 0x0000558c9d5de31f in main (argc=<optimized out>, argv=<optimized out>) at tests/test-replication.c:581
28
6
29
It is yet unclear whether this should really be considered a bug in the
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
30
test case or whether blk_unref() should work for callers that haven't
31
taken the AioContext lock, but in order to fix the build tests quickly,
32
just take the AioContext lock around blk_unref().
33
34
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
35
---
9
---
36
tests/test-replication.c | 11 +++++++++++
10
tests/qemu-iotests/common.filter | 36 ++++++++++++++++----------------
37
1 file changed, 11 insertions(+)
11
tests/qemu-iotests/common.rc | 13 ++++++++++++
12
2 files changed, 31 insertions(+), 18 deletions(-)
38
13
39
diff --git a/tests/test-replication.c b/tests/test-replication.c
14
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
40
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
41
--- a/tests/test-replication.c
16
--- a/tests/qemu-iotests/common.filter
42
+++ b/tests/test-replication.c
17
+++ b/tests/qemu-iotests/common.filter
43
@@ -XXX,XX +XXX,XX @@ static BlockBackend *start_primary(void)
18
@@ -XXX,XX +XXX,XX @@
44
static void teardown_primary(void)
19
#
20
_filter_date()
45
{
21
{
46
BlockBackend *blk;
22
- sed \
47
+ AioContext *ctx;
23
+ $SED \
48
24
-e 's/[A-Z][a-z][a-z] [A-z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATE/'
49
/* remove P_ID */
50
blk = blk_by_name(P_ID);
51
assert(blk);
52
53
+ ctx = blk_get_aio_context(blk);
54
+ aio_context_acquire(ctx);
55
monitor_remove_blk(blk);
56
blk_unref(blk);
57
+ aio_context_release(ctx);
58
}
25
}
59
26
60
static void test_primary_read(void)
27
_filter_generated_node_ids()
61
@@ -XXX,XX +XXX,XX @@ static void teardown_secondary(void)
62
{
28
{
63
/* only need to destroy two BBs */
29
- sed -re 's/\#block[0-9]{3,}/NODE_NAME/'
64
BlockBackend *blk;
30
+ $SED -re 's/\#block[0-9]{3,}/NODE_NAME/'
65
+ AioContext *ctx;
66
67
/* remove S_LOCAL_DISK_ID */
68
blk = blk_by_name(S_LOCAL_DISK_ID);
69
assert(blk);
70
71
+ ctx = blk_get_aio_context(blk);
72
+ aio_context_acquire(ctx);
73
monitor_remove_blk(blk);
74
blk_unref(blk);
75
+ aio_context_release(ctx);
76
77
/* remove S_ID */
78
blk = blk_by_name(S_ID);
79
assert(blk);
80
81
+ ctx = blk_get_aio_context(blk);
82
+ aio_context_acquire(ctx);
83
monitor_remove_blk(blk);
84
blk_unref(blk);
85
+ aio_context_release(ctx);
86
}
31
}
87
32
88
static void test_secondary_read(void)
33
_filter_qom_path()
34
{
35
- sed -e 's#\(Attached to: *\) /.*#\1 PATH#'
36
+ $SED -e 's#\(Attached to: *\) /.*#\1 PATH#'
37
}
38
39
# replace occurrences of the actual TEST_DIR value with TEST_DIR
40
_filter_testdir()
41
{
42
- sed -e "s#$TEST_DIR/#TEST_DIR/#g"
43
+ $SED -e "s#$TEST_DIR/#TEST_DIR/#g"
44
}
45
46
# replace occurrences of the actual IMGFMT value with IMGFMT
47
_filter_imgfmt()
48
{
49
- sed -e "s#$IMGFMT#IMGFMT#g"
50
+ $SED -e "s#$IMGFMT#IMGFMT#g"
51
}
52
53
# Replace error message when the format is not supported and delete
54
# the output lines after the first one
55
_filter_qemu_img_check()
56
{
57
- sed -e '/allocated.*fragmented.*compressed clusters/d' \
58
+ $SED -e '/allocated.*fragmented.*compressed clusters/d' \
59
-e 's/qemu-img: This image format does not support checks/No errors were found on the image./' \
60
-e '/Image end offset: [0-9]\+/d'
61
}
62
@@ -XXX,XX +XXX,XX @@ _filter_qemu_img_check()
63
# Removes \r from messages
64
_filter_win32()
65
{
66
- sed -e 's/\r//g'
67
+ $SED -e 's/\r//g'
68
}
69
70
# sanitize qemu-io output
71
_filter_qemu_io()
72
{
73
- _filter_win32 | sed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
74
+ _filter_win32 | $SED -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
75
-e "s/: line [0-9][0-9]*: *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
76
-e "s/qemu-io> //g"
77
}
78
@@ -XXX,XX +XXX,XX @@ _filter_qemu_io()
79
# replace occurrences of QEMU_PROG with "qemu"
80
_filter_qemu()
81
{
82
- sed -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
83
+ $SED -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
84
-e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#' \
85
-e $'s#\r##' # QEMU monitor uses \r\n line endings
86
}
87
@@ -XXX,XX +XXX,XX @@ _filter_qemu()
88
_filter_qmp()
89
{
90
_filter_win32 | \
91
- sed -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
92
+ $SED -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
93
-e 's#^{"QMP":.*}$#QMP_VERSION#' \
94
-e '/^ "QMP": {\s*$/, /^ }\s*$/ c\' \
95
-e ' QMP_VERSION'
96
@@ -XXX,XX +XXX,XX @@ _filter_qmp()
97
# readline makes HMP command strings so long that git complains
98
_filter_hmp()
99
{
100
- sed -e $'s/^\\((qemu) \\)\\?.*\e\\[D/\\1/g' \
101
+ $SED -e $'s/^\\((qemu) \\)\\?.*\e\\[D/\\1/g' \
102
-e $'s/\e\\[K//g'
103
}
104
105
# replace block job offset
106
_filter_block_job_offset()
107
{
108
- sed -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/'
109
+ $SED -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/'
110
}
111
112
# replace block job len
113
_filter_block_job_len()
114
{
115
- sed -e 's/, "len": [0-9]\+,/, "len": LEN,/g'
116
+ $SED -e 's/, "len": [0-9]\+,/, "len": LEN,/g'
117
}
118
119
# replace actual image size (depends on the host filesystem)
120
_filter_actual_image_size()
121
{
122
- sed -s 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g'
123
+ $SED -s 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g'
124
}
125
126
# replace driver-specific options in the "Formatting..." line
127
_filter_img_create()
128
{
129
- sed -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
130
+ $SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
131
-e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
132
-e "s#$TEST_DIR#TEST_DIR#g" \
133
-e "s#$IMGFMT#IMGFMT#g" \
134
@@ -XXX,XX +XXX,XX @@ _filter_img_info()
135
136
discard=0
137
regex_json_spec_start='^ *"format-specific": \{'
138
- sed -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
139
+ $SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
140
-e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
141
-e "s#$TEST_DIR#TEST_DIR#g" \
142
-e "s#$IMGFMT#IMGFMT#g" \
143
@@ -XXX,XX +XXX,XX @@ _filter_img_info()
144
# human and json output
145
_filter_qemu_img_map()
146
{
147
- sed -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
148
+ $SED -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
149
-e 's/"offset": [0-9]\+/"offset": OFFSET/g' \
150
-e 's/Mapped to *//' | _filter_testdir | _filter_imgfmt
151
}
152
@@ -XXX,XX +XXX,XX @@ _filter_nbd()
153
# receive callbacks sometimes, making them unreliable.
154
#
155
# Filter out the TCP port number since this changes between runs.
156
- sed -e '/nbd\/.*\.c:/d' \
157
+ $SED -e '/nbd\/.*\.c:/d' \
158
-e 's#127\.0\.0\.1:[0-9]*#127.0.0.1:PORT#g' \
159
-e "s#?socket=$TEST_DIR#?socket=TEST_DIR#g" \
160
-e 's#\(foo\|PORT/\?\|.sock\): Failed to .*$#\1#'
161
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
162
index XXXXXXX..XXXXXXX 100644
163
--- a/tests/qemu-iotests/common.rc
164
+++ b/tests/qemu-iotests/common.rc
165
@@ -XXX,XX +XXX,XX @@
166
# along with this program. If not, see <http://www.gnu.org/licenses/>.
167
#
168
169
+SED=
170
+for sed in sed gsed; do
171
+ ($sed --version | grep 'GNU sed') > /dev/null 2>&1
172
+ if [ "$?" -eq 0 ]; then
173
+ SED=$sed
174
+ break
175
+ fi
176
+done
177
+if [ -z "$SED" ]; then
178
+ echo "$0: GNU sed not found"
179
+ exit 1
180
+fi
181
+
182
dd()
183
{
184
if [ "$HOSTOS" == "Linux" ]
89
--
185
--
90
2.13.6
186
2.20.1
91
187
92
188
diff view generated by jsdifflib
New patch
1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2
Reviewed-by: Eric Blake <eblake@redhat.com>
3
---
4
tests/qemu-iotests/243 | 63 ++++++++++++++++++++++++++++++++++++++
5
tests/qemu-iotests/243.out | 26 ++++++++++++++++
6
tests/qemu-iotests/group | 1 +
7
3 files changed, 90 insertions(+)
8
create mode 100755 tests/qemu-iotests/243
9
create mode 100644 tests/qemu-iotests/243.out
1
10
11
diff --git a/tests/qemu-iotests/243 b/tests/qemu-iotests/243
12
new file mode 100755
13
index XXXXXXX..XXXXXXX
14
--- /dev/null
15
+++ b/tests/qemu-iotests/243
16
@@ -XXX,XX +XXX,XX @@
17
+#!/bin/bash
18
+#
19
+# Test qcow2 preallocation
20
+#
21
+# Copyright (C) 2019 Red Hat, Inc.
22
+#
23
+# This program is free software; you can redistribute it and/or modify
24
+# it under the terms of the GNU General Public License as published by
25
+# the Free Software Foundation; either version 2 of the License, or
26
+# (at your option) any later version.
27
+#
28
+# This program is distributed in the hope that it will be useful,
29
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
30
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
+# GNU General Public License for more details.
32
+#
33
+# You should have received a copy of the GNU General Public License
34
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
35
+#
36
+
37
+# creator
38
+owner=kwolf@redhat.com
39
+
40
+seq=$(basename $0)
41
+echo "QA output created by $seq"
42
+
43
+status=1    # failure is the default!
44
+
45
+_cleanup()
46
+{
47
+ _cleanup_test_img
48
+}
49
+trap "_cleanup; exit \$status" 0 1 2 3 15
50
+
51
+# get standard environment, filters and checks
52
+. ./common.rc
53
+. ./common.filter
54
+
55
+_supported_fmt qcow2
56
+_supported_proto file
57
+_supported_os Linux
58
+
59
+for mode in off metadata falloc full; do
60
+
61
+ echo
62
+ echo "=== preallocation=$mode ==="
63
+ echo
64
+
65
+ IMGOPTS="preallocation=$mode" _make_test_img 64M
66
+
67
+ printf "File size: "
68
+ du -b $TEST_IMG | cut -f1
69
+
70
+ # Can't use precise numbers here because they differ between filesystems
71
+ printf "Disk usage: "
72
+ [ $(du -B1 $TEST_IMG | cut -f1) -lt 1048576 ] && echo "low" || echo "high"
73
+
74
+done
75
+
76
+# success, all done
77
+echo "*** done"
78
+rm -f $seq.full
79
+status=0
80
diff --git a/tests/qemu-iotests/243.out b/tests/qemu-iotests/243.out
81
new file mode 100644
82
index XXXXXXX..XXXXXXX
83
--- /dev/null
84
+++ b/tests/qemu-iotests/243.out
85
@@ -XXX,XX +XXX,XX @@
86
+QA output created by 243
87
+
88
+=== preallocation=off ===
89
+
90
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 preallocation=off
91
+File size: 196616
92
+Disk usage: low
93
+
94
+=== preallocation=metadata ===
95
+
96
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 preallocation=metadata
97
+File size: 67436544
98
+Disk usage: low
99
+
100
+=== preallocation=falloc ===
101
+
102
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 preallocation=falloc
103
+File size: 67436544
104
+Disk usage: high
105
+
106
+=== preallocation=full ===
107
+
108
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 preallocation=full
109
+File size: 67436544
110
+Disk usage: high
111
+*** done
112
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
113
index XXXXXXX..XXXXXXX 100644
114
--- a/tests/qemu-iotests/group
115
+++ b/tests/qemu-iotests/group
116
@@ -XXX,XX +XXX,XX @@
117
239 rw auto quick
118
240 auto quick
119
242 rw auto quick
120
+243 rw auto quick
121
--
122
2.20.1
123
124
diff view generated by jsdifflib
1
From: Leonid Bloch <lbloch@janustech.com>
1
Image creation already involves a bdrv_co_truncate() call, which allows
2
to specify a preallocation mode. Just pass the right mode there and
3
remove the code that is made redundant by this.
2
4
3
The refcount cache size does not need to be set to its minimum value in
4
read_cache_sizes(), as it is set to at least its minimum value in
5
qcow2_update_options_prepare().
6
7
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
8
Reviewed-by: Alberto Garcia <berto@igalia.com>
9
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
---
6
---
12
block/qcow2.c | 5 ++---
7
block/qcow2.c | 28 +---------------------------
13
1 file changed, 2 insertions(+), 3 deletions(-)
8
1 file changed, 1 insertion(+), 27 deletions(-)
14
9
15
diff --git a/block/qcow2.c b/block/qcow2.c
10
diff --git a/block/qcow2.c b/block/qcow2.c
16
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
17
--- a/block/qcow2.c
12
--- a/block/qcow2.c
18
+++ b/block/qcow2.c
13
+++ b/block/qcow2.c
19
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
14
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
20
(uint64_t)DEFAULT_L2_CACHE_CLUSTERS
15
goto out;
21
* s->cluster_size);
16
}
17
18
- if (qcow2_opts->preallocation == PREALLOC_MODE_FULL ||
19
- qcow2_opts->preallocation == PREALLOC_MODE_FALLOC)
20
- {
21
- int64_t prealloc_size =
22
- qcow2_calc_prealloc_size(qcow2_opts->size, cluster_size,
23
- refcount_order);
24
-
25
- ret = blk_truncate(blk, prealloc_size, qcow2_opts->preallocation, errp);
26
- if (ret < 0) {
27
- goto out;
28
- }
29
- }
30
-
31
/* Write the header */
32
QEMU_BUILD_BUG_ON((1 << MIN_CLUSTER_BITS) < sizeof(*header));
33
header = g_malloc0(cluster_size);
34
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
35
}
36
37
/* Okay, now that we have a valid image, let's give it the right size */
38
- ret = blk_truncate(blk, qcow2_opts->size, PREALLOC_MODE_OFF, errp);
39
+ ret = blk_truncate(blk, qcow2_opts->size, qcow2_opts->preallocation, errp);
40
if (ret < 0) {
41
error_prepend(errp, "Could not resize image: ");
42
goto out;
43
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
22
}
44
}
23
- if (!refcount_cache_size_set) {
45
}
24
- *refcount_cache_size = min_refcount_cache;
46
47
- /* And if we're supposed to preallocate metadata, do that now */
48
- if (qcow2_opts->preallocation != PREALLOC_MODE_OFF) {
49
- BDRVQcow2State *s = blk_bs(blk)->opaque;
50
- qemu_co_mutex_lock(&s->lock);
51
- ret = preallocate_co(blk_bs(blk), 0, qcow2_opts->size);
52
- qemu_co_mutex_unlock(&s->lock);
53
-
54
- if (ret < 0) {
55
- error_setg_errno(errp, -ret, "Could not preallocate metadata");
56
- goto out;
25
- }
57
- }
26
}
58
- }
27
+ /* l2_cache_size and refcount_cache_size are ensured to have at least
59
-
28
+ * their minimum values in qcow2_update_options_prepare() */
60
blk_unref(blk);
29
61
blk = NULL;
30
if (*l2_cache_entry_size < (1 << MIN_CLUSTER_BITS) ||
62
31
*l2_cache_entry_size > s->cluster_size ||
32
--
63
--
33
2.13.6
64
2.20.1
34
65
35
66
diff view generated by jsdifflib
New patch
1
This adds external data file to the qcow2 spec as a new incompatible
2
feature.
1
3
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
---
6
docs/interop/qcow2.txt | 42 ++++++++++++++++++++++++++++++++++++++----
7
1 file changed, 38 insertions(+), 4 deletions(-)
8
9
diff --git a/docs/interop/qcow2.txt b/docs/interop/qcow2.txt
10
index XXXXXXX..XXXXXXX 100644
11
--- a/docs/interop/qcow2.txt
12
+++ b/docs/interop/qcow2.txt
13
@@ -XXX,XX +XXX,XX @@ in the description of a field.
14
be written to (unless for regaining
15
consistency).
16
17
- Bits 2-63: Reserved (set to 0)
18
+ Bit 2: External data file bit. If this bit is set, an
19
+ external data file is used. Guest clusters are
20
+ then stored in the external data file. For such
21
+ images, clusters in the external data file are
22
+ not refcounted. The offset field in the
23
+ Standard Cluster Descriptor must match the
24
+ guest offset and neither compressed clusters
25
+ nor internal snapshots are supported.
26
+
27
+ An External Data File Name header extension may
28
+ be present if this bit is set.
29
+
30
+ Bits 3-63: Reserved (set to 0)
31
32
80 - 87: compatible_features
33
Bitmask of compatible features. An implementation can
34
@@ -XXX,XX +XXX,XX @@ in the description of a field.
35
bit is unset, the bitmaps extension data must be
36
considered inconsistent.
37
38
- Bits 1-63: Reserved (set to 0)
39
+ Bit 1: If this bit is set, the external data file can
40
+ be read as a consistent standalone raw image
41
+ without looking at the qcow2 metadata.
42
+
43
+ Setting this bit has a performance impact for
44
+ some operations on the image (e.g. writing
45
+ zeros requires writing to the data file instead
46
+ of only setting the zero flag in the L2 table
47
+ entry) and conflicts with backing files.
48
+
49
+ This bit may only be set if the External Data
50
+ File bit (incompatible feature bit 1) is also
51
+ set.
52
+
53
+ Bits 2-63: Reserved (set to 0)
54
55
96 - 99: refcount_order
56
Describes the width of a reference count block entry (width
57
@@ -XXX,XX +XXX,XX @@ be stored. Each extension has a structure like the following:
58
0x6803f857 - Feature name table
59
0x23852875 - Bitmaps extension
60
0x0537be77 - Full disk encryption header pointer
61
+ 0x44415441 - External data file name
62
other - Unknown header extension, can be safely
63
ignored
64
65
@@ -XXX,XX +XXX,XX @@ L2 table entry:
66
This information is only accurate in L2 tables
67
that are reachable from the active L1 table.
68
69
+ With external data files, all guest clusters have an
70
+ implicit refcount of 1 (because of the fixed host = guest
71
+ mapping for guest cluster offsets), so this bit should be 1
72
+ for all allocated clusters.
73
+
74
Standard Cluster Descriptor:
75
76
Bit 0: If set to 1, the cluster reads as all zeros. The host
77
@@ -XXX,XX +XXX,XX @@ Standard Cluster Descriptor:
78
1 - 8: Reserved (set to 0)
79
80
9 - 55: Bits 9-55 of host cluster offset. Must be aligned to a
81
- cluster boundary. If the offset is 0, the cluster is
82
- unallocated.
83
+ cluster boundary. If the offset is 0 and bit 63 is clear,
84
+ the cluster is unallocated. The offset may only be 0 with
85
+ bit 63 set (indicating a host cluster offset of 0) when an
86
+ external data file is used.
87
88
56 - 61: Reserved (set to 0)
89
90
--
91
2.20.1
92
93
diff view generated by jsdifflib
New patch
1
1
This adds basic constants, struct fields and helper function for
2
external data file support to the implementation.
3
4
QCOW2_INCOMPAT_MASK and QCOW2_AUTOCLEAR_MASK are not updated yet so that
5
opening images with an external data file still fails (we don't handle
6
them correctly yet).
7
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
10
block/qcow2.h | 32 ++++++++++++++++++++++----------
11
block/qcow2.c | 9 +++++++++
12
tests/qemu-iotests/031.out | 8 ++++----
13
tests/qemu-iotests/036.out | 4 ++--
14
tests/qemu-iotests/061.out | 14 +++++++-------
15
5 files changed, 44 insertions(+), 23 deletions(-)
16
17
diff --git a/block/qcow2.h b/block/qcow2.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/block/qcow2.h
20
+++ b/block/qcow2.h
21
@@ -XXX,XX +XXX,XX @@ enum {
22
23
/* Incompatible feature bits */
24
enum {
25
- QCOW2_INCOMPAT_DIRTY_BITNR = 0,
26
- QCOW2_INCOMPAT_CORRUPT_BITNR = 1,
27
- QCOW2_INCOMPAT_DIRTY = 1 << QCOW2_INCOMPAT_DIRTY_BITNR,
28
- QCOW2_INCOMPAT_CORRUPT = 1 << QCOW2_INCOMPAT_CORRUPT_BITNR,
29
-
30
- QCOW2_INCOMPAT_MASK = QCOW2_INCOMPAT_DIRTY
31
- | QCOW2_INCOMPAT_CORRUPT,
32
+ QCOW2_INCOMPAT_DIRTY_BITNR = 0,
33
+ QCOW2_INCOMPAT_CORRUPT_BITNR = 1,
34
+ QCOW2_INCOMPAT_DATA_FILE_BITNR = 2,
35
+ QCOW2_INCOMPAT_DIRTY = 1 << QCOW2_INCOMPAT_DIRTY_BITNR,
36
+ QCOW2_INCOMPAT_CORRUPT = 1 << QCOW2_INCOMPAT_CORRUPT_BITNR,
37
+ QCOW2_INCOMPAT_DATA_FILE = 1 << QCOW2_INCOMPAT_DATA_FILE_BITNR,
38
+
39
+ QCOW2_INCOMPAT_MASK = QCOW2_INCOMPAT_DIRTY
40
+ | QCOW2_INCOMPAT_CORRUPT,
41
};
42
43
/* Compatible feature bits */
44
@@ -XXX,XX +XXX,XX @@ enum {
45
46
/* Autoclear feature bits */
47
enum {
48
- QCOW2_AUTOCLEAR_BITMAPS_BITNR = 0,
49
- QCOW2_AUTOCLEAR_BITMAPS = 1 << QCOW2_AUTOCLEAR_BITMAPS_BITNR,
50
+ QCOW2_AUTOCLEAR_BITMAPS_BITNR = 0,
51
+ QCOW2_AUTOCLEAR_DATA_FILE_RAW_BITNR = 1,
52
+ QCOW2_AUTOCLEAR_BITMAPS = 1 << QCOW2_AUTOCLEAR_BITMAPS_BITNR,
53
+ QCOW2_AUTOCLEAR_DATA_FILE_RAW = 1 << QCOW2_AUTOCLEAR_DATA_FILE_RAW_BITNR,
54
55
- QCOW2_AUTOCLEAR_MASK = QCOW2_AUTOCLEAR_BITMAPS,
56
+ QCOW2_AUTOCLEAR_MASK = QCOW2_AUTOCLEAR_BITMAPS,
57
};
58
59
enum qcow2_discard_type {
60
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVQcow2State {
61
62
CoQueue compress_wait_queue;
63
int nb_compress_threads;
64
+
65
+ BdrvChild *data_file;
66
} BDRVQcow2State;
67
68
typedef struct Qcow2COWRegion {
69
@@ -XXX,XX +XXX,XX @@ typedef enum QCow2MetadataOverlap {
70
71
#define REFT_OFFSET_MASK 0xfffffffffffffe00ULL
72
73
+static inline bool has_data_file(BlockDriverState *bs)
74
+{
75
+ BDRVQcow2State *s = bs->opaque;
76
+ return (s->data_file != bs->file);
77
+}
78
+
79
static inline int64_t start_of_cluster(BDRVQcow2State *s, int64_t offset)
80
{
81
return offset & ~(s->cluster_size - 1);
82
diff --git a/block/qcow2.c b/block/qcow2.c
83
index XXXXXXX..XXXXXXX 100644
84
--- a/block/qcow2.c
85
+++ b/block/qcow2.c
86
@@ -XXX,XX +XXX,XX @@ typedef struct {
87
#define QCOW2_EXT_MAGIC_FEATURE_TABLE 0x6803f857
88
#define QCOW2_EXT_MAGIC_CRYPTO_HEADER 0x0537be77
89
#define QCOW2_EXT_MAGIC_BITMAPS 0x23852875
90
+#define QCOW2_EXT_MAGIC_DATA_FILE 0x44415441
91
92
static int coroutine_fn
93
qcow2_co_preadv_compressed(BlockDriverState *bs,
94
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
95
goto fail;
96
}
97
98
+ /* TODO Open external data file */
99
+ s->data_file = bs->file;
100
+
101
/* qcow2_read_extension may have set up the crypto context
102
* if the crypt method needs a header region, some methods
103
* don't need header extensions, so must check here
104
@@ -XXX,XX +XXX,XX @@ int qcow2_update_header(BlockDriverState *bs)
105
.bit = QCOW2_INCOMPAT_CORRUPT_BITNR,
106
.name = "corrupt bit",
107
},
108
+ {
109
+ .type = QCOW2_FEAT_TYPE_INCOMPATIBLE,
110
+ .bit = QCOW2_INCOMPAT_DATA_FILE_BITNR,
111
+ .name = "external data file",
112
+ },
113
{
114
.type = QCOW2_FEAT_TYPE_COMPATIBLE,
115
.bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR,
116
diff --git a/tests/qemu-iotests/031.out b/tests/qemu-iotests/031.out
117
index XXXXXXX..XXXXXXX 100644
118
--- a/tests/qemu-iotests/031.out
119
+++ b/tests/qemu-iotests/031.out
120
@@ -XXX,XX +XXX,XX @@ header_length 104
121
122
Header extension:
123
magic 0x6803f857
124
-length 144
125
+length 192
126
data <binary>
127
128
Header extension:
129
@@ -XXX,XX +XXX,XX @@ header_length 104
130
131
Header extension:
132
magic 0x6803f857
133
-length 144
134
+length 192
135
data <binary>
136
137
Header extension:
138
@@ -XXX,XX +XXX,XX @@ No errors were found on the image.
139
140
magic 0x514649fb
141
version 3
142
-backing_file_offset 0x148
143
+backing_file_offset 0x178
144
backing_file_size 0x17
145
cluster_bits 16
146
size 67108864
147
@@ -XXX,XX +XXX,XX @@ data 'host_device'
148
149
Header extension:
150
magic 0x6803f857
151
-length 144
152
+length 192
153
data <binary>
154
155
Header extension:
156
diff --git a/tests/qemu-iotests/036.out b/tests/qemu-iotests/036.out
157
index XXXXXXX..XXXXXXX 100644
158
--- a/tests/qemu-iotests/036.out
159
+++ b/tests/qemu-iotests/036.out
160
@@ -XXX,XX +XXX,XX @@ header_length 104
161
162
Header extension:
163
magic 0x6803f857
164
-length 144
165
+length 192
166
data <binary>
167
168
169
@@ -XXX,XX +XXX,XX @@ header_length 104
170
171
Header extension:
172
magic 0x6803f857
173
-length 144
174
+length 192
175
data <binary>
176
177
*** done
178
diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out
179
index XXXXXXX..XXXXXXX 100644
180
--- a/tests/qemu-iotests/061.out
181
+++ b/tests/qemu-iotests/061.out
182
@@ -XXX,XX +XXX,XX @@ header_length 104
183
184
Header extension:
185
magic 0x6803f857
186
-length 144
187
+length 192
188
data <binary>
189
190
magic 0x514649fb
191
@@ -XXX,XX +XXX,XX @@ header_length 104
192
193
Header extension:
194
magic 0x6803f857
195
-length 144
196
+length 192
197
data <binary>
198
199
magic 0x514649fb
200
@@ -XXX,XX +XXX,XX @@ header_length 104
201
202
Header extension:
203
magic 0x6803f857
204
-length 144
205
+length 192
206
data <binary>
207
208
ERROR cluster 5 refcount=0 reference=1
209
@@ -XXX,XX +XXX,XX @@ header_length 104
210
211
Header extension:
212
magic 0x6803f857
213
-length 144
214
+length 192
215
data <binary>
216
217
magic 0x514649fb
218
@@ -XXX,XX +XXX,XX @@ header_length 104
219
220
Header extension:
221
magic 0x6803f857
222
-length 144
223
+length 192
224
data <binary>
225
226
read 65536/65536 bytes at offset 44040192
227
@@ -XXX,XX +XXX,XX @@ header_length 104
228
229
Header extension:
230
magic 0x6803f857
231
-length 144
232
+length 192
233
data <binary>
234
235
ERROR cluster 5 refcount=0 reference=1
236
@@ -XXX,XX +XXX,XX @@ header_length 104
237
238
Header extension:
239
magic 0x6803f857
240
-length 144
241
+length 192
242
data <binary>
243
244
read 131072/131072 bytes at offset 0
245
--
246
2.20.1
247
248
diff view generated by jsdifflib
1
From: Leonid Bloch <lbloch@janustech.com>
2
3
Adding a lookup table for the powers of two, with the appropriate size
4
prefixes. This is needed when a size has to be stringified, in which
5
case something like '(1 * KiB)' would become a literal '(1 * (1L << 10))'
6
string. Powers of two are used very often for sizes, so such a table
7
will also make it easier and more intuitive to write them.
8
9
This table is generatred using the following AWK script:
10
11
BEGIN {
12
    suffix="KMGTPE";
13
    for(i=10; i<64; i++) {
14
        val=2**i;
15
        s=substr(suffix, int(i/10), 1);
16
        n=2**(i%10);
17
        pad=21-int(log(n)/log(10));
18
        printf("#define S_%d%siB %*d\n", n, s, pad, val);
19
    }
20
}
21
22
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
23
Reviewed-by: Alberto Garcia <berto@igalia.com>
24
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26
---
2
---
27
include/qemu/units.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
3
block/qcow2.h | 3 ++-
28
1 file changed, 55 insertions(+)
4
block/qcow2-cluster.c | 37 +++++++++++++++++++------------------
5
block/qcow2-refcount.c | 10 +++++-----
6
3 files changed, 26 insertions(+), 24 deletions(-)
29
7
30
diff --git a/include/qemu/units.h b/include/qemu/units.h
8
diff --git a/block/qcow2.h b/block/qcow2.h
31
index XXXXXXX..XXXXXXX 100644
9
index XXXXXXX..XXXXXXX 100644
32
--- a/include/qemu/units.h
10
--- a/block/qcow2.h
33
+++ b/include/qemu/units.h
11
+++ b/block/qcow2.h
34
@@ -XXX,XX +XXX,XX @@
12
@@ -XXX,XX +XXX,XX @@ static inline int64_t qcow2_vm_state_offset(BDRVQcow2State *s)
35
#define PiB (INT64_C(1) << 50)
13
return (int64_t)s->l1_vm_state_index << (s->cluster_bits + s->l2_bits);
36
#define EiB (INT64_C(1) << 60)
14
}
37
15
38
+#define S_1KiB 1024
16
-static inline QCow2ClusterType qcow2_get_cluster_type(uint64_t l2_entry)
39
+#define S_2KiB 2048
17
+static inline QCow2ClusterType qcow2_get_cluster_type(BlockDriverState *bs,
40
+#define S_4KiB 4096
18
+ uint64_t l2_entry)
41
+#define S_8KiB 8192
19
{
42
+#define S_16KiB 16384
20
if (l2_entry & QCOW_OFLAG_COMPRESSED) {
43
+#define S_32KiB 32768
21
return QCOW2_CLUSTER_COMPRESSED;
44
+#define S_64KiB 65536
22
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
45
+#define S_128KiB 131072
23
index XXXXXXX..XXXXXXX 100644
46
+#define S_256KiB 262144
24
--- a/block/qcow2-cluster.c
47
+#define S_512KiB 524288
25
+++ b/block/qcow2-cluster.c
48
+#define S_1MiB 1048576
26
@@ -XXX,XX +XXX,XX @@ fail:
49
+#define S_2MiB 2097152
27
* as contiguous. (This allows it, for example, to stop at the first compressed
50
+#define S_4MiB 4194304
28
* cluster which may require a different handling)
51
+#define S_8MiB 8388608
29
*/
52
+#define S_16MiB 16777216
30
-static int count_contiguous_clusters(int nb_clusters, int cluster_size,
53
+#define S_32MiB 33554432
31
- uint64_t *l2_slice, uint64_t stop_flags)
54
+#define S_64MiB 67108864
32
+static int count_contiguous_clusters(BlockDriverState *bs, int nb_clusters,
55
+#define S_128MiB 134217728
33
+ int cluster_size, uint64_t *l2_slice, uint64_t stop_flags)
56
+#define S_256MiB 268435456
34
{
57
+#define S_512MiB 536870912
35
int i;
58
+#define S_1GiB 1073741824
36
QCow2ClusterType first_cluster_type;
59
+#define S_2GiB 2147483648
37
@@ -XXX,XX +XXX,XX @@ static int count_contiguous_clusters(int nb_clusters, int cluster_size,
60
+#define S_4GiB 4294967296
38
}
61
+#define S_8GiB 8589934592
39
62
+#define S_16GiB 17179869184
40
/* must be allocated */
63
+#define S_32GiB 34359738368
41
- first_cluster_type = qcow2_get_cluster_type(first_entry);
64
+#define S_64GiB 68719476736
42
+ first_cluster_type = qcow2_get_cluster_type(bs, first_entry);
65
+#define S_128GiB 137438953472
43
assert(first_cluster_type == QCOW2_CLUSTER_NORMAL ||
66
+#define S_256GiB 274877906944
44
first_cluster_type == QCOW2_CLUSTER_ZERO_ALLOC);
67
+#define S_512GiB 549755813888
45
68
+#define S_1TiB 1099511627776
46
@@ -XXX,XX +XXX,XX @@ static int count_contiguous_clusters(int nb_clusters, int cluster_size,
69
+#define S_2TiB 2199023255552
47
* Checks how many consecutive unallocated clusters in a given L2
70
+#define S_4TiB 4398046511104
48
* slice have the same cluster type.
71
+#define S_8TiB 8796093022208
49
*/
72
+#define S_16TiB 17592186044416
50
-static int count_contiguous_clusters_unallocated(int nb_clusters,
73
+#define S_32TiB 35184372088832
51
+static int count_contiguous_clusters_unallocated(BlockDriverState *bs,
74
+#define S_64TiB 70368744177664
52
+ int nb_clusters,
75
+#define S_128TiB 140737488355328
53
uint64_t *l2_slice,
76
+#define S_256TiB 281474976710656
54
QCow2ClusterType wanted_type)
77
+#define S_512TiB 562949953421312
55
{
78
+#define S_1PiB 1125899906842624
56
@@ -XXX,XX +XXX,XX @@ static int count_contiguous_clusters_unallocated(int nb_clusters,
79
+#define S_2PiB 2251799813685248
57
wanted_type == QCOW2_CLUSTER_UNALLOCATED);
80
+#define S_4PiB 4503599627370496
58
for (i = 0; i < nb_clusters; i++) {
81
+#define S_8PiB 9007199254740992
59
uint64_t entry = be64_to_cpu(l2_slice[i]);
82
+#define S_16PiB 18014398509481984
60
- QCow2ClusterType type = qcow2_get_cluster_type(entry);
83
+#define S_32PiB 36028797018963968
61
+ QCow2ClusterType type = qcow2_get_cluster_type(bs, entry);
84
+#define S_64PiB 72057594037927936
62
85
+#define S_128PiB 144115188075855872
63
if (type != wanted_type) {
86
+#define S_256PiB 288230376151711744
64
break;
87
+#define S_512PiB 576460752303423488
65
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
88
+#define S_1EiB 1152921504606846976
66
* true */
89
+#define S_2EiB 2305843009213693952
67
assert(nb_clusters <= INT_MAX);
90
+#define S_4EiB 4611686018427387904
68
91
+#define S_8EiB 9223372036854775808
69
- type = qcow2_get_cluster_type(*cluster_offset);
92
+
70
+ type = qcow2_get_cluster_type(bs, *cluster_offset);
93
#endif
71
if (s->qcow_version < 3 && (type == QCOW2_CLUSTER_ZERO_PLAIN ||
72
type == QCOW2_CLUSTER_ZERO_ALLOC)) {
73
qcow2_signal_corruption(bs, true, -1, -1, "Zero cluster entry found"
74
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
75
case QCOW2_CLUSTER_ZERO_PLAIN:
76
case QCOW2_CLUSTER_UNALLOCATED:
77
/* how many empty clusters ? */
78
- c = count_contiguous_clusters_unallocated(nb_clusters,
79
+ c = count_contiguous_clusters_unallocated(bs, nb_clusters,
80
&l2_slice[l2_index], type);
81
*cluster_offset = 0;
82
break;
83
case QCOW2_CLUSTER_ZERO_ALLOC:
84
case QCOW2_CLUSTER_NORMAL:
85
/* how many allocated clusters ? */
86
- c = count_contiguous_clusters(nb_clusters, s->cluster_size,
87
+ c = count_contiguous_clusters(bs, nb_clusters, s->cluster_size,
88
&l2_slice[l2_index], QCOW_OFLAG_ZERO);
89
*cluster_offset &= L2E_OFFSET_MASK;
90
if (offset_into_cluster(s, *cluster_offset)) {
91
@@ -XXX,XX +XXX,XX @@ void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m)
92
* write, but require COW to be performed (this includes yet unallocated space,
93
* which must copy from the backing file)
94
*/
95
-static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters,
96
+static int count_cow_clusters(BlockDriverState *bs, int nb_clusters,
97
uint64_t *l2_slice, int l2_index)
98
{
99
int i;
100
101
for (i = 0; i < nb_clusters; i++) {
102
uint64_t l2_entry = be64_to_cpu(l2_slice[l2_index + i]);
103
- QCow2ClusterType cluster_type = qcow2_get_cluster_type(l2_entry);
104
+ QCow2ClusterType cluster_type = qcow2_get_cluster_type(bs, l2_entry);
105
106
switch(cluster_type) {
107
case QCOW2_CLUSTER_NORMAL:
108
@@ -XXX,XX +XXX,XX @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset,
109
cluster_offset = be64_to_cpu(l2_slice[l2_index]);
110
111
/* Check how many clusters are already allocated and don't need COW */
112
- if (qcow2_get_cluster_type(cluster_offset) == QCOW2_CLUSTER_NORMAL
113
+ if (qcow2_get_cluster_type(bs, cluster_offset) == QCOW2_CLUSTER_NORMAL
114
&& (cluster_offset & QCOW_OFLAG_COPIED))
115
{
116
/* If a specific host_offset is required, check it */
117
@@ -XXX,XX +XXX,XX @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset,
118
119
/* We keep all QCOW_OFLAG_COPIED clusters */
120
keep_clusters =
121
- count_contiguous_clusters(nb_clusters, s->cluster_size,
122
+ count_contiguous_clusters(bs, nb_clusters, s->cluster_size,
123
&l2_slice[l2_index],
124
QCOW_OFLAG_COPIED | QCOW_OFLAG_ZERO);
125
assert(keep_clusters <= nb_clusters);
126
@@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
127
if (entry & QCOW_OFLAG_COMPRESSED) {
128
nb_clusters = 1;
129
} else {
130
- nb_clusters = count_cow_clusters(s, nb_clusters, l2_slice, l2_index);
131
+ nb_clusters = count_cow_clusters(bs, nb_clusters, l2_slice, l2_index);
132
}
133
134
/* This function is only called when there were no non-COW clusters, so if
135
@@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
136
* wrong with our code. */
137
assert(nb_clusters > 0);
138
139
- if (qcow2_get_cluster_type(entry) == QCOW2_CLUSTER_ZERO_ALLOC &&
140
+ if (qcow2_get_cluster_type(bs, entry) == QCOW2_CLUSTER_ZERO_ALLOC &&
141
(entry & QCOW_OFLAG_COPIED) &&
142
(!*host_offset ||
143
start_of_cluster(s, *host_offset) == (entry & L2E_OFFSET_MASK)))
144
@@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
145
* would be fine, too, but count_cow_clusters() above has limited
146
* nb_clusters already to a range of COW clusters */
147
preallocated_nb_clusters =
148
- count_contiguous_clusters(nb_clusters, s->cluster_size,
149
+ count_contiguous_clusters(bs, nb_clusters, s->cluster_size,
150
&l2_slice[l2_index], QCOW_OFLAG_COPIED);
151
assert(preallocated_nb_clusters > 0);
152
153
@@ -XXX,XX +XXX,XX @@ static int discard_in_l2_slice(BlockDriverState *bs, uint64_t offset,
154
* If full_discard is true, the sector should not read back as zeroes,
155
* but rather fall through to the backing file.
156
*/
157
- switch (qcow2_get_cluster_type(old_l2_entry)) {
158
+ switch (qcow2_get_cluster_type(bs, old_l2_entry)) {
159
case QCOW2_CLUSTER_UNALLOCATED:
160
if (full_discard || !bs->backing) {
161
continue;
162
@@ -XXX,XX +XXX,XX @@ static int zero_in_l2_slice(BlockDriverState *bs, uint64_t offset,
163
* Minimize L2 changes if the cluster already reads back as
164
* zeroes with correct allocation.
165
*/
166
- cluster_type = qcow2_get_cluster_type(old_offset);
167
+ cluster_type = qcow2_get_cluster_type(bs, old_offset);
168
if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN ||
169
(cluster_type == QCOW2_CLUSTER_ZERO_ALLOC && !unmap)) {
170
continue;
171
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
172
uint64_t l2_entry = be64_to_cpu(l2_slice[j]);
173
int64_t offset = l2_entry & L2E_OFFSET_MASK;
174
QCow2ClusterType cluster_type =
175
- qcow2_get_cluster_type(l2_entry);
176
+ qcow2_get_cluster_type(bs, l2_entry);
177
178
if (cluster_type != QCOW2_CLUSTER_ZERO_PLAIN &&
179
cluster_type != QCOW2_CLUSTER_ZERO_ALLOC) {
180
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
181
index XXXXXXX..XXXXXXX 100644
182
--- a/block/qcow2-refcount.c
183
+++ b/block/qcow2-refcount.c
184
@@ -XXX,XX +XXX,XX @@ void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry,
185
{
186
BDRVQcow2State *s = bs->opaque;
187
188
- switch (qcow2_get_cluster_type(l2_entry)) {
189
+ switch (qcow2_get_cluster_type(bs, l2_entry)) {
190
case QCOW2_CLUSTER_COMPRESSED:
191
{
192
int nb_csectors;
193
@@ -XXX,XX +XXX,XX @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
194
entry &= ~QCOW_OFLAG_COPIED;
195
offset = entry & L2E_OFFSET_MASK;
196
197
- switch (qcow2_get_cluster_type(entry)) {
198
+ switch (qcow2_get_cluster_type(bs, entry)) {
199
case QCOW2_CLUSTER_COMPRESSED:
200
nb_csectors = ((entry >> s->csize_shift) &
201
s->csize_mask) + 1;
202
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
203
for(i = 0; i < s->l2_size; i++) {
204
l2_entry = be64_to_cpu(l2_table[i]);
205
206
- switch (qcow2_get_cluster_type(l2_entry)) {
207
+ switch (qcow2_get_cluster_type(bs, l2_entry)) {
208
case QCOW2_CLUSTER_COMPRESSED:
209
/* Compressed clusters don't have QCOW_OFLAG_COPIED */
210
if (l2_entry & QCOW_OFLAG_COPIED) {
211
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
212
213
/* Correct offsets are cluster aligned */
214
if (offset_into_cluster(s, offset)) {
215
- if (qcow2_get_cluster_type(l2_entry) ==
216
+ if (qcow2_get_cluster_type(bs, l2_entry) ==
217
QCOW2_CLUSTER_ZERO_ALLOC)
218
{
219
fprintf(stderr, "%s offset=%" PRIx64 ": Preallocated zero "
220
@@ -XXX,XX +XXX,XX @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res,
221
for (j = 0; j < s->l2_size; j++) {
222
uint64_t l2_entry = be64_to_cpu(l2_table[j]);
223
uint64_t data_offset = l2_entry & L2E_OFFSET_MASK;
224
- QCow2ClusterType cluster_type = qcow2_get_cluster_type(l2_entry);
225
+ QCow2ClusterType cluster_type = qcow2_get_cluster_type(bs, l2_entry);
226
227
if (cluster_type == QCOW2_CLUSTER_NORMAL ||
228
cluster_type == QCOW2_CLUSTER_ZERO_ALLOC) {
94
--
229
--
95
2.13.6
230
2.20.1
96
231
97
232
diff view generated by jsdifflib
1
From: Leonid Bloch <lbloch@janustech.com>
2
3
The upper limit on the L2 cache size is increased from 1 MB to 32 MB
4
on Linux platforms, and to 8 MB on other platforms (this difference is
5
caused by the ability to set intervals for cache cleaning on Linux
6
platforms only).
7
8
This is done in order to allow default full coverage with the L2 cache
9
for images of up to 256 GB in size (was 8 GB). Note, that only the
10
needed amount to cover the full image is allocated. The value which is
11
changed here is just the upper limit on the L2 cache size, beyond which
12
it will not grow, even if the size of the image will require it to.
13
14
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
15
Reviewed-by: Alberto Garcia <berto@igalia.com>
16
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
17
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
18
---
2
---
19
docs/qcow2-cache.txt | 15 +++++++++------
3
block/qcow2.h | 10 +++++++++-
20
block/qcow2.h | 6 +++++-
4
1 file changed, 9 insertions(+), 1 deletion(-)
21
qemu-options.hx | 6 +++---
22
3 files changed, 17 insertions(+), 10 deletions(-)
23
5
24
diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt
25
index XXXXXXX..XXXXXXX 100644
26
--- a/docs/qcow2-cache.txt
27
+++ b/docs/qcow2-cache.txt
28
@@ -XXX,XX +XXX,XX @@ There are a few things that need to be taken into account:
29
- Both caches must have a size that is a multiple of the cluster size
30
(or the cache entry size: see "Using smaller cache sizes" below).
31
32
- - The maximum L2 cache size is 1 MB by default (enough for full coverage
33
- of 8 GB images, with the default cluster size). This value can be
34
- modified using the "l2-cache-size" option. QEMU will not use more memory
35
- than needed to hold all of the image's L2 tables, regardless of this max.
36
- value. The minimal L2 cache size is 2 clusters (or 2 cache entries, see
37
- below).
38
+ - The maximum L2 cache size is 32 MB by default on Linux platforms (enough
39
+ for full coverage of 256 GB images, with the default cluster size). This
40
+ value can be modified using the "l2-cache-size" option. QEMU will not use
41
+ more memory than needed to hold all of the image's L2 tables, regardless
42
+ of this max. value.
43
+ On non-Linux platforms the maximal value is smaller by default (8 MB) and
44
+ this difference stems from the fact that on Linux the cache can be cleared
45
+ periodically if needed, using the "cache-clean-interval" option (see below).
46
+ The minimal L2 cache size is 2 clusters (or 2 cache entries, see below).
47
48
- The default (and minimum) refcount cache size is 4 clusters.
49
50
diff --git a/block/qcow2.h b/block/qcow2.h
6
diff --git a/block/qcow2.h b/block/qcow2.h
51
index XXXXXXX..XXXXXXX 100644
7
index XXXXXXX..XXXXXXX 100644
52
--- a/block/qcow2.h
8
--- a/block/qcow2.h
53
+++ b/block/qcow2.h
9
+++ b/block/qcow2.h
54
@@ -XXX,XX +XXX,XX @@
10
@@ -XXX,XX +XXX,XX @@ static inline QCow2ClusterType qcow2_get_cluster_type(BlockDriverState *bs,
55
/* Must be at least 4 to cover all cases of refcount table growth */
11
}
56
#define MIN_REFCOUNT_CACHE_SIZE 4 /* clusters */
12
return QCOW2_CLUSTER_ZERO_PLAIN;
57
13
} else if (!(l2_entry & L2E_OFFSET_MASK)) {
58
-#define DEFAULT_L2_CACHE_MAX_SIZE S_1MiB
14
- return QCOW2_CLUSTER_UNALLOCATED;
59
+#ifdef CONFIG_LINUX
15
+ /* Offset 0 generally means unallocated, but it is ambiguous with
60
+#define DEFAULT_L2_CACHE_MAX_SIZE S_32MiB
16
+ * external data files because 0 is a valid offset there. However, all
61
+#else
17
+ * clusters in external data files always have refcount 1, so we can
62
+#define DEFAULT_L2_CACHE_MAX_SIZE S_8MiB
18
+ * rely on QCOW_OFLAG_COPIED to disambiguate. */
63
+#endif
19
+ if (has_data_file(bs) && (l2_entry & QCOW_OFLAG_COPIED)) {
64
20
+ return QCOW2_CLUSTER_NORMAL;
65
#define DEFAULT_CLUSTER_SIZE S_64KiB
21
+ } else {
66
22
+ return QCOW2_CLUSTER_UNALLOCATED;
67
diff --git a/qemu-options.hx b/qemu-options.hx
23
+ }
68
index XXXXXXX..XXXXXXX 100644
24
} else {
69
--- a/qemu-options.hx
25
return QCOW2_CLUSTER_NORMAL;
70
+++ b/qemu-options.hx
26
}
71
@@ -XXX,XX +XXX,XX @@ The maximum total size of the L2 table and refcount block caches in bytes
72
73
@item l2-cache-size
74
The maximum size of the L2 table cache in bytes
75
-(default: if cache-size is not specified - 1M; otherwise, as large as possible
76
-within the cache-size, while permitting the requested or the minimal refcount
77
-cache size)
78
+(default: if cache-size is not specified - 32M on Linux platforms, and 8M on
79
+non-Linux platforms; otherwise, as large as possible within the cache-size,
80
+while permitting the requested or the minimal refcount cache size)
81
82
@item refcount-cache-size
83
The maximum size of the refcount block cache in bytes
84
--
27
--
85
2.13.6
28
2.20.1
86
29
87
30
diff view generated by jsdifflib
1
qemu_event_reset() must be called before the AIO request in a different
1
Offset 0 can be valid for normal (allocated) clusters now, so use
2
iothread is submitted. Otherwise the request could be completed before
2
qcow2_get_cluster_type() instead.
3
we do the qemu_event_reset() and the test would hang in
4
qemu_event_wait().
5
3
6
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
Tested-by: Max Reitz <mreitz@redhat.com>
9
---
5
---
10
tests/test-bdrv-drain.c | 4 ++--
6
block/qcow2-cluster.c | 4 ++--
11
1 file changed, 2 insertions(+), 2 deletions(-)
7
1 file changed, 2 insertions(+), 2 deletions(-)
12
8
13
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
9
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
14
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
15
--- a/tests/test-bdrv-drain.c
11
--- a/block/qcow2-cluster.c
16
+++ b/tests/test-bdrv-drain.c
12
+++ b/block/qcow2-cluster.c
17
@@ -XXX,XX +XXX,XX @@ static void test_iothread_common(enum drain_type drain_type, int drain_thread)
13
@@ -XXX,XX +XXX,XX @@ static int count_contiguous_clusters(BlockDriverState *bs, int nb_clusters,
18
s->bh_indirection_ctx = ctx_b;
14
uint64_t first_entry = be64_to_cpu(l2_slice[0]);
19
15
uint64_t offset = first_entry & mask;
20
aio_ret = -EINPROGRESS;
16
21
+ qemu_event_reset(&done_event);
17
- if (!offset) {
22
+
18
+ first_cluster_type = qcow2_get_cluster_type(bs, first_entry);
23
if (drain_thread == 0) {
19
+ if (first_cluster_type == QCOW2_CLUSTER_UNALLOCATED) {
24
acb = blk_aio_preadv(blk, 0, &qiov, 0, test_iothread_aio_cb, &aio_ret);
20
return 0;
25
} else {
21
}
26
@@ -XXX,XX +XXX,XX @@ static void test_iothread_common(enum drain_type drain_type, int drain_thread)
22
27
* but the drain in this thread can continue immediately after
23
/* must be allocated */
28
* bdrv_dec_in_flight() and aio_ret might be assigned only slightly
24
- first_cluster_type = qcow2_get_cluster_type(bs, first_entry);
29
* later. */
25
assert(first_cluster_type == QCOW2_CLUSTER_NORMAL ||
30
- qemu_event_reset(&done_event);
26
first_cluster_type == QCOW2_CLUSTER_ZERO_ALLOC);
31
do_drain_begin(drain_type, bs);
27
32
g_assert_cmpint(bs->in_flight, ==, 0);
33
34
@@ -XXX,XX +XXX,XX @@ static void test_iothread_common(enum drain_type drain_type, int drain_thread)
35
}
36
break;
37
case 1:
38
- qemu_event_reset(&done_event);
39
aio_bh_schedule_oneshot(ctx_a, test_iothread_drain_entry, &data);
40
qemu_event_wait(&done_event);
41
break;
42
--
28
--
43
2.13.6
29
2.20.1
44
30
45
31
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
The cluster allocation code uses 0 as an invalid offset that is used in
2
case of errors or as "offset not yet determined". With external data
3
files, a host cluster offset of 0 becomes valid, though.
2
4
3
The file-posix code is used for the "file", "host_device" and
5
Define a constant INV_OFFSET (which is not cluster aligned and will
4
"host_cdrom" drivers, and it allows reopening images. However the only
6
therefore never be a valid offset) that can be used for such purposes.
5
option that is actually processed is "x-check-cache-dropped", and
6
changes in all other options (e.g. "filename") are silently ignored:
7
7
8
(qemu) qemu-io virtio0 "reopen -o file.filename=no-such-file"
8
This removes the additional host_offset == 0 check that commit
9
ff52aab2df5 introduced; the confusion between an invalid offset and
10
(erroneous) allocation at offset 0 is removed with this change.
9
11
10
While we could allow changing some of the other options, let's keep
11
things as they are for now but return an error if the user tries to
12
change any of them.
13
14
Signed-off-by: Alberto Garcia <berto@igalia.com>
15
Reviewed-by: Max Reitz <mreitz@redhat.com>
16
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
17
---
13
---
18
block/file-posix.c | 9 +++++++--
14
block/qcow2.h | 2 ++
19
1 file changed, 7 insertions(+), 2 deletions(-)
15
block/qcow2-cluster.c | 59 ++++++++++++++++++++-----------------------
16
2 files changed, 29 insertions(+), 32 deletions(-)
20
17
21
diff --git a/block/file-posix.c b/block/file-posix.c
18
diff --git a/block/qcow2.h b/block/qcow2.h
22
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
23
--- a/block/file-posix.c
20
--- a/block/qcow2.h
24
+++ b/block/file-posix.c
21
+++ b/block/qcow2.h
25
@@ -XXX,XX +XXX,XX @@ static int raw_reopen_prepare(BDRVReopenState *state,
22
@@ -XXX,XX +XXX,XX @@ typedef enum QCow2MetadataOverlap {
26
goto out;
23
24
#define REFT_OFFSET_MASK 0xfffffffffffffe00ULL
25
26
+#define INV_OFFSET (-1ULL)
27
+
28
static inline bool has_data_file(BlockDriverState *bs)
29
{
30
BDRVQcow2State *s = bs->opaque;
31
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/block/qcow2-cluster.c
34
+++ b/block/qcow2-cluster.c
35
@@ -XXX,XX +XXX,XX @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
36
37
/*
38
* Checks how many already allocated clusters that don't require a copy on
39
- * write there are at the given guest_offset (up to *bytes). If
40
- * *host_offset is not zero, only physically contiguous clusters beginning at
41
- * this host offset are counted.
42
+ * write there are at the given guest_offset (up to *bytes). If *host_offset is
43
+ * not INV_OFFSET, only physically contiguous clusters beginning at this host
44
+ * offset are counted.
45
*
46
* Note that guest_offset may not be cluster aligned. In this case, the
47
* returned *host_offset points to exact byte referenced by guest_offset and
48
@@ -XXX,XX +XXX,XX @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset,
49
trace_qcow2_handle_copied(qemu_coroutine_self(), guest_offset, *host_offset,
50
*bytes);
51
52
- assert(*host_offset == 0 || offset_into_cluster(s, guest_offset)
53
- == offset_into_cluster(s, *host_offset));
54
+ assert(*host_offset == INV_OFFSET || offset_into_cluster(s, guest_offset)
55
+ == offset_into_cluster(s, *host_offset));
56
57
/*
58
* Calculate the number of clusters to look for. We stop at L2 slice
59
@@ -XXX,XX +XXX,XX @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset,
60
goto out;
61
}
62
63
- if (*host_offset != 0 && !offset_matches) {
64
+ if (*host_offset != INV_OFFSET && !offset_matches) {
65
*bytes = 0;
66
ret = 0;
67
goto out;
68
@@ -XXX,XX +XXX,XX @@ out:
69
* contain the number of clusters that have been allocated and are contiguous
70
* in the image file.
71
*
72
- * If *host_offset is non-zero, it specifies the offset in the image file at
73
- * which the new clusters must start. *nb_clusters can be 0 on return in this
74
- * case if the cluster at host_offset is already in use. If *host_offset is
75
- * zero, the clusters can be allocated anywhere in the image file.
76
+ * If *host_offset is not INV_OFFSET, it specifies the offset in the image file
77
+ * at which the new clusters must start. *nb_clusters can be 0 on return in
78
+ * this case if the cluster at host_offset is already in use. If *host_offset
79
+ * is INV_OFFSET, the clusters can be allocated anywhere in the image file.
80
*
81
* *host_offset is updated to contain the offset into the image file at which
82
* the first allocated cluster starts.
83
@@ -XXX,XX +XXX,XX @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset,
84
85
/* Allocate new clusters */
86
trace_qcow2_cluster_alloc_phys(qemu_coroutine_self());
87
- if (*host_offset == 0) {
88
+ if (*host_offset == INV_OFFSET) {
89
int64_t cluster_offset =
90
qcow2_alloc_clusters(bs, *nb_clusters * s->cluster_size);
91
if (cluster_offset < 0) {
92
@@ -XXX,XX +XXX,XX @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset,
93
94
/*
95
* Allocates new clusters for an area that either is yet unallocated or needs a
96
- * copy on write. If *host_offset is non-zero, clusters are only allocated if
97
- * the new allocation can match the specified host offset.
98
+ * copy on write. If *host_offset is not INV_OFFSET, clusters are only
99
+ * allocated if the new allocation can match the specified host offset.
100
*
101
* Note that guest_offset may not be cluster aligned. In this case, the
102
* returned *host_offset points to exact byte referenced by guest_offset and
103
@@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
104
int ret;
105
bool keep_old_clusters = false;
106
107
- uint64_t alloc_cluster_offset = 0;
108
+ uint64_t alloc_cluster_offset = INV_OFFSET;
109
110
trace_qcow2_handle_alloc(qemu_coroutine_self(), guest_offset, *host_offset,
111
*bytes);
112
@@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
113
114
if (qcow2_get_cluster_type(bs, entry) == QCOW2_CLUSTER_ZERO_ALLOC &&
115
(entry & QCOW_OFLAG_COPIED) &&
116
- (!*host_offset ||
117
+ (*host_offset == INV_OFFSET ||
118
start_of_cluster(s, *host_offset) == (entry & L2E_OFFSET_MASK)))
119
{
120
int preallocated_nb_clusters;
121
@@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
122
123
qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
124
125
- if (!alloc_cluster_offset) {
126
+ if (alloc_cluster_offset == INV_OFFSET) {
127
/* Allocate, if necessary at a given offset in the image file */
128
- alloc_cluster_offset = start_of_cluster(s, *host_offset);
129
+ alloc_cluster_offset = *host_offset == INV_OFFSET ? INV_OFFSET :
130
+ start_of_cluster(s, *host_offset);
131
ret = do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_offset,
132
&nb_clusters);
133
if (ret < 0) {
134
@@ -XXX,XX +XXX,XX @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
135
return 0;
136
}
137
138
- /* !*host_offset would overwrite the image header and is reserved for
139
- * "no host offset preferred". If 0 was a valid host offset, it'd
140
- * trigger the following overlap check; do that now to avoid having an
141
- * invalid value in *host_offset. */
142
- if (!alloc_cluster_offset) {
143
- ret = qcow2_pre_write_overlap_check(bs, 0, alloc_cluster_offset,
144
- nb_clusters * s->cluster_size);
145
- assert(ret < 0);
146
- goto fail;
147
- }
148
+ assert(alloc_cluster_offset != INV_OFFSET);
27
}
149
}
28
150
29
- rs->check_cache_dropped = qemu_opt_get_bool(opts, "x-check-cache-dropped",
151
/*
30
- false);
152
@@ -XXX,XX +XXX,XX @@ int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset,
31
+ rs->check_cache_dropped =
153
again:
32
+ qemu_opt_get_bool_del(opts, "x-check-cache-dropped", false);
154
start = offset;
155
remaining = *bytes;
156
- cluster_offset = 0;
157
- *host_offset = 0;
158
+ cluster_offset = INV_OFFSET;
159
+ *host_offset = INV_OFFSET;
160
cur_bytes = 0;
161
*m = NULL;
162
163
while (true) {
164
165
- if (!*host_offset) {
166
+ if (*host_offset == INV_OFFSET && cluster_offset != INV_OFFSET) {
167
*host_offset = start_of_cluster(s, cluster_offset);
168
}
169
170
@@ -XXX,XX +XXX,XX @@ again:
171
172
start += cur_bytes;
173
remaining -= cur_bytes;
174
- cluster_offset += cur_bytes;
33
+
175
+
34
+ /* This driver's reopen function doesn't currently allow changing
176
+ if (cluster_offset != INV_OFFSET) {
35
+ * other options, so let's put them back in the original QDict and
177
+ cluster_offset += cur_bytes;
36
+ * bdrv_reopen_prepare() will detect changes and complain. */
178
+ }
37
+ qemu_opts_to_qdict(opts, state->options);
179
38
180
if (remaining == 0) {
39
if (s->type == FTYPE_CD) {
181
break;
40
rs->open_flags |= O_NONBLOCK;
182
@@ -XXX,XX +XXX,XX @@ again:
183
184
*bytes -= remaining;
185
assert(*bytes > 0);
186
- assert(*host_offset != 0);
187
+ assert(*host_offset != INV_OFFSET);
188
189
return 0;
190
}
41
--
191
--
42
2.13.6
192
2.20.1
43
193
44
194
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
qcow2_alloc_compressed_cluster_offset() used to return the cluster
2
offset for success and 0 for error. This doesn't only conflict with 0 as
3
a valid host offset, but also loses the error code.
2
4
3
The bdrv_reopen_prepare() function checks all options passed to each
5
Similar to the change made to qcow2_alloc_cluster_offset() for
4
BlockDriverState (in the reopen_state->options QDict) and makes all
6
uncompressed clusters in commit 148da7ea9d6, make the function return
5
necessary preparations to apply the option changes requested by the
7
0/-errno and return the allocated cluster offset in a by-reference
6
user.
8
parameter.
7
9
8
Options are removed from the QDict as they are processed, so at the
9
end of bdrv_reopen_prepare() only the options that can't be changed
10
are left. Then a loop goes over all remaining options and verifies
11
that the old and new values are identical, returning an error if
12
they're not.
13
14
The problem is that at the moment there are options that are removed
15
from the QDict although they can't be changed. The consequence of this
16
is any modification to any of those options is silently ignored:
17
18
(qemu) qemu-io virtio0 "reopen -o discard=on"
19
20
This happens when all options from bdrv_runtime_opts are removed
21
from the QDict but then only a few of them are processed. Since
22
it's especially important that "node-name" and "driver" are not
23
changed, the code puts them back into the QDict so they are checked
24
at the end of the function. Instead of putting only those two options
25
back into the QDict, this patch puts all unprocessed options using
26
qemu_opts_to_qdict().
27
28
update_flags_from_options() also needs to be modified to prevent
29
BDRV_OPT_CACHE_NO_FLUSH, BDRV_OPT_CACHE_DIRECT and BDRV_OPT_READ_ONLY
30
from going back to the QDict.
31
32
Signed-off-by: Alberto Garcia <berto@igalia.com>
33
Reviewed-by: Max Reitz <mreitz@redhat.com>
34
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
35
---
11
---
36
block.c | 22 +++++++---------------
12
block/qcow2.h | 7 ++++---
37
1 file changed, 7 insertions(+), 15 deletions(-)
13
block/qcow2-cluster.c | 28 +++++++++++++---------------
14
block/qcow2.c | 19 ++++++++-----------
15
tests/qemu-iotests/220.out | 2 +-
16
4 files changed, 26 insertions(+), 30 deletions(-)
38
17
39
diff --git a/block.c b/block.c
18
diff --git a/block/qcow2.h b/block/qcow2.h
40
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
41
--- a/block.c
20
--- a/block/qcow2.h
42
+++ b/block.c
21
+++ b/block/qcow2.h
43
@@ -XXX,XX +XXX,XX @@ static void update_flags_from_options(int *flags, QemuOpts *opts)
22
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
44
*flags &= ~BDRV_O_CACHE_MASK;
23
int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset,
45
24
unsigned int *bytes, uint64_t *host_offset,
46
assert(qemu_opt_find(opts, BDRV_OPT_CACHE_NO_FLUSH));
25
QCowL2Meta **m);
47
- if (qemu_opt_get_bool(opts, BDRV_OPT_CACHE_NO_FLUSH, false)) {
26
-uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
48
+ if (qemu_opt_get_bool_del(opts, BDRV_OPT_CACHE_NO_FLUSH, false)) {
27
- uint64_t offset,
49
*flags |= BDRV_O_NO_FLUSH;
28
- int compressed_size);
29
+int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
30
+ uint64_t offset,
31
+ int compressed_size,
32
+ uint64_t *host_offset);
33
34
int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m);
35
void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m);
36
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/block/qcow2-cluster.c
39
+++ b/block/qcow2-cluster.c
40
@@ -XXX,XX +XXX,XX @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
41
/*
42
* alloc_compressed_cluster_offset
43
*
44
- * For a given offset of the disk image, return cluster offset in
45
- * qcow2 file.
46
- *
47
- * If the offset is not found, allocate a new compressed cluster.
48
- *
49
- * Return the cluster offset if successful,
50
- * Return 0, otherwise.
51
+ * For a given offset on the virtual disk, allocate a new compressed cluster
52
+ * and put the host offset of the cluster into *host_offset. If a cluster is
53
+ * already allocated at the offset, return an error.
54
*
55
+ * Return 0 on success and -errno in error cases
56
*/
57
-
58
-uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
59
- uint64_t offset,
60
- int compressed_size)
61
+int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
62
+ uint64_t offset,
63
+ int compressed_size,
64
+ uint64_t *host_offset)
65
{
66
BDRVQcow2State *s = bs->opaque;
67
int l2_index, ret;
68
@@ -XXX,XX +XXX,XX @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
69
70
ret = get_cluster_table(bs, offset, &l2_slice, &l2_index);
71
if (ret < 0) {
72
- return 0;
73
+ return ret;
50
}
74
}
51
75
52
assert(qemu_opt_find(opts, BDRV_OPT_CACHE_DIRECT));
76
/* Compression can't overwrite anything. Fail if the cluster was already
53
- if (qemu_opt_get_bool(opts, BDRV_OPT_CACHE_DIRECT, false)) {
77
@@ -XXX,XX +XXX,XX @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
54
+ if (qemu_opt_get_bool_del(opts, BDRV_OPT_CACHE_DIRECT, false)) {
78
cluster_offset = be64_to_cpu(l2_slice[l2_index]);
55
*flags |= BDRV_O_NOCACHE;
79
if (cluster_offset & L2E_OFFSET_MASK) {
80
qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
81
- return 0;
82
+ return -EIO;
56
}
83
}
57
84
58
*flags &= ~BDRV_O_RDWR;
85
cluster_offset = qcow2_alloc_bytes(bs, compressed_size);
59
86
if (cluster_offset < 0) {
60
assert(qemu_opt_find(opts, BDRV_OPT_READ_ONLY));
87
qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
61
- if (!qemu_opt_get_bool(opts, BDRV_OPT_READ_ONLY, false)) {
88
- return 0;
62
+ if (!qemu_opt_get_bool_del(opts, BDRV_OPT_READ_ONLY, false)) {
89
+ return cluster_offset;
63
*flags |= BDRV_O_RDWR;
64
}
90
}
65
91
66
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
92
nb_csectors = ((cluster_offset + compressed_size - 1) >> 9) -
67
BlockDriver *drv;
93
@@ -XXX,XX +XXX,XX @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
68
QemuOpts *opts;
94
l2_slice[l2_index] = cpu_to_be64(cluster_offset);
69
QDict *orig_reopen_opts;
95
qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
70
- const char *value;
96
71
bool read_only;
97
- return cluster_offset;
72
98
+ *host_offset = cluster_offset & s->cluster_offset_mask;
73
assert(reopen_state != NULL);
99
+ return 0;
74
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
100
}
75
101
76
update_flags_from_options(&reopen_state->flags, opts);
102
static int perform_cow(BlockDriverState *bs, QCowL2Meta *m)
77
103
diff --git a/block/qcow2.c b/block/qcow2.c
78
- /* node-name and driver must be unchanged. Put them back into the QDict, so
104
index XXXXXXX..XXXXXXX 100644
79
- * that they are checked at the end of this function. */
105
--- a/block/qcow2.c
80
- value = qemu_opt_get(opts, "node-name");
106
+++ b/block/qcow2.c
81
- if (value) {
107
@@ -XXX,XX +XXX,XX @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset,
82
- qdict_put_str(reopen_state->options, "node-name", value);
108
int ret;
83
- }
109
size_t out_len;
84
-
110
uint8_t *buf, *out_buf;
85
- value = qemu_opt_get(opts, "driver");
111
- int64_t cluster_offset;
86
- if (value) {
112
+ uint64_t cluster_offset;
87
- qdict_put_str(reopen_state->options, "driver", value);
113
88
- }
114
if (bytes == 0) {
89
+ /* All other options (including node-name and driver) must be unchanged.
115
/* align end of file to a sector boundary to ease reading with
90
+ * Put them back into the QDict, so that they are checked at the end
116
sector based I/Os */
91
+ * of this function. */
117
- cluster_offset = bdrv_getlength(bs->file->bs);
92
+ qemu_opts_to_qdict(opts, reopen_state->options);
118
- if (cluster_offset < 0) {
93
119
- return cluster_offset;
94
/* If we are to stay read-only, do not allow permission change
120
+ int64_t len = bdrv_getlength(bs->file->bs);
95
* to r/w. Attempting to set to r/w may fail if either BDRV_O_ALLOW_RDWR is
121
+ if (len < 0) {
122
+ return len;
123
}
124
- return bdrv_co_truncate(bs->file, cluster_offset, PREALLOC_MODE_OFF,
125
- NULL);
126
+ return bdrv_co_truncate(bs->file, len, PREALLOC_MODE_OFF, NULL);
127
}
128
129
if (offset_into_cluster(s, offset)) {
130
@@ -XXX,XX +XXX,XX @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset,
131
}
132
133
qemu_co_mutex_lock(&s->lock);
134
- cluster_offset =
135
- qcow2_alloc_compressed_cluster_offset(bs, offset, out_len);
136
- if (!cluster_offset) {
137
+ ret = qcow2_alloc_compressed_cluster_offset(bs, offset, out_len,
138
+ &cluster_offset);
139
+ if (ret < 0) {
140
qemu_co_mutex_unlock(&s->lock);
141
- ret = -EIO;
142
goto fail;
143
}
144
- cluster_offset &= s->cluster_offset_mask;
145
146
ret = qcow2_pre_write_overlap_check(bs, 0, cluster_offset, out_len);
147
qemu_co_mutex_unlock(&s->lock);
148
diff --git a/tests/qemu-iotests/220.out b/tests/qemu-iotests/220.out
149
index XXXXXXX..XXXXXXX 100644
150
--- a/tests/qemu-iotests/220.out
151
+++ b/tests/qemu-iotests/220.out
152
@@ -XXX,XX +XXX,XX @@ wrote 2097152/2097152 bytes at offset 37748736
153
No errors were found on the image.
154
image size 39845888
155
== Trying to write compressed cluster ==
156
-write failed: Input/output error
157
+write failed: File too large
158
image size 562949957615616
159
== Writing normal cluster ==
160
wrote 2097152/2097152 bytes at offset 0
96
--
161
--
97
2.13.6
162
2.20.1
98
163
99
164
diff view generated by jsdifflib
1
From: Leonid Bloch <lbloch@janustech.com>
1
Offset 0 cannot be assumed to mean an unallocated cluster any more.
2
Instead, the cluster type needs to be checked.
2
3
3
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
4
*file must refer to the data file instead of the image file if a valid
4
Reviewed-by: Alberto Garcia <berto@igalia.com>
5
offset is returned from qcow2_co_block_status().
5
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
6
6
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7
---
8
---
8
block/qcow2.c | 4 ++--
9
block/qcow2.c | 4 ++--
9
1 file changed, 2 insertions(+), 2 deletions(-)
10
1 file changed, 2 insertions(+), 2 deletions(-)
10
11
11
diff --git a/block/qcow2.c b/block/qcow2.c
12
diff --git a/block/qcow2.c b/block/qcow2.c
12
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
13
--- a/block/qcow2.c
14
--- a/block/qcow2.c
14
+++ b/block/qcow2.c
15
+++ b/block/qcow2.c
15
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
16
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,
16
/* 2^(s->refcount_order - 3) is the refcount width in bytes */
17
17
s->refcount_block_bits = s->cluster_bits - (s->refcount_order - 3);
18
*pnum = bytes;
18
s->refcount_block_size = 1 << s->refcount_block_bits;
19
19
- bs->total_sectors = header.size / 512;
20
- if (cluster_offset != 0 && ret != QCOW2_CLUSTER_COMPRESSED &&
20
+ bs->total_sectors = header.size / BDRV_SECTOR_SIZE;
21
+ if ((ret == QCOW2_CLUSTER_NORMAL || ret == QCOW2_CLUSTER_ZERO_ALLOC) &&
21
s->csize_shift = (62 - (s->cluster_bits - 8));
22
!s->crypto) {
22
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
23
index_in_cluster = offset & (s->cluster_size - 1);
23
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
24
*map = cluster_offset | index_in_cluster;
24
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
25
- *file = bs->file->bs;
25
goto fail;
26
+ *file = s->data_file->bs;
27
status |= BDRV_BLOCK_OFFSET_VALID;
26
}
28
}
27
29
if (ret == QCOW2_CLUSTER_ZERO_PLAIN || ret == QCOW2_CLUSTER_ZERO_ALLOC) {
28
- old_length = bs->total_sectors * 512;
29
+ old_length = bs->total_sectors * BDRV_SECTOR_SIZE;
30
new_l1_size = size_to_l1(s, offset);
31
32
if (offset < old_length) {
33
--
30
--
34
2.13.6
31
2.20.1
35
32
36
33
diff view generated by jsdifflib
1
From: Leonid Bloch <lbloch@janustech.com>
1
This changes the qcow2 implementation to direct all guest data I/O to
2
s->data_file rather than bs->file, while metadata I/O still uses
3
bs->file. At the moment, this is still always the same, but soon we'll
4
add options to set s->data_file to an external data file.
2
5
3
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
4
Reviewed-by: Alberto Garcia <berto@igalia.com>
5
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
6
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7
---
7
---
8
block/qcow2.h | 9 +++++----
8
block/qcow2.h | 2 +-
9
block/qcow2.c | 2 +-
9
block/qcow2-bitmap.c | 7 +++---
10
2 files changed, 6 insertions(+), 5 deletions(-)
10
block/qcow2-cache.c | 6 ++---
11
block/qcow2-cluster.c | 46 +++++++++++++++++++++++++++++++------
12
block/qcow2-refcount.c | 39 +++++++++++++++++++++++--------
13
block/qcow2-snapshot.c | 7 +++---
14
block/qcow2.c | 52 +++++++++++++++++++++++++++++++++---------
15
7 files changed, 122 insertions(+), 37 deletions(-)
11
16
12
diff --git a/block/qcow2.h b/block/qcow2.h
17
diff --git a/block/qcow2.h b/block/qcow2.h
13
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
14
--- a/block/qcow2.h
19
--- a/block/qcow2.h
15
+++ b/block/qcow2.h
20
+++ b/block/qcow2.h
16
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ void qcow2_process_discards(BlockDriverState *bs, int ret);
17
22
int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset,
18
#include "crypto/block.h"
23
int64_t size);
19
#include "qemu/coroutine.h"
24
int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset,
20
+#include "qemu/units.h"
25
- int64_t size);
21
26
+ int64_t size, bool data_file);
22
//#define DEBUG_ALLOC
27
int qcow2_inc_refcounts_imrt(BlockDriverState *bs, BdrvCheckResult *res,
23
//#define DEBUG_ALLOC2
28
void **refcount_table,
24
@@ -XXX,XX +XXX,XX @@
29
int64_t *refcount_table_size,
25
30
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
26
/* 8 MB refcount table is enough for 2 PB images at 64k cluster size
31
index XXXXXXX..XXXXXXX 100644
27
* (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */
32
--- a/block/qcow2-bitmap.c
28
-#define QCOW_MAX_REFTABLE_SIZE 0x800000
33
+++ b/block/qcow2-bitmap.c
29
+#define QCOW_MAX_REFTABLE_SIZE S_8MiB
34
@@ -XXX,XX +XXX,XX @@ static int bitmap_list_store(BlockDriverState *bs, Qcow2BitmapList *bm_list,
30
35
* directory in-place (actually, turn-off the extension), which is checked
31
/* 32 MB L1 table is enough for 2 PB images at 64k cluster size
36
* in qcow2_check_metadata_overlap() */
32
* (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */
37
ret = qcow2_pre_write_overlap_check(
33
-#define QCOW_MAX_L1_SIZE 0x2000000
38
- bs, in_place ? QCOW2_OL_BITMAP_DIRECTORY : 0, dir_offset, dir_size);
34
+#define QCOW_MAX_L1_SIZE S_32MiB
39
+ bs, in_place ? QCOW2_OL_BITMAP_DIRECTORY : 0, dir_offset, dir_size,
35
40
+ false);
36
/* Allow for an average of 1k per snapshot table entry, should be plenty of
41
if (ret < 0) {
37
* space for snapshot names and IDs */
42
goto fail;
38
@@ -XXX,XX +XXX,XX @@
43
}
39
44
@@ -XXX,XX +XXX,XX @@ static uint64_t *store_bitmap_data(BlockDriverState *bs,
40
/* Whichever is more */
45
memset(buf + write_size, 0, s->cluster_size - write_size);
41
#define DEFAULT_L2_CACHE_CLUSTERS 8 /* clusters */
46
}
42
-#define DEFAULT_L2_CACHE_BYTE_SIZE 1048576 /* bytes */
47
43
+#define DEFAULT_L2_CACHE_SIZE S_1MiB
48
- ret = qcow2_pre_write_overlap_check(bs, 0, off, s->cluster_size);
44
49
+ ret = qcow2_pre_write_overlap_check(bs, 0, off, s->cluster_size, false);
45
-#define DEFAULT_CLUSTER_SIZE 65536
50
if (ret < 0) {
46
+#define DEFAULT_CLUSTER_SIZE S_64KiB
51
error_setg_errno(errp, -ret, "Qcow2 overlap check failed");
47
52
goto fail;
48
53
@@ -XXX,XX +XXX,XX @@ static int store_bitmap(BlockDriverState *bs, Qcow2Bitmap *bm, Error **errp)
49
#define QCOW2_OPT_LAZY_REFCOUNTS "lazy-refcounts"
54
}
55
56
ret = qcow2_pre_write_overlap_check(bs, 0, tb_offset,
57
- tb_size * sizeof(tb[0]));
58
+ tb_size * sizeof(tb[0]), false);
59
if (ret < 0) {
60
error_setg_errno(errp, -ret, "Qcow2 overlap check failed");
61
goto fail;
62
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
63
index XXXXXXX..XXXXXXX 100644
64
--- a/block/qcow2-cache.c
65
+++ b/block/qcow2-cache.c
66
@@ -XXX,XX +XXX,XX @@ static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i)
67
68
if (c == s->refcount_block_cache) {
69
ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_REFCOUNT_BLOCK,
70
- c->entries[i].offset, c->table_size);
71
+ c->entries[i].offset, c->table_size, false);
72
} else if (c == s->l2_table_cache) {
73
ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L2,
74
- c->entries[i].offset, c->table_size);
75
+ c->entries[i].offset, c->table_size, false);
76
} else {
77
ret = qcow2_pre_write_overlap_check(bs, 0,
78
- c->entries[i].offset, c->table_size);
79
+ c->entries[i].offset, c->table_size, false);
80
}
81
82
if (ret < 0) {
83
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
84
index XXXXXXX..XXXXXXX 100644
85
--- a/block/qcow2-cluster.c
86
+++ b/block/qcow2-cluster.c
87
@@ -XXX,XX +XXX,XX @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
88
/* the L1 position has not yet been updated, so these clusters must
89
* indeed be completely free */
90
ret = qcow2_pre_write_overlap_check(bs, 0, new_l1_table_offset,
91
- new_l1_size2);
92
+ new_l1_size2, false);
93
if (ret < 0) {
94
goto fail;
95
}
96
@@ -XXX,XX +XXX,XX @@ int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index)
97
}
98
99
ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L1,
100
- s->l1_table_offset + 8 * l1_start_index, sizeof(buf));
101
+ s->l1_table_offset + 8 * l1_start_index, sizeof(buf), false);
102
if (ret < 0) {
103
return ret;
104
}
105
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn do_perform_cow_write(BlockDriverState *bs,
106
unsigned offset_in_cluster,
107
QEMUIOVector *qiov)
108
{
109
+ BDRVQcow2State *s = bs->opaque;
110
int ret;
111
112
if (qiov->size == 0) {
113
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn do_perform_cow_write(BlockDriverState *bs,
114
}
115
116
ret = qcow2_pre_write_overlap_check(bs, 0,
117
- cluster_offset + offset_in_cluster, qiov->size);
118
+ cluster_offset + offset_in_cluster, qiov->size, true);
119
if (ret < 0) {
120
return ret;
121
}
122
123
BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE);
124
- ret = bdrv_co_pwritev(bs->file, cluster_offset + offset_in_cluster,
125
+ ret = bdrv_co_pwritev(s->data_file, cluster_offset + offset_in_cluster,
126
qiov->size, qiov, 0);
127
if (ret < 0) {
128
return ret;
129
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
130
}
131
switch (type) {
132
case QCOW2_CLUSTER_COMPRESSED:
133
+ if (has_data_file(bs)) {
134
+ qcow2_signal_corruption(bs, true, -1, -1, "Compressed cluster "
135
+ "entry found in image with external data "
136
+ "file (L2 offset: %#" PRIx64 ", L2 index: "
137
+ "%#x)", l2_offset, l2_index);
138
+ ret = -EIO;
139
+ goto fail;
140
+ }
141
/* Compressed clusters can only be processed one by one */
142
c = 1;
143
*cluster_offset &= L2E_COMPRESSED_OFFSET_SIZE_MASK;
144
@@ -XXX,XX +XXX,XX @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
145
ret = -EIO;
146
goto fail;
147
}
148
+ if (has_data_file(bs) && *cluster_offset != offset - offset_in_cluster)
149
+ {
150
+ qcow2_signal_corruption(bs, true, -1, -1,
151
+ "External data file host cluster offset %#"
152
+ PRIx64 " does not match guest cluster "
153
+ "offset: %#" PRIx64
154
+ ", L2 index: %#x)", *cluster_offset,
155
+ offset - offset_in_cluster, l2_index);
156
+ ret = -EIO;
157
+ goto fail;
158
+ }
159
break;
160
default:
161
abort();
162
@@ -XXX,XX +XXX,XX @@ int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
163
int64_t cluster_offset;
164
int nb_csectors;
165
166
+ if (has_data_file(bs)) {
167
+ return 0;
168
+ }
169
+
170
ret = get_cluster_table(bs, offset, &l2_slice, &l2_index);
171
if (ret < 0) {
172
return ret;
173
@@ -XXX,XX +XXX,XX @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset,
174
trace_qcow2_do_alloc_clusters_offset(qemu_coroutine_self(), guest_offset,
175
*host_offset, *nb_clusters);
176
177
+ if (has_data_file(bs)) {
178
+ assert(*host_offset == INV_OFFSET ||
179
+ *host_offset == start_of_cluster(s, guest_offset));
180
+ *host_offset = start_of_cluster(s, guest_offset);
181
+ return 0;
182
+ }
183
+
184
/* Allocate new clusters */
185
trace_qcow2_cluster_alloc_phys(qemu_coroutine_self());
186
if (*host_offset == INV_OFFSET) {
187
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
188
}
189
190
ret = qcow2_pre_write_overlap_check(bs, 0, offset,
191
- s->cluster_size);
192
+ s->cluster_size, true);
193
if (ret < 0) {
194
if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN) {
195
qcow2_free_clusters(bs, offset, s->cluster_size,
196
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
197
goto fail;
198
}
199
200
- ret = bdrv_pwrite_zeroes(bs->file, offset, s->cluster_size, 0);
201
+ ret = bdrv_pwrite_zeroes(s->data_file, offset,
202
+ s->cluster_size, 0);
203
if (ret < 0) {
204
if (cluster_type == QCOW2_CLUSTER_ZERO_PLAIN) {
205
qcow2_free_clusters(bs, offset, s->cluster_size,
206
@@ -XXX,XX +XXX,XX @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table,
207
if (l2_dirty) {
208
ret = qcow2_pre_write_overlap_check(
209
bs, QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2,
210
- slice_offset, slice_size2);
211
+ slice_offset, slice_size2, false);
212
if (ret < 0) {
213
goto fail;
214
}
215
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
216
index XXXXXXX..XXXXXXX 100644
217
--- a/block/qcow2-refcount.c
218
+++ b/block/qcow2-refcount.c
219
@@ -XXX,XX +XXX,XX @@ void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry,
220
int nb_clusters, enum qcow2_discard_type type)
221
{
222
BDRVQcow2State *s = bs->opaque;
223
+ QCow2ClusterType ctype = qcow2_get_cluster_type(bs, l2_entry);
224
225
- switch (qcow2_get_cluster_type(bs, l2_entry)) {
226
+ if (has_data_file(bs)) {
227
+ if (s->discard_passthrough[type] &&
228
+ (ctype == QCOW2_CLUSTER_NORMAL ||
229
+ ctype == QCOW2_CLUSTER_ZERO_ALLOC))
230
+ {
231
+ bdrv_pdiscard(s->data_file, l2_entry & L2E_OFFSET_MASK,
232
+ nb_clusters << s->cluster_bits);
233
+ }
234
+ return;
235
+ }
236
+
237
+ switch (ctype) {
238
case QCOW2_CLUSTER_COMPRESSED:
239
{
240
int nb_csectors;
241
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
242
l2_table[i] = cpu_to_be64(l2_entry);
243
ret = qcow2_pre_write_overlap_check(bs,
244
QCOW2_OL_ACTIVE_L2 | QCOW2_OL_INACTIVE_L2,
245
- l2e_offset, sizeof(uint64_t));
246
+ l2e_offset, sizeof(uint64_t), false);
247
if (ret < 0) {
248
fprintf(stderr, "ERROR: Overlap check failed\n");
249
res->check_errors++;
250
@@ -XXX,XX +XXX,XX @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res,
251
252
if (l2_dirty) {
253
ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L2,
254
- l2_offset, s->cluster_size);
255
+ l2_offset, s->cluster_size,
256
+ false);
257
if (ret < 0) {
258
fprintf(stderr, "ERROR: Could not write L2 table; metadata "
259
"overlap check failed: %s\n", strerror(-ret));
260
@@ -XXX,XX +XXX,XX @@ write_refblocks:
261
}
262
263
ret = qcow2_pre_write_overlap_check(bs, 0, refblock_offset,
264
- s->cluster_size);
265
+ s->cluster_size, false);
266
if (ret < 0) {
267
fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
268
goto fail;
269
@@ -XXX,XX +XXX,XX @@ write_refblocks:
270
}
271
272
ret = qcow2_pre_write_overlap_check(bs, 0, reftable_offset,
273
- reftable_size * sizeof(uint64_t));
274
+ reftable_size * sizeof(uint64_t),
275
+ false);
276
if (ret < 0) {
277
fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
278
goto fail;
279
@@ -XXX,XX +XXX,XX @@ QEMU_BUILD_BUG_ON(QCOW2_OL_MAX_BITNR != ARRAY_SIZE(metadata_ol_names));
280
* overlaps; or a negative value (-errno) on error.
281
*/
282
int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset,
283
- int64_t size)
284
+ int64_t size, bool data_file)
285
{
286
- int ret = qcow2_check_metadata_overlap(bs, ign, offset, size);
287
+ int ret;
288
+
289
+ if (data_file && has_data_file(bs)) {
290
+ return 0;
291
+ }
292
293
+ ret = qcow2_check_metadata_overlap(bs, ign, offset, size);
294
if (ret < 0) {
295
return ret;
296
} else if (ret > 0) {
297
@@ -XXX,XX +XXX,XX @@ static int flush_refblock(BlockDriverState *bs, uint64_t **reftable,
298
if (reftable_index < *reftable_size && (*reftable)[reftable_index]) {
299
offset = (*reftable)[reftable_index];
300
301
- ret = qcow2_pre_write_overlap_check(bs, 0, offset, s->cluster_size);
302
+ ret = qcow2_pre_write_overlap_check(bs, 0, offset, s->cluster_size,
303
+ false);
304
if (ret < 0) {
305
error_setg_errno(errp, -ret, "Overlap check failed");
306
return ret;
307
@@ -XXX,XX +XXX,XX @@ int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order,
308
309
/* Write the new reftable */
310
ret = qcow2_pre_write_overlap_check(bs, 0, new_reftable_offset,
311
- new_reftable_size * sizeof(uint64_t));
312
+ new_reftable_size * sizeof(uint64_t),
313
+ false);
314
if (ret < 0) {
315
error_setg_errno(errp, -ret, "Overlap check failed");
316
goto done;
317
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
318
index XXXXXXX..XXXXXXX 100644
319
--- a/block/qcow2-snapshot.c
320
+++ b/block/qcow2-snapshot.c
321
@@ -XXX,XX +XXX,XX @@ static int qcow2_write_snapshots(BlockDriverState *bs)
322
323
/* The snapshot list position has not yet been updated, so these clusters
324
* must indeed be completely free */
325
- ret = qcow2_pre_write_overlap_check(bs, 0, offset, snapshots_size);
326
+ ret = qcow2_pre_write_overlap_check(bs, 0, offset, snapshots_size, false);
327
if (ret < 0) {
328
goto fail;
329
}
330
@@ -XXX,XX +XXX,XX @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
331
}
332
333
ret = qcow2_pre_write_overlap_check(bs, 0, sn->l1_table_offset,
334
- s->l1_size * sizeof(uint64_t));
335
+ s->l1_size * sizeof(uint64_t), false);
336
if (ret < 0) {
337
goto fail;
338
}
339
@@ -XXX,XX +XXX,XX @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
340
}
341
342
ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L1,
343
- s->l1_table_offset, cur_l1_bytes);
344
+ s->l1_table_offset, cur_l1_bytes,
345
+ false);
346
if (ret < 0) {
347
goto fail;
348
}
50
diff --git a/block/qcow2.c b/block/qcow2.c
349
diff --git a/block/qcow2.c b/block/qcow2.c
51
index XXXXXXX..XXXXXXX 100644
350
index XXXXXXX..XXXXXXX 100644
52
--- a/block/qcow2.c
351
--- a/block/qcow2.c
53
+++ b/block/qcow2.c
352
+++ b/block/qcow2.c
54
@@ -XXX,XX +XXX,XX @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts,
353
@@ -XXX,XX +XXX,XX @@ static ssize_t qcow2_crypto_hdr_init_func(QCryptoBlock *block, size_t headerlen,
354
/* Zero fill remaining space in cluster so it has predictable
355
* content in case of future spec changes */
356
clusterlen = size_to_clusters(s, headerlen) * s->cluster_size;
357
- assert(qcow2_pre_write_overlap_check(bs, 0, ret, clusterlen) == 0);
358
+ assert(qcow2_pre_write_overlap_check(bs, 0, ret, clusterlen, false) == 0);
359
ret = bdrv_pwrite_zeroes(bs->file,
360
ret + headerlen,
361
clusterlen - headerlen, 0);
362
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset,
363
*/
364
if (!cluster_data) {
365
cluster_data =
366
- qemu_try_blockalign(bs->file->bs,
367
+ qemu_try_blockalign(s->data_file->bs,
368
QCOW_MAX_CRYPT_CLUSTERS
369
* s->cluster_size);
370
if (cluster_data == NULL) {
371
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset,
372
373
BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
374
qemu_co_mutex_unlock(&s->lock);
375
- ret = bdrv_co_preadv(bs->file,
376
+ ret = bdrv_co_preadv(s->data_file,
377
cluster_offset + offset_in_cluster,
378
cur_bytes, &hd_qiov, 0);
379
qemu_co_mutex_lock(&s->lock);
380
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset,
55
}
381
}
56
} else {
382
57
if (!l2_cache_size_set) {
383
ret = qcow2_pre_write_overlap_check(bs, 0,
58
- *l2_cache_size = MAX(DEFAULT_L2_CACHE_BYTE_SIZE,
384
- cluster_offset + offset_in_cluster, cur_bytes);
59
+ *l2_cache_size = MAX(DEFAULT_L2_CACHE_SIZE,
385
+ cluster_offset + offset_in_cluster, cur_bytes, true);
60
(uint64_t)DEFAULT_L2_CACHE_CLUSTERS
386
if (ret < 0) {
61
* s->cluster_size);
387
goto fail;
62
}
388
}
389
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset,
390
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
391
trace_qcow2_writev_data(qemu_coroutine_self(),
392
cluster_offset + offset_in_cluster);
393
- ret = bdrv_co_pwritev(bs->file,
394
+ ret = bdrv_co_pwritev(s->data_file,
395
cluster_offset + offset_in_cluster,
396
cur_bytes, &hd_qiov, 0);
397
qemu_co_mutex_lock(&s->lock);
398
@@ -XXX,XX +XXX,XX @@ qcow2_co_copy_range_from(BlockDriverState *bs,
399
goto out;
400
401
case QCOW2_CLUSTER_NORMAL:
402
- child = bs->file;
403
+ child = s->data_file;
404
copy_offset += offset_into_cluster(s, src_offset);
405
if ((copy_offset & 511) != 0) {
406
ret = -EIO;
407
@@ -XXX,XX +XXX,XX @@ qcow2_co_copy_range_to(BlockDriverState *bs,
408
assert((cluster_offset & 511) == 0);
409
410
ret = qcow2_pre_write_overlap_check(bs, 0,
411
- cluster_offset + offset_in_cluster, cur_bytes);
412
+ cluster_offset + offset_in_cluster, cur_bytes, true);
413
if (ret < 0) {
414
goto fail;
415
}
416
417
qemu_co_mutex_unlock(&s->lock);
418
ret = bdrv_co_copy_range_to(src, src_offset,
419
- bs->file,
420
+ s->data_file,
421
cluster_offset + offset_in_cluster,
422
cur_bytes, read_flags, write_flags);
423
qemu_co_mutex_lock(&s->lock);
424
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
425
int64_t old_file_size, new_file_size;
426
uint64_t nb_new_data_clusters, nb_new_l2_tables;
427
428
+ /* With a data file, preallocation means just allocating the metadata
429
+ * and forwarding the truncate request to the data file */
430
+ if (has_data_file(bs)) {
431
+ ret = preallocate_co(bs, old_length, offset);
432
+ if (ret < 0) {
433
+ error_setg_errno(errp, -ret, "Preallocation failed");
434
+ goto fail;
435
+ }
436
+ break;
437
+ }
438
+
439
old_file_size = bdrv_getlength(bs->file->bs);
440
if (old_file_size < 0) {
441
error_setg_errno(errp, -old_file_size,
442
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
443
444
bs->total_sectors = offset / BDRV_SECTOR_SIZE;
445
446
+ if (has_data_file(bs)) {
447
+ if (prealloc == PREALLOC_MODE_METADATA) {
448
+ prealloc = PREALLOC_MODE_OFF;
449
+ }
450
+ ret = bdrv_co_truncate(s->data_file, offset, prealloc, errp);
451
+ if (ret < 0) {
452
+ goto fail;
453
+ }
454
+ }
455
+
456
/* write updated header.size */
457
offset = cpu_to_be64(offset);
458
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size),
459
@@ -XXX,XX +XXX,XX @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset,
460
uint8_t *buf, *out_buf;
461
uint64_t cluster_offset;
462
463
+ if (has_data_file(bs)) {
464
+ return -ENOTSUP;
465
+ }
466
+
467
if (bytes == 0) {
468
/* align end of file to a sector boundary to ease reading with
469
sector based I/Os */
470
@@ -XXX,XX +XXX,XX @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset,
471
goto fail;
472
}
473
474
- ret = qcow2_pre_write_overlap_check(bs, 0, cluster_offset, out_len);
475
+ ret = qcow2_pre_write_overlap_check(bs, 0, cluster_offset, out_len, true);
476
qemu_co_mutex_unlock(&s->lock);
477
if (ret < 0) {
478
goto fail;
479
@@ -XXX,XX +XXX,XX @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset,
480
481
qemu_iovec_init_buf(&hd_qiov, out_buf, out_len);
482
483
- BLKDBG_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED);
484
- ret = bdrv_co_pwritev(bs->file, cluster_offset, out_len, &hd_qiov, 0);
485
+ BLKDBG_EVENT(s->data_file, BLKDBG_WRITE_COMPRESSED);
486
+ ret = bdrv_co_pwritev(s->data_file, cluster_offset, out_len, &hd_qiov, 0);
487
if (ret < 0) {
488
goto fail;
489
}
490
@@ -XXX,XX +XXX,XX @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version,
491
return -ENOTSUP;
492
}
493
494
+ if (has_data_file(bs)) {
495
+ error_setg(errp, "Cannot downgrade an image with a data file");
496
+ return -ENOTSUP;
497
+ }
498
+
499
/* clear incompatible features */
500
if (s->incompatible_features & QCOW2_INCOMPAT_DIRTY) {
501
ret = qcow2_mark_clean(bs);
63
--
502
--
64
2.13.6
503
2.20.1
65
504
66
505
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
Internal snapshots and an external data file are incompatible because
2
snapshots require refcounting and non-linear mapping. Return an error
3
for all of the snapshot operations if an external data file is in use.
2
4
3
Block drivers allow opening their children using a reference to an
4
existing BlockDriverState. These references remain stored in the
5
'options' and 'explicit_options' QDicts, but we don't need to keep
6
them once everything is open.
7
8
What is more important, these values can become wrong if the children
9
change:
10
11
$ qemu-img create -f qcow2 hd0.qcow2 10M
12
$ qemu-img create -f qcow2 hd1.qcow2 10M
13
$ qemu-img create -f qcow2 hd2.qcow2 10M
14
$ $QEMU -drive if=none,file=hd0.qcow2,node-name=hd0 \
15
-drive if=none,file=hd1.qcow2,node-name=hd1,backing=hd0 \
16
-drive file=hd2.qcow2,node-name=hd2,backing=hd1
17
18
After this hd2 has hd1 as its backing file. Now let's remove it using
19
block_stream:
20
21
(qemu) block_stream hd2 0 hd0.qcow2
22
23
Now hd0 is the backing file of hd2, but hd2's options QDicts still
24
contain backing=hd1.
25
26
Signed-off-by: Alberto Garcia <berto@igalia.com>
27
Reviewed-by: Max Reitz <mreitz@redhat.com>
28
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
29
---
6
---
30
block.c | 13 ++++++++++++-
7
block/qcow2-snapshot.c | 15 +++++++++++++++
31
1 file changed, 12 insertions(+), 1 deletion(-)
8
1 file changed, 15 insertions(+)
32
9
33
diff --git a/block.c b/block.c
10
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
34
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
35
--- a/block.c
12
--- a/block/qcow2-snapshot.c
36
+++ b/block.c
13
+++ b/block/qcow2-snapshot.c
37
@@ -XXX,XX +XXX,XX @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
14
@@ -XXX,XX +XXX,XX @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
38
}
15
return -EFBIG;
39
}
16
}
40
17
41
- /* Remove all children options from bs->options and bs->explicit_options */
18
+ if (has_data_file(bs)) {
42
+ /* Remove all children options and references
19
+ return -ENOTSUP;
43
+ * from bs->options and bs->explicit_options */
44
QLIST_FOREACH(child, &bs->children, next) {
45
char *child_key_dot;
46
child_key_dot = g_strdup_printf("%s.", child->name);
47
qdict_extract_subqdict(bs->explicit_options, NULL, child_key_dot);
48
qdict_extract_subqdict(bs->options, NULL, child_key_dot);
49
+ qdict_del(bs->explicit_options, child->name);
50
+ qdict_del(bs->options, child->name);
51
g_free(child_key_dot);
52
}
53
54
@@ -XXX,XX +XXX,XX @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
55
{
56
BlockDriver *drv;
57
BlockDriverState *bs;
58
+ BdrvChild *child;
59
bool old_can_write, new_can_write;
60
61
assert(reopen_state != NULL);
62
@@ -XXX,XX +XXX,XX @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
63
bs->open_flags = reopen_state->flags;
64
bs->read_only = !(reopen_state->flags & BDRV_O_RDWR);
65
66
+ /* Remove child references from bs->options and bs->explicit_options.
67
+ * Child options were already removed in bdrv_reopen_queue_child() */
68
+ QLIST_FOREACH(child, &bs->children, next) {
69
+ qdict_del(bs->explicit_options, child->name);
70
+ qdict_del(bs->options, child->name);
71
+ }
20
+ }
72
+
21
+
73
bdrv_refresh_limits(bs, NULL);
22
memset(sn, 0, sizeof(*sn));
74
23
75
bdrv_set_perm(reopen_state->bs, reopen_state->perm,
24
/* Generate an ID */
25
@@ -XXX,XX +XXX,XX @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
26
int ret;
27
uint64_t *sn_l1_table = NULL;
28
29
+ if (has_data_file(bs)) {
30
+ return -ENOTSUP;
31
+ }
32
+
33
/* Search the snapshot */
34
snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id);
35
if (snapshot_index < 0) {
36
@@ -XXX,XX +XXX,XX @@ int qcow2_snapshot_delete(BlockDriverState *bs,
37
QCowSnapshot sn;
38
int snapshot_index, ret;
39
40
+ if (has_data_file(bs)) {
41
+ return -ENOTSUP;
42
+ }
43
+
44
/* Search the snapshot */
45
snapshot_index = find_snapshot_by_id_and_name(bs, snapshot_id, name);
46
if (snapshot_index < 0) {
47
@@ -XXX,XX +XXX,XX @@ int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
48
QCowSnapshot *sn;
49
int i;
50
51
+ if (has_data_file(bs)) {
52
+ return -ENOTSUP;
53
+ }
54
if (!s->nb_snapshots) {
55
*psn_tab = NULL;
56
return s->nb_snapshots;
76
--
57
--
77
2.13.6
58
2.20.1
78
59
79
60
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
For external data files, data clusters must be excluded from the
2
refcount calculations. Instead, an implicit refcount of 1 is assumed for
3
the COPIED flag.
2
4
3
In the previous patches we removed all child references from
5
Compressed clusters and internal snapshots are incompatible with
4
bs->{options,explicit_options} because keeping them is useless and
6
external data files, so print an error if they are in use for images
5
wrong.
7
with an external data file.
6
8
7
Because of this, any attempt to reopen a BlockDriverState using a
8
child reference as one of its options would result in a failure,
9
because bdrv_reopen_prepare() would detect that there's a new option
10
(the child reference) that wasn't present in bs->options.
11
12
But passing child references on reopen can be useful. It's a way to
13
specify a BDS's child without having to pass recursively all of the
14
child's options, and if the reference points to a different BDS then
15
this can allow us to replace the child.
16
17
However, replacing the child is something that needs to be implemented
18
case by case and only when it makes sense. For now, this patch allows
19
passing a child reference as long as it points to the current child of
20
the BlockDriverState.
21
22
It's also important to remember that, as a consequence of the
23
previous patches, this child reference will be removed from
24
bs->{options,explicit_options} after the reopening has been completed.
25
26
Signed-off-by: Alberto Garcia <berto@igalia.com>
27
Reviewed-by: Max Reitz <mreitz@redhat.com>
28
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
29
---
10
---
30
block.c | 18 ++++++++++++++++++
11
block/qcow2-refcount.c | 41 ++++++++++++++++++++++++++++++-----------
31
1 file changed, 18 insertions(+)
12
1 file changed, 30 insertions(+), 11 deletions(-)
32
13
33
diff --git a/block.c b/block.c
14
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
34
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
35
--- a/block.c
16
--- a/block/qcow2-refcount.c
36
+++ b/block.c
17
+++ b/block/qcow2-refcount.c
37
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
18
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
38
QObject *new = entry->value;
19
res->corruptions++;
39
QObject *old = qdict_get(reopen_state->bs->options, entry->key);
20
}
40
21
41
+ /* Allow child references (child_name=node_name) as long as they
22
+ if (has_data_file(bs)) {
42
+ * point to the current child (i.e. everything stays the same). */
23
+ fprintf(stderr, "ERROR compressed cluster %d with data file, "
43
+ if (qobject_type(new) == QTYPE_QSTRING) {
24
+ "entry=0x%" PRIx64 "\n", i, l2_entry);
44
+ BdrvChild *child;
25
+ res->corruptions++;
45
+ QLIST_FOREACH(child, &reopen_state->bs->children, next) {
26
+ break;
46
+ if (!strcmp(child->name, entry->key)) {
47
+ break;
48
+ }
49
+ }
50
+
51
+ if (child) {
52
+ const char *str = qobject_get_try_str(new);
53
+ if (!strcmp(child->bs->node_name, str)) {
54
+ continue; /* Found child with this name, skip option */
55
+ }
56
+ }
57
+ }
27
+ }
58
+
28
+
59
/*
29
/* Mark cluster as used */
60
* TODO: When using -drive to specify blockdev options, all values
30
nb_csectors = ((l2_entry >> s->csize_shift) &
61
* will be strings; however, when using -blockdev, blockdev-add or
31
s->csize_mask) + 1;
32
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
33
}
34
35
/* Mark cluster as used */
36
- ret = qcow2_inc_refcounts_imrt(bs, res,
37
- refcount_table, refcount_table_size,
38
- offset, s->cluster_size);
39
- if (ret < 0) {
40
- goto fail;
41
+ if (!has_data_file(bs)) {
42
+ ret = qcow2_inc_refcounts_imrt(bs, res, refcount_table,
43
+ refcount_table_size,
44
+ offset, s->cluster_size);
45
+ if (ret < 0) {
46
+ goto fail;
47
+ }
48
}
49
break;
50
}
51
@@ -XXX,XX +XXX,XX @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res,
52
53
if (cluster_type == QCOW2_CLUSTER_NORMAL ||
54
cluster_type == QCOW2_CLUSTER_ZERO_ALLOC) {
55
- ret = qcow2_get_refcount(bs,
56
- data_offset >> s->cluster_bits,
57
- &refcount);
58
- if (ret < 0) {
59
- /* don't print message nor increment check_errors */
60
- continue;
61
+ if (has_data_file(bs)) {
62
+ refcount = 1;
63
+ } else {
64
+ ret = qcow2_get_refcount(bs,
65
+ data_offset >> s->cluster_bits,
66
+ &refcount);
67
+ if (ret < 0) {
68
+ /* don't print message nor increment check_errors */
69
+ continue;
70
+ }
71
}
72
if ((refcount == 1) != ((l2_entry & QCOW_OFLAG_COPIED) != 0)) {
73
fprintf(stderr, "%s OFLAG_COPIED data cluster: "
74
@@ -XXX,XX +XXX,XX @@ static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
75
}
76
77
/* snapshots */
78
+ if (has_data_file(bs) && s->nb_snapshots) {
79
+ fprintf(stderr, "ERROR %d snapshots in image with data file\n",
80
+ s->nb_snapshots);
81
+ res->corruptions++;
82
+ }
83
+
84
for (i = 0; i < s->nb_snapshots; i++) {
85
sn = s->snapshots + i;
86
if (offset_into_cluster(s, sn->l1_table_offset)) {
62
--
87
--
63
2.13.6
88
2.20.1
64
89
65
90
diff view generated by jsdifflib
1
From: Leonid Bloch <lbloch@janustech.com>
1
This adds a .bdrv_open option to specify the external data file node.
2
2
3
The default cache-clean-interval is set to 10 minutes, in order to lower
4
the overhead of the qcow2 caches (before the default was 0, i.e.
5
disabled).
6
7
* For non-Linux platforms the default is kept at 0, because
8
cache-clean-interval is not supported there yet.
9
10
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
11
Reviewed-by: Alberto Garcia <berto@igalia.com>
12
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
13
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
3
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14
---
4
---
15
qapi/block-core.json | 3 ++-
5
qapi/block-core.json | 7 ++++++-
16
docs/qcow2-cache.txt | 4 ++--
6
block/qcow2.h | 4 +++-
17
block/qcow2.h | 4 +++-
7
block/qcow2.c | 34 ++++++++++++++++++++++++++++++++--
18
block/qcow2.c | 2 +-
8
3 files changed, 41 insertions(+), 4 deletions(-)
19
qemu-options.hx | 2 +-
20
5 files changed, 9 insertions(+), 6 deletions(-)
21
9
22
diff --git a/qapi/block-core.json b/qapi/block-core.json
10
diff --git a/qapi/block-core.json b/qapi/block-core.json
23
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
24
--- a/qapi/block-core.json
12
--- a/qapi/block-core.json
25
+++ b/qapi/block-core.json
13
+++ b/qapi/block-core.json
26
@@ -XXX,XX +XXX,XX @@
14
@@ -XXX,XX +XXX,XX @@
27
#
28
# @cache-clean-interval: clean unused entries in the L2 and refcount
29
# caches. The interval is in seconds. The default value
30
-# is 0 and it disables this feature (since 2.5)
31
+# is 600, and 0 disables this feature. (since 2.5)
32
+#
33
# @encrypt: Image decryption options. Mandatory for
34
# encrypted images, except when doing a metadata-only
15
# encrypted images, except when doing a metadata-only
35
# probe of the image. (since 2.10)
16
# probe of the image. (since 2.10)
36
diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt
17
#
37
index XXXXXXX..XXXXXXX 100644
18
+# @data-file: reference to or definition of the external data file.
38
--- a/docs/qcow2-cache.txt
19
+# This may only be specified for images that require an
39
+++ b/docs/qcow2-cache.txt
20
+# external data file. (since 4.0)
40
@@ -XXX,XX +XXX,XX @@ This example removes all unused cache entries every 15 minutes:
21
+#
41
22
# Since: 2.9
42
-drive file=hd.qcow2,cache-clean-interval=900
23
##
43
24
{ 'struct': 'BlockdevOptionsQcow2',
44
-If unset, the default value for this parameter is 0 and it disables
25
@@ -XXX,XX +XXX,XX @@
45
-this feature.
26
'*l2-cache-entry-size': 'int',
46
+If unset, the default value for this parameter is 600. Setting it to 0
27
'*refcount-cache-size': 'int',
47
+disables this feature.
28
'*cache-clean-interval': 'int',
48
29
- '*encrypt': 'BlockdevQcow2Encryption' } }
49
Note that this functionality currently relies on the MADV_DONTNEED
30
+ '*encrypt': 'BlockdevQcow2Encryption',
50
argument for madvise() to actually free the memory. This is a
31
+ '*data-file': 'BlockdevRef' } }
32
33
##
34
# @SshHostKeyCheckMode:
51
diff --git a/block/qcow2.h b/block/qcow2.h
35
diff --git a/block/qcow2.h b/block/qcow2.h
52
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
53
--- a/block/qcow2.h
37
--- a/block/qcow2.h
54
+++ b/block/qcow2.h
38
+++ b/block/qcow2.h
55
@@ -XXX,XX +XXX,XX @@
39
@@ -XXX,XX +XXX,XX @@
56
40
57
#ifdef CONFIG_LINUX
41
#define DEFAULT_CLUSTER_SIZE 65536
58
#define DEFAULT_L2_CACHE_MAX_SIZE S_32MiB
42
59
+#define DEFAULT_CACHE_CLEAN_INTERVAL 600 /* seconds */
43
+#define QCOW2_OPT_DATA_FILE "data-file"
60
#else
61
#define DEFAULT_L2_CACHE_MAX_SIZE S_8MiB
62
+/* Cache clean interval is currently available only on Linux, so must be 0 */
63
+#define DEFAULT_CACHE_CLEAN_INTERVAL 0
64
#endif
65
66
#define DEFAULT_CLUSTER_SIZE S_64KiB
67
68
-
69
#define QCOW2_OPT_LAZY_REFCOUNTS "lazy-refcounts"
44
#define QCOW2_OPT_LAZY_REFCOUNTS "lazy-refcounts"
70
#define QCOW2_OPT_DISCARD_REQUEST "pass-discard-request"
45
#define QCOW2_OPT_DISCARD_REQUEST "pass-discard-request"
71
#define QCOW2_OPT_DISCARD_SNAPSHOT "pass-discard-snapshot"
46
#define QCOW2_OPT_DISCARD_SNAPSHOT "pass-discard-snapshot"
47
@@ -XXX,XX +XXX,XX @@ enum {
48
QCOW2_INCOMPAT_DATA_FILE = 1 << QCOW2_INCOMPAT_DATA_FILE_BITNR,
49
50
QCOW2_INCOMPAT_MASK = QCOW2_INCOMPAT_DIRTY
51
- | QCOW2_INCOMPAT_CORRUPT,
52
+ | QCOW2_INCOMPAT_CORRUPT
53
+ | QCOW2_INCOMPAT_DATA_FILE,
54
};
55
56
/* Compatible feature bits */
72
diff --git a/block/qcow2.c b/block/qcow2.c
57
diff --git a/block/qcow2.c b/block/qcow2.c
73
index XXXXXXX..XXXXXXX 100644
58
index XXXXXXX..XXXXXXX 100644
74
--- a/block/qcow2.c
59
--- a/block/qcow2.c
75
+++ b/block/qcow2.c
60
+++ b/block/qcow2.c
76
@@ -XXX,XX +XXX,XX @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
61
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
77
/* New interval for cache cleanup timer */
62
goto fail;
78
r->cache_clean_interval =
63
}
79
qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL,
64
80
- s->cache_clean_interval);
65
- /* TODO Open external data file */
81
+ DEFAULT_CACHE_CLEAN_INTERVAL);
66
- s->data_file = bs->file;
82
#ifndef CONFIG_LINUX
67
+ /* Open external data file */
83
if (r->cache_clean_interval != 0) {
68
+ s->data_file = bdrv_open_child(NULL, options, "data-file", bs, &child_file,
84
error_setg(errp, QCOW2_OPT_CACHE_CLEAN_INTERVAL
69
+ true, &local_err);
85
diff --git a/qemu-options.hx b/qemu-options.hx
70
+ if (local_err) {
86
index XXXXXXX..XXXXXXX 100644
71
+ error_propagate(errp, local_err);
87
--- a/qemu-options.hx
72
+ ret = -EINVAL;
88
+++ b/qemu-options.hx
73
+ goto fail;
89
@@ -XXX,XX +XXX,XX @@ it which is not used for the L2 cache)
74
+ }
90
75
+
91
@item cache-clean-interval
76
+ if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) {
92
Clean unused entries in the L2 and refcount caches. The interval is in seconds.
77
+ if (!s->data_file) {
93
-The default value is 0 and it disables this feature.
78
+ error_setg(errp, "'data-file' is required for this image");
94
+The default value is 600. Setting it to 0 disables this feature.
79
+ ret = -EINVAL;
95
80
+ goto fail;
96
@item pass-discard-request
81
+ }
97
Whether discard requests to the qcow2 device should be forwarded to the data
82
+ } else {
83
+ if (s->data_file) {
84
+ error_setg(errp, "'data-file' can only be set for images with an "
85
+ "external data file");
86
+ ret = -EINVAL;
87
+ goto fail;
88
+ } else {
89
+ s->data_file = bs->file;
90
+ }
91
+ }
92
93
/* qcow2_read_extension may have set up the crypto context
94
* if the crypt method needs a header region, some methods
95
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
96
return ret;
97
98
fail:
99
+ if (has_data_file(bs)) {
100
+ bdrv_unref_child(bs, s->data_file);
101
+ }
102
g_free(s->unknown_header_fields);
103
cleanup_unknown_header_ext(bs);
104
qcow2_free_snapshots(bs);
105
@@ -XXX,XX +XXX,XX @@ static void qcow2_close(BlockDriverState *bs)
106
g_free(s->image_backing_file);
107
g_free(s->image_backing_format);
108
109
+ if (has_data_file(bs)) {
110
+ bdrv_unref_child(bs, s->data_file);
111
+ }
112
+
113
qcow2_refcount_close(bs);
114
qcow2_free_snapshots(bs);
115
}
98
--
116
--
99
2.13.6
117
2.20.1
100
118
101
119
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
This adds a .bdrv_create option to use an external data file.
2
2
3
'discard' is one of the basic BlockdevOptions available for all
4
drivers, but it's not handled by bdrv_reopen_prepare() so any attempt
5
to change it results in an error:
6
7
(qemu) qemu-io virtio0 "reopen -o discard=on"
8
Cannot change the option 'discard'
9
10
Since there's no reason why we shouldn't allow changing it and the
11
implementation is simple let's just do it.
12
13
Signed-off-by: Alberto Garcia <berto@igalia.com>
14
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
3
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
15
---
4
---
16
block.c | 11 +++++++++++
5
qapi/block-core.json | 4 ++++
17
1 file changed, 11 insertions(+)
6
include/block/block_int.h | 1 +
7
block/qcow2.c | 26 ++++++++++++++++++++++++++
8
3 files changed, 31 insertions(+)
18
9
19
diff --git a/block.c b/block.c
10
diff --git a/qapi/block-core.json b/qapi/block-core.json
20
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
21
--- a/block.c
12
--- a/qapi/block-core.json
22
+++ b/block.c
13
+++ b/qapi/block-core.json
23
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
14
@@ -XXX,XX +XXX,XX @@
24
BlockDriver *drv;
15
# Driver specific image creation options for qcow2.
25
QemuOpts *opts;
16
#
26
QDict *orig_reopen_opts;
17
# @file Node to create the image format on
27
+ char *discard = NULL;
18
+# @data-file Node to use as an external data file in which all guest
28
bool read_only;
19
+# data is stored so that only metadata remains in the qcow2
29
20
+# file (since: 4.0)
30
assert(reopen_state != NULL);
21
# @size Size of the virtual disk in bytes
31
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
22
# @version Compatibility level (default: v3)
32
23
# @backing-file File name of the backing file if a backing file
33
update_flags_from_options(&reopen_state->flags, opts);
24
@@ -XXX,XX +XXX,XX @@
34
25
##
35
+ discard = qemu_opt_get_del(opts, "discard");
26
{ 'struct': 'BlockdevCreateOptionsQcow2',
36
+ if (discard != NULL) {
27
'data': { 'file': 'BlockdevRef',
37
+ if (bdrv_parse_discard_flags(discard, &reopen_state->flags) != 0) {
28
+ '*data-file': 'BlockdevRef',
38
+ error_setg(errp, "Invalid discard option");
29
'size': 'size',
30
'*version': 'BlockdevQcow2Version',
31
'*backing-file': 'str',
32
diff --git a/include/block/block_int.h b/include/block/block_int.h
33
index XXXXXXX..XXXXXXX 100644
34
--- a/include/block/block_int.h
35
+++ b/include/block/block_int.h
36
@@ -XXX,XX +XXX,XX @@
37
#define BLOCK_OPT_NOCOW "nocow"
38
#define BLOCK_OPT_OBJECT_SIZE "object_size"
39
#define BLOCK_OPT_REFCOUNT_BITS "refcount_bits"
40
+#define BLOCK_OPT_DATA_FILE "data_file"
41
42
#define BLOCK_PROBE_BUF_SIZE 512
43
44
diff --git a/block/qcow2.c b/block/qcow2.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/block/qcow2.c
47
+++ b/block/qcow2.c
48
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
49
*/
50
BlockBackend *blk = NULL;
51
BlockDriverState *bs = NULL;
52
+ BlockDriverState *data_bs = NULL;
53
QCowHeader *header;
54
size_t cluster_size;
55
int version;
56
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
57
}
58
refcount_order = ctz32(qcow2_opts->refcount_bits);
59
60
+ if (qcow2_opts->data_file) {
61
+ if (version < 3) {
62
+ error_setg(errp, "External data files are only supported with "
63
+ "compatibility level 1.1 and above (use version=v3 or "
64
+ "greater)");
39
+ ret = -EINVAL;
65
+ ret = -EINVAL;
40
+ goto error;
66
+ goto out;
67
+ }
68
+ data_bs = bdrv_open_blockdev_ref(qcow2_opts->data_file, errp);
69
+ if (bs == NULL) {
70
+ ret = -EIO;
71
+ goto out;
41
+ }
72
+ }
42
+ }
73
+ }
43
+
74
44
/* All other options (including node-name and driver) must be unchanged.
75
/* Create BlockBackend to write to the image */
45
* Put them back into the QDict, so that they are checked at the end
76
blk = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
46
* of this function. */
77
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
47
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
78
header->compatible_features |=
48
error:
79
cpu_to_be64(QCOW2_COMPAT_LAZY_REFCOUNTS);
49
qemu_opts_del(opts);
80
}
50
qobject_unref(orig_reopen_opts);
81
+ if (data_bs) {
51
+ g_free(discard);
82
+ header->incompatible_features |=
83
+ cpu_to_be64(QCOW2_INCOMPAT_DATA_FILE);
84
+ }
85
86
ret = blk_pwrite(blk, 0, header, cluster_size, 0);
87
g_free(header);
88
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
89
options = qdict_new();
90
qdict_put_str(options, "driver", "qcow2");
91
qdict_put_str(options, "file", bs->node_name);
92
+ if (data_bs) {
93
+ qdict_put_str(options, "data-file", data_bs->node_name);
94
+ }
95
blk = blk_new_open(NULL, NULL, options,
96
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH,
97
&local_err);
98
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
99
options = qdict_new();
100
qdict_put_str(options, "driver", "qcow2");
101
qdict_put_str(options, "file", bs->node_name);
102
+ if (data_bs) {
103
+ qdict_put_str(options, "data-file", data_bs->node_name);
104
+ }
105
blk = blk_new_open(NULL, NULL, options,
106
BDRV_O_RDWR | BDRV_O_NO_BACKING | BDRV_O_NO_IO,
107
&local_err);
108
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
109
out:
110
blk_unref(blk);
111
bdrv_unref(bs);
112
+ bdrv_unref(data_bs);
52
return ret;
113
return ret;
53
}
114
}
54
115
55
--
116
--
56
2.13.6
117
2.20.1
57
118
58
119
diff view generated by jsdifflib
1
From: Leonid Bloch <lbloch@janustech.com>
1
Rather than requiring that the external data file node is passed
2
explicitly when creating the qcow2 node, store the filename in the
3
designated header extension during .bdrv_create and read it from there
4
as a default during .bdrv_open.
2
5
3
Fixing cache-clean-interval documentation following the recent change to
4
a default of 600 seconds on supported plarforms (only Linux currently).
5
6
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
7
---
10
qapi/block-core.json | 3 ++-
8
qapi/block-core.json | 8 +++-
11
docs/qcow2-cache.txt | 20 ++++++++++----------
9
block/qcow2.h | 1 +
12
qemu-options.hx | 3 ++-
10
block/qcow2.c | 94 +++++++++++++++++++++++++++++++++++++-
13
3 files changed, 14 insertions(+), 12 deletions(-)
11
tests/qemu-iotests/082.out | 27 +++++++++++
12
4 files changed, 128 insertions(+), 2 deletions(-)
14
13
15
diff --git a/qapi/block-core.json b/qapi/block-core.json
14
diff --git a/qapi/block-core.json b/qapi/block-core.json
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/qapi/block-core.json
16
--- a/qapi/block-core.json
18
+++ b/qapi/block-core.json
17
+++ b/qapi/block-core.json
19
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@
20
#
19
#
21
# @cache-clean-interval: clean unused entries in the L2 and refcount
20
# @compat: compatibility level
22
# caches. The interval is in seconds. The default value
23
-# is 600, and 0 disables this feature. (since 2.5)
24
+# is 600 on supporting platforms, and 0 on other
25
+# platforms. 0 disables this feature. (since 2.5)
26
#
21
#
27
# @encrypt: Image decryption options. Mandatory for
22
+# @data-file: the filename of the external data file that is stored in the
28
# encrypted images, except when doing a metadata-only
23
+# image and used as a default for opening the image (since: 4.0)
29
diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt
24
+#
25
# @lazy-refcounts: on or off; only valid for compat >= 1.1
26
#
27
# @corrupt: true if the image has been marked corrupt; only valid for
28
@@ -XXX,XX +XXX,XX @@
29
{ 'struct': 'ImageInfoSpecificQCow2',
30
'data': {
31
'compat': 'str',
32
+ '*data-file': 'str',
33
'*lazy-refcounts': 'bool',
34
'*corrupt': 'bool',
35
'refcount-bits': 'int',
36
@@ -XXX,XX +XXX,XX @@
37
#
38
# @data-file: reference to or definition of the external data file.
39
# This may only be specified for images that require an
40
-# external data file. (since 4.0)
41
+# external data file. If it is not specified for such
42
+# an image, the data file name is loaded from the image
43
+# file. (since 4.0)
44
#
45
# Since: 2.9
46
##
47
diff --git a/block/qcow2.h b/block/qcow2.h
30
index XXXXXXX..XXXXXXX 100644
48
index XXXXXXX..XXXXXXX 100644
31
--- a/docs/qcow2-cache.txt
49
--- a/block/qcow2.h
32
+++ b/docs/qcow2-cache.txt
50
+++ b/block/qcow2.h
33
@@ -XXX,XX +XXX,XX @@ Reducing the memory usage
51
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVQcow2State {
34
It is possible to clean unused cache entries in order to reduce the
52
* override) */
35
memory usage during periods of low I/O activity.
53
char *image_backing_file;
36
54
char *image_backing_format;
37
-The parameter "cache-clean-interval" defines an interval (in seconds).
55
+ char *image_data_file;
38
-All cache entries that haven't been accessed during that interval are
56
39
-removed from memory.
57
CoQueue compress_wait_queue;
40
+The parameter "cache-clean-interval" defines an interval (in seconds),
58
int nb_compress_threads;
41
+after which all the cache entries that haven't been accessed during the
59
diff --git a/block/qcow2.c b/block/qcow2.c
42
+interval are removed from memory. Setting this parameter to 0 disables this
43
+feature.
44
45
-This example removes all unused cache entries every 15 minutes:
46
+The following example removes all unused cache entries every 15 minutes:
47
48
-drive file=hd.qcow2,cache-clean-interval=900
49
50
-If unset, the default value for this parameter is 600. Setting it to 0
51
-disables this feature.
52
+If unset, the default value for this parameter is 600 on platforms which
53
+support this functionality, and is 0 (disabled) on other platforms.
54
55
-Note that this functionality currently relies on the MADV_DONTNEED
56
-argument for madvise() to actually free the memory. This is a
57
-Linux-specific feature, so cache-clean-interval is not supported in
58
-other systems.
59
+This functionality currently relies on the MADV_DONTNEED argument for
60
+madvise() to actually free the memory. This is a Linux-specific feature,
61
+so cache-clean-interval is not supported on other systems.
62
diff --git a/qemu-options.hx b/qemu-options.hx
63
index XXXXXXX..XXXXXXX 100644
60
index XXXXXXX..XXXXXXX 100644
64
--- a/qemu-options.hx
61
--- a/block/qcow2.c
65
+++ b/qemu-options.hx
62
+++ b/block/qcow2.c
66
@@ -XXX,XX +XXX,XX @@ it which is not used for the L2 cache)
63
@@ -XXX,XX +XXX,XX @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
67
64
#endif
68
@item cache-clean-interval
65
break;
69
Clean unused entries in the L2 and refcount caches. The interval is in seconds.
66
70
-The default value is 600. Setting it to 0 disables this feature.
67
+ case QCOW2_EXT_MAGIC_DATA_FILE:
71
+The default value is 600 on supporting platforms, and 0 on other platforms.
68
+ {
72
+Setting it to 0 disables this feature.
69
+ s->image_data_file = g_malloc0(ext.len + 1);
73
70
+ ret = bdrv_pread(bs->file, offset, s->image_data_file, ext.len);
74
@item pass-discard-request
71
+ if (ret < 0) {
75
Whether discard requests to the qcow2 device should be forwarded to the data
72
+ error_setg_errno(errp, -ret,
73
+ "ERROR: Could not read data file name");
74
+ return ret;
75
+ }
76
+#ifdef DEBUG_EXT
77
+ printf("Qcow2: Got external data file %s\n", s->image_data_file);
78
+#endif
79
+ break;
80
+ }
81
+
82
default:
83
/* unknown magic - save it in case we need to rewrite the header */
84
/* If you add a new feature, make sure to also update the fast
85
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
86
}
87
88
if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) {
89
+ if (!s->data_file && s->image_data_file) {
90
+ s->data_file = bdrv_open_child(s->image_data_file, options,
91
+ "data-file", bs, &child_file,
92
+ false, errp);
93
+ if (!s->data_file) {
94
+ ret = -EINVAL;
95
+ goto fail;
96
+ }
97
+ }
98
if (!s->data_file) {
99
error_setg(errp, "'data-file' is required for this image");
100
ret = -EINVAL;
101
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
102
return ret;
103
104
fail:
105
+ g_free(s->image_data_file);
106
if (has_data_file(bs)) {
107
bdrv_unref_child(bs, s->data_file);
108
}
109
@@ -XXX,XX +XXX,XX @@ static void qcow2_close(BlockDriverState *bs)
110
g_free(s->unknown_header_fields);
111
cleanup_unknown_header_ext(bs);
112
113
+ g_free(s->image_data_file);
114
g_free(s->image_backing_file);
115
g_free(s->image_backing_format);
116
117
@@ -XXX,XX +XXX,XX @@ int qcow2_update_header(BlockDriverState *bs)
118
buflen -= ret;
119
}
120
121
+ /* External data file header extension */
122
+ if (has_data_file(bs) && s->image_data_file) {
123
+ ret = header_ext_add(buf, QCOW2_EXT_MAGIC_DATA_FILE,
124
+ s->image_data_file, strlen(s->image_data_file),
125
+ buflen);
126
+ if (ret < 0) {
127
+ goto fail;
128
+ }
129
+
130
+ buf += ret;
131
+ buflen -= ret;
132
+ }
133
+
134
/* Full disk encryption header pointer extension */
135
if (s->crypto_header.offset != 0) {
136
s->crypto_header.offset = cpu_to_be64(s->crypto_header.offset);
137
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
138
abort();
139
}
140
141
+ /* Set the external data file if necessary */
142
+ if (data_bs) {
143
+ BDRVQcow2State *s = blk_bs(blk)->opaque;
144
+ s->image_data_file = g_strdup(data_bs->filename);
145
+ }
146
+
147
/* Create a full header (including things like feature table) */
148
ret = qcow2_update_header(blk_bs(blk));
149
if (ret < 0) {
150
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
151
QDict *qdict;
152
Visitor *v;
153
BlockDriverState *bs = NULL;
154
+ BlockDriverState *data_bs = NULL;
155
Error *local_err = NULL;
156
const char *val;
157
int ret;
158
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
159
goto finish;
160
}
161
162
+ /* Create and open an external data file (protocol layer) */
163
+ val = qdict_get_try_str(qdict, BLOCK_OPT_DATA_FILE);
164
+ if (val) {
165
+ ret = bdrv_create_file(val, opts, errp);
166
+ if (ret < 0) {
167
+ goto finish;
168
+ }
169
+
170
+ data_bs = bdrv_open(val, NULL, NULL,
171
+ BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL,
172
+ errp);
173
+ if (data_bs == NULL) {
174
+ ret = -EIO;
175
+ goto finish;
176
+ }
177
+
178
+ qdict_del(qdict, BLOCK_OPT_DATA_FILE);
179
+ qdict_put_str(qdict, "data-file", data_bs->node_name);
180
+ }
181
+
182
/* Set 'driver' and 'node' options */
183
qdict_put_str(qdict, "driver", "qcow2");
184
qdict_put_str(qdict, "file", bs->node_name);
185
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
186
finish:
187
qobject_unref(qdict);
188
bdrv_unref(bs);
189
+ bdrv_unref(data_bs);
190
qapi_free_BlockdevCreateOptions(create_options);
191
return ret;
192
}
193
@@ -XXX,XX +XXX,XX @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs,
194
.refcount_bits = s->refcount_bits,
195
.has_bitmaps = !!bitmaps,
196
.bitmaps = bitmaps,
197
+ .has_data_file = !!s->image_data_file,
198
+ .data_file = g_strdup(s->image_data_file),
199
};
200
} else {
201
/* if this assertion fails, this probably means a new version was
202
@@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
203
BDRVQcow2State *s = bs->opaque;
204
int old_version = s->qcow_version, new_version = old_version;
205
uint64_t new_size = 0;
206
- const char *backing_file = NULL, *backing_format = NULL;
207
+ const char *backing_file = NULL, *backing_format = NULL, *data_file = NULL;
208
bool lazy_refcounts = s->use_lazy_refcounts;
209
const char *compat = NULL;
210
uint64_t cluster_size = s->cluster_size;
211
@@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
212
"may not exceed 64 bits");
213
return -EINVAL;
214
}
215
+ } else if (!strcmp(desc->name, BLOCK_OPT_DATA_FILE)) {
216
+ data_file = qemu_opt_get(opts, BLOCK_OPT_DATA_FILE);
217
+ if (data_file && !has_data_file(bs)) {
218
+ error_setg(errp, "data-file can only be set for images that "
219
+ "use an external data file");
220
+ return -EINVAL;
221
+ }
222
} else {
223
/* if this point is reached, this probably means a new option was
224
* added without having it covered here */
225
@@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
226
}
227
}
228
229
+ if (data_file) {
230
+ g_free(s->image_data_file);
231
+ s->image_data_file = *data_file ? g_strdup(data_file) : NULL;
232
+ }
233
+
234
+ ret = qcow2_update_header(bs);
235
+ if (ret < 0) {
236
+ error_setg_errno(errp, -ret, "Failed to update the image header");
237
+ return ret;
238
+ }
239
+
240
if (backing_file || backing_format) {
241
ret = qcow2_change_backing_file(bs,
242
backing_file ?: s->image_backing_file,
243
@@ -XXX,XX +XXX,XX @@ static QemuOptsList qcow2_create_opts = {
244
.type = QEMU_OPT_STRING,
245
.help = "Image format of the base image"
246
},
247
+ {
248
+ .name = BLOCK_OPT_DATA_FILE,
249
+ .type = QEMU_OPT_STRING,
250
+ .help = "File name of an external data file"
251
+ },
252
{
253
.name = BLOCK_OPT_ENCRYPT,
254
.type = QEMU_OPT_BOOL,
255
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
256
index XXXXXXX..XXXXXXX 100644
257
--- a/tests/qemu-iotests/082.out
258
+++ b/tests/qemu-iotests/082.out
259
@@ -XXX,XX +XXX,XX @@ Supported options:
260
backing_fmt=<str> - Image format of the base image
261
cluster_size=<size> - qcow2 cluster size
262
compat=<str> - Compatibility level (0.10 or 1.1)
263
+ data_file=<str> - File name of an external data file
264
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
265
encrypt.cipher-mode=<str> - Name of encryption cipher mode
266
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
267
@@ -XXX,XX +XXX,XX @@ Supported options:
268
backing_fmt=<str> - Image format of the base image
269
cluster_size=<size> - qcow2 cluster size
270
compat=<str> - Compatibility level (0.10 or 1.1)
271
+ data_file=<str> - File name of an external data file
272
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
273
encrypt.cipher-mode=<str> - Name of encryption cipher mode
274
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
275
@@ -XXX,XX +XXX,XX @@ Supported options:
276
backing_fmt=<str> - Image format of the base image
277
cluster_size=<size> - qcow2 cluster size
278
compat=<str> - Compatibility level (0.10 or 1.1)
279
+ data_file=<str> - File name of an external data file
280
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
281
encrypt.cipher-mode=<str> - Name of encryption cipher mode
282
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
283
@@ -XXX,XX +XXX,XX @@ Supported options:
284
backing_fmt=<str> - Image format of the base image
285
cluster_size=<size> - qcow2 cluster size
286
compat=<str> - Compatibility level (0.10 or 1.1)
287
+ data_file=<str> - File name of an external data file
288
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
289
encrypt.cipher-mode=<str> - Name of encryption cipher mode
290
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
291
@@ -XXX,XX +XXX,XX @@ Supported options:
292
backing_fmt=<str> - Image format of the base image
293
cluster_size=<size> - qcow2 cluster size
294
compat=<str> - Compatibility level (0.10 or 1.1)
295
+ data_file=<str> - File name of an external data file
296
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
297
encrypt.cipher-mode=<str> - Name of encryption cipher mode
298
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
299
@@ -XXX,XX +XXX,XX @@ Supported options:
300
backing_fmt=<str> - Image format of the base image
301
cluster_size=<size> - qcow2 cluster size
302
compat=<str> - Compatibility level (0.10 or 1.1)
303
+ data_file=<str> - File name of an external data file
304
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
305
encrypt.cipher-mode=<str> - Name of encryption cipher mode
306
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
307
@@ -XXX,XX +XXX,XX @@ Supported options:
308
backing_fmt=<str> - Image format of the base image
309
cluster_size=<size> - qcow2 cluster size
310
compat=<str> - Compatibility level (0.10 or 1.1)
311
+ data_file=<str> - File name of an external data file
312
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
313
encrypt.cipher-mode=<str> - Name of encryption cipher mode
314
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
315
@@ -XXX,XX +XXX,XX @@ Supported options:
316
backing_fmt=<str> - Image format of the base image
317
cluster_size=<size> - qcow2 cluster size
318
compat=<str> - Compatibility level (0.10 or 1.1)
319
+ data_file=<str> - File name of an external data file
320
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
321
encrypt.cipher-mode=<str> - Name of encryption cipher mode
322
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
323
@@ -XXX,XX +XXX,XX @@ Supported options:
324
backing_fmt=<str> - Image format of the base image
325
cluster_size=<size> - qcow2 cluster size
326
compat=<str> - Compatibility level (0.10 or 1.1)
327
+ data_file=<str> - File name of an external data file
328
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
329
encrypt.cipher-mode=<str> - Name of encryption cipher mode
330
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
331
@@ -XXX,XX +XXX,XX @@ Supported options:
332
backing_fmt=<str> - Image format of the base image
333
cluster_size=<size> - qcow2 cluster size
334
compat=<str> - Compatibility level (0.10 or 1.1)
335
+ data_file=<str> - File name of an external data file
336
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
337
encrypt.cipher-mode=<str> - Name of encryption cipher mode
338
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
339
@@ -XXX,XX +XXX,XX @@ Supported options:
340
backing_fmt=<str> - Image format of the base image
341
cluster_size=<size> - qcow2 cluster size
342
compat=<str> - Compatibility level (0.10 or 1.1)
343
+ data_file=<str> - File name of an external data file
344
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
345
encrypt.cipher-mode=<str> - Name of encryption cipher mode
346
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
347
@@ -XXX,XX +XXX,XX @@ Supported options:
348
backing_fmt=<str> - Image format of the base image
349
cluster_size=<size> - qcow2 cluster size
350
compat=<str> - Compatibility level (0.10 or 1.1)
351
+ data_file=<str> - File name of an external data file
352
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
353
encrypt.cipher-mode=<str> - Name of encryption cipher mode
354
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
355
@@ -XXX,XX +XXX,XX @@ Supported options:
356
backing_fmt=<str> - Image format of the base image
357
cluster_size=<size> - qcow2 cluster size
358
compat=<str> - Compatibility level (0.10 or 1.1)
359
+ data_file=<str> - File name of an external data file
360
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
361
encrypt.cipher-mode=<str> - Name of encryption cipher mode
362
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
363
@@ -XXX,XX +XXX,XX @@ Supported options:
364
backing_fmt=<str> - Image format of the base image
365
cluster_size=<size> - qcow2 cluster size
366
compat=<str> - Compatibility level (0.10 or 1.1)
367
+ data_file=<str> - File name of an external data file
368
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
369
encrypt.cipher-mode=<str> - Name of encryption cipher mode
370
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
371
@@ -XXX,XX +XXX,XX @@ Supported options:
372
backing_fmt=<str> - Image format of the base image
373
cluster_size=<size> - qcow2 cluster size
374
compat=<str> - Compatibility level (0.10 or 1.1)
375
+ data_file=<str> - File name of an external data file
376
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
377
encrypt.cipher-mode=<str> - Name of encryption cipher mode
378
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
379
@@ -XXX,XX +XXX,XX @@ Supported options:
380
backing_fmt=<str> - Image format of the base image
381
cluster_size=<size> - qcow2 cluster size
382
compat=<str> - Compatibility level (0.10 or 1.1)
383
+ data_file=<str> - File name of an external data file
384
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
385
encrypt.cipher-mode=<str> - Name of encryption cipher mode
386
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
387
@@ -XXX,XX +XXX,XX @@ Supported options:
388
backing_fmt=<str> - Image format of the base image
389
cluster_size=<size> - qcow2 cluster size
390
compat=<str> - Compatibility level (0.10 or 1.1)
391
+ data_file=<str> - File name of an external data file
392
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
393
encrypt.cipher-mode=<str> - Name of encryption cipher mode
394
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
395
@@ -XXX,XX +XXX,XX @@ Supported options:
396
backing_fmt=<str> - Image format of the base image
397
cluster_size=<size> - qcow2 cluster size
398
compat=<str> - Compatibility level (0.10 or 1.1)
399
+ data_file=<str> - File name of an external data file
400
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
401
encrypt.cipher-mode=<str> - Name of encryption cipher mode
402
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
403
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
404
backing_fmt=<str> - Image format of the base image
405
cluster_size=<size> - qcow2 cluster size
406
compat=<str> - Compatibility level (0.10 or 1.1)
407
+ data_file=<str> - File name of an external data file
408
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
409
encrypt.cipher-mode=<str> - Name of encryption cipher mode
410
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
411
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
412
backing_fmt=<str> - Image format of the base image
413
cluster_size=<size> - qcow2 cluster size
414
compat=<str> - Compatibility level (0.10 or 1.1)
415
+ data_file=<str> - File name of an external data file
416
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
417
encrypt.cipher-mode=<str> - Name of encryption cipher mode
418
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
419
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
420
backing_fmt=<str> - Image format of the base image
421
cluster_size=<size> - qcow2 cluster size
422
compat=<str> - Compatibility level (0.10 or 1.1)
423
+ data_file=<str> - File name of an external data file
424
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
425
encrypt.cipher-mode=<str> - Name of encryption cipher mode
426
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
427
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
428
backing_fmt=<str> - Image format of the base image
429
cluster_size=<size> - qcow2 cluster size
430
compat=<str> - Compatibility level (0.10 or 1.1)
431
+ data_file=<str> - File name of an external data file
432
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
433
encrypt.cipher-mode=<str> - Name of encryption cipher mode
434
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
435
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
436
backing_fmt=<str> - Image format of the base image
437
cluster_size=<size> - qcow2 cluster size
438
compat=<str> - Compatibility level (0.10 or 1.1)
439
+ data_file=<str> - File name of an external data file
440
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
441
encrypt.cipher-mode=<str> - Name of encryption cipher mode
442
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
443
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
444
backing_fmt=<str> - Image format of the base image
445
cluster_size=<size> - qcow2 cluster size
446
compat=<str> - Compatibility level (0.10 or 1.1)
447
+ data_file=<str> - File name of an external data file
448
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
449
encrypt.cipher-mode=<str> - Name of encryption cipher mode
450
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
451
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
452
backing_fmt=<str> - Image format of the base image
453
cluster_size=<size> - qcow2 cluster size
454
compat=<str> - Compatibility level (0.10 or 1.1)
455
+ data_file=<str> - File name of an external data file
456
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
457
encrypt.cipher-mode=<str> - Name of encryption cipher mode
458
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
459
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
460
backing_fmt=<str> - Image format of the base image
461
cluster_size=<size> - qcow2 cluster size
462
compat=<str> - Compatibility level (0.10 or 1.1)
463
+ data_file=<str> - File name of an external data file
464
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
465
encrypt.cipher-mode=<str> - Name of encryption cipher mode
466
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
467
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
468
backing_fmt=<str> - Image format of the base image
469
cluster_size=<size> - qcow2 cluster size
470
compat=<str> - Compatibility level (0.10 or 1.1)
471
+ data_file=<str> - File name of an external data file
472
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
473
encrypt.cipher-mode=<str> - Name of encryption cipher mode
474
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
76
--
475
--
77
2.13.6
476
2.20.1
78
477
79
478
diff view generated by jsdifflib
1
From: Leonid Bloch <lbloch@janustech.com>
1
Provide an option to force QEMU to always keep the external data file
2
consistent as a standalone read-only raw image.
2
3
3
The caches are now recalculated upon image resizing. This is done
4
At the moment, this means making sure that write_zeroes requests are
4
because the new default behavior of assigning L2 cache relatively to
5
forwarded to the data file instead of just updating the metadata, and
5
the image size, implies that the cache will be adapted accordingly
6
checking that no backing file is used.
6
after an image resize.
7
7
8
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
9
Reviewed-by: Alberto Garcia <berto@igalia.com>
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11
---
9
---
12
block/qcow2.c | 11 +++++++++++
10
qapi/block-core.json | 9 ++++++
13
1 file changed, 11 insertions(+)
11
block/qcow2.h | 9 +++++-
12
include/block/block_int.h | 1 +
13
block/qcow2-cluster.c | 10 +++++++
14
block/qcow2.c | 56 ++++++++++++++++++++++++++++++++++++--
15
tests/qemu-iotests/082.out | 27 ++++++++++++++++++
16
6 files changed, 109 insertions(+), 3 deletions(-)
14
17
18
diff --git a/qapi/block-core.json b/qapi/block-core.json
19
index XXXXXXX..XXXXXXX 100644
20
--- a/qapi/block-core.json
21
+++ b/qapi/block-core.json
22
@@ -XXX,XX +XXX,XX @@
23
# @data-file: the filename of the external data file that is stored in the
24
# image and used as a default for opening the image (since: 4.0)
25
#
26
+# @data-file-raw: True if the external data file must stay valid as a
27
+# standalone (read-only) raw image without looking at qcow2
28
+# metadata (since: 4.0)
29
+#
30
# @lazy-refcounts: on or off; only valid for compat >= 1.1
31
#
32
# @corrupt: true if the image has been marked corrupt; only valid for
33
@@ -XXX,XX +XXX,XX @@
34
'data': {
35
'compat': 'str',
36
'*data-file': 'str',
37
+ '*data-file-raw': 'bool',
38
'*lazy-refcounts': 'bool',
39
'*corrupt': 'bool',
40
'refcount-bits': 'int',
41
@@ -XXX,XX +XXX,XX @@
42
# @data-file Node to use as an external data file in which all guest
43
# data is stored so that only metadata remains in the qcow2
44
# file (since: 4.0)
45
+# @data-file-raw True if the external data file must stay valid as a
46
+# standalone (read-only) raw image without looking at qcow2
47
+# metadata (default: false; since: 4.0)
48
# @size Size of the virtual disk in bytes
49
# @version Compatibility level (default: v3)
50
# @backing-file File name of the backing file if a backing file
51
@@ -XXX,XX +XXX,XX @@
52
{ 'struct': 'BlockdevCreateOptionsQcow2',
53
'data': { 'file': 'BlockdevRef',
54
'*data-file': 'BlockdevRef',
55
+ '*data-file-raw': 'bool',
56
'size': 'size',
57
'*version': 'BlockdevQcow2Version',
58
'*backing-file': 'str',
59
diff --git a/block/qcow2.h b/block/qcow2.h
60
index XXXXXXX..XXXXXXX 100644
61
--- a/block/qcow2.h
62
+++ b/block/qcow2.h
63
@@ -XXX,XX +XXX,XX @@ enum {
64
QCOW2_AUTOCLEAR_BITMAPS = 1 << QCOW2_AUTOCLEAR_BITMAPS_BITNR,
65
QCOW2_AUTOCLEAR_DATA_FILE_RAW = 1 << QCOW2_AUTOCLEAR_DATA_FILE_RAW_BITNR,
66
67
- QCOW2_AUTOCLEAR_MASK = QCOW2_AUTOCLEAR_BITMAPS,
68
+ QCOW2_AUTOCLEAR_MASK = QCOW2_AUTOCLEAR_BITMAPS
69
+ | QCOW2_AUTOCLEAR_DATA_FILE_RAW,
70
};
71
72
enum qcow2_discard_type {
73
@@ -XXX,XX +XXX,XX @@ static inline bool has_data_file(BlockDriverState *bs)
74
return (s->data_file != bs->file);
75
}
76
77
+static inline bool data_file_is_raw(BlockDriverState *bs)
78
+{
79
+ BDRVQcow2State *s = bs->opaque;
80
+ return !!(s->autoclear_features & QCOW2_AUTOCLEAR_DATA_FILE_RAW);
81
+}
82
+
83
static inline int64_t start_of_cluster(BDRVQcow2State *s, int64_t offset)
84
{
85
return offset & ~(s->cluster_size - 1);
86
diff --git a/include/block/block_int.h b/include/block/block_int.h
87
index XXXXXXX..XXXXXXX 100644
88
--- a/include/block/block_int.h
89
+++ b/include/block/block_int.h
90
@@ -XXX,XX +XXX,XX @@
91
#define BLOCK_OPT_OBJECT_SIZE "object_size"
92
#define BLOCK_OPT_REFCOUNT_BITS "refcount_bits"
93
#define BLOCK_OPT_DATA_FILE "data_file"
94
+#define BLOCK_OPT_DATA_FILE_RAW "data_file_raw"
95
96
#define BLOCK_PROBE_BUF_SIZE 512
97
98
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
99
index XXXXXXX..XXXXXXX 100644
100
--- a/block/qcow2-cluster.c
101
+++ b/block/qcow2-cluster.c
102
@@ -XXX,XX +XXX,XX @@ int qcow2_cluster_zeroize(BlockDriverState *bs, uint64_t offset,
103
int64_t cleared;
104
int ret;
105
106
+ /* If we have to stay in sync with an external data file, zero out
107
+ * s->data_file first. */
108
+ if (data_file_is_raw(bs)) {
109
+ assert(has_data_file(bs));
110
+ ret = bdrv_co_pwrite_zeroes(s->data_file, offset, bytes, flags);
111
+ if (ret < 0) {
112
+ return ret;
113
+ }
114
+ }
115
+
116
/* Caller must pass aligned values, except at image end */
117
assert(QEMU_IS_ALIGNED(offset, s->cluster_size));
118
assert(QEMU_IS_ALIGNED(end_offset, s->cluster_size) ||
15
diff --git a/block/qcow2.c b/block/qcow2.c
119
diff --git a/block/qcow2.c b/block/qcow2.c
16
index XXXXXXX..XXXXXXX 100644
120
index XXXXXXX..XXXXXXX 100644
17
--- a/block/qcow2.c
121
--- a/block/qcow2.c
18
+++ b/block/qcow2.c
122
+++ b/block/qcow2.c
19
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
123
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
20
uint64_t old_length;
124
"external data file");
21
int64_t new_l1_size;
125
ret = -EINVAL;
22
int ret;
126
goto fail;
23
+ QDict *options;
127
- } else {
24
128
- s->data_file = bs->file;
25
if (prealloc != PREALLOC_MODE_OFF && prealloc != PREALLOC_MODE_METADATA &&
129
+ }
26
prealloc != PREALLOC_MODE_FALLOC && prealloc != PREALLOC_MODE_FULL)
130
+
27
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
131
+ s->data_file = bs->file;
132
+
133
+ if (data_file_is_raw(bs)) {
134
+ error_setg(errp, "data-file-raw requires a data file");
135
+ ret = -EINVAL;
136
+ goto fail;
28
}
137
}
29
}
138
}
30
139
31
+ bs->total_sectors = offset / BDRV_SECTOR_SIZE;
140
@@ -XXX,XX +XXX,XX @@ static int qcow2_change_backing_file(BlockDriverState *bs,
32
+
141
{
33
/* write updated header.size */
142
BDRVQcow2State *s = bs->opaque;
34
offset = cpu_to_be64(offset);
143
35
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size),
144
+ /* Adding a backing file means that the external data file alone won't be
36
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
145
+ * enough to make sense of the content */
146
+ if (backing_file && data_file_is_raw(bs)) {
147
+ return -EINVAL;
148
+ }
149
+
150
if (backing_file && strlen(backing_file) > 1023) {
151
return -EINVAL;
37
}
152
}
38
153
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
39
s->l1_vm_state_index = new_l1_size;
154
}
40
+
155
refcount_order = ctz32(qcow2_opts->refcount_bits);
41
+ /* Update cache sizes */
156
42
+ options = qdict_clone_shallow(bs->options);
157
+ if (qcow2_opts->data_file_raw && !qcow2_opts->data_file) {
43
+ ret = qcow2_update_options(bs, options, s->flags, errp);
158
+ error_setg(errp, "data-file-raw requires data-file");
44
+ qobject_unref(options);
159
+ ret = -EINVAL;
45
+ if (ret < 0) {
160
+ goto out;
46
+ goto fail;
161
+ }
47
+ }
162
+ if (qcow2_opts->data_file_raw && qcow2_opts->has_backing_file) {
48
ret = 0;
163
+ error_setg(errp, "Backing file and data-file-raw cannot be used at "
49
fail:
164
+ "the same time");
50
qemu_co_mutex_unlock(&s->lock);
165
+ ret = -EINVAL;
166
+ goto out;
167
+ }
168
+
169
if (qcow2_opts->data_file) {
170
if (version < 3) {
171
error_setg(errp, "External data files are only supported with "
172
@@ -XXX,XX +XXX,XX @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
173
header->incompatible_features |=
174
cpu_to_be64(QCOW2_INCOMPAT_DATA_FILE);
175
}
176
+ if (qcow2_opts->data_file_raw) {
177
+ header->autoclear_features |=
178
+ cpu_to_be64(QCOW2_AUTOCLEAR_DATA_FILE_RAW);
179
+ }
180
181
ret = blk_pwrite(blk, 0, header, cluster_size, 0);
182
g_free(header);
183
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
184
{ BLOCK_OPT_REFCOUNT_BITS, "refcount-bits" },
185
{ BLOCK_OPT_ENCRYPT, BLOCK_OPT_ENCRYPT_FORMAT },
186
{ BLOCK_OPT_COMPAT_LEVEL, "version" },
187
+ { BLOCK_OPT_DATA_FILE_RAW, "data-file-raw" },
188
{ NULL, NULL },
189
};
190
191
@@ -XXX,XX +XXX,XX @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs,
192
.bitmaps = bitmaps,
193
.has_data_file = !!s->image_data_file,
194
.data_file = g_strdup(s->image_data_file),
195
+ .has_data_file_raw = has_data_file(bs),
196
+ .data_file_raw = data_file_is_raw(bs),
197
};
198
} else {
199
/* if this assertion fails, this probably means a new version was
200
@@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
201
uint64_t new_size = 0;
202
const char *backing_file = NULL, *backing_format = NULL, *data_file = NULL;
203
bool lazy_refcounts = s->use_lazy_refcounts;
204
+ bool data_file_raw = data_file_is_raw(bs);
205
const char *compat = NULL;
206
uint64_t cluster_size = s->cluster_size;
207
bool encrypt;
208
@@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
209
"use an external data file");
210
return -EINVAL;
211
}
212
+ } else if (!strcmp(desc->name, BLOCK_OPT_DATA_FILE_RAW)) {
213
+ data_file_raw = qemu_opt_get_bool(opts, BLOCK_OPT_DATA_FILE_RAW,
214
+ data_file_raw);
215
+ if (data_file_raw && !data_file_is_raw(bs)) {
216
+ error_setg(errp, "data-file-raw cannot be set on existing "
217
+ "images");
218
+ return -EINVAL;
219
+ }
220
} else {
221
/* if this point is reached, this probably means a new option was
222
* added without having it covered here */
223
@@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
224
}
225
}
226
227
+ /* data-file-raw blocks backing files, so clear it first if requested */
228
+ if (data_file_raw) {
229
+ s->autoclear_features |= QCOW2_AUTOCLEAR_DATA_FILE_RAW;
230
+ } else {
231
+ s->autoclear_features &= ~QCOW2_AUTOCLEAR_DATA_FILE_RAW;
232
+ }
233
+
234
if (data_file) {
235
g_free(s->image_data_file);
236
s->image_data_file = *data_file ? g_strdup(data_file) : NULL;
237
@@ -XXX,XX +XXX,XX @@ static QemuOptsList qcow2_create_opts = {
238
.type = QEMU_OPT_STRING,
239
.help = "File name of an external data file"
240
},
241
+ {
242
+ .name = BLOCK_OPT_DATA_FILE_RAW,
243
+ .type = QEMU_OPT_BOOL,
244
+ .help = "The external data file must stay valid as a raw image"
245
+ },
246
{
247
.name = BLOCK_OPT_ENCRYPT,
248
.type = QEMU_OPT_BOOL,
249
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
250
index XXXXXXX..XXXXXXX 100644
251
--- a/tests/qemu-iotests/082.out
252
+++ b/tests/qemu-iotests/082.out
253
@@ -XXX,XX +XXX,XX @@ Supported options:
254
cluster_size=<size> - qcow2 cluster size
255
compat=<str> - Compatibility level (0.10 or 1.1)
256
data_file=<str> - File name of an external data file
257
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
258
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
259
encrypt.cipher-mode=<str> - Name of encryption cipher mode
260
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
261
@@ -XXX,XX +XXX,XX @@ Supported options:
262
cluster_size=<size> - qcow2 cluster size
263
compat=<str> - Compatibility level (0.10 or 1.1)
264
data_file=<str> - File name of an external data file
265
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
266
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
267
encrypt.cipher-mode=<str> - Name of encryption cipher mode
268
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
269
@@ -XXX,XX +XXX,XX @@ Supported options:
270
cluster_size=<size> - qcow2 cluster size
271
compat=<str> - Compatibility level (0.10 or 1.1)
272
data_file=<str> - File name of an external data file
273
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
274
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
275
encrypt.cipher-mode=<str> - Name of encryption cipher mode
276
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
277
@@ -XXX,XX +XXX,XX @@ Supported options:
278
cluster_size=<size> - qcow2 cluster size
279
compat=<str> - Compatibility level (0.10 or 1.1)
280
data_file=<str> - File name of an external data file
281
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
282
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
283
encrypt.cipher-mode=<str> - Name of encryption cipher mode
284
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
285
@@ -XXX,XX +XXX,XX @@ Supported options:
286
cluster_size=<size> - qcow2 cluster size
287
compat=<str> - Compatibility level (0.10 or 1.1)
288
data_file=<str> - File name of an external data file
289
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
290
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
291
encrypt.cipher-mode=<str> - Name of encryption cipher mode
292
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
293
@@ -XXX,XX +XXX,XX @@ Supported options:
294
cluster_size=<size> - qcow2 cluster size
295
compat=<str> - Compatibility level (0.10 or 1.1)
296
data_file=<str> - File name of an external data file
297
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
298
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
299
encrypt.cipher-mode=<str> - Name of encryption cipher mode
300
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
301
@@ -XXX,XX +XXX,XX @@ Supported options:
302
cluster_size=<size> - qcow2 cluster size
303
compat=<str> - Compatibility level (0.10 or 1.1)
304
data_file=<str> - File name of an external data file
305
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
306
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
307
encrypt.cipher-mode=<str> - Name of encryption cipher mode
308
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
309
@@ -XXX,XX +XXX,XX @@ Supported options:
310
cluster_size=<size> - qcow2 cluster size
311
compat=<str> - Compatibility level (0.10 or 1.1)
312
data_file=<str> - File name of an external data file
313
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
314
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
315
encrypt.cipher-mode=<str> - Name of encryption cipher mode
316
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
317
@@ -XXX,XX +XXX,XX @@ Supported options:
318
cluster_size=<size> - qcow2 cluster size
319
compat=<str> - Compatibility level (0.10 or 1.1)
320
data_file=<str> - File name of an external data file
321
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
322
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
323
encrypt.cipher-mode=<str> - Name of encryption cipher mode
324
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
325
@@ -XXX,XX +XXX,XX @@ Supported options:
326
cluster_size=<size> - qcow2 cluster size
327
compat=<str> - Compatibility level (0.10 or 1.1)
328
data_file=<str> - File name of an external data file
329
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
330
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
331
encrypt.cipher-mode=<str> - Name of encryption cipher mode
332
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
333
@@ -XXX,XX +XXX,XX @@ Supported options:
334
cluster_size=<size> - qcow2 cluster size
335
compat=<str> - Compatibility level (0.10 or 1.1)
336
data_file=<str> - File name of an external data file
337
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
338
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
339
encrypt.cipher-mode=<str> - Name of encryption cipher mode
340
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
341
@@ -XXX,XX +XXX,XX @@ Supported options:
342
cluster_size=<size> - qcow2 cluster size
343
compat=<str> - Compatibility level (0.10 or 1.1)
344
data_file=<str> - File name of an external data file
345
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
346
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
347
encrypt.cipher-mode=<str> - Name of encryption cipher mode
348
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
349
@@ -XXX,XX +XXX,XX @@ Supported options:
350
cluster_size=<size> - qcow2 cluster size
351
compat=<str> - Compatibility level (0.10 or 1.1)
352
data_file=<str> - File name of an external data file
353
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
354
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
355
encrypt.cipher-mode=<str> - Name of encryption cipher mode
356
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
357
@@ -XXX,XX +XXX,XX @@ Supported options:
358
cluster_size=<size> - qcow2 cluster size
359
compat=<str> - Compatibility level (0.10 or 1.1)
360
data_file=<str> - File name of an external data file
361
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
362
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
363
encrypt.cipher-mode=<str> - Name of encryption cipher mode
364
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
365
@@ -XXX,XX +XXX,XX @@ Supported options:
366
cluster_size=<size> - qcow2 cluster size
367
compat=<str> - Compatibility level (0.10 or 1.1)
368
data_file=<str> - File name of an external data file
369
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
370
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
371
encrypt.cipher-mode=<str> - Name of encryption cipher mode
372
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
373
@@ -XXX,XX +XXX,XX @@ Supported options:
374
cluster_size=<size> - qcow2 cluster size
375
compat=<str> - Compatibility level (0.10 or 1.1)
376
data_file=<str> - File name of an external data file
377
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
378
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
379
encrypt.cipher-mode=<str> - Name of encryption cipher mode
380
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
381
@@ -XXX,XX +XXX,XX @@ Supported options:
382
cluster_size=<size> - qcow2 cluster size
383
compat=<str> - Compatibility level (0.10 or 1.1)
384
data_file=<str> - File name of an external data file
385
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
386
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
387
encrypt.cipher-mode=<str> - Name of encryption cipher mode
388
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
389
@@ -XXX,XX +XXX,XX @@ Supported options:
390
cluster_size=<size> - qcow2 cluster size
391
compat=<str> - Compatibility level (0.10 or 1.1)
392
data_file=<str> - File name of an external data file
393
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
394
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
395
encrypt.cipher-mode=<str> - Name of encryption cipher mode
396
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
397
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
398
cluster_size=<size> - qcow2 cluster size
399
compat=<str> - Compatibility level (0.10 or 1.1)
400
data_file=<str> - File name of an external data file
401
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
402
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
403
encrypt.cipher-mode=<str> - Name of encryption cipher mode
404
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
405
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
406
cluster_size=<size> - qcow2 cluster size
407
compat=<str> - Compatibility level (0.10 or 1.1)
408
data_file=<str> - File name of an external data file
409
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
410
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
411
encrypt.cipher-mode=<str> - Name of encryption cipher mode
412
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
413
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
414
cluster_size=<size> - qcow2 cluster size
415
compat=<str> - Compatibility level (0.10 or 1.1)
416
data_file=<str> - File name of an external data file
417
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
418
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
419
encrypt.cipher-mode=<str> - Name of encryption cipher mode
420
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
421
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
422
cluster_size=<size> - qcow2 cluster size
423
compat=<str> - Compatibility level (0.10 or 1.1)
424
data_file=<str> - File name of an external data file
425
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
426
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
427
encrypt.cipher-mode=<str> - Name of encryption cipher mode
428
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
429
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
430
cluster_size=<size> - qcow2 cluster size
431
compat=<str> - Compatibility level (0.10 or 1.1)
432
data_file=<str> - File name of an external data file
433
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
434
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
435
encrypt.cipher-mode=<str> - Name of encryption cipher mode
436
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
437
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
438
cluster_size=<size> - qcow2 cluster size
439
compat=<str> - Compatibility level (0.10 or 1.1)
440
data_file=<str> - File name of an external data file
441
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
442
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
443
encrypt.cipher-mode=<str> - Name of encryption cipher mode
444
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
445
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
446
cluster_size=<size> - qcow2 cluster size
447
compat=<str> - Compatibility level (0.10 or 1.1)
448
data_file=<str> - File name of an external data file
449
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
450
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
451
encrypt.cipher-mode=<str> - Name of encryption cipher mode
452
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
453
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
454
cluster_size=<size> - qcow2 cluster size
455
compat=<str> - Compatibility level (0.10 or 1.1)
456
data_file=<str> - File name of an external data file
457
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
458
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
459
encrypt.cipher-mode=<str> - Name of encryption cipher mode
460
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
461
@@ -XXX,XX +XXX,XX @@ Creation options for 'qcow2':
462
cluster_size=<size> - qcow2 cluster size
463
compat=<str> - Compatibility level (0.10 or 1.1)
464
data_file=<str> - File name of an external data file
465
+ data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image
466
encrypt.cipher-alg=<str> - Name of encryption cipher algorithm
467
encrypt.cipher-mode=<str> - Name of encryption cipher mode
468
encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks'
51
--
469
--
52
2.13.6
470
2.20.1
53
471
54
472
diff view generated by jsdifflib
1
From: Leonid Bloch <lbloch@janustech.com>
1
Test that preallocating metadata results in a somewhat larger qcow2
2
file, but preallocating data only affects the disk usage of the data
3
file and the qcow2 file stays small.
2
4
3
Signed-off-by: Leonid Bloch <lbloch@janustech.com>
4
Reviewed-by: Alberto Garcia <berto@igalia.com>
5
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
6
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
5
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7
---
6
---
8
docs/qcow2-cache.txt | 21 ++++++++++++++-------
7
tests/qemu-iotests/243 | 22 ++++++++++++++++++++++
9
qemu-options.hx | 9 ++++++---
8
tests/qemu-iotests/243.out | 32 ++++++++++++++++++++++++++++++++
10
2 files changed, 20 insertions(+), 10 deletions(-)
9
2 files changed, 54 insertions(+)
11
10
12
diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt
11
diff --git a/tests/qemu-iotests/243 b/tests/qemu-iotests/243
12
index XXXXXXX..XXXXXXX 100755
13
--- a/tests/qemu-iotests/243
14
+++ b/tests/qemu-iotests/243
15
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
16
_cleanup()
17
{
18
_cleanup_test_img
19
+ rm -f $TEST_IMG.data
20
}
21
trap "_cleanup; exit \$status" 0 1 2 3 15
22
23
@@ -XXX,XX +XXX,XX @@ for mode in off metadata falloc full; do
24
25
done
26
27
+for mode in off metadata falloc full; do
28
+
29
+ echo
30
+ echo "=== External data file: preallocation=$mode ==="
31
+ echo
32
+
33
+ IMGOPTS="data_file=$TEST_IMG.data,preallocation=$mode" _make_test_img 64M
34
+
35
+ echo -n "qcow2 file size: "
36
+ du -b $TEST_IMG | cut -f1
37
+ echo -n "data file size: "
38
+ du -b $TEST_IMG.data | cut -f1
39
+
40
+ # Can't use precise numbers here because they differ between filesystems
41
+ echo -n "qcow2 disk usage: "
42
+ [ $(du -B1 $TEST_IMG | cut -f1) -lt 1048576 ] && echo "low" || echo "high"
43
+ echo -n "data disk usage: "
44
+ [ $(du -B1 $TEST_IMG.data | cut -f1) -lt 1048576 ] && echo "low" || echo "high"
45
+
46
+done
47
+
48
# success, all done
49
echo "*** done"
50
rm -f $seq.full
51
diff --git a/tests/qemu-iotests/243.out b/tests/qemu-iotests/243.out
13
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
14
--- a/docs/qcow2-cache.txt
53
--- a/tests/qemu-iotests/243.out
15
+++ b/docs/qcow2-cache.txt
54
+++ b/tests/qemu-iotests/243.out
16
@@ -XXX,XX +XXX,XX @@ Choosing the right cache sizes
55
@@ -XXX,XX +XXX,XX @@ Disk usage: high
17
In order to choose the cache sizes we need to know how they relate to
56
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 preallocation=full
18
the amount of allocated space.
57
File size: 67436544
19
58
Disk usage: high
20
-The amount of virtual disk that can be mapped by the L2 and refcount
21
+The part of the virtual disk that can be mapped by the L2 and refcount
22
caches (in bytes) is:
23
24
disk_size = l2_cache_size * cluster_size / 8
25
disk_size = refcount_cache_size * cluster_size * 8 / refcount_bits
26
27
With the default values for cluster_size (64KB) and refcount_bits
28
-(16), that is
29
+(16), this becomes:
30
31
disk_size = l2_cache_size * 8192
32
disk_size = refcount_cache_size * 32768
33
@@ -XXX,XX +XXX,XX @@ need:
34
l2_cache_size = disk_size_GB * 131072
35
refcount_cache_size = disk_size_GB * 32768
36
37
-QEMU has a default L2 cache of 1MB (1048576 bytes) and a refcount
38
-cache of 256KB (262144 bytes), so using the formulas we've just seen
39
-we have
40
+For example, 1MB of L2 cache is needed to cover every 8 GB of the virtual
41
+image size (given that the default cluster size is used):
42
43
- 1048576 / 131072 = 8 GB of virtual disk covered by that cache
44
- 262144 / 32768 = 8 GB
45
+ 8 GB / 8192 = 1 MB
46
+
59
+
47
+The refcount cache is 4 times the cluster size by default. With the default
60
+=== External data file: preallocation=off ===
48
+cluster size of 64 KB, it is 256 KB (262144 bytes). This is sufficient for
49
+8 GB of image size:
50
+
61
+
51
+ 262144 * 32768 = 8 GB
62
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data preallocation=off
52
63
+qcow2 file size: 196616
53
64
+data file size: 67108864
54
How to configure the cache sizes
65
+qcow2 disk usage: low
55
@@ -XXX,XX +XXX,XX @@ There are a few things that need to be taken into account:
66
+data disk usage: low
56
memory as possible to the L2 cache before increasing the refcount
57
cache size.
58
59
+ - At most two of "l2-cache-size", "refcount-cache-size", and "cache-size"
60
+ can be set simultaneously.
61
+
67
+
62
Unlike L2 tables, refcount blocks are not used during normal I/O but
68
+=== External data file: preallocation=metadata ===
63
only during allocations and internal snapshots. In most cases they are
69
+
64
accessed sequentially (even during random guest I/O) so increasing the
70
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data preallocation=metadata
65
diff --git a/qemu-options.hx b/qemu-options.hx
71
+qcow2 file size: 327680
66
index XXXXXXX..XXXXXXX 100644
72
+data file size: 67108864
67
--- a/qemu-options.hx
73
+qcow2 disk usage: low
68
+++ b/qemu-options.hx
74
+data disk usage: low
69
@@ -XXX,XX +XXX,XX @@ image file)
75
+
70
76
+=== External data file: preallocation=falloc ===
71
@item cache-size
77
+
72
The maximum total size of the L2 table and refcount block caches in bytes
78
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data preallocation=falloc
73
-(default: 1048576 bytes or 8 clusters, whichever is larger)
79
+qcow2 file size: 327680
74
+(default: the sum of l2-cache-size and refcount-cache-size)
80
+data file size: 67108864
75
81
+qcow2 disk usage: low
76
@item l2-cache-size
82
+data disk usage: high
77
The maximum size of the L2 table cache in bytes
83
+
78
-(default: 4/5 of the total cache size)
84
+=== External data file: preallocation=full ===
79
+(default: if cache-size is not defined - 1048576 bytes or 8 clusters, whichever
85
+
80
+is larger; otherwise, as large as possible or needed within the cache-size,
86
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data preallocation=full
81
+while permitting the requested or the minimal refcount cache size)
87
+qcow2 file size: 327680
82
88
+data file size: 67108864
83
@item refcount-cache-size
89
+qcow2 disk usage: low
84
The maximum size of the refcount block cache in bytes
90
+data disk usage: high
85
-(default: 1/5 of the total cache size)
91
*** done
86
+(default: 4 times the cluster size; or if cache-size is specified, the part of
87
+it which is not used for the L2 cache)
88
89
@item cache-clean-interval
90
Clean unused entries in the L2 and refcount caches. The interval is in seconds.
91
--
92
--
92
2.13.6
93
2.20.1
93
94
94
95
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
2
3
In the previous patch we removed child references from bs->options, so
4
there's no need to look for them here anymore.
5
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
7
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9
---
2
---
10
block.c | 13 +------------
3
tests/qemu-iotests/244 | 200 +++++++++++++++++++++++++++++++++++++
11
1 file changed, 1 insertion(+), 12 deletions(-)
4
tests/qemu-iotests/244.out | 125 +++++++++++++++++++++++
5
tests/qemu-iotests/group | 1 +
6
3 files changed, 326 insertions(+)
7
create mode 100755 tests/qemu-iotests/244
8
create mode 100644 tests/qemu-iotests/244.out
12
9
13
diff --git a/block.c b/block.c
10
diff --git a/tests/qemu-iotests/244 b/tests/qemu-iotests/244
11
new file mode 100755
12
index XXXXXXX..XXXXXXX
13
--- /dev/null
14
+++ b/tests/qemu-iotests/244
15
@@ -XXX,XX +XXX,XX @@
16
+#!/bin/bash
17
+#
18
+# Test qcow2 with external data files
19
+#
20
+# Copyright (C) 2019 Red Hat, Inc.
21
+#
22
+# This program is free software; you can redistribute it and/or modify
23
+# it under the terms of the GNU General Public License as published by
24
+# the Free Software Foundation; either version 2 of the License, or
25
+# (at your option) any later version.
26
+#
27
+# This program is distributed in the hope that it will be useful,
28
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
29
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
+# GNU General Public License for more details.
31
+#
32
+# You should have received a copy of the GNU General Public License
33
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
34
+#
35
+
36
+# creator
37
+owner=kwolf@redhat.com
38
+
39
+seq=$(basename $0)
40
+echo "QA output created by $seq"
41
+
42
+status=1    # failure is the default!
43
+
44
+_cleanup()
45
+{
46
+ _cleanup_test_img
47
+ rm -f $TEST_IMG.data
48
+ rm -f $TEST_IMG.src
49
+}
50
+trap "_cleanup; exit \$status" 0 1 2 3 15
51
+
52
+# get standard environment, filters and checks
53
+. ./common.rc
54
+. ./common.filter
55
+
56
+_supported_fmt qcow2
57
+_supported_proto file
58
+_supported_os Linux
59
+
60
+echo
61
+echo "=== Create and open image with external data file ==="
62
+echo
63
+
64
+echo "With data file name in the image:"
65
+IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M
66
+_check_test_img
67
+
68
+$QEMU_IO -c "open $TEST_IMG" -c "read -P 0 0 64k" 2>&1 | _filter_qemu_io | _filter_testdir
69
+$QEMU_IO -c "open -odata-file.filename=$TEST_IMG.data $TEST_IMG" -c "read -P 0 0 64k" 2>&1 | _filter_qemu_io | _filter_testdir
70
+$QEMU_IO -c "open -odata-file.filename=inexistent $TEST_IMG" -c "read -P 0 0 64k" 2>&1 | _filter_qemu_io | _filter_testdir
71
+
72
+echo
73
+echo "Data file required, but without data file name in the image:"
74
+$QEMU_IMG amend -odata_file= $TEST_IMG
75
+
76
+$QEMU_IO -c "open $TEST_IMG" -c "read -P 0 0 64k" 2>&1 | _filter_qemu_io | _filter_testdir
77
+$QEMU_IO -c "open -odata-file.filename=$TEST_IMG.data $TEST_IMG" -c "read -P 0 0 64k" 2>&1 | _filter_qemu_io | _filter_testdir
78
+$QEMU_IO -c "open -odata-file.filename=inexistent $TEST_IMG" -c "read -P 0 0 64k" 2>&1 | _filter_qemu_io | _filter_testdir
79
+
80
+echo
81
+echo "Setting data-file for an image with internal data:"
82
+_make_test_img 64M
83
+
84
+$QEMU_IO -c "open -odata-file.filename=$TEST_IMG.data $TEST_IMG" -c "read -P 0 0 64k" 2>&1 | _filter_qemu_io | _filter_testdir
85
+$QEMU_IO -c "open -odata-file.filename=inexistent $TEST_IMG" -c "read -P 0 0 64k" 2>&1 | _filter_qemu_io | _filter_testdir
86
+
87
+echo
88
+echo "=== Conflicting features ==="
89
+echo
90
+
91
+echo "Convert to compressed target with data file:"
92
+TEST_IMG="$TEST_IMG.src" _make_test_img 64M
93
+
94
+$QEMU_IO -c 'write -P 0x11 0 1M' \
95
+ -f $IMGFMT "$TEST_IMG.src" |
96
+ _filter_qemu_io
97
+
98
+$QEMU_IMG convert -f $IMGFMT -O $IMGFMT -c -odata_file="$TEST_IMG.data" \
99
+ "$TEST_IMG.src" "$TEST_IMG"
100
+
101
+echo
102
+echo "Convert uncompressed, then write compressed data manually:"
103
+$QEMU_IMG convert -f $IMGFMT -O $IMGFMT -odata_file="$TEST_IMG.data" \
104
+ "$TEST_IMG.src" "$TEST_IMG"
105
+$QEMU_IMG compare "$TEST_IMG.src" "$TEST_IMG"
106
+
107
+$QEMU_IO -c 'write -c -P 0x22 0 1M' \
108
+ -f $IMGFMT "$TEST_IMG" |
109
+ _filter_qemu_io
110
+_check_test_img
111
+
112
+echo
113
+echo "Take an internal snapshot:"
114
+
115
+$QEMU_IMG snapshot -c test "$TEST_IMG"
116
+_check_test_img
117
+
118
+echo
119
+echo "=== Standalone image with external data file (efficient) ==="
120
+echo
121
+
122
+IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M
123
+
124
+echo -n "qcow2 file size before I/O: "
125
+du -b $TEST_IMG | cut -f1
126
+
127
+# Create image with the following layout
128
+# 0-1 MB: Unallocated
129
+# 1-2 MB: Written (pattern 0x11)
130
+# 2-3 MB: Discarded
131
+# 3-4 MB: Zero write over discarded space
132
+# 4-5 MB: Zero write over written space
133
+# 5-6 MB: Zero write over unallocated space
134
+
135
+echo
136
+$QEMU_IO -c 'write -P 0x11 1M 4M' \
137
+ -c 'discard 2M 2M' \
138
+ -c 'write -z 3M 3M' \
139
+ -f $IMGFMT "$TEST_IMG" |
140
+ _filter_qemu_io
141
+_check_test_img
142
+
143
+echo
144
+$QEMU_IMG map --output=json "$TEST_IMG"
145
+
146
+echo
147
+$QEMU_IO -c 'read -P 0 0 1M' \
148
+ -c 'read -P 0x11 1M 1M' \
149
+ -c 'read -P 0 2M 4M' \
150
+ -f $IMGFMT "$TEST_IMG" |
151
+ _filter_qemu_io
152
+
153
+# Zero clusters are only marked as such in the qcow2 metadata, but contain
154
+# stale data in the external data file
155
+echo
156
+$QEMU_IO -c 'read -P 0 0 1M' \
157
+ -c 'read -P 0x11 1M 1M' \
158
+ -c 'read -P 0 2M 2M' \
159
+ -c 'read -P 0x11 4M 1M' \
160
+ -c 'read -P 0 5M 1M' \
161
+ -f raw "$TEST_IMG.data" |
162
+ _filter_qemu_io
163
+
164
+
165
+echo -n "qcow2 file size after I/O: "
166
+du -b $TEST_IMG | cut -f1
167
+
168
+echo
169
+echo "=== Standalone image with external data file (valid raw) ==="
170
+echo
171
+
172
+IMGOPTS="data_file=$TEST_IMG.data,data_file_raw=on" _make_test_img 64M
173
+
174
+echo -n "qcow2 file size before I/O: "
175
+du -b $TEST_IMG | cut -f1
176
+
177
+echo
178
+$QEMU_IO -c 'write -P 0x11 1M 4M' \
179
+ -c 'discard 2M 2M' \
180
+ -c 'write -z 3M 3M' \
181
+ -f $IMGFMT "$TEST_IMG" |
182
+ _filter_qemu_io
183
+_check_test_img
184
+
185
+echo
186
+$QEMU_IMG map --output=json "$TEST_IMG"
187
+
188
+echo
189
+$QEMU_IO -c 'read -P 0 0 1M' \
190
+ -c 'read -P 0x11 1M 1M' \
191
+ -c 'read -P 0 2M 4M' \
192
+ -f $IMGFMT "$TEST_IMG" |
193
+ _filter_qemu_io
194
+
195
+echo
196
+$QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.data"
197
+
198
+echo -n "qcow2 file size after I/O: "
199
+du -b $TEST_IMG | cut -f1
200
+
201
+echo
202
+echo "=== bdrv_co_block_status test for file and offset=0 ==="
203
+echo
204
+
205
+IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M
206
+
207
+$QEMU_IO -c 'write -P 0x11 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
208
+$QEMU_IO -c 'read -P 0x11 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
209
+$QEMU_IMG map --output=human "$TEST_IMG" | _filter_testdir
210
+$QEMU_IMG map --output=json "$TEST_IMG"
211
+
212
+# success, all done
213
+echo "*** done"
214
+rm -f $seq.full
215
+status=0
216
diff --git a/tests/qemu-iotests/244.out b/tests/qemu-iotests/244.out
217
new file mode 100644
218
index XXXXXXX..XXXXXXX
219
--- /dev/null
220
+++ b/tests/qemu-iotests/244.out
221
@@ -XXX,XX +XXX,XX @@
222
+QA output created by 244
223
+
224
+=== Create and open image with external data file ===
225
+
226
+With data file name in the image:
227
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data
228
+No errors were found on the image.
229
+read 65536/65536 bytes at offset 0
230
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
231
+read 65536/65536 bytes at offset 0
232
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
233
+can't open device TEST_DIR/t.qcow2: Could not open 'inexistent': No such file or directory
234
+no file open, try 'help open'
235
+
236
+Data file required, but without data file name in the image:
237
+can't open device TEST_DIR/t.qcow2: 'data-file' is required for this image
238
+no file open, try 'help open'
239
+read 65536/65536 bytes at offset 0
240
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
241
+can't open device TEST_DIR/t.qcow2: Could not open 'inexistent': No such file or directory
242
+no file open, try 'help open'
243
+
244
+Setting data-file for an image with internal data:
245
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
246
+can't open device TEST_DIR/t.qcow2: 'data-file' can only be set for images with an external data file
247
+no file open, try 'help open'
248
+can't open device TEST_DIR/t.qcow2: Could not open 'inexistent': No such file or directory
249
+no file open, try 'help open'
250
+
251
+=== Conflicting features ===
252
+
253
+Convert to compressed target with data file:
254
+Formatting 'TEST_DIR/t.IMGFMT.src', fmt=IMGFMT size=67108864
255
+wrote 1048576/1048576 bytes at offset 0
256
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
257
+qemu-img: error while writing sector 0: Operation not supported
258
+
259
+Convert uncompressed, then write compressed data manually:
260
+Images are identical.
261
+write failed: Operation not supported
262
+No errors were found on the image.
263
+
264
+Take an internal snapshot:
265
+qemu-img: Could not create snapshot 'test': -95 (Operation not supported)
266
+No errors were found on the image.
267
+
268
+=== Standalone image with external data file (efficient) ===
269
+
270
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data
271
+qcow2 file size before I/O: 196616
272
+
273
+wrote 4194304/4194304 bytes at offset 1048576
274
+4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
275
+discard 2097152/2097152 bytes at offset 2097152
276
+2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
277
+wrote 3145728/3145728 bytes at offset 3145728
278
+3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
279
+No errors were found on the image.
280
+
281
+[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false},
282
+{ "start": 1048576, "length": 1048576, "depth": 0, "zero": false, "data": true, "offset": 1048576},
283
+{ "start": 2097152, "length": 2097152, "depth": 0, "zero": true, "data": false},
284
+{ "start": 4194304, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": 4194304},
285
+{ "start": 5242880, "length": 61865984, "depth": 0, "zero": true, "data": false}]
286
+
287
+read 1048576/1048576 bytes at offset 0
288
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
289
+read 1048576/1048576 bytes at offset 1048576
290
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
291
+read 4194304/4194304 bytes at offset 2097152
292
+4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
293
+
294
+read 1048576/1048576 bytes at offset 0
295
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
296
+read 1048576/1048576 bytes at offset 1048576
297
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
298
+read 2097152/2097152 bytes at offset 2097152
299
+2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
300
+read 1048576/1048576 bytes at offset 4194304
301
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
302
+read 1048576/1048576 bytes at offset 5242880
303
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
304
+qcow2 file size after I/O: 327680
305
+
306
+=== Standalone image with external data file (valid raw) ===
307
+
308
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data data_file_raw=on
309
+qcow2 file size before I/O: 196616
310
+
311
+wrote 4194304/4194304 bytes at offset 1048576
312
+4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
313
+discard 2097152/2097152 bytes at offset 2097152
314
+2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
315
+wrote 3145728/3145728 bytes at offset 3145728
316
+3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
317
+No errors were found on the image.
318
+
319
+[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false},
320
+{ "start": 1048576, "length": 1048576, "depth": 0, "zero": false, "data": true, "offset": 1048576},
321
+{ "start": 2097152, "length": 2097152, "depth": 0, "zero": true, "data": false},
322
+{ "start": 4194304, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": 4194304},
323
+{ "start": 5242880, "length": 61865984, "depth": 0, "zero": true, "data": false}]
324
+
325
+read 1048576/1048576 bytes at offset 0
326
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
327
+read 1048576/1048576 bytes at offset 1048576
328
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
329
+read 4194304/4194304 bytes at offset 2097152
330
+4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
331
+
332
+Images are identical.
333
+qcow2 file size after I/O: 327680
334
+
335
+=== bdrv_co_block_status test for file and offset=0 ===
336
+
337
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data
338
+wrote 1048576/1048576 bytes at offset 0
339
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
340
+read 1048576/1048576 bytes at offset 0
341
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
342
+Offset Length Mapped to File
343
+0 0x100000 0 TEST_DIR/t.qcow2.data
344
+[{ "start": 0, "length": 1048576, "depth": 0, "zero": false, "data": true, "offset": 0},
345
+{ "start": 1048576, "length": 66060288, "depth": 0, "zero": true, "data": false}]
346
+*** done
347
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
14
index XXXXXXX..XXXXXXX 100644
348
index XXXXXXX..XXXXXXX 100644
15
--- a/block.c
349
--- a/tests/qemu-iotests/group
16
+++ b/block.c
350
+++ b/tests/qemu-iotests/group
17
@@ -XXX,XX +XXX,XX @@ static bool append_open_options(QDict *d, BlockDriverState *bs)
351
@@ -XXX,XX +XXX,XX @@
18
{
352
240 auto quick
19
const QDictEntry *entry;
353
242 rw auto quick
20
QemuOptDesc *desc;
354
243 rw auto quick
21
- BdrvChild *child;
355
+244 rw auto quick
22
bool found_any = false;
23
24
for (entry = qdict_first(bs->options); entry;
25
entry = qdict_next(bs->options, entry))
26
{
27
- /* Exclude node-name references to children */
28
- QLIST_FOREACH(child, &bs->children, next) {
29
- if (!strcmp(entry->key, child->name)) {
30
- break;
31
- }
32
- }
33
- if (child) {
34
- continue;
35
- }
36
-
37
- /* And exclude all non-driver-specific options */
38
+ /* Exclude all non-driver-specific options */
39
for (desc = bdrv_runtime_opts.desc; desc->name; desc++) {
40
if (!strcmp(qdict_entry_key(entry), desc->name)) {
41
break;
42
--
356
--
43
2.13.6
357
2.20.1
44
358
45
359
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
2
3
Image locking errors happening at device initialization time doesn't say
4
which file cannot be locked, for instance,
5
6
-device scsi-disk,drive=drive-1: Failed to get shared "write" lock
7
Is another process using the image?
8
9
could refer to either the overlay image or its backing image.
10
11
Hoist the error_append_hint to the caller of raw_check_lock_bytes where
12
file name is known, and include it in the error hint.
13
14
Signed-off-by: Fam Zheng <famz@redhat.com>
15
Reviewed-by: Eric Blake <eblake@redhat.com>
16
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
17
---
2
---
18
block/file-posix.c | 10 +++---
3
tests/qemu-iotests/061 | 45 ++++++++++++++++++-
19
tests/qemu-iotests/153.out | 76 +++++++++++++++++++++++-----------------------
4
tests/qemu-iotests/061.out | 89 ++++++++++++++++++++++++++++++++++++++
20
tests/qemu-iotests/182.out | 2 +-
5
2 files changed, 133 insertions(+), 1 deletion(-)
21
3 files changed, 45 insertions(+), 43 deletions(-)
22
6
23
diff --git a/block/file-posix.c b/block/file-posix.c
7
diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061
8
index XXXXXXX..XXXXXXX 100755
9
--- a/tests/qemu-iotests/061
10
+++ b/tests/qemu-iotests/061
11
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
12
13
_cleanup()
14
{
15
-    _cleanup_test_img
16
+ _cleanup_test_img
17
+ rm -f $TEST_IMG.data
18
}
19
trap "_cleanup; exit \$status" 0 1 2 3 15
20
21
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG snapshot -c foo "$TEST_IMG"
22
$QEMU_IMG amend -p -o "compat=0.10" "$TEST_IMG"
23
_check_test_img
24
25
+echo
26
+echo "=== Testing version downgrade with external data file ==="
27
+echo
28
+IMGOPTS="compat=1.1,data_file=$TEST_IMG.data" _make_test_img 64M
29
+$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
30
+_img_info --format-specific
31
+_check_test_img
32
+
33
+echo
34
+echo "=== Try changing the external data file ==="
35
+echo
36
+IMGOPTS="compat=1.1" _make_test_img 64M
37
+$QEMU_IMG amend -o "data_file=foo" "$TEST_IMG"
38
+
39
+echo
40
+IMGOPTS="compat=1.1,data_file=$TEST_IMG.data" _make_test_img 64M
41
+$QEMU_IMG amend -o "data_file=foo" "$TEST_IMG"
42
+_img_info --format-specific
43
+TEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info --format-specific --image-opts
44
+
45
+echo
46
+$QEMU_IMG amend -o "data_file=" --image-opts "data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG"
47
+_img_info --format-specific
48
+TEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info --format-specific --image-opts
49
+
50
+echo
51
+echo "=== Clearing and setting data-file-raw ==="
52
+echo
53
+IMGOPTS="compat=1.1,data_file=$TEST_IMG.data,data_file_raw=on" _make_test_img 64M
54
+$QEMU_IMG amend -o "data_file_raw=on" "$TEST_IMG"
55
+_img_info --format-specific
56
+_check_test_img
57
+
58
+$QEMU_IMG amend -o "data_file_raw=off" "$TEST_IMG"
59
+_img_info --format-specific
60
+_check_test_img
61
+
62
+$QEMU_IMG amend -o "data_file_raw=on" "$TEST_IMG"
63
+_img_info --format-specific
64
+_check_test_img
65
+
66
+
67
# success, all done
68
echo "*** done"
69
rm -f $seq.full
70
diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out
24
index XXXXXXX..XXXXXXX 100644
71
index XXXXXXX..XXXXXXX 100644
25
--- a/block/file-posix.c
72
--- a/tests/qemu-iotests/061.out
26
+++ b/block/file-posix.c
73
+++ b/tests/qemu-iotests/061.out
27
@@ -XXX,XX +XXX,XX @@ static int raw_check_lock_bytes(int fd, uint64_t perm, uint64_t shared_perm,
74
@@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 3221225472
28
"Failed to get \"%s\" lock",
75
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
29
perm_name);
76
(0.00/100%)
30
g_free(perm_name);
77
(6.25/100%)
31
- error_append_hint(errp,
78
(12.50/100%)
32
- "Is another process using the image?\n");
79
(18.75/100%)
33
return ret;
80
(25.00/100%)
34
}
81
(31.25/100%)
35
}
82
(37.50/100%)
36
@@ -XXX,XX +XXX,XX @@ static int raw_check_lock_bytes(int fd, uint64_t perm, uint64_t shared_perm,
83
(43.75/100%)
37
"Failed to get shared \"%s\" lock",
84
(50.00/100%)
38
perm_name);
85
(56.25/100%)
39
g_free(perm_name);
86
(62.50/100%)
40
- error_append_hint(errp,
87
(68.75/100%)
41
- "Is another process using the image?\n");
88
(75.00/100%)
42
return ret;
89
(81.25/100%)
43
}
90
(87.50/100%)
44
}
91
(93.75/100%)
45
@@ -XXX,XX +XXX,XX @@ static int raw_handle_perm_lock(BlockDriverState *bs,
92
(100.00/100%)
46
if (!ret) {
93
(100.00/100%)
47
return 0;
94
No errors were found on the image.
48
}
95
+
49
+ error_append_hint(errp,
96
+=== Testing version downgrade with external data file ===
50
+ "Is another process using the image [%s]?\n",
97
+
51
+ bs->filename);
98
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data
52
}
99
+qemu-img: Cannot downgrade an image with a data file
53
op = RAW_PL_ABORT;
100
+image: TEST_DIR/t.IMGFMT
54
/* fall through to unlock bytes. */
101
+file format: IMGFMT
55
@@ -XXX,XX +XXX,XX @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
102
+virtual size: 64M (67108864 bytes)
56
/* Step two: Check that nobody else has taken conflicting locks */
103
+cluster_size: 65536
57
result = raw_check_lock_bytes(fd, perm, shared, errp);
104
+Format specific information:
58
if (result < 0) {
105
+ compat: 1.1
59
+ error_append_hint(errp,
106
+ lazy refcounts: false
60
+ "Is another process using the image [%s]?\n",
107
+ refcount bits: 16
61
+ file_opts->filename);
108
+ data file: TEST_DIR/t.IMGFMT.data
62
goto out_unlock;
109
+ data file raw: false
63
}
110
+ corrupt: false
64
111
+No errors were found on the image.
65
diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
112
+
66
index XXXXXXX..XXXXXXX 100644
113
+=== Try changing the external data file ===
67
--- a/tests/qemu-iotests/153.out
114
+
68
+++ b/tests/qemu-iotests/153.out
115
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
69
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 backing_file=TEST_DIR/t
116
+qemu-img: data-file can only be set for images that use an external data file
70
117
+
71
== Launching another QEMU, opts: '' ==
118
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data
72
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: Failed to get "write" lock
119
+qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Could not open 'foo': No such file or directory
73
-Is another process using the image?
120
+image: TEST_DIR/t.IMGFMT
74
+Is another process using the image [TEST_DIR/t.qcow2]?
121
+file format: IMGFMT
75
122
+virtual size: 64M (67108864 bytes)
76
== Launching another QEMU, opts: 'read-only=on' ==
123
+cluster_size: 65536
77
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,read-only=on: Failed to get shared "write" lock
124
+Format specific information:
78
-Is another process using the image?
125
+ compat: 1.1
79
+Is another process using the image [TEST_DIR/t.qcow2]?
126
+ lazy refcounts: false
80
127
+ refcount bits: 16
81
== Launching another QEMU, opts: 'read-only=on,force-share=on' ==
128
+ data file: foo
82
129
+ data file raw: false
83
@@ -XXX,XX +XXX,XX @@ Is another process using the image?
130
+ corrupt: false
84
131
+
85
_qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2
132
+qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'data-file' is required for this image
86
can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
133
+image: TEST_DIR/t.IMGFMT
87
-Is another process using the image?
134
+file format: IMGFMT
88
+Is another process using the image [TEST_DIR/t.qcow2]?
135
+virtual size: 64M (67108864 bytes)
89
136
+cluster_size: 65536
90
_qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2
137
+Format specific information:
91
can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock
138
+ compat: 1.1
92
-Is another process using the image?
139
+ lazy refcounts: false
93
+Is another process using the image [TEST_DIR/t.qcow2]?
140
+ refcount bits: 16
94
141
+ data file raw: false
95
_qemu_io_wrapper -c open TEST_DIR/t.qcow2 -c read 0 512
142
+ corrupt: false
96
can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
143
+
97
-Is another process using the image?
144
+=== Clearing and setting data-file-raw ===
98
+Is another process using the image [TEST_DIR/t.qcow2]?
145
+
99
no file open, try 'help open'
146
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 data_file=TEST_DIR/t.IMGFMT.data data_file_raw=on
100
147
+image: TEST_DIR/t.IMGFMT
101
_qemu_io_wrapper -c open -r TEST_DIR/t.qcow2 -c read 0 512
148
+file format: IMGFMT
102
can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock
149
+virtual size: 64M (67108864 bytes)
103
-Is another process using the image?
150
+cluster_size: 65536
104
+Is another process using the image [TEST_DIR/t.qcow2]?
151
+Format specific information:
105
no file open, try 'help open'
152
+ compat: 1.1
106
153
+ lazy refcounts: false
107
_qemu_img_wrapper info TEST_DIR/t.qcow2
154
+ refcount bits: 16
108
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
155
+ data file: TEST_DIR/t.IMGFMT.data
109
-Is another process using the image?
156
+ data file raw: true
110
+Is another process using the image [TEST_DIR/t.qcow2]?
157
+ corrupt: false
111
158
+No errors were found on the image.
112
_qemu_img_wrapper check TEST_DIR/t.qcow2
159
+image: TEST_DIR/t.IMGFMT
113
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
160
+file format: IMGFMT
114
-Is another process using the image?
161
+virtual size: 64M (67108864 bytes)
115
+Is another process using the image [TEST_DIR/t.qcow2]?
162
+cluster_size: 65536
116
163
+Format specific information:
117
_qemu_img_wrapper compare TEST_DIR/t.qcow2 TEST_DIR/t.qcow2
164
+ compat: 1.1
118
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
165
+ lazy refcounts: false
119
-Is another process using the image?
166
+ refcount bits: 16
120
+Is another process using the image [TEST_DIR/t.qcow2]?
167
+ data file: TEST_DIR/t.IMGFMT.data
121
168
+ data file raw: false
122
_qemu_img_wrapper map TEST_DIR/t.qcow2
169
+ corrupt: false
123
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
170
+No errors were found on the image.
124
-Is another process using the image?
171
+qemu-img: data-file-raw cannot be set on existing images
125
+Is another process using the image [TEST_DIR/t.qcow2]?
172
+image: TEST_DIR/t.IMGFMT
126
173
+file format: IMGFMT
127
_qemu_img_wrapper amend -o TEST_DIR/t.qcow2
174
+virtual size: 64M (67108864 bytes)
128
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
175
+cluster_size: 65536
129
-Is another process using the image?
176
+Format specific information:
130
+Is another process using the image [TEST_DIR/t.qcow2]?
177
+ compat: 1.1
131
178
+ lazy refcounts: false
132
_qemu_img_wrapper commit TEST_DIR/t.qcow2
179
+ refcount bits: 16
133
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
180
+ data file: TEST_DIR/t.IMGFMT.data
134
-Is another process using the image?
181
+ data file raw: false
135
+Is another process using the image [TEST_DIR/t.qcow2]?
182
+ corrupt: false
136
183
+No errors were found on the image.
137
_qemu_img_wrapper resize TEST_DIR/t.qcow2 32M
138
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
139
-Is another process using the image?
140
+Is another process using the image [TEST_DIR/t.qcow2]?
141
142
_qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
143
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
144
-Is another process using the image?
145
+Is another process using the image [TEST_DIR/t.qcow2]?
146
147
_qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2
148
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
149
-Is another process using the image?
150
+Is another process using the image [TEST_DIR/t.qcow2]?
151
152
_qemu_img_wrapper convert TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert
153
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
154
-Is another process using the image?
155
+Is another process using the image [TEST_DIR/t.qcow2]?
156
157
_qemu_img_wrapper dd if=TEST_DIR/t.qcow2 of=TEST_DIR/t.qcow2.convert bs=512 count=1
158
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
159
-Is another process using the image?
160
+Is another process using the image [TEST_DIR/t.qcow2]?
161
162
_qemu_img_wrapper bench -c 1 TEST_DIR/t.qcow2
163
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
164
-Is another process using the image?
165
+Is another process using the image [TEST_DIR/t.qcow2]?
166
167
_qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2
168
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
169
-Is another process using the image?
170
+Is another process using the image [TEST_DIR/t.qcow2]?
171
172
_qemu_img_wrapper create -f qcow2 TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
173
qemu-img: TEST_DIR/t.qcow2: Failed to get "write" lock
174
-Is another process using the image?
175
+Is another process using the image [TEST_DIR/t.qcow2]?
176
file format: IMGFMT
177
178
== Running utility commands -U ==
179
@@ -XXX,XX +XXX,XX @@ Try 'qemu-img --help' for more information
180
181
_qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
182
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
183
-Is another process using the image?
184
+Is another process using the image [TEST_DIR/t.qcow2]?
185
186
_qemu_img_wrapper snapshot -l -U TEST_DIR/t.qcow2
187
188
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 backing_file=TEST_DIR/t
189
190
== Launching another QEMU, opts: '' ==
191
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: Failed to get "write" lock
192
-Is another process using the image?
193
+Is another process using the image [TEST_DIR/t.qcow2]?
194
195
== Launching another QEMU, opts: 'read-only=on' ==
196
197
@@ -XXX,XX +XXX,XX @@ Is another process using the image?
198
199
_qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2
200
can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
201
-Is another process using the image?
202
+Is another process using the image [TEST_DIR/t.qcow2]?
203
204
_qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2
205
206
_qemu_io_wrapper -c open TEST_DIR/t.qcow2 -c read 0 512
207
can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
208
-Is another process using the image?
209
+Is another process using the image [TEST_DIR/t.qcow2]?
210
no file open, try 'help open'
211
212
_qemu_io_wrapper -c open -r TEST_DIR/t.qcow2 -c read 0 512
213
@@ -XXX,XX +XXX,XX @@ _qemu_img_wrapper map TEST_DIR/t.qcow2
214
215
_qemu_img_wrapper amend -o TEST_DIR/t.qcow2
216
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
217
-Is another process using the image?
218
+Is another process using the image [TEST_DIR/t.qcow2]?
219
220
_qemu_img_wrapper commit TEST_DIR/t.qcow2
221
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
222
-Is another process using the image?
223
+Is another process using the image [TEST_DIR/t.qcow2]?
224
225
_qemu_img_wrapper resize TEST_DIR/t.qcow2 32M
226
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
227
-Is another process using the image?
228
+Is another process using the image [TEST_DIR/t.qcow2]?
229
230
_qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
231
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
232
-Is another process using the image?
233
+Is another process using the image [TEST_DIR/t.qcow2]?
234
235
_qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2
236
237
@@ -XXX,XX +XXX,XX @@ _qemu_img_wrapper bench -c 1 TEST_DIR/t.qcow2
238
239
_qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2
240
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
241
-Is another process using the image?
242
+Is another process using the image [TEST_DIR/t.qcow2]?
243
244
_qemu_img_wrapper create -f qcow2 TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
245
qemu-img: TEST_DIR/t.qcow2: Failed to get "write" lock
246
-Is another process using the image?
247
+Is another process using the image [TEST_DIR/t.qcow2]?
248
file format: IMGFMT
249
250
== Running utility commands -U ==
251
@@ -XXX,XX +XXX,XX @@ Try 'qemu-img --help' for more information
252
253
_qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
254
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
255
-Is another process using the image?
256
+Is another process using the image [TEST_DIR/t.qcow2]?
257
258
_qemu_img_wrapper snapshot -l -U TEST_DIR/t.qcow2
259
260
@@ -XXX,XX +XXX,XX @@ Round done
261
262
== Two devices with the same image (read-only=off - read-only=off) ==
263
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=off: Failed to get "write" lock
264
-Is another process using the image?
265
+Is another process using the image [TEST_DIR/t.qcow2]?
266
267
== Two devices with the same image (read-only=off - read-only=on) ==
268
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=on: Failed to get shared "write" lock
269
-Is another process using the image?
270
+Is another process using the image [TEST_DIR/t.qcow2]?
271
272
== Two devices with the same image (read-only=off - read-only=on,force-share=on) ==
273
274
== Two devices with the same image (read-only=on - read-only=off) ==
275
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=off: Failed to get "write" lock
276
-Is another process using the image?
277
+Is another process using the image [TEST_DIR/t.qcow2]?
278
279
== Two devices with the same image (read-only=on - read-only=on) ==
280
281
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT.c', fmt=IMGFMT size=33554432 backing_file=TEST_DIR
282
283
== Backing image also as an active device ==
284
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: Failed to get "write" lock
285
-Is another process using the image?
286
+Is another process using the image [TEST_DIR/t.qcow2]?
287
288
== Backing image also as an active device (ro) ==
289
290
== Symbolic link ==
291
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: Failed to get "write" lock
292
-Is another process using the image?
293
+Is another process using the image [TEST_DIR/t.qcow2]?
294
295
== Active commit to intermediate layer should work when base in use ==
296
{"return": {}}
297
@@ -XXX,XX +XXX,XX @@ Adding drive
298
299
_qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
300
can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
301
-Is another process using the image?
302
+Is another process using the image [TEST_DIR/t.qcow2]?
303
Creating overlay with qemu-img when the guest is running should be allowed
304
305
_qemu_img_wrapper create -f qcow2 -b TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.overlay
306
@@ -XXX,XX +XXX,XX @@ _qemu_img_wrapper info TEST_DIR/t.qcow2
307
308
_qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
309
can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
310
-Is another process using the image?
311
+Is another process using the image [TEST_DIR/t.qcow2]?
312
Closing the other
313
314
_qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
315
diff --git a/tests/qemu-iotests/182.out b/tests/qemu-iotests/182.out
316
index XXXXXXX..XXXXXXX 100644
317
--- a/tests/qemu-iotests/182.out
318
+++ b/tests/qemu-iotests/182.out
319
@@ -XXX,XX +XXX,XX @@ Starting QEMU
320
321
Starting a second QEMU using the same image should fail
322
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,id=drive0,file.locking=on: Failed to get "write" lock
323
-Is another process using the image?
324
+Is another process using the image [TEST_DIR/t.qcow2]?
325
*** done
184
*** done
326
--
185
--
327
2.13.6
186
2.20.1
328
187
329
188
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
The default value of x-check-cache-dropped is false. There's no reason
3
Since the ahci-test uses qemu-img, add a dependency to build it
4
to use the previous value as a default in raw_reopen_prepare() because
4
before using it.
5
bdrv_reopen_queue_child() already takes care of putting the old
5
This fixes:
6
options in the BDRVReopenState.options QDict.
7
6
8
If x-check-cache-dropped was previously set but is now missing from
7
$ gmake check-qtest V=1
9
the reopen QDict then it should be reset to false.
8
QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 QTEST_QEMU_IMG=qemu-img tests/ahci-test
9
Failed to execute child process "/tmp/qemu-test.19tMRF/qemu-img" (No such file or directory)
10
ERROR:tests/libqos/libqos.c:192:mkimg: assertion failed: (ret && !err)
10
11
11
Signed-off-by: Alberto Garcia <berto@igalia.com>
12
Reviewed-by: John Snow <jsnow@redhat.com>
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14
---
15
---
15
block/file-posix.c | 2 +-
16
tests/Makefile.include | 2 +-
16
1 file changed, 1 insertion(+), 1 deletion(-)
17
1 file changed, 1 insertion(+), 1 deletion(-)
17
18
18
diff --git a/block/file-posix.c b/block/file-posix.c
19
diff --git a/tests/Makefile.include b/tests/Makefile.include
19
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
20
--- a/block/file-posix.c
21
--- a/tests/Makefile.include
21
+++ b/block/file-posix.c
22
+++ b/tests/Makefile.include
22
@@ -XXX,XX +XXX,XX @@ static int raw_reopen_prepare(BDRVReopenState *state,
23
@@ -XXX,XX +XXX,XX @@ tests/prom-env-test$(EXESUF): tests/prom-env-test.o $(libqos-obj-y)
23
}
24
tests/rtas-test$(EXESUF): tests/rtas-test.o $(libqos-spapr-obj-y)
24
25
tests/fdc-test$(EXESUF): tests/fdc-test.o
25
rs->check_cache_dropped = qemu_opt_get_bool(opts, "x-check-cache-dropped",
26
tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y)
26
- s->check_cache_dropped);
27
-tests/ahci-test$(EXESUF): tests/ahci-test.o $(libqos-pc-obj-y)
27
+ false);
28
+tests/ahci-test$(EXESUF): tests/ahci-test.o $(libqos-pc-obj-y) qemu-img$(EXESUF)
28
29
tests/ipmi-kcs-test$(EXESUF): tests/ipmi-kcs-test.o
29
if (s->type == FTYPE_CD) {
30
tests/ipmi-bt-test$(EXESUF): tests/ipmi-bt-test.o
30
rs->open_flags |= O_NONBLOCK;
31
tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o
31
--
32
--
32
2.13.6
33
2.20.1
33
34
34
35
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
"qemu-io reopen" doesn't allow changing the writethrough setting of
3
Since a9660664fde, some iotests use qemu-nbd.
4
the cache, but the check is wrong, causing an error even on a simple
4
Add a dependency to build it before using it.
5
reopen with the default parameters:
5
This fixes:
6
6
7
$ qemu-img create -f qcow2 hd.qcow2 1M
7
$ make check-block
8
$ qemu-system-x86_64 -monitor stdio -drive if=virtio,file=hd.qcow2
8
GEN qemu-img-cmds.h
9
(qemu) qemu-io virtio0 reopen
9
CC qemu-img.o
10
Cannot change cache.writeback: Device attached
10
LINK qemu-img
11
CC qemu-io.o
12
LINK qemu-io
13
CC tests/qemu-iotests/socket_scm_helper.o
14
LINK tests/qemu-iotests/socket_scm_helper
15
tests/qemu-iotests-quick.sh
16
check: qemu-nbd not found
17
make: *** [tests/Makefile.include:1059: check-tests/qemu-iotests-quick.sh] Error 1
11
18
12
Signed-off-by: Alberto Garcia <berto@igalia.com>
19
Reviewed-by: Eric Blake <eblake@redhat.com>
13
Reviewed-by: Max Reitz <mreitz@redhat.com>
20
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
21
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
15
---
22
---
16
qemu-io-cmds.c | 2 +-
23
tests/Makefile.include | 2 +-
17
1 file changed, 1 insertion(+), 1 deletion(-)
24
1 file changed, 1 insertion(+), 1 deletion(-)
18
25
19
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
26
diff --git a/tests/Makefile.include b/tests/Makefile.include
20
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
21
--- a/qemu-io-cmds.c
28
--- a/tests/Makefile.include
22
+++ b/qemu-io-cmds.c
29
+++ b/tests/Makefile.include
23
@@ -XXX,XX +XXX,XX @@ static int reopen_f(BlockBackend *blk, int argc, char **argv)
30
@@ -XXX,XX +XXX,XX @@ clean-tcg: $(CLEAN_TCG_TARGET_RULES)
24
return -EINVAL;
31
QEMU_IOTESTS_HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = tests/qemu-iotests/socket_scm_helper$(EXESUF)
25
}
32
26
33
.PHONY: check-tests/qemu-iotests-quick.sh
27
- if (writethrough != blk_enable_write_cache(blk) &&
34
-check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) qemu-io$(EXESUF) $(QEMU_IOTESTS_HELPERS-y)
28
+ if (!writethrough != blk_enable_write_cache(blk) &&
35
+check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) qemu-io$(EXESUF) qemu-nbd$(EXESUF) $(QEMU_IOTESTS_HELPERS-y)
29
blk_get_attached_dev(blk))
36
    $<
30
{
37
31
error_report("Cannot change cache.writeback: Device attached");
38
.PHONY: $(patsubst %, check-%, $(check-qapi-schema-y))
32
--
39
--
33
2.13.6
40
2.20.1
34
41
35
42
diff view generated by jsdifflib
1
Currently, the default values for werror and rerror have to be set
1
Be more specific about the string representation in header extensions.
2
explicitly with blk_set_on_error() by the callers of blk_new(). The only
3
caller actually doing this is blockdev_init(), which is called for
4
BlockBackends created using -drive.
5
2
6
In particular, anonymous BlockBackends created with
3
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
7
-device ...,drive=<node-name> didn't get the correct default set and
8
instead defaulted to the integer value 0 (= BLOCKDEV_ON_ERROR_REPORT).
9
This is the intended default for rerror anyway, but the default for
10
werror should be BLOCKDEV_ON_ERROR_ENOSPC.
11
12
Set the defaults in blk_new() instead so that they apply no matter what
13
way the BlockBackend was created.
14
15
Cc: qemu-stable@nongnu.org
16
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
17
Reviewed-by: Eric Blake <eblake@redhat.com>
5
Reviewed-by: Eric Blake <eblake@redhat.com>
18
Reviewed-by: Fam Zheng <famz@redhat.com>
6
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
19
---
7
---
20
block/block-backend.c | 3 +++
8
docs/interop/qcow2.txt | 14 ++++++++++++--
21
tests/qemu-iotests/067.out | 1 +
9
1 file changed, 12 insertions(+), 2 deletions(-)
22
2 files changed, 4 insertions(+)
23
10
24
diff --git a/block/block-backend.c b/block/block-backend.c
11
diff --git a/docs/interop/qcow2.txt b/docs/interop/qcow2.txt
25
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
26
--- a/block/block-backend.c
13
--- a/docs/interop/qcow2.txt
27
+++ b/block/block-backend.c
14
+++ b/docs/interop/qcow2.txt
28
@@ -XXX,XX +XXX,XX @@ BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm)
15
@@ -XXX,XX +XXX,XX @@ be stored. Each extension has a structure like the following:
29
blk->shared_perm = shared_perm;
16
30
blk_set_enable_write_cache(blk, true);
17
Byte 0 - 3: Header extension type:
31
18
0x00000000 - End of the header extension area
32
+ blk->on_read_error = BLOCKDEV_ON_ERROR_REPORT;
19
- 0xE2792ACA - Backing file format name
33
+ blk->on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
20
+ 0xE2792ACA - Backing file format name string
21
0x6803f857 - Feature name table
22
0x23852875 - Bitmaps extension
23
0x0537be77 - Full disk encryption header pointer
24
- 0x44415441 - External data file name
25
+ 0x44415441 - External data file name string
26
other - Unknown header extension, can be safely
27
ignored
28
29
@@ -XXX,XX +XXX,XX @@ data of compatible features that it doesn't support. Compatible features that
30
need space for additional data can use a header extension.
31
32
33
+== String header extensions ==
34
+
34
+
35
block_acct_init(&blk->stats);
35
+Some header extensions (such as the backing file format name and the external
36
36
+data file name) are just a single string. In this case, the header extension
37
notifier_list_init(&blk->remove_bs_notifiers);
37
+length is the string length and the string is not '\0' terminated. (The header
38
diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
38
+extension padding can make it look like a string is '\0' terminated, but
39
index XXXXXXX..XXXXXXX 100644
39
+neither is padding always necessary nor is there a guarantee that zero bytes
40
--- a/tests/qemu-iotests/067.out
40
+are used for padding.)
41
+++ b/tests/qemu-iotests/067.out
41
+
42
@@ -XXX,XX +XXX,XX @@ Testing: -device virtio-scsi -device scsi-cd,id=cd0
42
+
43
{
43
== Feature name table ==
44
"return": [
44
45
{
45
The feature name table is an optional header extension that contains the name
46
+ "io-status": "ok",
47
"device": "",
48
"locked": false,
49
"removable": true,
50
--
46
--
51
2.13.6
47
2.20.1
52
48
53
49
diff view generated by jsdifflib