1
The following changes since commit 23919ddfd56135cad3cb468a8f54d5a595f024f4:
1
The following changes since commit 848a6caa88b9f082c89c9b41afa975761262981d:
2
2
3
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190827' into staging (2019-08-27 15:52:36 +0100)
3
Merge tag 'migration-20230602-pull-request' of https://gitlab.com/juan.quintela/qemu into staging (2023-06-02 17:33:29 -0700)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://github.com/XanClic/qemu.git tags/pull-block-2019-08-27
7
https://gitlab.com/hreitz/qemu.git tags/pull-block-2023-06-05
8
8
9
for you to fetch changes up to bb043c056cffcc2f3ce88bfdaf2e76e455c09e2c:
9
for you to fetch changes up to 42a2890a76f4783cd1c212f27856edcf2b5e8a75:
10
10
11
iotests: Unify cache mode quoting (2019-08-27 19:48:44 +0200)
11
qcow2: add discard-no-unref option (2023-06-05 13:15:42 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches:
14
Block patches
15
- qemu-io now accepts a file to read a write pattern from
15
16
- Ensure that raw files have their first block allocated so we can probe
16
- Fix padding of unaligned vectored requests to match the host alignment
17
the O_DIRECT alignment if necessary
17
for vectors with 1023 or 1024 buffers
18
- Various fixes
18
- Refactor and fix bugs in parallels's image check functionality
19
- Add an option to the qcow2 driver to retain (qcow2-level) allocations
20
on discard requests from the guest (while still forwarding the discard
21
to the lower level and marking the range as zero)
19
22
20
----------------------------------------------------------------
23
----------------------------------------------------------------
21
Denis Plotnikov (1):
24
Alexander Ivanov (12):
22
qemu-io: add pattern file for write command
25
parallels: Out of image offset in BAT leads to image inflation
26
parallels: Fix high_off calculation in parallels_co_check()
27
parallels: Fix image_end_offset and data_end after out-of-image check
28
parallels: create parallels_set_bat_entry_helper() to assign BAT value
29
parallels: Use generic infrastructure for BAT writing in
30
parallels_co_check()
31
parallels: Move check of unclean image to a separate function
32
parallels: Move check of cluster outside image to a separate function
33
parallels: Fix statistics calculation
34
parallels: Move check of leaks to a separate function
35
parallels: Move statistic collection to a separate function
36
parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD
37
parallels: Incorrect condition in out-of-image check
23
38
24
Max Reitz (7):
39
Hanna Czenczek (4):
25
iotests: Fix _filter_img_create()
40
util/iov: Make qiov_slice() public
26
vmdk: Use bdrv_dirname() for relative extent paths
41
block: Collapse padded I/O vecs exceeding IOV_MAX
27
iotests: Keep testing broken relative extent paths
42
util/iov: Remove qemu_iovec_init_extended()
28
vmdk: Reject invalid compressed writes
43
iotests/iov-padding: New test
29
iotests: Disable broken streamOptimized tests
30
iotests: Disable 110 for vmdk.twoGbMaxExtentSparse
31
iotests: Disable 126 for flat vmdk subformats
32
44
33
Nir Soffer (3):
45
Jean-Louis Dupond (1):
34
block: posix: Always allocate the first block
46
qcow2: add discard-no-unref option
35
iotests: Test allocate_first_block() with O_DIRECT
36
iotests: Unify cache mode quoting
37
47
38
Stefan Hajnoczi (1):
48
qapi/block-core.json | 12 ++
39
file-posix: fix request_alignment typo
49
block/qcow2.h | 3 +
40
50
include/qemu/iov.h | 8 +-
41
Thomas Huth (2):
51
block/io.c | 166 ++++++++++++++++++--
42
iotests: Check for enabled drivers before testing them
52
block/parallels.c | 190 ++++++++++++++++-------
43
tests/check-block: Skip iotests when sanitizers are enabled
53
block/qcow2-cluster.c | 32 +++-
44
54
block/qcow2.c | 18 +++
45
Vladimir Sementsov-Ogievskiy (1):
55
util/iov.c | 89 ++---------
46
block: fix permission update in bdrv_replace_node
56
qemu-options.hx | 12 ++
47
57
tests/qemu-iotests/tests/iov-padding | 85 ++++++++++
48
block.c | 5 +-
58
tests/qemu-iotests/tests/iov-padding.out | 59 +++++++
49
block/file-posix.c | 53 +++++++++-
59
11 files changed, 523 insertions(+), 151 deletions(-)
50
block/vmdk.c | 64 ++++++++----
60
create mode 100755 tests/qemu-iotests/tests/iov-padding
51
qemu-io-cmds.c | 99 +++++++++++++++++--
61
create mode 100644 tests/qemu-iotests/tests/iov-padding.out
52
tests/check-block.sh | 5 +
53
tests/qemu-iotests/002 | 1 +
54
tests/qemu-iotests/003 | 1 +
55
tests/qemu-iotests/005 | 3 +-
56
tests/qemu-iotests/009 | 1 +
57
tests/qemu-iotests/010 | 1 +
58
tests/qemu-iotests/011 | 1 +
59
tests/qemu-iotests/017 | 3 +-
60
tests/qemu-iotests/018 | 3 +-
61
tests/qemu-iotests/019 | 3 +-
62
tests/qemu-iotests/020 | 3 +-
63
tests/qemu-iotests/026 | 4 +-
64
tests/qemu-iotests/027 | 1 +
65
tests/qemu-iotests/032 | 1 +
66
tests/qemu-iotests/033 | 1 +
67
tests/qemu-iotests/034 | 3 +-
68
tests/qemu-iotests/037 | 3 +-
69
tests/qemu-iotests/039 | 4 +-
70
tests/qemu-iotests/052 | 2 +-
71
tests/qemu-iotests/059 | 34 ++++++-
72
tests/qemu-iotests/059.out | 26 +++--
73
tests/qemu-iotests/063 | 3 +-
74
tests/qemu-iotests/071 | 1 +
75
tests/qemu-iotests/072 | 1 +
76
tests/qemu-iotests/081 | 4 +-
77
tests/qemu-iotests/091 | 4 +-
78
tests/qemu-iotests/099 | 1 +
79
tests/qemu-iotests/105 | 3 +-
80
tests/qemu-iotests/110 | 3 +-
81
tests/qemu-iotests/120 | 1 +
82
tests/qemu-iotests/126 | 2 +
83
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
84
tests/qemu-iotests/150.out.raw | 12 +++
85
tests/qemu-iotests/162 | 4 +-
86
tests/qemu-iotests/175 | 47 +++++++--
87
tests/qemu-iotests/175.out | 16 ++-
88
tests/qemu-iotests/178.out.qcow2 | 4 +-
89
tests/qemu-iotests/184 | 1 +
90
tests/qemu-iotests/186 | 1 +
91
tests/qemu-iotests/197 | 1 +
92
tests/qemu-iotests/215 | 1 +
93
tests/qemu-iotests/221.out | 12 ++-
94
tests/qemu-iotests/251 | 1 +
95
tests/qemu-iotests/253.out | 12 ++-
96
tests/qemu-iotests/common.filter | 4 +-
97
tests/qemu-iotests/common.rc | 14 +++
98
50 files changed, 391 insertions(+), 87 deletions(-)
99
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
100
create mode 100644 tests/qemu-iotests/150.out.raw
101
62
102
--
63
--
103
2.21.0
64
2.40.1
104
105
diff view generated by jsdifflib
New patch
1
We want to inline qemu_iovec_init_extended() in block/io.c for padding
2
requests, and having access to qiov_slice() is useful for this. As a
3
public function, it is renamed to qemu_iovec_slice().
1
4
5
(We will need to count the number of I/O vector elements of a slice
6
there, and then later process this slice. Without qiov_slice(), we
7
would need to call qemu_iovec_subvec_niov(), and all further
8
IOV-processing functions may need to skip prefixing elements to
9
accomodate for a qiov_offset. Because qemu_iovec_subvec_niov()
10
internally calls qiov_slice(), we can just have the block/io.c code call
11
qiov_slice() itself, thus get the number of elements, and also create an
12
iovec array with the superfluous prefixing elements stripped, so the
13
following processing functions no longer need to skip them.)
14
15
Reviewed-by: Eric Blake <eblake@redhat.com>
16
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
17
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
18
Message-Id: <20230411173418.19549-2-hreitz@redhat.com>
19
---
20
include/qemu/iov.h | 3 +++
21
util/iov.c | 14 +++++++-------
22
2 files changed, 10 insertions(+), 7 deletions(-)
23
24
diff --git a/include/qemu/iov.h b/include/qemu/iov.h
25
index XXXXXXX..XXXXXXX 100644
26
--- a/include/qemu/iov.h
27
+++ b/include/qemu/iov.h
28
@@ -XXX,XX +XXX,XX @@ int qemu_iovec_init_extended(
29
void *tail_buf, size_t tail_len);
30
void qemu_iovec_init_slice(QEMUIOVector *qiov, QEMUIOVector *source,
31
size_t offset, size_t len);
32
+struct iovec *qemu_iovec_slice(QEMUIOVector *qiov,
33
+ size_t offset, size_t len,
34
+ size_t *head, size_t *tail, int *niov);
35
int qemu_iovec_subvec_niov(QEMUIOVector *qiov, size_t offset, size_t len);
36
void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len);
37
void qemu_iovec_concat(QEMUIOVector *dst,
38
diff --git a/util/iov.c b/util/iov.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/util/iov.c
41
+++ b/util/iov.c
42
@@ -XXX,XX +XXX,XX @@ static struct iovec *iov_skip_offset(struct iovec *iov, size_t offset,
43
}
44
45
/*
46
- * qiov_slice
47
+ * qemu_iovec_slice
48
*
49
* Find subarray of iovec's, containing requested range. @head would
50
* be offset in first iov (returned by the function), @tail would be
51
* count of extra bytes in last iovec (returned iov + @niov - 1).
52
*/
53
-static struct iovec *qiov_slice(QEMUIOVector *qiov,
54
- size_t offset, size_t len,
55
- size_t *head, size_t *tail, int *niov)
56
+struct iovec *qemu_iovec_slice(QEMUIOVector *qiov,
57
+ size_t offset, size_t len,
58
+ size_t *head, size_t *tail, int *niov)
59
{
60
struct iovec *iov, *end_iov;
61
62
@@ -XXX,XX +XXX,XX @@ int qemu_iovec_subvec_niov(QEMUIOVector *qiov, size_t offset, size_t len)
63
size_t head, tail;
64
int niov;
65
66
- qiov_slice(qiov, offset, len, &head, &tail, &niov);
67
+ qemu_iovec_slice(qiov, offset, len, &head, &tail, &niov);
68
69
return niov;
70
}
71
@@ -XXX,XX +XXX,XX @@ int qemu_iovec_init_extended(
72
}
73
74
if (mid_len) {
75
- mid_iov = qiov_slice(mid_qiov, mid_offset, mid_len,
76
- &mid_head, &mid_tail, &mid_niov);
77
+ mid_iov = qemu_iovec_slice(mid_qiov, mid_offset, mid_len,
78
+ &mid_head, &mid_tail, &mid_niov);
79
}
80
81
total_niov = !!head_len + mid_niov + !!tail_len;
82
--
83
2.40.1
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
When processing vectored guest requests that are not aligned to the
2
2
storage request alignment, we pad them by adding head and/or tail
3
Using block_resize we can test allocate_first_block() with file
3
buffers for a read-modify-write cycle.
4
descriptor opened with O_DIRECT, ensuring that it works for any size
4
5
larger than 4096 bytes.
5
The guest can submit I/O vectors up to IOV_MAX (1024) in length, but
6
6
with this padding, the vector can exceed that limit. As of
7
Testing smaller sizes is tricky as the result depends on the filesystem
7
4c002cef0e9abe7135d7916c51abce47f7fc1ee2 ("util/iov: make
8
used for testing. For example on NFS any size will work since O_DIRECT
8
qemu_iovec_init_extended() honest"), we refuse to pad vectors beyond the
9
does not require any alignment.
9
limit, instead returning an error to the guest.
10
10
11
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
11
To the guest, this appears as a random I/O error. We should not return
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
12
an I/O error to the guest when it issued a perfectly valid request.
13
Message-id: 20190827010528.8818-3-nsoffer@redhat.com
13
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
14
Before 4c002cef0e9abe7135d7916c51abce47f7fc1ee2, we just made the vector
15
longer than IOV_MAX, which generally seems to work (because the guest
16
assumes a smaller alignment than we really have, file-posix's
17
raw_co_prw() will generally see bdrv_qiov_is_aligned() return false, and
18
so emulate the request, so that the IOV_MAX does not matter). However,
19
that does not seem exactly great.
20
21
I see two ways to fix this problem:
22
1. We split such long requests into two requests.
23
2. We join some elements of the vector into new buffers to make it
24
shorter.
25
26
I am wary of (1), because it seems like it may have unintended side
27
effects.
28
29
(2) on the other hand seems relatively simple to implement, with
30
hopefully few side effects, so this patch does that.
31
32
To do this, the use of qemu_iovec_init_extended() in bdrv_pad_request()
33
is effectively replaced by the new function bdrv_create_padded_qiov(),
34
which not only wraps the request IOV with padding head/tail, but also
35
ensures that the resulting vector will not have more than IOV_MAX
36
elements. Putting that functionality into qemu_iovec_init_extended() is
37
infeasible because it requires allocating a bounce buffer; doing so
38
would require many more parameters (buffer alignment, how to initialize
39
the buffer, and out parameters like the buffer, its length, and the
40
original elements), which is not reasonable.
41
42
Conversely, it is not difficult to move qemu_iovec_init_extended()'s
43
functionality into bdrv_create_padded_qiov() by using public
44
qemu_iovec_* functions, so that is what this patch does.
45
46
Because bdrv_pad_request() was the only "serious" user of
47
qemu_iovec_init_extended(), the next patch will remove the latter
48
function, so the functionality is not implemented twice.
49
50
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2141964
51
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
52
Message-Id: <20230411173418.19549-3-hreitz@redhat.com>
53
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
15
---
54
---
16
tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++
55
block/io.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++++-----
17
tests/qemu-iotests/175.out | 8 ++++++++
56
1 file changed, 151 insertions(+), 15 deletions(-)
18
2 files changed, 36 insertions(+)
57
19
58
diff --git a/block/io.c b/block/io.c
20
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
59
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100755
60
--- a/block/io.c
22
--- a/tests/qemu-iotests/175
61
+++ b/block/io.c
23
+++ b/tests/qemu-iotests/175
62
@@ -XXX,XX +XXX,XX @@ out:
24
@@ -XXX,XX +XXX,XX @@ _filter_blocks()
63
* @merge_reads is true for small requests,
25
-e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
64
* if @buf_len == @head + bytes + @tail. In this case it is possible that both
65
* head and tail exist but @buf_len == align and @tail_buf == @buf.
66
+ *
67
+ * @write is true for write requests, false for read requests.
68
+ *
69
+ * If padding makes the vector too long (exceeding IOV_MAX), then we need to
70
+ * merge existing vector elements into a single one. @collapse_bounce_buf acts
71
+ * as the bounce buffer in such cases. @pre_collapse_qiov has the pre-collapse
72
+ * I/O vector elements so for read requests, the data can be copied back after
73
+ * the read is done.
74
*/
75
typedef struct BdrvRequestPadding {
76
uint8_t *buf;
77
@@ -XXX,XX +XXX,XX @@ typedef struct BdrvRequestPadding {
78
size_t head;
79
size_t tail;
80
bool merge_reads;
81
+ bool write;
82
QEMUIOVector local_qiov;
83
+
84
+ uint8_t *collapse_bounce_buf;
85
+ size_t collapse_len;
86
+ QEMUIOVector pre_collapse_qiov;
87
} BdrvRequestPadding;
88
89
static bool bdrv_init_padding(BlockDriverState *bs,
90
int64_t offset, int64_t bytes,
91
+ bool write,
92
BdrvRequestPadding *pad)
93
{
94
int64_t align = bs->bl.request_alignment;
95
@@ -XXX,XX +XXX,XX @@ static bool bdrv_init_padding(BlockDriverState *bs,
96
pad->tail_buf = pad->buf + pad->buf_len - align;
97
}
98
99
+ pad->write = write;
100
+
101
return true;
26
}
102
}
27
103
28
+# Resize image using block_resize.
104
@@ -XXX,XX +XXX,XX @@ zero_mem:
29
+# Parameter 1: image path
105
return 0;
30
+# Parameter 2: new size
106
}
31
+_block_resize()
107
108
-static void bdrv_padding_destroy(BdrvRequestPadding *pad)
109
+/**
110
+ * Free *pad's associated buffers, and perform any necessary finalization steps.
111
+ */
112
+static void bdrv_padding_finalize(BdrvRequestPadding *pad)
113
{
114
+ if (pad->collapse_bounce_buf) {
115
+ if (!pad->write) {
116
+ /*
117
+ * If padding required elements in the vector to be collapsed into a
118
+ * bounce buffer, copy the bounce buffer content back
119
+ */
120
+ qemu_iovec_from_buf(&pad->pre_collapse_qiov, 0,
121
+ pad->collapse_bounce_buf, pad->collapse_len);
122
+ }
123
+ qemu_vfree(pad->collapse_bounce_buf);
124
+ qemu_iovec_destroy(&pad->pre_collapse_qiov);
125
+ }
126
if (pad->buf) {
127
qemu_vfree(pad->buf);
128
qemu_iovec_destroy(&pad->local_qiov);
129
@@ -XXX,XX +XXX,XX @@ static void bdrv_padding_destroy(BdrvRequestPadding *pad)
130
memset(pad, 0, sizeof(*pad));
131
}
132
133
+/*
134
+ * Create pad->local_qiov by wrapping @iov in the padding head and tail, while
135
+ * ensuring that the resulting vector will not exceed IOV_MAX elements.
136
+ *
137
+ * To ensure this, when necessary, the first two or three elements of @iov are
138
+ * merged into pad->collapse_bounce_buf and replaced by a reference to that
139
+ * bounce buffer in pad->local_qiov.
140
+ *
141
+ * After performing a read request, the data from the bounce buffer must be
142
+ * copied back into pad->pre_collapse_qiov (e.g. by bdrv_padding_finalize()).
143
+ */
144
+static int bdrv_create_padded_qiov(BlockDriverState *bs,
145
+ BdrvRequestPadding *pad,
146
+ struct iovec *iov, int niov,
147
+ size_t iov_offset, size_t bytes)
32
+{
148
+{
33
+ local path=$1
149
+ int padded_niov, surplus_count, collapse_count;
34
+ local size=$2
150
+
35
+
151
+ /* Assert this invariant */
36
+ $QEMU -qmp stdio -nographic -nodefaults \
152
+ assert(niov <= IOV_MAX);
37
+ -blockdev file,node-name=file,filename=$path,cache.direct=on \
153
+
38
+ <<EOF
154
+ /*
39
+{'execute': 'qmp_capabilities'}
155
+ * Cannot pad if resulting length would exceed SIZE_MAX. Returning an error
40
+{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}}
156
+ * to the guest is not ideal, but there is little else we can do. At least
41
+{'execute': 'quit'}
157
+ * this will practically never happen on 64-bit systems.
42
+EOF
158
+ */
159
+ if (SIZE_MAX - pad->head < bytes ||
160
+ SIZE_MAX - pad->head - bytes < pad->tail)
161
+ {
162
+ return -EINVAL;
163
+ }
164
+
165
+ /* Length of the resulting IOV if we just concatenated everything */
166
+ padded_niov = !!pad->head + niov + !!pad->tail;
167
+
168
+ qemu_iovec_init(&pad->local_qiov, MIN(padded_niov, IOV_MAX));
169
+
170
+ if (pad->head) {
171
+ qemu_iovec_add(&pad->local_qiov, pad->buf, pad->head);
172
+ }
173
+
174
+ /*
175
+ * If padded_niov > IOV_MAX, we cannot just concatenate everything.
176
+ * Instead, merge the first two or three elements of @iov to reduce the
177
+ * number of vector elements as necessary.
178
+ */
179
+ if (padded_niov > IOV_MAX) {
180
+ /*
181
+ * Only head and tail can have lead to the number of entries exceeding
182
+ * IOV_MAX, so we can exceed it by the head and tail at most. We need
183
+ * to reduce the number of elements by `surplus_count`, so we merge that
184
+ * many elements plus one into one element.
185
+ */
186
+ surplus_count = padded_niov - IOV_MAX;
187
+ assert(surplus_count <= !!pad->head + !!pad->tail);
188
+ collapse_count = surplus_count + 1;
189
+
190
+ /*
191
+ * Move the elements to collapse into `pad->pre_collapse_qiov`, then
192
+ * advance `iov` (and associated variables) by those elements.
193
+ */
194
+ qemu_iovec_init(&pad->pre_collapse_qiov, collapse_count);
195
+ qemu_iovec_concat_iov(&pad->pre_collapse_qiov, iov,
196
+ collapse_count, iov_offset, SIZE_MAX);
197
+ iov += collapse_count;
198
+ iov_offset = 0;
199
+ niov -= collapse_count;
200
+ bytes -= pad->pre_collapse_qiov.size;
201
+
202
+ /*
203
+ * Construct the bounce buffer to match the length of the to-collapse
204
+ * vector elements, and for write requests, initialize it with the data
205
+ * from those elements. Then add it to `pad->local_qiov`.
206
+ */
207
+ pad->collapse_len = pad->pre_collapse_qiov.size;
208
+ pad->collapse_bounce_buf = qemu_blockalign(bs, pad->collapse_len);
209
+ if (pad->write) {
210
+ qemu_iovec_to_buf(&pad->pre_collapse_qiov, 0,
211
+ pad->collapse_bounce_buf, pad->collapse_len);
212
+ }
213
+ qemu_iovec_add(&pad->local_qiov,
214
+ pad->collapse_bounce_buf, pad->collapse_len);
215
+ }
216
+
217
+ qemu_iovec_concat_iov(&pad->local_qiov, iov, niov, iov_offset, bytes);
218
+
219
+ if (pad->tail) {
220
+ qemu_iovec_add(&pad->local_qiov,
221
+ pad->buf + pad->buf_len - pad->tail, pad->tail);
222
+ }
223
+
224
+ assert(pad->local_qiov.niov == MIN(padded_niov, IOV_MAX));
225
+ return 0;
43
+}
226
+}
44
+
227
+
45
# get standard environment, filters and checks
228
/*
46
. ./common.rc
229
* bdrv_pad_request
47
. ./common.filter
230
*
48
@@ -XXX,XX +XXX,XX @@ _supported_fmt raw
231
@@ -XXX,XX +XXX,XX @@ static void bdrv_padding_destroy(BdrvRequestPadding *pad)
49
_supported_proto file
232
* read of padding, bdrv_padding_rmw_read() should be called separately if
50
_supported_os Linux
233
* needed.
51
234
*
52
+_default_cache_mode none
235
+ * @write is true for write requests, false for read requests.
53
+_supported_cache_modes none directsync
236
+ *
54
+
237
* Request parameters (@qiov, &qiov_offset, &offset, &bytes) are in-out:
55
size=$((1 * 1024 * 1024))
238
* - on function start they represent original request
56
239
* - on failure or when padding is not needed they are unchanged
57
touch "$TEST_DIR/empty"
240
@@ -XXX,XX +XXX,XX @@ static void bdrv_padding_destroy(BdrvRequestPadding *pad)
58
@@ -XXX,XX +XXX,XX @@ for mode in off full falloc; do
241
static int bdrv_pad_request(BlockDriverState *bs,
59
stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
242
QEMUIOVector **qiov, size_t *qiov_offset,
60
done
243
int64_t *offset, int64_t *bytes,
61
244
+ bool write,
62
+for new_size in 4096 1048576; do
245
BdrvRequestPadding *pad, bool *padded,
63
+ echo
246
BdrvRequestFlags *flags)
64
+ echo "== resize empty image with block_resize =="
247
{
65
+ _make_test_img 0 | _filter_imgfmt
248
int ret;
66
+ _block_resize $TEST_IMG $new_size >/dev/null
249
+ struct iovec *sliced_iov;
67
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $new_size
250
+ int sliced_niov;
68
+done
251
+ size_t sliced_head, sliced_tail;
69
+
252
70
# success, all done
253
bdrv_check_qiov_request(*offset, *bytes, *qiov, *qiov_offset, &error_abort);
71
echo "*** done"
254
72
rm -f $seq.full
255
- if (!bdrv_init_padding(bs, *offset, *bytes, pad)) {
73
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
256
+ if (!bdrv_init_padding(bs, *offset, *bytes, write, pad)) {
74
index XXXXXXX..XXXXXXX 100644
257
if (padded) {
75
--- a/tests/qemu-iotests/175.out
258
*padded = false;
76
+++ b/tests/qemu-iotests/175.out
259
}
77
@@ -XXX,XX +XXX,XX @@ size=1048576, max allocation
260
return 0;
78
== creating image with preallocation falloc ==
261
}
79
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
262
80
size=1048576, max allocation
263
- ret = qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head,
81
+
264
- *qiov, *qiov_offset, *bytes,
82
+== resize empty image with block_resize ==
265
- pad->buf + pad->buf_len - pad->tail,
83
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
266
- pad->tail);
84
+size=4096, min allocation
267
+ sliced_iov = qemu_iovec_slice(*qiov, *qiov_offset, *bytes,
85
+
268
+ &sliced_head, &sliced_tail,
86
+== resize empty image with block_resize ==
269
+ &sliced_niov);
87
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
270
+
88
+size=1048576, min allocation
271
+ /* Guaranteed by bdrv_check_qiov_request() */
89
*** done
272
+ assert(*bytes <= SIZE_MAX);
273
+ ret = bdrv_create_padded_qiov(bs, pad, sliced_iov, sliced_niov,
274
+ sliced_head, *bytes);
275
if (ret < 0) {
276
- bdrv_padding_destroy(pad);
277
+ bdrv_padding_finalize(pad);
278
return ret;
279
}
280
*bytes += pad->head + pad->tail;
281
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child,
282
flags |= BDRV_REQ_COPY_ON_READ;
283
}
284
285
- ret = bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, &pad,
286
- NULL, &flags);
287
+ ret = bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, false,
288
+ &pad, NULL, &flags);
289
if (ret < 0) {
290
goto fail;
291
}
292
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child,
293
bs->bl.request_alignment,
294
qiov, qiov_offset, flags);
295
tracked_request_end(&req);
296
- bdrv_padding_destroy(&pad);
297
+ bdrv_padding_finalize(&pad);
298
299
fail:
300
bdrv_dec_in_flight(bs);
301
@@ -XXX,XX +XXX,XX @@ bdrv_co_do_zero_pwritev(BdrvChild *child, int64_t offset, int64_t bytes,
302
/* This flag doesn't make sense for padding or zero writes */
303
flags &= ~BDRV_REQ_REGISTERED_BUF;
304
305
- padding = bdrv_init_padding(bs, offset, bytes, &pad);
306
+ padding = bdrv_init_padding(bs, offset, bytes, true, &pad);
307
if (padding) {
308
assert(!(flags & BDRV_REQ_NO_WAIT));
309
bdrv_make_request_serialising(req, align);
310
@@ -XXX,XX +XXX,XX @@ bdrv_co_do_zero_pwritev(BdrvChild *child, int64_t offset, int64_t bytes,
311
}
312
313
out:
314
- bdrv_padding_destroy(&pad);
315
+ bdrv_padding_finalize(&pad);
316
317
return ret;
318
}
319
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child,
320
* bdrv_co_do_zero_pwritev() does aligning by itself, so, we do
321
* alignment only if there is no ZERO flag.
322
*/
323
- ret = bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, &pad,
324
- &padded, &flags);
325
+ ret = bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, true,
326
+ &pad, &padded, &flags);
327
if (ret < 0) {
328
return ret;
329
}
330
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child,
331
ret = bdrv_aligned_pwritev(child, &req, offset, bytes, align,
332
qiov, qiov_offset, flags);
333
334
- bdrv_padding_destroy(&pad);
335
+ bdrv_padding_finalize(&pad);
336
337
out:
338
tracked_request_end(&req);
90
--
339
--
91
2.21.0
340
2.40.1
92
93
diff view generated by jsdifflib
New patch
1
bdrv_pad_request() was the main user of qemu_iovec_init_extended().
2
HEAD^ has removed that use, so we can remove qemu_iovec_init_extended()
3
now.
1
4
5
The only remaining user is qemu_iovec_init_slice(), which can easily
6
inline the small part it really needs.
7
8
Note that qemu_iovec_init_extended() offered a memcpy() optimization to
9
initialize the new I/O vector. qemu_iovec_concat_iov(), which is used
10
to replace its functionality, does not, but calls qemu_iovec_add() for
11
every single element. If we decide this optimization was important, we
12
will need to re-implement it in qemu_iovec_concat_iov(), which might
13
also benefit its pre-existing users.
14
15
Reviewed-by: Eric Blake <eblake@redhat.com>
16
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
17
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
18
Message-Id: <20230411173418.19549-4-hreitz@redhat.com>
19
---
20
include/qemu/iov.h | 5 ---
21
util/iov.c | 79 +++++++---------------------------------------
22
2 files changed, 11 insertions(+), 73 deletions(-)
23
24
diff --git a/include/qemu/iov.h b/include/qemu/iov.h
25
index XXXXXXX..XXXXXXX 100644
26
--- a/include/qemu/iov.h
27
+++ b/include/qemu/iov.h
28
@@ -XXX,XX +XXX,XX @@ static inline void *qemu_iovec_buf(QEMUIOVector *qiov)
29
30
void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint);
31
void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int niov);
32
-int qemu_iovec_init_extended(
33
- QEMUIOVector *qiov,
34
- void *head_buf, size_t head_len,
35
- QEMUIOVector *mid_qiov, size_t mid_offset, size_t mid_len,
36
- void *tail_buf, size_t tail_len);
37
void qemu_iovec_init_slice(QEMUIOVector *qiov, QEMUIOVector *source,
38
size_t offset, size_t len);
39
struct iovec *qemu_iovec_slice(QEMUIOVector *qiov,
40
diff --git a/util/iov.c b/util/iov.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/util/iov.c
43
+++ b/util/iov.c
44
@@ -XXX,XX +XXX,XX @@ int qemu_iovec_subvec_niov(QEMUIOVector *qiov, size_t offset, size_t len)
45
return niov;
46
}
47
48
-/*
49
- * Compile new iovec, combining @head_buf buffer, sub-qiov of @mid_qiov,
50
- * and @tail_buf buffer into new qiov.
51
- */
52
-int qemu_iovec_init_extended(
53
- QEMUIOVector *qiov,
54
- void *head_buf, size_t head_len,
55
- QEMUIOVector *mid_qiov, size_t mid_offset, size_t mid_len,
56
- void *tail_buf, size_t tail_len)
57
-{
58
- size_t mid_head, mid_tail;
59
- int total_niov, mid_niov = 0;
60
- struct iovec *p, *mid_iov = NULL;
61
-
62
- assert(mid_qiov->niov <= IOV_MAX);
63
-
64
- if (SIZE_MAX - head_len < mid_len ||
65
- SIZE_MAX - head_len - mid_len < tail_len)
66
- {
67
- return -EINVAL;
68
- }
69
-
70
- if (mid_len) {
71
- mid_iov = qemu_iovec_slice(mid_qiov, mid_offset, mid_len,
72
- &mid_head, &mid_tail, &mid_niov);
73
- }
74
-
75
- total_niov = !!head_len + mid_niov + !!tail_len;
76
- if (total_niov > IOV_MAX) {
77
- return -EINVAL;
78
- }
79
-
80
- if (total_niov == 1) {
81
- qemu_iovec_init_buf(qiov, NULL, 0);
82
- p = &qiov->local_iov;
83
- } else {
84
- qiov->niov = qiov->nalloc = total_niov;
85
- qiov->size = head_len + mid_len + tail_len;
86
- p = qiov->iov = g_new(struct iovec, qiov->niov);
87
- }
88
-
89
- if (head_len) {
90
- p->iov_base = head_buf;
91
- p->iov_len = head_len;
92
- p++;
93
- }
94
-
95
- assert(!mid_niov == !mid_len);
96
- if (mid_niov) {
97
- memcpy(p, mid_iov, mid_niov * sizeof(*p));
98
- p[0].iov_base = (uint8_t *)p[0].iov_base + mid_head;
99
- p[0].iov_len -= mid_head;
100
- p[mid_niov - 1].iov_len -= mid_tail;
101
- p += mid_niov;
102
- }
103
-
104
- if (tail_len) {
105
- p->iov_base = tail_buf;
106
- p->iov_len = tail_len;
107
- }
108
-
109
- return 0;
110
-}
111
-
112
/*
113
* Check if the contents of subrange of qiov data is all zeroes.
114
*/
115
@@ -XXX,XX +XXX,XX @@ bool qemu_iovec_is_zero(QEMUIOVector *qiov, size_t offset, size_t bytes)
116
void qemu_iovec_init_slice(QEMUIOVector *qiov, QEMUIOVector *source,
117
size_t offset, size_t len)
118
{
119
- int ret;
120
+ struct iovec *slice_iov;
121
+ int slice_niov;
122
+ size_t slice_head, slice_tail;
123
124
assert(source->size >= len);
125
assert(source->size - len >= offset);
126
127
- /* We shrink the request, so we can't overflow neither size_t nor MAX_IOV */
128
- ret = qemu_iovec_init_extended(qiov, NULL, 0, source, offset, len, NULL, 0);
129
- assert(ret == 0);
130
+ slice_iov = qemu_iovec_slice(source, offset, len,
131
+ &slice_head, &slice_tail, &slice_niov);
132
+ if (slice_niov == 1) {
133
+ qemu_iovec_init_buf(qiov, slice_iov[0].iov_base + slice_head, len);
134
+ } else {
135
+ qemu_iovec_init(qiov, slice_niov);
136
+ qemu_iovec_concat_iov(qiov, slice_iov, slice_niov, slice_head, len);
137
+ }
138
}
139
140
void qemu_iovec_destroy(QEMUIOVector *qiov)
141
--
142
2.40.1
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
Test that even vectored IO requests with 1024 vector elements that are
2
not aligned to the device's request alignment will succeed.
2
3
3
The sanitizers (especially the address sanitizer from Clang) are
4
Reviewed-by: Eric Blake <eblake@redhat.com>
4
sometimes printing out warnings or false positives - this spoils
5
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
5
the output of the iotests, causing some of the tests to fail.
6
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
6
Thus let's skip the automatic iotests during "make check" when the
7
Message-Id: <20230411173418.19549-5-hreitz@redhat.com>
7
user configured QEMU with --enable-sanitizers.
8
---
9
tests/qemu-iotests/tests/iov-padding | 85 ++++++++++++++++++++++++
10
tests/qemu-iotests/tests/iov-padding.out | 59 ++++++++++++++++
11
2 files changed, 144 insertions(+)
12
create mode 100755 tests/qemu-iotests/tests/iov-padding
13
create mode 100644 tests/qemu-iotests/tests/iov-padding.out
8
14
9
Signed-off-by: Thomas Huth <thuth@redhat.com>
15
diff --git a/tests/qemu-iotests/tests/iov-padding b/tests/qemu-iotests/tests/iov-padding
10
Message-id: 20190823084203.29734-1-thuth@redhat.com
16
new file mode 100755
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
17
index XXXXXXX..XXXXXXX
12
---
18
--- /dev/null
13
tests/check-block.sh | 5 +++++
19
+++ b/tests/qemu-iotests/tests/iov-padding
14
1 file changed, 5 insertions(+)
20
@@ -XXX,XX +XXX,XX @@
15
21
+#!/usr/bin/env bash
16
diff --git a/tests/check-block.sh b/tests/check-block.sh
22
+# group: rw quick
17
index XXXXXXX..XXXXXXX 100755
23
+#
18
--- a/tests/check-block.sh
24
+# Check the interaction of request padding (to fit alignment restrictions) with
19
+++ b/tests/check-block.sh
25
+# vectored I/O from the guest
20
@@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then
26
+#
21
exit 0
27
+# Copyright Red Hat
22
fi
28
+#
23
29
+# This program is free software; you can redistribute it and/or modify
24
+if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then
30
+# it under the terms of the GNU General Public License as published by
25
+ echo "Sanitizers are enabled ==> Not running the qemu-iotests."
31
+# the Free Software Foundation; either version 2 of the License, or
26
+ exit 0
32
+# (at your option) any later version.
27
+fi
33
+#
34
+# This program is distributed in the hope that it will be useful,
35
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
36
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37
+# GNU General Public License for more details.
38
+#
39
+# You should have received a copy of the GNU General Public License
40
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
41
+#
28
+
42
+
29
if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then
43
+seq=$(basename $0)
30
echo "No qemu-system binary available ==> Not running the qemu-iotests."
44
+echo "QA output created by $seq"
31
exit 0
45
+
46
+status=1    # failure is the default!
47
+
48
+_cleanup()
49
+{
50
+ _cleanup_test_img
51
+}
52
+trap "_cleanup; exit \$status" 0 1 2 3 15
53
+
54
+# get standard environment, filters and checks
55
+cd ..
56
+. ./common.rc
57
+. ./common.filter
58
+
59
+_supported_fmt raw
60
+_supported_proto file
61
+
62
+_make_test_img 1M
63
+
64
+IMGSPEC="driver=blkdebug,align=4096,image.driver=file,image.filename=$TEST_IMG"
65
+
66
+# Four combinations:
67
+# - Offset 4096, length 1023 * 512 + 512: Fully aligned to 4k
68
+# - Offset 4096, length 1023 * 512 + 4096: Head is aligned, tail is not
69
+# - Offset 512, length 1023 * 512 + 512: Neither head nor tail are aligned
70
+# - Offset 512, length 1023 * 512 + 4096: Tail is aligned, head is not
71
+for start_offset in 4096 512; do
72
+ for last_element_length in 512 4096; do
73
+ length=$((1023 * 512 + $last_element_length))
74
+
75
+ echo
76
+ echo "== performing 1024-element vectored requests to image (offset: $start_offset; length: $length) =="
77
+
78
+ # Fill with data for testing
79
+ $QEMU_IO -c 'write -P 1 0 1M' "$TEST_IMG" | _filter_qemu_io
80
+
81
+ # 1023 512-byte buffers, and then one with length $last_element_length
82
+ cmd_params="-P 2 $start_offset $(yes 512 | head -n 1023 | tr '\n' ' ') $last_element_length"
83
+ QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS_NO_FMT" $QEMU_IO \
84
+ -c "writev $cmd_params" \
85
+ --image-opts \
86
+ "$IMGSPEC" \
87
+ | _filter_qemu_io
88
+
89
+ # Read all patterns -- read the part we just wrote with writev twice,
90
+ # once "normally", and once with a readv, so we see that that works, too
91
+ QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS_NO_FMT" $QEMU_IO \
92
+ -c "read -P 1 0 $start_offset" \
93
+ -c "read -P 2 $start_offset $length" \
94
+ -c "readv $cmd_params" \
95
+ -c "read -P 1 $((start_offset + length)) $((1024 * 1024 - length - start_offset))" \
96
+ --image-opts \
97
+ "$IMGSPEC" \
98
+ | _filter_qemu_io
99
+ done
100
+done
101
+
102
+# success, all done
103
+echo "*** done"
104
+rm -f $seq.full
105
+status=0
106
diff --git a/tests/qemu-iotests/tests/iov-padding.out b/tests/qemu-iotests/tests/iov-padding.out
107
new file mode 100644
108
index XXXXXXX..XXXXXXX
109
--- /dev/null
110
+++ b/tests/qemu-iotests/tests/iov-padding.out
111
@@ -XXX,XX +XXX,XX @@
112
+QA output created by iov-padding
113
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
114
+
115
+== performing 1024-element vectored requests to image (offset: 4096; length: 524288) ==
116
+wrote 1048576/1048576 bytes at offset 0
117
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
118
+wrote 524288/524288 bytes at offset 4096
119
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
120
+read 4096/4096 bytes at offset 0
121
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
122
+read 524288/524288 bytes at offset 4096
123
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
124
+read 524288/524288 bytes at offset 4096
125
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
126
+read 520192/520192 bytes at offset 528384
127
+508 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
128
+
129
+== performing 1024-element vectored requests to image (offset: 4096; length: 527872) ==
130
+wrote 1048576/1048576 bytes at offset 0
131
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
132
+wrote 527872/527872 bytes at offset 4096
133
+515.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
134
+read 4096/4096 bytes at offset 0
135
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
136
+read 527872/527872 bytes at offset 4096
137
+515.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
138
+read 527872/527872 bytes at offset 4096
139
+515.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
140
+read 516608/516608 bytes at offset 531968
141
+504.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
142
+
143
+== performing 1024-element vectored requests to image (offset: 512; length: 524288) ==
144
+wrote 1048576/1048576 bytes at offset 0
145
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
146
+wrote 524288/524288 bytes at offset 512
147
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
148
+read 512/512 bytes at offset 0
149
+512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
150
+read 524288/524288 bytes at offset 512
151
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
152
+read 524288/524288 bytes at offset 512
153
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
154
+read 523776/523776 bytes at offset 524800
155
+511.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
156
+
157
+== performing 1024-element vectored requests to image (offset: 512; length: 527872) ==
158
+wrote 1048576/1048576 bytes at offset 0
159
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
160
+wrote 527872/527872 bytes at offset 512
161
+515.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
162
+read 512/512 bytes at offset 0
163
+512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
164
+read 527872/527872 bytes at offset 512
165
+515.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
166
+read 527872/527872 bytes at offset 512
167
+515.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
168
+read 520192/520192 bytes at offset 528384
169
+508 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
170
+*** done
32
--
171
--
33
2.21.0
172
2.40.1
34
35
diff view generated by jsdifflib
1
iotest 126 requires backing file support, which flat vmdks cannot offer.
1
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
2
Skip this test for such subformats.
3
2
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
data_end field in BDRVParallelsState is set to the biggest offset present
5
Message-id: 20190815153638.4600-8-mreitz@redhat.com
4
in BAT. If this offset is outside of the image, any further write will
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
create the cluster at this offset and/or the image will be truncated to
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
this offset on close. This is definitely not correct.
7
8
Raise an error in parallels_open() if data_end points outside the image
9
and it is not a check (let the check to repaire the image). Set data_end
10
to the end of the cluster with the last correct offset.
11
12
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
13
Message-Id: <20230424093147.197643-2-alexander.ivanov@virtuozzo.com>
14
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
15
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
8
---
16
---
9
tests/qemu-iotests/126 | 2 ++
17
block/parallels.c | 17 +++++++++++++++++
10
1 file changed, 2 insertions(+)
18
1 file changed, 17 insertions(+)
11
19
12
diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
20
diff --git a/block/parallels.c b/block/parallels.c
13
index XXXXXXX..XXXXXXX 100755
21
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/qemu-iotests/126
22
--- a/block/parallels.c
15
+++ b/tests/qemu-iotests/126
23
+++ b/block/parallels.c
16
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
24
@@ -XXX,XX +XXX,XX @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
17
25
BDRVParallelsState *s = bs->opaque;
18
# Needs backing file support
26
ParallelsHeader ph;
19
_supported_fmt qcow qcow2 qed vmdk
27
int ret, size, i;
20
+_unsupported_imgopts "subformat=monolithicFlat" \
28
+ int64_t file_nb_sectors;
21
+ "subformat=twoGbMaxExtentFlat"
29
QemuOpts *opts = NULL;
22
# This is the default protocol (and we want to test the difference between
30
Error *local_err = NULL;
23
# colons which separate a protocol prefix from the rest and colons which are
31
char *buf;
24
# just part of the filename, so we cannot test protocols which require a prefix)
32
@@ -XXX,XX +XXX,XX @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
33
return ret;
34
}
35
36
+ file_nb_sectors = bdrv_nb_sectors(bs->file->bs);
37
+ if (file_nb_sectors < 0) {
38
+ return -EINVAL;
39
+ }
40
+
41
ret = bdrv_pread(bs->file, 0, sizeof(ph), &ph, 0);
42
if (ret < 0) {
43
goto fail;
44
@@ -XXX,XX +XXX,XX @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
45
46
for (i = 0; i < s->bat_size; i++) {
47
int64_t off = bat2sect(s, i);
48
+ if (off >= file_nb_sectors) {
49
+ if (flags & BDRV_O_CHECK) {
50
+ continue;
51
+ }
52
+ error_setg(errp, "parallels: Offset %" PRIi64 " in BAT[%d] entry "
53
+ "is larger than file size (%" PRIi64 ")",
54
+ off << BDRV_SECTOR_BITS, i,
55
+ file_nb_sectors << BDRV_SECTOR_BITS);
56
+ ret = -EINVAL;
57
+ goto fail;
58
+ }
59
if (off >= s->data_end) {
60
s->data_end = off + s->tracks;
61
}
25
--
62
--
26
2.21.0
63
2.40.1
27
28
diff view generated by jsdifflib
1
streamOptimized does not support writes that do not span exactly one
1
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
2
cluster. Furthermore, it cannot rewrite already allocated clusters.
3
As such, many iotests do not work with it. Disable them.
4
2
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
Don't let high_off be more than the file size even if we don't fix the
6
Message-id: 20190815153638.4600-6-mreitz@redhat.com
4
image.
7
Reviewed-by: John Snow <jsnow@redhat.com>
5
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
7
Reviewed-by: Denis V. Lunev <den@openvz.org>
8
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
9
Message-Id: <20230424093147.197643-3-alexander.ivanov@virtuozzo.com>
10
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
11
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
9
---
12
---
10
tests/qemu-iotests/002 | 1 +
13
block/parallels.c | 4 ++--
11
tests/qemu-iotests/003 | 1 +
14
1 file changed, 2 insertions(+), 2 deletions(-)
12
tests/qemu-iotests/005 | 3 ++-
13
tests/qemu-iotests/009 | 1 +
14
tests/qemu-iotests/010 | 1 +
15
tests/qemu-iotests/011 | 1 +
16
tests/qemu-iotests/017 | 3 ++-
17
tests/qemu-iotests/018 | 3 ++-
18
tests/qemu-iotests/019 | 3 ++-
19
tests/qemu-iotests/020 | 3 ++-
20
tests/qemu-iotests/027 | 1 +
21
tests/qemu-iotests/032 | 1 +
22
tests/qemu-iotests/033 | 1 +
23
tests/qemu-iotests/034 | 3 ++-
24
tests/qemu-iotests/037 | 3 ++-
25
tests/qemu-iotests/063 | 3 ++-
26
tests/qemu-iotests/072 | 1 +
27
tests/qemu-iotests/105 | 3 ++-
28
tests/qemu-iotests/197 | 1 +
29
tests/qemu-iotests/215 | 1 +
30
tests/qemu-iotests/251 | 1 +
31
21 files changed, 30 insertions(+), 9 deletions(-)
32
15
33
diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002
16
diff --git a/block/parallels.c b/block/parallels.c
34
index XXXXXXX..XXXXXXX 100755
17
index XXXXXXX..XXXXXXX 100644
35
--- a/tests/qemu-iotests/002
18
--- a/block/parallels.c
36
+++ b/tests/qemu-iotests/002
19
+++ b/block/parallels.c
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
20
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
38
21
fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i);
39
_supported_fmt generic
22
res->corruptions++;
40
_supported_proto generic
23
if (fix & BDRV_FIX_ERRORS) {
41
+_unsupported_imgopts "subformat=streamOptimized"
24
- prev_off = 0;
42
25
s->bat_bitmap[i] = 0;
43
26
res->corruptions_fixed++;
44
size=128M
27
flush_bat = true;
45
diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003
28
- continue;
46
index XXXXXXX..XXXXXXX 100755
29
}
47
--- a/tests/qemu-iotests/003
30
+ prev_off = 0;
48
+++ b/tests/qemu-iotests/003
31
+ continue;
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
32
}
50
33
51
_supported_fmt generic
34
res->bfi.allocated_clusters++;
52
_supported_proto generic
53
+_unsupported_imgopts "subformat=streamOptimized"
54
55
size=128M
56
offset=67M
57
diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005
58
index XXXXXXX..XXXXXXX 100755
59
--- a/tests/qemu-iotests/005
60
+++ b/tests/qemu-iotests/005
61
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
62
_supported_proto generic
63
_supported_os Linux
64
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
65
- "subformat=twoGbMaxExtentSparse"
66
+ "subformat=twoGbMaxExtentSparse" \
67
+ "subformat=streamOptimized"
68
69
# vpc is limited to 127GB, so we can't test it here
70
if [ "$IMGFMT" = "vpc" ]; then
71
diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009
72
index XXXXXXX..XXXXXXX 100755
73
--- a/tests/qemu-iotests/009
74
+++ b/tests/qemu-iotests/009
75
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
76
77
_supported_fmt generic
78
_supported_proto generic
79
+_unsupported_imgopts "subformat=streamOptimized"
80
81
82
size=6G
83
diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010
84
index XXXXXXX..XXXXXXX 100755
85
--- a/tests/qemu-iotests/010
86
+++ b/tests/qemu-iotests/010
87
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
88
89
_supported_fmt generic
90
_supported_proto generic
91
+_unsupported_imgopts "subformat=streamOptimized"
92
93
94
size=6G
95
diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011
96
index XXXXXXX..XXXXXXX 100755
97
--- a/tests/qemu-iotests/011
98
+++ b/tests/qemu-iotests/011
99
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
100
101
_supported_fmt generic
102
_supported_proto generic
103
+_unsupported_imgopts "subformat=streamOptimized"
104
105
106
size=6G
107
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
108
index XXXXXXX..XXXXXXX 100755
109
--- a/tests/qemu-iotests/017
110
+++ b/tests/qemu-iotests/017
111
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
112
_supported_fmt qcow qcow2 vmdk qed
113
_supported_proto generic
114
_unsupported_proto vxhs
115
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
116
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
117
+ "subformat=streamOptimized"
118
119
TEST_OFFSETS="0 4294967296"
120
121
diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018
122
index XXXXXXX..XXXXXXX 100755
123
--- a/tests/qemu-iotests/018
124
+++ b/tests/qemu-iotests/018
125
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
126
_supported_fmt qcow qcow2 vmdk qed
127
_supported_proto file
128
_supported_os Linux
129
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
130
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
131
+ "streamOptimized"
132
133
TEST_OFFSETS="0 4294967296"
134
135
diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
136
index XXXXXXX..XXXXXXX 100755
137
--- a/tests/qemu-iotests/019
138
+++ b/tests/qemu-iotests/019
139
@@ -XXX,XX +XXX,XX @@ _supported_proto file
140
_supported_os Linux
141
_unsupported_imgopts "subformat=monolithicFlat" \
142
"subformat=twoGbMaxExtentFlat" \
143
- "subformat=twoGbMaxExtentSparse"
144
+ "subformat=twoGbMaxExtentSparse" \
145
+ "subformat=streamOptimized"
146
147
TEST_OFFSETS="0 4294967296"
148
CLUSTER_SIZE=65536
149
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
150
index XXXXXXX..XXXXXXX 100755
151
--- a/tests/qemu-iotests/020
152
+++ b/tests/qemu-iotests/020
153
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
154
_supported_proto file
155
_unsupported_imgopts "subformat=monolithicFlat" \
156
"subformat=twoGbMaxExtentFlat" \
157
- "subformat=twoGbMaxExtentSparse"
158
+ "subformat=twoGbMaxExtentSparse" \
159
+ "subformat=streamOptimized"
160
161
TEST_OFFSETS="0 4294967296"
162
163
diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027
164
index XXXXXXX..XXXXXXX 100755
165
--- a/tests/qemu-iotests/027
166
+++ b/tests/qemu-iotests/027
167
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
168
169
_supported_fmt vmdk qcow qcow2 qed
170
_supported_proto generic
171
+_unsupported_imgopts "subformat=streamOptimized"
172
173
174
size=128M
175
diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032
176
index XXXXXXX..XXXXXXX 100755
177
--- a/tests/qemu-iotests/032
178
+++ b/tests/qemu-iotests/032
179
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
180
# This works for any image format (though unlikely to segfault for raw)
181
_supported_fmt generic
182
_supported_proto generic
183
+_unsupported_imgopts "subformat=streamOptimized"
184
185
echo
186
echo === Prepare image ===
187
diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033
188
index XXXXXXX..XXXXXXX 100755
189
--- a/tests/qemu-iotests/033
190
+++ b/tests/qemu-iotests/033
191
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
192
193
_supported_fmt generic
194
_supported_proto generic
195
+_unsupported_imgopts "subformat=streamOptimized"
196
197
198
size=128M
199
diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034
200
index XXXXXXX..XXXXXXX 100755
201
--- a/tests/qemu-iotests/034
202
+++ b/tests/qemu-iotests/034
203
@@ -XXX,XX +XXX,XX @@ _supported_proto file
204
_supported_os Linux
205
_unsupported_imgopts "subformat=monolithicFlat" \
206
"subformat=twoGbMaxExtentFlat" \
207
- "subformat=twoGbMaxExtentSparse"
208
+ "subformat=twoGbMaxExtentSparse" \
209
+ "subformat=streamOptimized"
210
211
CLUSTER_SIZE=4k
212
size=128M
213
diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037
214
index XXXXXXX..XXXXXXX 100755
215
--- a/tests/qemu-iotests/037
216
+++ b/tests/qemu-iotests/037
217
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
218
_supported_proto file
219
_unsupported_imgopts "subformat=monolithicFlat" \
220
"subformat=twoGbMaxExtentFlat" \
221
- "subformat=twoGbMaxExtentSparse"
222
+ "subformat=twoGbMaxExtentSparse" \
223
+ "subformat=streamOptimized"
224
225
CLUSTER_SIZE=4k
226
size=128M
227
diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
228
index XXXXXXX..XXXXXXX 100755
229
--- a/tests/qemu-iotests/063
230
+++ b/tests/qemu-iotests/063
231
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed raw
232
_supported_proto file
233
_unsupported_imgopts "subformat=monolithicFlat" \
234
"subformat=twoGbMaxExtentFlat" \
235
- "subformat=twoGbMaxExtentSparse"
236
+ "subformat=twoGbMaxExtentSparse" \
237
+ "subformat=streamOptimized"
238
239
_make_test_img 4M
240
241
diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072
242
index XXXXXXX..XXXXXXX 100755
243
--- a/tests/qemu-iotests/072
244
+++ b/tests/qemu-iotests/072
245
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
246
247
_supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow
248
_supported_proto file
249
+_unsupported_imgopts "subformat=streamOptimized"
250
251
IMG_SIZE=64M
252
253
diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105
254
index XXXXXXX..XXXXXXX 100755
255
--- a/tests/qemu-iotests/105
256
+++ b/tests/qemu-iotests/105
257
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
258
_supported_fmt qcow2 vmdk vhdx qed
259
_supported_proto generic
260
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
261
- "subformat=twoGbMaxExtentSparse"
262
+ "subformat=twoGbMaxExtentSparse" \
263
+ "subformat=streamOptimized"
264
265
echo
266
echo "creating large image"
267
diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197
268
index XXXXXXX..XXXXXXX 100755
269
--- a/tests/qemu-iotests/197
270
+++ b/tests/qemu-iotests/197
271
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
272
_supported_proto generic
273
# LUKS support may be possible, but it complicates things.
274
_unsupported_fmt luks
275
+_unsupported_imgopts "subformat=streamOptimized"
276
277
echo
278
echo '=== Copy-on-read ==='
279
diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215
280
index XXXXXXX..XXXXXXX 100755
281
--- a/tests/qemu-iotests/215
282
+++ b/tests/qemu-iotests/215
283
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
284
_supported_proto generic
285
# LUKS support may be possible, but it complicates things.
286
_unsupported_fmt luks
287
+_unsupported_imgopts "subformat=streamOptimized"
288
289
echo
290
echo '=== Copy-on-read ==='
291
diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251
292
index XXXXXXX..XXXXXXX 100755
293
--- a/tests/qemu-iotests/251
294
+++ b/tests/qemu-iotests/251
295
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
296
_supported_fmt generic
297
_supported_proto file
298
_supported_os Linux
299
+_unsupported_imgopts "subformat=streamOptimized"
300
301
if [ "$IMGOPTSSYNTAX" = "true" ]; then
302
# We use json:{} filenames here, so we cannot work with additional options.
303
--
35
--
304
2.21.0
36
2.40.1
305
306
diff view generated by jsdifflib
1
Compressed writes generally have to write full clusters, not just in
1
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
2
theory but also in practice when it comes to vmdk's streamOptimized
3
subformat. It currently is just silently broken for writes with
4
non-zero in-cluster offsets:
5
2
6
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
3
Set data_end to the end of the last cluster inside the image. In such a
7
$ qemu-io -c 'write 4k 4k' -c 'read 4k 4k' foo.vmdk
4
way we can be sure that corrupted offsets in the BAT can't affect on the
8
wrote 4096/4096 bytes at offset 4096
5
image size. If there are no allocated clusters set image_end_offset by
9
4 KiB, 1 ops; 00.01 sec (443.724 KiB/sec and 110.9309 ops/sec)
6
data_end.
10
read failed: Invalid argument
11
7
12
(The technical reason is that vmdk_write_extent() just writes the
8
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
13
incomplete compressed data actually to offset 4k. When reading the
9
Reviewed-by: Denis V. Lunev <den@openvz.org>
14
data, vmdk_read_extent() looks at offset 0 and finds the compressed data
10
Message-Id: <20230424093147.197643-4-alexander.ivanov@virtuozzo.com>
15
size to be 0, because that is what it reads from there. This yields an
11
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
16
error.)
12
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
13
---
14
block/parallels.c | 8 +++++++-
15
1 file changed, 7 insertions(+), 1 deletion(-)
17
16
18
For incomplete writes with zero in-cluster offsets, the error path when
17
diff --git a/block/parallels.c b/block/parallels.c
19
reading the rest of the cluster is a bit different, but the result is
20
the same:
21
22
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
23
$ qemu-io -c 'write 0k 4k' -c 'read 4k 4k' foo.vmdk
24
wrote 4096/4096 bytes at offset 0
25
4 KiB, 1 ops; 00.01 sec (362.641 KiB/sec and 90.6603 ops/sec)
26
read failed: Invalid argument
27
28
(Here, vmdk_read_extent() finds the data and then sees that the
29
uncompressed data is short.)
30
31
It is better to reject invalid writes than to make the user believe they
32
might have succeeded and then fail when trying to read it back.
33
34
Signed-off-by: Max Reitz <mreitz@redhat.com>
35
Reviewed-by: John Snow <jsnow@redhat.com>
36
Message-id: 20190815153638.4600-5-mreitz@redhat.com
37
Reviewed-by: John Snow <jsnow@redhat.com>
38
Signed-off-by: Max Reitz <mreitz@redhat.com>
39
---
40
block/vmdk.c | 10 ++++++++++
41
1 file changed, 10 insertions(+)
42
43
diff --git a/block/vmdk.c b/block/vmdk.c
44
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
45
--- a/block/vmdk.c
19
--- a/block/parallels.c
46
+++ b/block/vmdk.c
20
+++ b/block/parallels.c
47
@@ -XXX,XX +XXX,XX @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset,
21
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
48
if (extent->compressed) {
22
}
49
void *compressed_data;
23
}
50
24
51
+ /* Only whole clusters */
25
- res->image_end_offset = high_off + s->cluster_size;
52
+ if (offset_in_cluster ||
26
+ if (high_off == 0) {
53
+ n_bytes > (extent->cluster_sectors * SECTOR_SIZE) ||
27
+ res->image_end_offset = s->data_end << BDRV_SECTOR_BITS;
54
+ (n_bytes < (extent->cluster_sectors * SECTOR_SIZE) &&
28
+ } else {
55
+ offset + n_bytes != extent->end_sector * SECTOR_SIZE))
29
+ res->image_end_offset = high_off + s->cluster_size;
56
+ {
30
+ s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS;
57
+ ret = -EINVAL;
31
+ }
58
+ goto out;
59
+ }
60
+
32
+
61
if (!extent->has_marker) {
33
if (size > res->image_end_offset) {
62
ret = -EINVAL;
34
int64_t count;
63
goto out;
35
count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size);
64
--
36
--
65
2.21.0
37
2.40.1
66
67
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
2
2
3
It is possible to enable only a subset of the block drivers with the
3
This helper will be reused in next patches during parallels_co_check
4
"--block-drv-rw-whitelist" option of the "configure" script. All other
4
rework to simplify its code.
5
drivers are marked as unusable (or only included as read-only with the
6
"--block-drv-ro-whitelist" option). If an iotest is now using such a
7
disabled block driver, it is failing - which is bad, since at least the
8
tests in the "auto" group should be able to deal with this situation.
9
Thus let's introduce a "_require_drivers" function that can be used by
10
the shell tests to check for the availability of certain drivers first,
11
and marks the test as "not run" if one of the drivers is missing.
12
5
13
This patch mainly targets the test in the "auto" group which should
6
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
14
never fail in such a case, but also improves some of the other tests
7
Reviewed-by: Denis V. Lunev <den@openvz.org>
15
along the way. Note that we also assume that the "qcow2" and "file"
8
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
16
drivers are always available - otherwise it does not make sense to
9
Message-Id: <20230424093147.197643-5-alexander.ivanov@virtuozzo.com>
17
run "make check-block" at all (which only tests with qcow2 by default).
10
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
11
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
12
---
13
block/parallels.c | 11 ++++++++---
14
1 file changed, 8 insertions(+), 3 deletions(-)
18
15
19
Signed-off-by: Thomas Huth <thuth@redhat.com>
16
diff --git a/block/parallels.c b/block/parallels.c
20
Message-id: 20190823133552.11680-1-thuth@redhat.com
17
index XXXXXXX..XXXXXXX 100644
21
Signed-off-by: Max Reitz <mreitz@redhat.com>
18
--- a/block/parallels.c
22
---
19
+++ b/block/parallels.c
23
tests/qemu-iotests/071 | 1 +
20
@@ -XXX,XX +XXX,XX @@ static int64_t block_status(BDRVParallelsState *s, int64_t sector_num,
24
tests/qemu-iotests/081 | 4 +---
21
return start_off;
25
tests/qemu-iotests/099 | 1 +
26
tests/qemu-iotests/120 | 1 +
27
tests/qemu-iotests/162 | 4 +---
28
tests/qemu-iotests/184 | 1 +
29
tests/qemu-iotests/186 | 1 +
30
tests/qemu-iotests/common.rc | 14 ++++++++++++++
31
8 files changed, 21 insertions(+), 6 deletions(-)
32
33
diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071
34
index XXXXXXX..XXXXXXX 100755
35
--- a/tests/qemu-iotests/071
36
+++ b/tests/qemu-iotests/071
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
38
39
_supported_fmt qcow2
40
_supported_proto file
41
+_require_drivers blkdebug blkverify
42
43
do_run_qemu()
44
{
45
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
46
index XXXXXXX..XXXXXXX 100755
47
--- a/tests/qemu-iotests/081
48
+++ b/tests/qemu-iotests/081
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
50
_supported_fmt raw
51
_supported_proto file
52
_supported_os Linux
53
+_require_drivers quorum
54
55
do_run_qemu()
56
{
57
@@ -XXX,XX +XXX,XX @@ run_qemu()
58
| _filter_qemu_io | _filter_generated_node_ids
59
}
22
}
60
23
61
-test_quorum=$($QEMU_IMG --help|grep quorum)
24
+static void parallels_set_bat_entry(BDRVParallelsState *s,
62
-[ "$test_quorum" = "" ] && _supported_fmt quorum
25
+ uint32_t index, uint32_t offset)
63
-
64
quorum="driver=raw,file.driver=quorum,file.vote-threshold=2"
65
quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw"
66
quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw"
67
diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099
68
index XXXXXXX..XXXXXXX 100755
69
--- a/tests/qemu-iotests/099
70
+++ b/tests/qemu-iotests/099
71
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
72
_supported_fmt qcow qcow2 qed vdi vhdx vmdk vpc
73
_supported_proto file
74
_supported_os Linux
75
+_require_drivers blkdebug blkverify
76
_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
77
"subformat=twoGbMaxExtentSparse"
78
79
diff --git a/tests/qemu-iotests/120 b/tests/qemu-iotests/120
80
index XXXXXXX..XXXXXXX 100755
81
--- a/tests/qemu-iotests/120
82
+++ b/tests/qemu-iotests/120
83
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
84
_supported_fmt generic
85
_supported_proto file
86
_unsupported_fmt luks
87
+_require_drivers raw
88
89
_make_test_img 64M
90
91
diff --git a/tests/qemu-iotests/162 b/tests/qemu-iotests/162
92
index XXXXXXX..XXXXXXX 100755
93
--- a/tests/qemu-iotests/162
94
+++ b/tests/qemu-iotests/162
95
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
96
. ./common.filter
97
98
_supported_fmt generic
99
-
100
-test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)')
101
-[ "$test_ssh" = "" ] && _notrun "ssh support required"
102
+_require_drivers ssh
103
104
echo
105
echo '=== NBD ==='
106
diff --git a/tests/qemu-iotests/184 b/tests/qemu-iotests/184
107
index XXXXXXX..XXXXXXX 100755
108
--- a/tests/qemu-iotests/184
109
+++ b/tests/qemu-iotests/184
110
@@ -XXX,XX +XXX,XX @@ trap "exit \$status" 0 1 2 3 15
111
. ./common.filter
112
113
_supported_os Linux
114
+_require_drivers throttle
115
116
do_run_qemu()
117
{
118
diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186
119
index XXXXXXX..XXXXXXX 100755
120
--- a/tests/qemu-iotests/186
121
+++ b/tests/qemu-iotests/186
122
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
123
124
_supported_fmt qcow2
125
_supported_proto file
126
+_require_drivers null-co
127
128
if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
129
_notrun "Requires a PC machine"
130
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
131
index XXXXXXX..XXXXXXX 100644
132
--- a/tests/qemu-iotests/common.rc
133
+++ b/tests/qemu-iotests/common.rc
134
@@ -XXX,XX +XXX,XX @@ _require_command()
135
[ -x "$c" ] || _notrun "$1 utility required, skipped this test"
136
}
137
138
+# Check that a set of drivers has been whitelisted in the QEMU binary
139
+#
140
+_require_drivers()
141
+{
26
+{
142
+ available=$($QEMU -drive format=help | \
27
+ s->bat_bitmap[index] = cpu_to_le32(offset);
143
+ sed -e '/Supported formats:/!d' -e 's/Supported formats://')
28
+ bitmap_set(s->bat_dirty_bmap, bat_entry_off(index) / s->bat_dirty_block, 1);
144
+ for driver
145
+ do
146
+ if ! echo "$available" | grep -q " $driver\( \|$\)"; then
147
+ _notrun "$driver not available"
148
+ fi
149
+ done
150
+}
29
+}
151
+
30
+
152
# make sure this script returns success
31
static int64_t coroutine_fn GRAPH_RDLOCK
153
true
32
allocate_clusters(BlockDriverState *bs, int64_t sector_num,
33
int nb_sectors, int *pnum)
34
@@ -XXX,XX +XXX,XX @@ allocate_clusters(BlockDriverState *bs, int64_t sector_num,
35
}
36
37
for (i = 0; i < to_allocate; i++) {
38
- s->bat_bitmap[idx + i] = cpu_to_le32(s->data_end / s->off_multiplier);
39
+ parallels_set_bat_entry(s, idx + i, s->data_end / s->off_multiplier);
40
s->data_end += s->tracks;
41
- bitmap_set(s->bat_dirty_bmap,
42
- bat_entry_off(idx + i) / s->bat_dirty_block, 1);
43
}
44
45
return bat2sect(s, idx) + sector_num % s->tracks;
154
--
46
--
155
2.21.0
47
2.40.1
156
157
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
2
2
3
Quoting cache mode is not needed, and most tests use unquoted values.
3
BAT is written in the context of conventional operations over the image
4
Unify all test to use the same style.
4
inside bdrv_co_flush() when it calls parallels_co_flush_to_os() callback.
5
Thus we should not modify BAT array directly, but call
6
parallels_set_bat_entry() helper and bdrv_co_flush() further on. After
7
that there is no need to manually write BAT and track its modification.
5
8
6
Message-id: 20190827173432.7656-1-nsoffer@redhat.com
9
This makes code more generic and allows to split parallels_set_bat_entry()
7
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
10
for independent pieces.
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
12
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
13
Reviewed-by: Denis V. Lunev <den@openvz.org>
14
Message-Id: <20230424093147.197643-6-alexander.ivanov@virtuozzo.com>
15
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
16
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
9
---
17
---
10
tests/qemu-iotests/026 | 4 ++--
18
block/parallels.c | 23 ++++++++++-------------
11
tests/qemu-iotests/039 | 4 ++--
19
1 file changed, 10 insertions(+), 13 deletions(-)
12
tests/qemu-iotests/052 | 2 +-
13
tests/qemu-iotests/091 | 4 ++--
14
4 files changed, 7 insertions(+), 7 deletions(-)
15
20
16
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
21
diff --git a/block/parallels.c b/block/parallels.c
17
index XXXXXXX..XXXXXXX 100755
22
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qemu-iotests/026
23
--- a/block/parallels.c
19
+++ b/tests/qemu-iotests/026
24
+++ b/block/parallels.c
20
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
25
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
21
# Currently only qcow2 supports rebasing
26
{
22
_supported_fmt qcow2
27
BDRVParallelsState *s = bs->opaque;
23
_supported_proto file
28
int64_t size, prev_off, high_off;
24
-_default_cache_mode "writethrough"
29
- int ret;
25
-_supported_cache_modes "writethrough" "none"
30
+ int ret = 0;
26
+_default_cache_mode writethrough
31
uint32_t i;
27
+_supported_cache_modes writethrough none
32
- bool flush_bat = false;
28
# The refcount table tests expect a certain minimum width for refcount entries
33
29
# (so that the refcount table actually needs to grow); that minimum is 16 bits,
34
size = bdrv_getlength(bs->file->bs);
30
# being the default refcount entry width.
35
if (size < 0) {
31
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
36
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
32
index XXXXXXX..XXXXXXX 100755
37
fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i);
33
--- a/tests/qemu-iotests/039
38
res->corruptions++;
34
+++ b/tests/qemu-iotests/039
39
if (fix & BDRV_FIX_ERRORS) {
35
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
40
- s->bat_bitmap[i] = 0;
36
_supported_fmt qcow2
41
+ parallels_set_bat_entry(s, i, 0);
37
_supported_proto file
42
res->corruptions_fixed++;
38
_supported_os Linux
43
- flush_bat = true;
39
-_default_cache_mode "writethrough"
44
}
40
-_supported_cache_modes "writethrough"
45
prev_off = 0;
41
+_default_cache_mode writethrough
46
continue;
42
+_supported_cache_modes writethrough
47
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
43
48
prev_off = off;
44
size=128M
49
}
45
50
46
diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052
51
- ret = 0;
47
index XXXXXXX..XXXXXXX 100755
52
- if (flush_bat) {
48
--- a/tests/qemu-iotests/052
53
- ret = bdrv_co_pwrite_sync(bs->file, 0, s->header_size, s->header, 0);
49
+++ b/tests/qemu-iotests/052
54
- if (ret < 0) {
50
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
55
- res->check_errors++;
51
_supported_proto file
56
- goto out;
52
57
- }
53
# Don't do O_DIRECT on tmpfs
58
- }
54
-_supported_cache_modes "writeback" "writethrough" "unsafe"
59
-
55
+_supported_cache_modes writeback writethrough unsafe
60
if (high_off == 0) {
56
61
res->image_end_offset = s->data_end << BDRV_SECTOR_BITS;
57
size=128M
62
} else {
58
_make_test_img $size
63
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
59
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
64
60
index XXXXXXX..XXXXXXX 100755
65
out:
61
--- a/tests/qemu-iotests/091
66
qemu_co_mutex_unlock(&s->lock);
62
+++ b/tests/qemu-iotests/091
67
+
63
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
68
+ if (ret == 0) {
64
_supported_fmt qcow2
69
+ ret = bdrv_co_flush(bs);
65
_supported_proto file
70
+ if (ret < 0) {
66
_supported_os Linux
71
+ res->check_errors++;
67
-_default_cache_mode "none"
72
+ }
68
-_supported_cache_modes "writethrough" "none" "writeback"
73
+ }
69
+_default_cache_mode none
74
+
70
+_supported_cache_modes writethrough none writeback
75
return ret;
71
76
}
72
size=1G
73
77
74
--
78
--
75
2.21.0
79
2.40.1
76
77
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
2
2
3
When creating an image with preallocation "off" or "falloc", the first
3
We will add more and more checks so we need a better code structure
4
block of the image is typically not allocated. When using Gluster
4
in parallels_co_check. Let each check performs in a separate loop
5
storage backed by XFS filesystem, reading this block using direct I/O
5
in a separate helper.
6
succeeds regardless of request length, fooling alignment detection.
7
6
8
In this case we fallback to a safe value (4096) instead of the optimal
7
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
9
value (512), which may lead to unneeded data copying when aligning
8
Reviewed-by: Denis V. Lunev <den@openvz.org>
10
requests. Allocating the first block avoids the fallback.
9
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
10
Message-Id: <20230424093147.197643-7-alexander.ivanov@virtuozzo.com>
11
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
12
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
13
---
14
block/parallels.c | 31 +++++++++++++++++++++----------
15
1 file changed, 21 insertions(+), 10 deletions(-)
11
16
12
Since we allocate the first block even with preallocation=off, we no
17
diff --git a/block/parallels.c b/block/parallels.c
13
longer create images with zero disk size:
14
15
$ ./qemu-img create -f raw test.raw 1g
16
Formatting 'test.raw', fmt=raw size=1073741824
17
18
$ ls -lhs test.raw
19
4.0K -rw-r--r--. 1 nsoffer nsoffer 1.0G Aug 16 23:48 test.raw
20
21
And converting the image requires additional cluster:
22
23
$ ./qemu-img measure -f raw -O qcow2 test.raw
24
required size: 458752
25
fully allocated size: 1074135040
26
27
When using format like vmdk with multiple files per image, we allocate
28
one block per file:
29
30
$ ./qemu-img create -f vmdk -o subformat=twoGbMaxExtentFlat test.vmdk 4g
31
Formatting 'test.vmdk', fmt=vmdk size=4294967296 compat6=off hwversion=undefined subformat=twoGbMaxExtentFlat
32
33
$ ls -lhs test*.vmdk
34
4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f001.vmdk
35
4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f002.vmdk
36
4.0K -rw-r--r--. 1 nsoffer nsoffer 353 Aug 27 03:23 test.vmdk
37
38
I did quick performance test for copying disks with qemu-img convert to
39
new raw target image to Gluster storage with sector size of 512 bytes:
40
41
for i in $(seq 10); do
42
rm -f dst.raw
43
sleep 10
44
time ./qemu-img convert -f raw -O raw -t none -T none src.raw dst.raw
45
done
46
47
Here is a table comparing the total time spent:
48
49
Type Before(s) After(s) Diff(%)
50
---------------------------------------
51
real 530.028 469.123 -11.4
52
user 17.204 10.768 -37.4
53
sys 17.881 7.011 -60.7
54
55
We can see very clear improvement in CPU usage.
56
57
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
58
Message-id: 20190827010528.8818-2-nsoffer@redhat.com
59
Reviewed-by: Max Reitz <mreitz@redhat.com>
60
Signed-off-by: Max Reitz <mreitz@redhat.com>
61
---
62
block/file-posix.c | 51 +++++++++++++++++++
63
tests/qemu-iotests/059.out | 2 +-
64
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
65
tests/qemu-iotests/150.out.raw | 12 +++++
66
tests/qemu-iotests/175 | 19 ++++---
67
tests/qemu-iotests/175.out | 8 +--
68
tests/qemu-iotests/178.out.qcow2 | 4 +-
69
tests/qemu-iotests/221.out | 12 +++--
70
tests/qemu-iotests/253.out | 12 +++--
71
9 files changed, 99 insertions(+), 21 deletions(-)
72
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
73
create mode 100644 tests/qemu-iotests/150.out.raw
74
75
diff --git a/block/file-posix.c b/block/file-posix.c
76
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
77
--- a/block/file-posix.c
19
--- a/block/parallels.c
78
+++ b/block/file-posix.c
20
+++ b/block/parallels.c
79
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque)
21
@@ -XXX,XX +XXX,XX @@ parallels_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
80
return ret;
22
return ret;
81
}
23
}
82
24
83
+/*
25
+static void parallels_check_unclean(BlockDriverState *bs,
84
+ * Help alignment probing by allocating the first block.
26
+ BdrvCheckResult *res,
85
+ *
27
+ BdrvCheckMode fix)
86
+ * When reading with direct I/O from unallocated area on Gluster backed by XFS,
87
+ * reading succeeds regardless of request length. In this case we fallback to
88
+ * safe alignment which is not optimal. Allocating the first block avoids this
89
+ * fallback.
90
+ *
91
+ * fd may be opened with O_DIRECT, but we don't know the buffer alignment or
92
+ * request alignment, so we use safe values.
93
+ *
94
+ * Returns: 0 on success, -errno on failure. Since this is an optimization,
95
+ * caller may ignore failures.
96
+ */
97
+static int allocate_first_block(int fd, size_t max_size)
98
+{
28
+{
99
+ size_t write_size = (max_size < MAX_BLOCKSIZE)
29
+ BDRVParallelsState *s = bs->opaque;
100
+ ? BDRV_SECTOR_SIZE
101
+ : MAX_BLOCKSIZE;
102
+ size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize());
103
+ void *buf;
104
+ ssize_t n;
105
+ int ret;
106
+
30
+
107
+ buf = qemu_memalign(max_align, write_size);
31
+ if (!s->header_unclean) {
108
+ memset(buf, 0, write_size);
32
+ return;
33
+ }
109
+
34
+
110
+ do {
35
+ fprintf(stderr, "%s image was not closed correctly\n",
111
+ n = pwrite(fd, buf, write_size, 0);
36
+ fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR");
112
+ } while (n == -1 && errno == EINTR);
37
+ res->corruptions++;
38
+ if (fix & BDRV_FIX_ERRORS) {
39
+ /* parallels_close will do the job right */
40
+ res->corruptions_fixed++;
41
+ s->header_unclean = false;
42
+ }
43
+}
44
45
static int coroutine_fn GRAPH_RDLOCK
46
parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
47
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
48
}
49
50
qemu_co_mutex_lock(&s->lock);
51
- if (s->header_unclean) {
52
- fprintf(stderr, "%s image was not closed correctly\n",
53
- fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR");
54
- res->corruptions++;
55
- if (fix & BDRV_FIX_ERRORS) {
56
- /* parallels_close will do the job right */
57
- res->corruptions_fixed++;
58
- s->header_unclean = false;
59
- }
60
- }
113
+
61
+
114
+ ret = (n == -1) ? -errno : 0;
62
+ parallels_check_unclean(bs, res, fix);
115
+
63
116
+ qemu_vfree(buf);
64
res->bfi.total_clusters = s->bat_size;
117
+ return ret;
65
res->bfi.compressed_clusters = 0; /* compression is not supported */
118
+}
119
+
120
static int handle_aiocb_truncate(void *opaque)
121
{
122
RawPosixAIOData *aiocb = opaque;
123
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
124
/* posix_fallocate() doesn't set errno. */
125
error_setg_errno(errp, -result,
126
"Could not preallocate new data");
127
+ } else if (current_length == 0) {
128
+ /*
129
+ * posix_fallocate() uses fallocate() if the filesystem
130
+ * supports it, or fallback to manually writing zeroes. If
131
+ * fallocate() was used, unaligned reads from the fallocated
132
+ * area in raw_probe_alignment() will succeed, hence we need to
133
+ * allocate the first block.
134
+ *
135
+ * Optimize future alignment probing; ignore failures.
136
+ */
137
+ allocate_first_block(fd, offset);
138
}
139
} else {
140
result = 0;
141
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
142
if (ftruncate(fd, offset) != 0) {
143
result = -errno;
144
error_setg_errno(errp, -result, "Could not resize file");
145
+ } else if (current_length == 0 && offset > current_length) {
146
+ /* Optimize future alignment probing; ignore failures. */
147
+ allocate_first_block(fd, offset);
148
}
149
return result;
150
default:
151
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
152
index XXXXXXX..XXXXXXX 100644
153
--- a/tests/qemu-iotests/059.out
154
+++ b/tests/qemu-iotests/059.out
155
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMax
156
image: TEST_DIR/t.vmdk
157
file format: vmdk
158
virtual size: 0.977 TiB (1073741824000 bytes)
159
-disk size: 16 KiB
160
+disk size: 1.97 MiB
161
Format specific information:
162
cid: XXXXXXXX
163
parent cid: XXXXXXXX
164
diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out.qcow2
165
similarity index 100%
166
rename from tests/qemu-iotests/150.out
167
rename to tests/qemu-iotests/150.out.qcow2
168
diff --git a/tests/qemu-iotests/150.out.raw b/tests/qemu-iotests/150.out.raw
169
new file mode 100644
170
index XXXXXXX..XXXXXXX
171
--- /dev/null
172
+++ b/tests/qemu-iotests/150.out.raw
173
@@ -XXX,XX +XXX,XX @@
174
+QA output created by 150
175
+
176
+=== Mapping sparse conversion ===
177
+
178
+Offset Length File
179
+0 0x1000 TEST_DIR/t.IMGFMT
180
+
181
+=== Mapping non-sparse conversion ===
182
+
183
+Offset Length File
184
+0 0x100000 TEST_DIR/t.IMGFMT
185
+*** done
186
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
187
index XXXXXXX..XXXXXXX 100755
188
--- a/tests/qemu-iotests/175
189
+++ b/tests/qemu-iotests/175
190
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
191
# the file size. This function hides the resulting difference in the
192
# stat -c '%b' output.
193
# Parameter 1: Number of blocks an empty file occupies
194
-# Parameter 2: Image size in bytes
195
+# Parameter 2: Minimal number of blocks in an image
196
+# Parameter 3: Image size in bytes
197
_filter_blocks()
198
{
199
extra_blocks=$1
200
- img_size=$2
201
+ min_blocks=$2
202
+ img_size=$3
203
204
- sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \
205
- -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/everything allocated/"
206
+ sed -e "s/blocks=$min_blocks\\(\$\\|[^0-9]\\)/min allocation/" \
207
+ -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
208
}
209
210
# get standard environment, filters and checks
211
@@ -XXX,XX +XXX,XX @@ size=$((1 * 1024 * 1024))
212
touch "$TEST_DIR/empty"
213
extra_blocks=$(stat -c '%b' "$TEST_DIR/empty")
214
215
+# We always write the first byte; check how many blocks this filesystem
216
+# allocates to match empty image alloation.
217
+printf "\0" > "$TEST_DIR/empty"
218
+min_blocks=$(stat -c '%b' "$TEST_DIR/empty")
219
+
220
echo
221
echo "== creating image with default preallocation =="
222
_make_test_img $size | _filter_imgfmt
223
-stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size
224
+stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
225
226
for mode in off full falloc; do
227
echo
228
echo "== creating image with preallocation $mode =="
229
IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt
230
- stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size
231
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
232
done
233
234
# success, all done
235
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
236
index XXXXXXX..XXXXXXX 100644
237
--- a/tests/qemu-iotests/175.out
238
+++ b/tests/qemu-iotests/175.out
239
@@ -XXX,XX +XXX,XX @@ QA output created by 175
240
241
== creating image with default preallocation ==
242
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
243
-size=1048576, nothing allocated
244
+size=1048576, min allocation
245
246
== creating image with preallocation off ==
247
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=off
248
-size=1048576, nothing allocated
249
+size=1048576, min allocation
250
251
== creating image with preallocation full ==
252
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=full
253
-size=1048576, everything allocated
254
+size=1048576, max allocation
255
256
== creating image with preallocation falloc ==
257
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
258
-size=1048576, everything allocated
259
+size=1048576, max allocation
260
*** done
261
diff --git a/tests/qemu-iotests/178.out.qcow2 b/tests/qemu-iotests/178.out.qcow2
262
index XXXXXXX..XXXXXXX 100644
263
--- a/tests/qemu-iotests/178.out.qcow2
264
+++ b/tests/qemu-iotests/178.out.qcow2
265
@@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608
266
== raw input image with data (human) ==
267
268
Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824
269
-required size: 393216
270
+required size: 458752
271
fully allocated size: 1074135040
272
wrote 512/512 bytes at offset 512
273
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
274
@@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608
275
276
Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824
277
{
278
- "required": 393216,
279
+ "required": 458752,
280
"fully-allocated": 1074135040
281
}
282
wrote 512/512 bytes at offset 512
283
diff --git a/tests/qemu-iotests/221.out b/tests/qemu-iotests/221.out
284
index XXXXXXX..XXXXXXX 100644
285
--- a/tests/qemu-iotests/221.out
286
+++ b/tests/qemu-iotests/221.out
287
@@ -XXX,XX +XXX,XX @@ QA output created by 221
288
=== Check mapping of unaligned raw image ===
289
290
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65537
291
-[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
292
-[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
293
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
294
+{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
295
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
296
+{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
297
wrote 1/1 bytes at offset 65536
298
1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
299
-[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
300
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
301
+{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
302
{ "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
303
{ "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
304
-[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
305
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
306
+{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
307
{ "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
308
{ "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
309
*** done
310
diff --git a/tests/qemu-iotests/253.out b/tests/qemu-iotests/253.out
311
index XXXXXXX..XXXXXXX 100644
312
--- a/tests/qemu-iotests/253.out
313
+++ b/tests/qemu-iotests/253.out
314
@@ -XXX,XX +XXX,XX @@ QA output created by 253
315
=== Check mapping of unaligned raw image ===
316
317
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048575
318
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
319
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
320
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
321
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
322
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
323
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
324
wrote 65535/65535 bytes at offset 983040
325
63.999 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
326
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
327
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
328
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
329
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
330
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
331
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
332
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
333
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
334
*** done
335
--
66
--
336
2.21.0
67
2.40.1
337
338
diff view generated by jsdifflib
1
From: Denis Plotnikov <dplotnikov@virtuozzo.com>
1
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
2
2
3
The patch allows to provide a pattern file for write
3
We will add more and more checks so we need a better code structure in
4
command. There was no similar ability before.
4
parallels_co_check. Let each check performs in a separate loop in a
5
separate helper.
5
6
6
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
7
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
7
Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com
8
Reviewed-by: Denis V. Lunev <den@openvz.org>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Message-Id: <20230424093147.197643-8-alexander.ivanov@virtuozzo.com>
9
[mreitz: Keep optstring in alphabetical order]
10
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
11
---
12
---
12
qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++---
13
block/parallels.c | 75 +++++++++++++++++++++++++++++++----------------
13
1 file changed, 93 insertions(+), 6 deletions(-)
14
1 file changed, 49 insertions(+), 26 deletions(-)
14
15
15
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
16
diff --git a/block/parallels.c b/block/parallels.c
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/qemu-io-cmds.c
18
--- a/block/parallels.c
18
+++ b/qemu-io-cmds.c
19
+++ b/block/parallels.c
19
@@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p)
20
@@ -XXX,XX +XXX,XX @@ static void parallels_check_unclean(BlockDriverState *bs,
20
qemu_vfree(p);
21
}
21
}
22
}
22
23
23
+/*
24
+static int coroutine_fn GRAPH_RDLOCK
24
+ * qemu_io_alloc_from_file()
25
+parallels_check_outside_image(BlockDriverState *bs, BdrvCheckResult *res,
25
+ *
26
+ BdrvCheckMode fix)
26
+ * Allocates the buffer and populates it with the content of the given file
27
+ * up to @len bytes. If the file length is less than @len, then the buffer
28
+ * is populated with the file content cyclically.
29
+ *
30
+ * @blk - the block backend where the buffer content is going to be written to
31
+ * @len - the buffer length
32
+ * @file_name - the file to read the content from
33
+ *
34
+ * Returns: the buffer pointer on success
35
+ * NULL on error
36
+ */
37
+static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len,
38
+ const char *file_name)
39
+{
27
+{
40
+ char *buf, *buf_origin;
28
+ BDRVParallelsState *s = bs->opaque;
41
+ FILE *f = fopen(file_name, "r");
29
+ uint32_t i;
42
+ int pattern_len;
30
+ int64_t off, high_off, size;
43
+
31
+
44
+ if (!f) {
32
+ size = bdrv_getlength(bs->file->bs);
45
+ perror(file_name);
33
+ if (size < 0) {
46
+ return NULL;
34
+ res->check_errors++;
35
+ return size;
47
+ }
36
+ }
48
+
37
+
49
+ if (qemuio_misalign) {
38
+ high_off = 0;
50
+ len += MISALIGN_OFFSET;
39
+ for (i = 0; i < s->bat_size; i++) {
51
+ }
40
+ off = bat2sect(s, i) << BDRV_SECTOR_BITS;
52
+
41
+ if (off > size) {
53
+ buf_origin = buf = blk_blockalign(blk, len);
42
+ fprintf(stderr, "%s cluster %u is outside image\n",
54
+
43
+ fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i);
55
+ if (qemuio_misalign) {
44
+ res->corruptions++;
56
+ buf_origin += MISALIGN_OFFSET;
45
+ if (fix & BDRV_FIX_ERRORS) {
57
+ buf += MISALIGN_OFFSET;
46
+ parallels_set_bat_entry(s, i, 0);
58
+ len -= MISALIGN_OFFSET;
47
+ res->corruptions_fixed++;
59
+ }
48
+ }
60
+
49
+ continue;
61
+ pattern_len = fread(buf_origin, 1, len, f);
50
+ }
62
+
51
+ if (high_off < off) {
63
+ if (ferror(f)) {
52
+ high_off = off;
64
+ perror(file_name);
65
+ goto error;
66
+ }
67
+
68
+ if (pattern_len == 0) {
69
+ fprintf(stderr, "%s: file is empty\n", file_name);
70
+ goto error;
71
+ }
72
+
73
+ fclose(f);
74
+
75
+ if (len > pattern_len) {
76
+ len -= pattern_len;
77
+ buf += pattern_len;
78
+
79
+ while (len > 0) {
80
+ size_t len_to_copy = MIN(pattern_len, len);
81
+
82
+ memcpy(buf, buf_origin, len_to_copy);
83
+
84
+ len -= len_to_copy;
85
+ buf += len_to_copy;
86
+ }
53
+ }
87
+ }
54
+ }
88
+
55
+
89
+ return buf_origin;
56
+ if (high_off == 0) {
57
+ res->image_end_offset = s->data_end << BDRV_SECTOR_BITS;
58
+ } else {
59
+ res->image_end_offset = high_off + s->cluster_size;
60
+ s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS;
61
+ }
90
+
62
+
91
+error:
63
+ return 0;
92
+ qemu_io_free(buf_origin);
93
+ return NULL;
94
+}
64
+}
95
+
65
+
96
static void dump_buffer(const void *buffer, int64_t offset, int64_t len)
66
static int coroutine_fn GRAPH_RDLOCK
67
parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
68
BdrvCheckMode fix)
97
{
69
{
98
uint64_t i;
70
BDRVParallelsState *s = bs->opaque;
99
@@ -XXX,XX +XXX,XX @@ static void write_help(void)
71
- int64_t size, prev_off, high_off;
100
" -n, -- with -z, don't allow slow fallback\n"
72
- int ret = 0;
101
" -p, -- ignored for backwards compatibility\n"
73
+ int64_t size, prev_off;
102
" -P, -- use different pattern to fill file\n"
74
+ int ret;
103
+" -s, -- use a pattern file to fill the write buffer\n"
75
uint32_t i;
104
" -C, -- report statistics in a machine parsable format\n"
76
105
" -q, -- quiet mode, do not show I/O statistics\n"
77
size = bdrv_getlength(bs->file->bs);
106
" -u, -- with -z, allow unmapping\n"
78
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
107
@@ -XXX,XX +XXX,XX @@ static const cmdinfo_t write_cmd = {
79
108
.perm = BLK_PERM_WRITE,
80
parallels_check_unclean(bs, res, fix);
109
.argmin = 2,
81
110
.argmax = -1,
82
+ ret = parallels_check_outside_image(bs, res, fix);
111
- .args = "[-bcCfnquz] [-P pattern] off len",
83
+ if (ret < 0) {
112
+ .args = "[-bcCfnquz] [-P pattern | -s source_file] off len",
84
+ goto out;
113
.oneline = "writes a number of bytes at a specified offset",
85
+ }
114
.help = write_help,
86
+
115
};
87
res->bfi.total_clusters = s->bat_size;
116
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
88
res->bfi.compressed_clusters = 0; /* compression is not supported */
117
{
89
118
struct timespec t1, t2;
90
- high_off = 0;
119
bool Cflag = false, qflag = false, bflag = false;
91
prev_off = 0;
120
- bool Pflag = false, zflag = false, cflag = false;
92
for (i = 0; i < s->bat_size; i++) {
121
+ bool Pflag = false, zflag = false, cflag = false, sflag = false;
93
int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS;
122
int flags = 0;
94
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
123
int c, cnt, ret;
95
continue;
124
char *buf = NULL;
96
}
125
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
97
126
/* Some compilers get confused and warn if this is not initialized. */
98
- /* cluster outside the image */
127
int64_t total = 0;
99
- if (off > size) {
128
int pattern = 0xcd;
100
- fprintf(stderr, "%s cluster %u is outside image\n",
129
+ const char *file_name = NULL;
101
- fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i);
130
102
- res->corruptions++;
131
- while ((c = getopt(argc, argv, "bcCfnpP:quz")) != -1) {
103
- if (fix & BDRV_FIX_ERRORS) {
132
+ while ((c = getopt(argc, argv, "bcCfnpP:qs:uz")) != -1) {
104
- parallels_set_bat_entry(s, i, 0);
133
switch (c) {
105
- res->corruptions_fixed++;
134
case 'b':
106
- }
135
bflag = true;
107
- prev_off = 0;
136
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
108
- continue;
137
case 'q':
109
- }
138
qflag = true;
110
-
139
break;
111
res->bfi.allocated_clusters++;
140
+ case 's':
112
- if (off > high_off) {
141
+ sflag = true;
113
- high_off = off;
142
+ file_name = optarg;
114
- }
143
+ break;
115
144
case 'u':
116
if (prev_off != 0 && (prev_off + s->cluster_size) != off) {
145
flags |= BDRV_REQ_MAY_UNMAP;
117
res->bfi.fragmented_clusters++;
146
break;
118
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
147
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
119
prev_off = off;
148
return -EINVAL;
149
}
120
}
150
121
151
- if (zflag && Pflag) {
122
- if (high_off == 0) {
152
- printf("-z and -P cannot be specified at the same time\n");
123
- res->image_end_offset = s->data_end << BDRV_SECTOR_BITS;
153
+ if (zflag + Pflag + sflag > 1) {
124
- } else {
154
+ printf("Only one of -z, -P, and -s "
125
- res->image_end_offset = high_off + s->cluster_size;
155
+ "can be specified at the same time\n");
126
- s->data_end = res->image_end_offset >> BDRV_SECTOR_BITS;
156
return -EINVAL;
127
- }
157
}
128
-
158
129
if (size > res->image_end_offset) {
159
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
130
int64_t count;
160
}
131
count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size);
161
162
if (!zflag) {
163
- buf = qemu_io_alloc(blk, count, pattern);
164
+ if (sflag) {
165
+ buf = qemu_io_alloc_from_file(blk, count, file_name);
166
+ if (!buf) {
167
+ return -EINVAL;
168
+ }
169
+ } else {
170
+ buf = qemu_io_alloc(blk, count, pattern);
171
+ }
172
}
173
174
clock_gettime(CLOCK_MONOTONIC, &t1);
175
--
132
--
176
2.21.0
133
2.40.1
177
178
diff view generated by jsdifflib
1
We had a test for a case where relative extent paths did not work, but
1
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
2
unfortunately we just fixed the underlying problem, so it works now.
3
This patch adds a new test case that still fails.
4
2
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
Exclude out-of-image clusters from allocated and fragmented clusters
6
Reviewed-by: John Snow <jsnow@redhat.com>
4
calculation.
7
Message-id: 20190815153638.4600-4-mreitz@redhat.com
5
8
Reviewed-by: John Snow <jsnow@redhat.com>
6
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Message-Id: <20230424093147.197643-9-alexander.ivanov@virtuozzo.com>
8
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
9
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
10
---
10
---
11
tests/qemu-iotests/059 | 27 +++++++++++++++++++++++++++
11
block/parallels.c | 6 +++++-
12
tests/qemu-iotests/059.out | 4 ++++
12
1 file changed, 5 insertions(+), 1 deletion(-)
13
2 files changed, 31 insertions(+)
14
13
15
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
14
diff --git a/block/parallels.c b/block/parallels.c
16
index XXXXXXX..XXXXXXX 100755
17
--- a/tests/qemu-iotests/059
18
+++ b/tests/qemu-iotests/059
19
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
20
21
echo
22
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
23
+
24
+echo '--- blkdebug ---'
25
# Should work, because bdrv_dirname() works fine with blkdebug
26
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
27
$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
28
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TE
29
| _filter_testdir | _filter_imgfmt | _filter_img_info
30
_cleanup_test_img
31
32
+echo '--- quorum ---'
33
+# Should not work, because bdrv_dirname() does not work with quorum
34
+IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
35
+cp "$TEST_IMG" "$TEST_IMG.orig"
36
+
37
+filename="json:{
38
+ \"driver\": \"$IMGFMT\",
39
+ \"file\": {
40
+ \"driver\": \"quorum\",
41
+ \"children\": [ {
42
+ \"driver\": \"file\",
43
+ \"filename\": \"$TEST_IMG\"
44
+ }, {
45
+ \"driver\": \"file\",
46
+ \"filename\": \"$TEST_IMG.orig\"
47
+ } ],
48
+ \"vote-threshold\": 1
49
+ } }"
50
+
51
+filename=$(echo "$filename" | tr '\n' ' ' | sed -e 's/\s\+/ /g')
52
+$QEMU_IMG info "$filename" 2>&1 \
53
+ | sed -e "s/'json:[^']*'/\$QUORUM_FILE/g" \
54
+ | _filter_testdir | _filter_imgfmt | _filter_img_info
55
+
56
+
57
echo
58
echo "=== Testing version 3 ==="
59
_use_sample_img iotest-version3.vmdk.bz2
60
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
61
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
62
--- a/tests/qemu-iotests/059.out
16
--- a/block/parallels.c
63
+++ b/tests/qemu-iotests/059.out
17
+++ b/block/parallels.c
64
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
18
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
65
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
19
prev_off = 0;
66
20
for (i = 0; i < s->bat_size; i++) {
67
=== Testing monolithicFlat with internally generated JSON file name ===
21
int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS;
68
+--- blkdebug ---
22
- if (off == 0) {
69
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
23
+ /*
70
format name: IMGFMT
24
+ * If BDRV_FIX_ERRORS is not set, out-of-image BAT entries were not
71
cluster size: 0 bytes
25
+ * fixed. Skip not allocated and out-of-image BAT entries.
72
vm state offset: 0 bytes
26
+ */
73
+--- quorum ---
27
+ if (off == 0 || off + s->cluster_size > res->image_end_offset) {
74
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
28
prev_off = 0;
75
+qemu-img: Could not open $QUORUM_FILE: Cannot use relative paths with VMDK descriptor file $QUORUM_FILE: Cannot generate a base directory for quorum nodes
29
continue;
76
30
}
77
=== Testing version 3 ===
78
image: TEST_DIR/iotest-version3.IMGFMT
79
--
31
--
80
2.21.0
32
2.40.1
81
82
diff view generated by jsdifflib
1
The error message for the test case where we have a quorum node for
1
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
2
which no directory name can be generated is different: For
3
twoGbMaxExtentSparse, it complains that it cannot open the extent file.
4
For other (sub)formats, it just notes that it cannot determine the
5
backing file path. Both are fine, but just disable twoGbMaxExtentSparse
6
for simplicity's sake.
7
2
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
We will add more and more checks so we need a better code structure
9
Reviewed-by: John Snow <jsnow@redhat.com>
4
in parallels_co_check. Let each check performs in a separate loop
10
Message-id: 20190815153638.4600-7-mreitz@redhat.com
5
in a separate helper.
11
Reviewed-by: John Snow <jsnow@redhat.com>
6
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
8
Message-Id: <20230424093147.197643-10-alexander.ivanov@virtuozzo.com>
9
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
10
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
13
---
11
---
14
tests/qemu-iotests/110 | 3 ++-
12
block/parallels.c | 74 ++++++++++++++++++++++++++++-------------------
15
1 file changed, 2 insertions(+), 1 deletion(-)
13
1 file changed, 45 insertions(+), 29 deletions(-)
16
14
17
diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110
15
diff --git a/block/parallels.c b/block/parallels.c
18
index XXXXXXX..XXXXXXX 100755
16
index XXXXXXX..XXXXXXX 100644
19
--- a/tests/qemu-iotests/110
17
--- a/block/parallels.c
20
+++ b/tests/qemu-iotests/110
18
+++ b/block/parallels.c
21
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
19
@@ -XXX,XX +XXX,XX @@ parallels_check_outside_image(BlockDriverState *bs, BdrvCheckResult *res,
22
# Any format supporting backing files
20
}
23
_supported_fmt qed qcow qcow2 vmdk
21
24
_supported_proto file
22
static int coroutine_fn GRAPH_RDLOCK
25
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
23
-parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
26
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
24
- BdrvCheckMode fix)
27
+ "subformat=twoGbMaxExtentSparse"
25
+parallels_check_leak(BlockDriverState *bs, BdrvCheckResult *res,
28
26
+ BdrvCheckMode fix)
29
TEST_IMG_REL=$(basename "$TEST_IMG")
27
{
28
BDRVParallelsState *s = bs->opaque;
29
- int64_t size, prev_off;
30
+ int64_t size;
31
int ret;
32
- uint32_t i;
33
34
size = bdrv_getlength(bs->file->bs);
35
if (size < 0) {
36
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
37
return size;
38
}
39
40
+ if (size > res->image_end_offset) {
41
+ int64_t count;
42
+ count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size);
43
+ fprintf(stderr, "%s space leaked at the end of the image %" PRId64 "\n",
44
+ fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR",
45
+ size - res->image_end_offset);
46
+ res->leaks += count;
47
+ if (fix & BDRV_FIX_LEAKS) {
48
+ Error *local_err = NULL;
49
+
50
+ /*
51
+ * In order to really repair the image, we must shrink it.
52
+ * That means we have to pass exact=true.
53
+ */
54
+ ret = bdrv_co_truncate(bs->file, res->image_end_offset, true,
55
+ PREALLOC_MODE_OFF, 0, &local_err);
56
+ if (ret < 0) {
57
+ error_report_err(local_err);
58
+ res->check_errors++;
59
+ return ret;
60
+ }
61
+ res->leaks_fixed += count;
62
+ }
63
+ }
64
+
65
+ return 0;
66
+}
67
+
68
+static int coroutine_fn GRAPH_RDLOCK
69
+parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
70
+ BdrvCheckMode fix)
71
+{
72
+ BDRVParallelsState *s = bs->opaque;
73
+ int64_t prev_off;
74
+ int ret;
75
+ uint32_t i;
76
+
77
qemu_co_mutex_lock(&s->lock);
78
79
parallels_check_unclean(bs, res, fix);
80
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
81
goto out;
82
}
83
84
+ ret = parallels_check_leak(bs, res, fix);
85
+ if (ret < 0) {
86
+ goto out;
87
+ }
88
+
89
res->bfi.total_clusters = s->bat_size;
90
res->bfi.compressed_clusters = 0; /* compression is not supported */
91
92
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
93
prev_off = off;
94
}
95
96
- if (size > res->image_end_offset) {
97
- int64_t count;
98
- count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size);
99
- fprintf(stderr, "%s space leaked at the end of the image %" PRId64 "\n",
100
- fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR",
101
- size - res->image_end_offset);
102
- res->leaks += count;
103
- if (fix & BDRV_FIX_LEAKS) {
104
- Error *local_err = NULL;
105
-
106
- /*
107
- * In order to really repair the image, we must shrink it.
108
- * That means we have to pass exact=true.
109
- */
110
- ret = bdrv_co_truncate(bs->file, res->image_end_offset, true,
111
- PREALLOC_MODE_OFF, 0, &local_err);
112
- if (ret < 0) {
113
- error_report_err(local_err);
114
- res->check_errors++;
115
- goto out;
116
- }
117
- res->leaks_fixed += count;
118
- }
119
- }
120
-
121
out:
122
qemu_co_mutex_unlock(&s->lock);
30
123
31
--
124
--
32
2.21.0
125
2.40.1
33
34
diff view generated by jsdifflib
1
This makes iotest 033 pass with e.g. subformat=monolithicFlat. It also
1
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
2
turns a former error in 059 into success.
3
2
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
We will add more and more checks so we need a better code structure
5
Message-id: 20190815153638.4600-3-mreitz@redhat.com
4
in parallels_co_check. Let each check performs in a separate loop
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
in a separate helper.
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
7
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
8
Reviewed-by: Denis V. Lunev <den@openvz.org>
9
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
10
Message-Id: <20230424093147.197643-11-alexander.ivanov@virtuozzo.com>
11
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
12
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
8
---
13
---
9
block/vmdk.c | 54 ++++++++++++++++++++++++--------------
14
block/parallels.c | 52 +++++++++++++++++++++++++++--------------------
10
tests/qemu-iotests/059 | 7 +++--
15
1 file changed, 30 insertions(+), 22 deletions(-)
11
tests/qemu-iotests/059.out | 4 ++-
12
3 files changed, 42 insertions(+), 23 deletions(-)
13
16
14
diff --git a/block/vmdk.c b/block/vmdk.c
17
diff --git a/block/parallels.c b/block/parallels.c
15
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
16
--- a/block/vmdk.c
19
--- a/block/parallels.c
17
+++ b/block/vmdk.c
20
+++ b/block/parallels.c
18
@@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s)
21
@@ -XXX,XX +XXX,XX @@ parallels_check_leak(BlockDriverState *bs, BdrvCheckResult *res,
22
return 0;
19
}
23
}
20
24
21
static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
25
-static int coroutine_fn GRAPH_RDLOCK
22
- const char *desc_file_path, QDict *options,
26
-parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
23
- Error **errp)
27
- BdrvCheckMode fix)
24
+ QDict *options, Error **errp)
28
+static void parallels_collect_statistics(BlockDriverState *bs,
29
+ BdrvCheckResult *res,
30
+ BdrvCheckMode fix)
25
{
31
{
26
int ret;
32
BDRVParallelsState *s = bs->opaque;
27
int matches;
33
- int64_t prev_off;
28
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
34
- int ret;
29
const char *p, *np;
35
+ int64_t off, prev_off;
30
int64_t sectors = 0;
36
uint32_t i;
31
int64_t flat_offset;
37
32
+ char *desc_file_dir = NULL;
38
- qemu_co_mutex_lock(&s->lock);
33
char *extent_path;
39
-
34
BdrvChild *extent_file;
40
- parallels_check_unclean(bs, res, fix);
35
BDRVVmdkState *s = bs->opaque;
41
-
36
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
42
- ret = parallels_check_outside_image(bs, res, fix);
43
- if (ret < 0) {
44
- goto out;
45
- }
46
-
47
- ret = parallels_check_leak(bs, res, fix);
48
- if (ret < 0) {
49
- goto out;
50
- }
51
-
52
res->bfi.total_clusters = s->bat_size;
53
res->bfi.compressed_clusters = 0; /* compression is not supported */
54
55
prev_off = 0;
56
for (i = 0; i < s->bat_size; i++) {
57
- int64_t off = bat2sect(s, i) << BDRV_SECTOR_BITS;
58
+ off = bat2sect(s, i) << BDRV_SECTOR_BITS;
59
/*
60
* If BDRV_FIX_ERRORS is not set, out-of-image BAT entries were not
61
* fixed. Skip not allocated and out-of-image BAT entries.
62
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
37
continue;
63
continue;
38
}
64
}
39
65
40
- if (!path_is_absolute(fname) && !path_has_protocol(fname) &&
66
- res->bfi.allocated_clusters++;
41
- !desc_file_path[0])
67
-
42
- {
68
if (prev_off != 0 && (prev_off + s->cluster_size) != off) {
43
- bdrv_refresh_filename(bs->file->bs);
69
res->bfi.fragmented_clusters++;
44
- error_setg(errp, "Cannot use relative extent paths with VMDK "
45
- "descriptor file '%s'", bs->file->bs->filename);
46
- return -EINVAL;
47
- }
48
+ if (path_is_absolute(fname)) {
49
+ extent_path = g_strdup(fname);
50
+ } else {
51
+ if (!desc_file_dir) {
52
+ desc_file_dir = bdrv_dirname(bs->file->bs, errp);
53
+ if (!desc_file_dir) {
54
+ bdrv_refresh_filename(bs->file->bs);
55
+ error_prepend(errp, "Cannot use relative paths with VMDK "
56
+ "descriptor file '%s': ",
57
+ bs->file->bs->filename);
58
+ ret = -EINVAL;
59
+ goto out;
60
+ }
61
+ }
62
63
- extent_path = path_combine(desc_file_path, fname);
64
+ extent_path = g_strconcat(desc_file_dir, fname, NULL);
65
+ }
66
67
ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents);
68
assert(ret < 32);
69
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
70
g_free(extent_path);
71
if (local_err) {
72
error_propagate(errp, local_err);
73
- return -EINVAL;
74
+ ret = -EINVAL;
75
+ goto out;
76
}
70
}
77
71
prev_off = off;
78
/* save to extents array */
72
+ res->bfi.allocated_clusters++;
79
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
80
0, 0, 0, 0, 0, &extent, errp);
81
if (ret < 0) {
82
bdrv_unref_child(bs, extent_file);
83
- return ret;
84
+ goto out;
85
}
86
extent->flat_start_offset = flat_offset << 9;
87
} else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) {
88
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
89
g_free(buf);
90
if (ret) {
91
bdrv_unref_child(bs, extent_file);
92
- return ret;
93
+ goto out;
94
}
95
extent = &s->extents[s->num_extents - 1];
96
} else if (!strcmp(type, "SESPARSE")) {
97
ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp);
98
if (ret) {
99
bdrv_unref_child(bs, extent_file);
100
- return ret;
101
+ goto out;
102
}
103
extent = &s->extents[s->num_extents - 1];
104
} else {
105
error_setg(errp, "Unsupported extent type '%s'", type);
106
bdrv_unref_child(bs, extent_file);
107
- return -ENOTSUP;
108
+ ret = -ENOTSUP;
109
+ goto out;
110
}
111
extent->type = g_strdup(type);
112
}
73
}
113
- return 0;
74
+}
114
+
75
+
115
+ ret = 0;
76
+static int coroutine_fn GRAPH_RDLOCK
116
+ goto out;
77
+parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
117
78
+ BdrvCheckMode fix)
118
invalid:
79
+{
119
np = next_line(p);
80
+ BDRVParallelsState *s = bs->opaque;
120
@@ -XXX,XX +XXX,XX @@ invalid:
81
+ int ret;
121
np--;
122
}
123
error_setg(errp, "Invalid extent line: %.*s", (int)(np - p), p);
124
- return -EINVAL;
125
+ ret = -EINVAL;
126
+
82
+
127
+out:
83
+ qemu_co_mutex_lock(&s->lock);
128
+ g_free(desc_file_dir);
84
+
129
+ return ret;
85
+ parallels_check_unclean(bs, res, fix);
130
}
86
+
131
87
+ ret = parallels_check_outside_image(bs, res, fix);
132
static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
88
+ if (ret < 0) {
133
@@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
89
+ goto out;
134
}
90
+ }
135
s->create_type = g_strdup(ct);
91
+
136
s->desc_offset = 0;
92
+ ret = parallels_check_leak(bs, res, fix);
137
- ret = vmdk_parse_extents(buf, bs, bs->file->bs->exact_filename, options,
93
+ if (ret < 0) {
138
- errp);
94
+ goto out;
139
+ ret = vmdk_parse_extents(buf, bs, options, errp);
95
+ }
140
exit:
96
+
141
return ret;
97
+ parallels_collect_statistics(bs, res, fix);
142
}
98
143
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
99
out:
144
index XXXXXXX..XXXXXXX 100755
100
qemu_co_mutex_unlock(&s->lock);
145
--- a/tests/qemu-iotests/059
146
+++ b/tests/qemu-iotests/059
147
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
148
149
echo
150
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
151
+# Should work, because bdrv_dirname() works fine with blkdebug
152
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
153
-$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" 2>&1 \
154
- | _filter_testdir | _filter_imgfmt
155
+$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
156
+ -c info \
157
+ 2>&1 \
158
+ | _filter_testdir | _filter_imgfmt | _filter_img_info
159
_cleanup_test_img
160
161
echo
162
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
163
index XXXXXXX..XXXXXXX 100644
164
--- a/tests/qemu-iotests/059.out
165
+++ b/tests/qemu-iotests/059.out
166
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
167
168
=== Testing monolithicFlat with internally generated JSON file name ===
169
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
170
-qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}'
171
+format name: IMGFMT
172
+cluster size: 0 bytes
173
+vm state offset: 0 bytes
174
175
=== Testing version 3 ===
176
image: TEST_DIR/iotest-version3.IMGFMT
177
--
101
--
178
2.21.0
102
2.40.1
179
180
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
2
2
3
It's wrong to OR shared permissions. It may lead to crash on further
3
Replace the way we use mutex in parallels_co_check() for simplier
4
permission updates.
4
and less error prone code.
5
Also, no needs to consider previously calculated permissions, as at
6
this point we already bind all new parents and bdrv_get_cumulative_perm
7
result is enough. So fix the bug by just set permissions by
8
bdrv_get_cumulative_perm result.
9
5
10
Bug was introduced in long ago 234ac1a9025, in 2.9.
6
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
7
Reviewed-by: Denis V. Lunev <den@openvz.org>
8
Message-Id: <20230424093147.197643-12-alexander.ivanov@virtuozzo.com>
9
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
10
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
11
---
12
block/parallels.c | 33 ++++++++++++++-------------------
13
1 file changed, 14 insertions(+), 19 deletions(-)
11
14
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
15
diff --git a/block/parallels.c b/block/parallels.c
13
Message-id: 20190824100740.61635-1-vsementsov@virtuozzo.com
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
block.c | 5 ++---
17
1 file changed, 2 insertions(+), 3 deletions(-)
18
19
diff --git a/block.c b/block.c
20
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
21
--- a/block.c
17
--- a/block/parallels.c
22
+++ b/block.c
18
+++ b/block/parallels.c
23
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
19
@@ -XXX,XX +XXX,XX @@ parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
24
{
20
BDRVParallelsState *s = bs->opaque;
25
BdrvChild *c, *next;
26
GSList *list = NULL, *p;
27
- uint64_t old_perm, old_shared;
28
uint64_t perm = 0, shared = BLK_PERM_ALL;
29
int ret;
21
int ret;
30
22
31
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
23
- qemu_co_mutex_lock(&s->lock);
32
bdrv_unref(from);
24
+ WITH_QEMU_LOCK_GUARD(&s->lock) {
25
+ parallels_check_unclean(bs, res, fix);
26
27
- parallels_check_unclean(bs, res, fix);
28
+ ret = parallels_check_outside_image(bs, res, fix);
29
+ if (ret < 0) {
30
+ return ret;
31
+ }
32
33
- ret = parallels_check_outside_image(bs, res, fix);
34
- if (ret < 0) {
35
- goto out;
36
- }
37
+ ret = parallels_check_leak(bs, res, fix);
38
+ if (ret < 0) {
39
+ return ret;
40
+ }
41
42
- ret = parallels_check_leak(bs, res, fix);
43
- if (ret < 0) {
44
- goto out;
45
+ parallels_collect_statistics(bs, res, fix);
33
}
46
}
34
47
35
- bdrv_get_cumulative_perm(to, &old_perm, &old_shared);
48
- parallels_collect_statistics(bs, res, fix);
36
- bdrv_set_perm(to, old_perm | perm, old_shared | shared);
49
-
37
+ bdrv_get_cumulative_perm(to, &perm, &shared);
50
-out:
38
+ bdrv_set_perm(to, perm, shared);
51
- qemu_co_mutex_unlock(&s->lock);
39
52
-
40
out:
53
- if (ret == 0) {
41
g_slist_free(list);
54
- ret = bdrv_co_flush(bs);
55
- if (ret < 0) {
56
- res->check_errors++;
57
- }
58
+ ret = bdrv_co_flush(bs);
59
+ if (ret < 0) {
60
+ res->check_errors++;
61
}
62
63
return ret;
42
--
64
--
43
2.21.0
65
2.40.1
44
45
diff view generated by jsdifflib
1
From: Stefan Hajnoczi <stefanha@redhat.com>
1
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
2
2
3
Fixes: a6b257a08e3d72219f03e461a52152672fec0612
3
All the offsets in the BAT must be lower than the file size.
4
("file-posix: Handle undetectable alignment")
4
Fix the check condition for correct check.
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5
6
Message-id: 20190827101328.4062-1-stefanha@redhat.com
6
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
7
Reviewed-by: Thomas Huth <thuth@redhat.com>
7
Reviewed-by: Denis V. Lunev <den@openvz.org>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
Message-Id: <20230424093147.197643-13-alexander.ivanov@virtuozzo.com>
9
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
10
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
9
---
11
---
10
block/file-posix.c | 2 +-
12
block/parallels.c | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
13
1 file changed, 1 insertion(+), 1 deletion(-)
12
14
13
diff --git a/block/file-posix.c b/block/file-posix.c
15
diff --git a/block/parallels.c b/block/parallels.c
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/block/file-posix.c
17
--- a/block/parallels.c
16
+++ b/block/file-posix.c
18
+++ b/block/parallels.c
17
@@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
19
@@ -XXX,XX +XXX,XX @@ parallels_check_outside_image(BlockDriverState *bs, BdrvCheckResult *res,
18
for (i = 0; i < ARRAY_SIZE(alignments); i++) {
20
high_off = 0;
19
align = alignments[i];
21
for (i = 0; i < s->bat_size; i++) {
20
if (raw_is_io_aligned(fd, buf + align, max_align)) {
22
off = bat2sect(s, i) << BDRV_SECTOR_BITS;
21
- /* Fallback to request_aligment. */
23
- if (off > size) {
22
+ /* Fallback to request_alignment. */
24
+ if (off + s->cluster_size > size) {
23
s->buf_align = (align != 1) ? align : bs->bl.request_alignment;
25
fprintf(stderr, "%s cluster %u is outside image\n",
24
break;
26
fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i);
25
}
27
res->corruptions++;
26
--
28
--
27
2.21.0
29
2.40.1
28
29
diff view generated by jsdifflib
1
fe646693acc changed qemu-img create's output so that it no longer prints
1
From: Jean-Louis Dupond <jean-louis@dupond.be>
2
single quotes around parameter values. The subformat and adapter_type
2
3
filters in _filter_img_create() have never been adapted to that change.
3
When we for example have a sparse qcow2 image and discard: unmap is enabled,
4
4
there can be a lot of fragmentation in the image after some time. Especially on VM's
5
Fixes: fe646693acc13ac48b98435d14149ab04dc597bc
5
that do a lot of writes/deletes.
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
This causes the qcow2 image to grow even over 110% of its virtual size,
7
Reviewed-by: John Snow <jsnow@redhat.com>
7
because the free gaps in the image get too small to allocate new
8
Message-id: 20190815153638.4600-2-mreitz@redhat.com
8
continuous clusters. So it allocates new space at the end of the image.
9
Reviewed-by: John Snow <jsnow@redhat.com>
9
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Disabling discard is not an option, as discard is needed to keep the
11
incremental backup size as low as possible. Without discard, the
12
incremental backups would become large, as qemu thinks it's just dirty
13
blocks but it doesn't know the blocks are unneeded.
14
So we need to avoid fragmentation but also 'empty' the unneeded blocks in
15
the image to have a small incremental backup.
16
17
In addition, we also want to send the discards further down the stack, so
18
the underlying blocks are still discarded.
19
20
Therefor we introduce a new qcow2 option "discard-no-unref".
21
When setting this option to true, discards will no longer have the qcow2
22
driver relinquish cluster allocations. Other than that, the request is
23
handled as normal: All clusters in range are marked as zero, and, if
24
pass-discard-request is true, it is passed further down the stack.
25
The only difference is that the now-zero clusters are preallocated
26
instead of being unallocated.
27
This will avoid fragmentation on the qcow2 image.
28
29
Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1621
30
Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
31
Message-Id: <20230605084523.34134-2-jean-louis@dupond.be>
32
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
33
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
11
---
34
---
12
tests/qemu-iotests/059.out | 16 ++++++++--------
35
qapi/block-core.json | 12 ++++++++++++
13
tests/qemu-iotests/common.filter | 4 ++--
36
block/qcow2.h | 3 +++
14
2 files changed, 10 insertions(+), 10 deletions(-)
37
block/qcow2-cluster.c | 32 ++++++++++++++++++++++++++++----
15
38
block/qcow2.c | 18 ++++++++++++++++++
16
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
39
qemu-options.hx | 12 ++++++++++++
17
index XXXXXXX..XXXXXXX 100644
40
5 files changed, 73 insertions(+), 4 deletions(-)
18
--- a/tests/qemu-iotests/059.out
41
19
+++ b/tests/qemu-iotests/059.out
42
diff --git a/qapi/block-core.json b/qapi/block-core.json
20
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
43
index XXXXXXX..XXXXXXX 100644
21
qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big
44
--- a/qapi/block-core.json
22
45
+++ b/qapi/block-core.json
23
=== Testing monolithicFlat creation and opening ===
46
@@ -XXX,XX +XXX,XX @@
24
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
47
# @pass-discard-other: whether discard requests for the data source
25
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
48
# should be issued on other occasions where a cluster gets freed
26
image: TEST_DIR/t.IMGFMT
49
#
27
file format: IMGFMT
50
+# @discard-no-unref: when enabled, discards from the guest will not cause
28
virtual size: 2 GiB (2147483648 bytes)
51
+# cluster allocations to be relinquished. This prevents qcow2 fragmentation
29
52
+# that would be caused by such discards. Besides potential
30
=== Testing monolithicFlat with zeroed_grain ===
53
+# performance degradation, such fragmentation can lead to increased
31
qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain
54
+# allocation of clusters past the end of the image file,
32
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
55
+# resulting in image files whose file length can grow much larger
33
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
56
+# than their guest disk size would suggest.
34
57
+# If image file length is of concern (e.g. when storing qcow2
35
=== Testing big twoGbMaxExtentFlat ===
58
+# images directly on block devices), you should consider enabling
36
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMaxExtentFlat
59
+# this option. (since 8.1)
37
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000
60
+#
38
image: TEST_DIR/t.vmdk
61
# @overlap-check: which overlap checks to perform for writes to the
39
file format: vmdk
62
# image, defaults to 'cached' (since 2.2)
40
virtual size: 0.977 TiB (1073741824000 bytes)
63
#
41
@@ -XXX,XX +XXX,XX @@ Format specific information:
64
@@ -XXX,XX +XXX,XX @@
42
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 12582912 VMFS "dummy.IMGFMT" 1
65
'*pass-discard-request': 'bool',
43
66
'*pass-discard-snapshot': 'bool',
44
=== Testing truncated sparse ===
67
'*pass-discard-other': 'bool',
45
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 subformat=monolithicSparse
68
+ '*discard-no-unref': 'bool',
46
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400
69
'*overlap-check': 'Qcow2OverlapChecks',
47
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes
70
'*cache-size': 'int',
48
71
'*l2-cache-size': 'int',
49
=== Converting to streamOptimized from image with small cluster size===
72
diff --git a/block/qcow2.h b/block/qcow2.h
50
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
73
index XXXXXXX..XXXXXXX 100644
51
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
74
--- a/block/qcow2.h
52
75
+++ b/block/qcow2.h
53
=== Testing monolithicFlat with internally generated JSON file name ===
76
@@ -XXX,XX +XXX,XX @@
54
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 subformat=monolithicFlat
77
#define QCOW2_OPT_DISCARD_REQUEST "pass-discard-request"
55
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
78
#define QCOW2_OPT_DISCARD_SNAPSHOT "pass-discard-snapshot"
56
qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}'
79
#define QCOW2_OPT_DISCARD_OTHER "pass-discard-other"
57
80
+#define QCOW2_OPT_DISCARD_NO_UNREF "discard-no-unref"
58
=== Testing version 3 ===
81
#define QCOW2_OPT_OVERLAP "overlap-check"
59
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 64931328
82
#define QCOW2_OPT_OVERLAP_TEMPLATE "overlap-check.template"
60
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
83
#define QCOW2_OPT_OVERLAP_MAIN_HEADER "overlap-check.main-header"
61
84
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVQcow2State {
62
=== Testing 4TB monolithicFlat creation and IO ===
85
63
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 subformat=monolithicFlat
86
bool discard_passthrough[QCOW2_DISCARD_MAX];
64
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104
87
65
image: TEST_DIR/t.IMGFMT
88
+ bool discard_no_unref;
66
file format: IMGFMT
89
+
67
virtual size: 4 TiB (4398046511104 bytes)
90
int overlap_check; /* bitmask of Qcow2MetadataOverlap values */
68
@@ -XXX,XX +XXX,XX @@ read 1024/1024 bytes at offset 966367641600
91
bool signaled_corruption;
69
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
92
70
93
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
71
=== Testing qemu-img map on extents ===
94
index XXXXXXX..XXXXXXX 100644
72
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=monolithicSparse
95
--- a/block/qcow2-cluster.c
73
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
96
+++ b/block/qcow2-cluster.c
74
wrote 1024/1024 bytes at offset 65024
97
@@ -XXX,XX +XXX,XX @@ static int discard_in_l2_slice(BlockDriverState *bs, uint64_t offset,
75
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
98
uint64_t new_l2_bitmap = old_l2_bitmap;
76
wrote 1024/1024 bytes at offset 2147483136
99
QCow2ClusterType cluster_type =
77
@@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File
100
qcow2_get_cluster_type(bs, old_l2_entry);
78
0 0x20000 0x3f0000 TEST_DIR/t.vmdk
101
+ bool keep_reference = (cluster_type != QCOW2_CLUSTER_COMPRESSED) &&
79
0x7fff0000 0x20000 0x410000 TEST_DIR/t.vmdk
102
+ !full_discard &&
80
0x140000000 0x10000 0x430000 TEST_DIR/t.vmdk
103
+ (s->discard_no_unref &&
81
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=twoGbMaxExtentSparse
104
+ type == QCOW2_DISCARD_REQUEST);
82
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
105
83
wrote 1024/1024 bytes at offset 65024
106
/*
84
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
107
* If full_discard is true, the cluster should not read back as zeroes,
85
wrote 1024/1024 bytes at offset 2147483136
108
@@ -XXX,XX +XXX,XX @@ static int discard_in_l2_slice(BlockDriverState *bs, uint64_t offset,
86
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
109
new_l2_entry = new_l2_bitmap = 0;
87
index XXXXXXX..XXXXXXX 100644
110
} else if (bs->backing || qcow2_cluster_is_allocated(cluster_type)) {
88
--- a/tests/qemu-iotests/common.filter
111
if (has_subclusters(s)) {
89
+++ b/tests/qemu-iotests/common.filter
112
- new_l2_entry = 0;
90
@@ -XXX,XX +XXX,XX @@ _filter_img_create()
113
+ if (keep_reference) {
91
-e "s# compat6=\\(on\\|off\\)##g" \
114
+ new_l2_entry = old_l2_entry;
92
-e "s# static=\\(on\\|off\\)##g" \
115
+ } else {
93
-e "s# zeroed_grain=\\(on\\|off\\)##g" \
116
+ new_l2_entry = 0;
94
- -e "s# subformat='[^']*'##g" \
117
+ }
95
- -e "s# adapter_type='[^']*'##g" \
118
new_l2_bitmap = QCOW_L2_BITMAP_ALL_ZEROES;
96
+ -e "s# subformat=[^ ]*##g" \
119
} else {
97
+ -e "s# adapter_type=[^ ]*##g" \
120
- new_l2_entry = s->qcow_version >= 3 ? QCOW_OFLAG_ZERO : 0;
98
-e "s# hwversion=[^ ]*##g" \
121
+ if (s->qcow_version >= 3) {
99
-e "s# lazy_refcounts=\\(on\\|off\\)##g" \
122
+ if (keep_reference) {
100
-e "s# block_size=[0-9]\\+##g" \
123
+ new_l2_entry |= QCOW_OFLAG_ZERO;
124
+ } else {
125
+ new_l2_entry = QCOW_OFLAG_ZERO;
126
+ }
127
+ } else {
128
+ new_l2_entry = 0;
129
+ }
130
}
131
}
132
133
@@ -XXX,XX +XXX,XX @@ static int discard_in_l2_slice(BlockDriverState *bs, uint64_t offset,
134
if (has_subclusters(s)) {
135
set_l2_bitmap(s, l2_slice, l2_index + i, new_l2_bitmap);
136
}
137
- /* Then decrease the refcount */
138
- qcow2_free_any_cluster(bs, old_l2_entry, type);
139
+ if (!keep_reference) {
140
+ /* Then decrease the refcount */
141
+ qcow2_free_any_cluster(bs, old_l2_entry, type);
142
+ } else if (s->discard_passthrough[type] &&
143
+ (cluster_type == QCOW2_CLUSTER_NORMAL ||
144
+ cluster_type == QCOW2_CLUSTER_ZERO_ALLOC)) {
145
+ /* If we keep the reference, pass on the discard still */
146
+ bdrv_pdiscard(s->data_file, old_l2_entry & L2E_OFFSET_MASK,
147
+ s->cluster_size);
148
+ }
149
}
150
151
qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
152
diff --git a/block/qcow2.c b/block/qcow2.c
153
index XXXXXXX..XXXXXXX 100644
154
--- a/block/qcow2.c
155
+++ b/block/qcow2.c
156
@@ -XXX,XX +XXX,XX @@ static const char *const mutable_opts[] = {
157
QCOW2_OPT_DISCARD_REQUEST,
158
QCOW2_OPT_DISCARD_SNAPSHOT,
159
QCOW2_OPT_DISCARD_OTHER,
160
+ QCOW2_OPT_DISCARD_NO_UNREF,
161
QCOW2_OPT_OVERLAP,
162
QCOW2_OPT_OVERLAP_TEMPLATE,
163
QCOW2_OPT_OVERLAP_MAIN_HEADER,
164
@@ -XXX,XX +XXX,XX @@ static QemuOptsList qcow2_runtime_opts = {
165
.type = QEMU_OPT_BOOL,
166
.help = "Generate discard requests when other clusters are freed",
167
},
168
+ {
169
+ .name = QCOW2_OPT_DISCARD_NO_UNREF,
170
+ .type = QEMU_OPT_BOOL,
171
+ .help = "Do not unreference discarded clusters",
172
+ },
173
{
174
.name = QCOW2_OPT_OVERLAP,
175
.type = QEMU_OPT_STRING,
176
@@ -XXX,XX +XXX,XX @@ typedef struct Qcow2ReopenState {
177
bool use_lazy_refcounts;
178
int overlap_check;
179
bool discard_passthrough[QCOW2_DISCARD_MAX];
180
+ bool discard_no_unref;
181
uint64_t cache_clean_interval;
182
QCryptoBlockOpenOptions *crypto_opts; /* Disk encryption runtime options */
183
} Qcow2ReopenState;
184
@@ -XXX,XX +XXX,XX @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
185
r->discard_passthrough[QCOW2_DISCARD_OTHER] =
186
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);
187
188
+ r->discard_no_unref = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_NO_UNREF,
189
+ false);
190
+ if (r->discard_no_unref && s->qcow_version < 3) {
191
+ error_setg(errp,
192
+ "discard-no-unref is only supported since qcow2 version 3");
193
+ ret = -EINVAL;
194
+ goto fail;
195
+ }
196
+
197
switch (s->crypt_method_header) {
198
case QCOW_CRYPT_NONE:
199
if (encryptfmt) {
200
@@ -XXX,XX +XXX,XX @@ static void qcow2_update_options_commit(BlockDriverState *bs,
201
s->discard_passthrough[i] = r->discard_passthrough[i];
202
}
203
204
+ s->discard_no_unref = r->discard_no_unref;
205
+
206
if (s->cache_clean_interval != r->cache_clean_interval) {
207
cache_clean_timer_del(bs);
208
s->cache_clean_interval = r->cache_clean_interval;
209
diff --git a/qemu-options.hx b/qemu-options.hx
210
index XXXXXXX..XXXXXXX 100644
211
--- a/qemu-options.hx
212
+++ b/qemu-options.hx
213
@@ -XXX,XX +XXX,XX @@ SRST
214
issued on other occasions where a cluster gets freed
215
(on/off; default: off)
216
217
+ ``discard-no-unref``
218
+ When enabled, discards from the guest will not cause cluster
219
+ allocations to be relinquished. This prevents qcow2 fragmentation
220
+ that would be caused by such discards. Besides potential
221
+ performance degradation, such fragmentation can lead to increased
222
+ allocation of clusters past the end of the image file,
223
+ resulting in image files whose file length can grow much larger
224
+ than their guest disk size would suggest.
225
+ If image file length is of concern (e.g. when storing qcow2
226
+ images directly on block devices), you should consider enabling
227
+ this option.
228
+
229
``overlap-check``
230
Which overlap checks to perform for writes to the image
231
(none/constant/cached/all; default: cached). For details or
101
--
232
--
102
2.21.0
233
2.40.1
103
104
diff view generated by jsdifflib