1
The following changes since commit bfec359afba088aaacc7d316f43302f28c6e642a:
1
The following changes since commit 0b6206b9c6825619cd721085fe082d7a0abc9af4:
2
2
3
Merge remote-tracking branch 'remotes/armbru/tags/pull-qdev-2017-04-21' into staging (2017-04-21 11:42:03 +0100)
3
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210914-4' into staging (2021-09-15 13:27:49 +0100)
4
4
5
are available in the git repository at:
5
are available in the Git repository at:
6
6
7
git://github.com/codyprime/qemu-kvm-jtc.git tags/block-pull-request
7
https://github.com/XanClic/qemu.git tags/pull-block-2021-09-15
8
8
9
for you to fetch changes up to 1507631e438930bc07f776f303af127a9cdb4d41:
9
for you to fetch changes up to 1899bf47375ad40555dcdff12ba49b4b8b82df38:
10
10
11
qemu-iotests: _cleanup_qemu must be called on exit (2017-04-21 08:32:44 -0400)
11
qemu-img: Add -F shorthand to convert (2021-09-15 18:42:38 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
14
Block patches:
15
Block patches for 2.10
15
- Block-status cache for data regions
16
- qcow2 optimization (when using subclusters)
17
- iotests delinting, and let 297 (lint checker) cover named iotests
18
- qcow2 check improvements
19
- Added -F (target backing file format) option to qemu-img convert
20
- Mirror job fix
21
- Fix for when a migration is initiated while a backup job runs
22
- Fix for uncached qemu-img convert to a volume with 4k sectors (for an
23
unaligned image)
24
- Minor gluster driver fix
16
25
17
----------------------------------------------------------------
26
----------------------------------------------------------------
27
Eric Blake (1):
28
qemu-img: Add -F shorthand to convert
18
29
19
Ashish Mittal (2):
30
Hanna Reitz (15):
20
block/vxhs.c: Add support for a new block device type called "vxhs"
31
gluster: Align block-status tail
21
block/vxhs.c: Add qemu-iotests for new block device type "vxhs"
32
block: Drop BDS comment regarding bdrv_append()
33
block: block-status cache for data regions
34
block: Clarify that @bytes is no limit on *pnum
35
block/file-posix: Do not force-cap *pnum
36
block/gluster: Do not force-cap *pnum
37
block/iscsi: Do not force-cap *pnum
38
iotests: Fix unspecified-encoding pylint warnings
39
iotests: Fix use-{list,dict}-literal warnings
40
iotests/297: Drop 169 and 199 from the skip list
41
migrate-bitmaps-postcopy-test: Fix pylint warnings
42
migrate-bitmaps-test: Fix pylint warnings
43
mirror-top-perms: Fix AbnormalShutdown path
44
iotests/297: Cover tests/
45
qemu-img: Allow target be aligned to sector size
22
46
23
Jeff Cody (10):
47
Stefano Garzarella (1):
24
qemu-iotests: exclude vxhs from image creation via protocol
48
block/mirror: fix NULL pointer dereference in
25
block: add bdrv_set_read_only() helper function
49
mirror_wait_on_conflicts()
26
block: do not set BDS read_only if copy_on_read enabled
27
block: honor BDRV_O_ALLOW_RDWR when clearing bs->read_only
28
block: code movement
29
block: introduce bdrv_can_set_read_only()
30
block: use bdrv_can_set_read_only() during reopen
31
block/rbd - update variable names to more apt names
32
block/rbd: Add support for reopen()
33
qemu-iotests: _cleanup_qemu must be called on exit
34
50
35
block.c | 56 +++-
51
Vladimir Sementsov-Ogievskiy (15):
36
block/Makefile.objs | 2 +
52
tests: add migrate-during-backup
37
block/bochs.c | 5 +-
53
block: bdrv_inactivate_recurse(): check for permissions and fix crash
38
block/cloop.c | 5 +-
54
simplebench: add img_bench_templater.py
39
block/dmg.c | 6 +-
55
qcow2: refactor handle_dependencies() loop body
40
block/rbd.c | 65 +++--
56
qcow2: handle_dependencies(): relax conflict detection
41
block/trace-events | 17 ++
57
qcow2-refcount: improve style of check_refcounts_l2()
42
block/vvfat.c | 19 +-
58
qcow2: compressed read: simplify cluster descriptor passing
43
block/vxhs.c | 575 +++++++++++++++++++++++++++++++++++++++
59
qcow2: introduce qcow2_parse_compressed_l2_entry() helper
44
configure | 39 +++
60
qcow2-refcount: introduce fix_l2_entry_by_zero()
45
include/block/block.h | 2 +
61
qcow2-refcount: fix_l2_entry_by_zero(): also zero L2 entry bitmap
46
qapi/block-core.json | 23 +-
62
qcow2-refcount: check_refcounts_l2(): check l2_bitmap
47
tests/qemu-iotests/017 | 1 +
63
qcow2-refcount: check_refcounts_l2(): check reserved bits
48
tests/qemu-iotests/020 | 1 +
64
qcow2-refcount: improve style of check_refcounts_l1()
49
tests/qemu-iotests/028 | 1 +
65
qcow2-refcount: check_refcounts_l1(): check reserved bits
50
tests/qemu-iotests/029 | 1 +
66
qcow2-refcount: check_refblocks(): add separate message for reserved
51
tests/qemu-iotests/073 | 1 +
67
52
tests/qemu-iotests/094 | 11 +-
68
docs/tools/qemu-img.rst | 4 +-
53
tests/qemu-iotests/102 | 5 +-
69
block/qcow2.h | 7 +-
54
tests/qemu-iotests/109 | 1 +
70
include/block/block_int.h | 61 +++-
55
tests/qemu-iotests/114 | 1 +
71
block.c | 88 +++++
56
tests/qemu-iotests/117 | 1 +
72
block/file-posix.c | 7 +-
57
tests/qemu-iotests/130 | 2 +
73
block/gluster.c | 23 +-
58
tests/qemu-iotests/134 | 1 +
74
block/io.c | 68 +++-
59
tests/qemu-iotests/140 | 1 +
75
block/iscsi.c | 3 -
60
tests/qemu-iotests/141 | 1 +
76
block/mirror.c | 25 +-
61
tests/qemu-iotests/143 | 1 +
77
block/qcow2-cluster.c | 78 +++--
62
tests/qemu-iotests/156 | 2 +
78
block/qcow2-refcount.c | 326 ++++++++++++------
63
tests/qemu-iotests/158 | 1 +
79
block/qcow2.c | 13 +-
64
tests/qemu-iotests/common | 6 +
80
qemu-img.c | 18 +-
65
tests/qemu-iotests/common.config | 13 +
81
qemu-img-cmds.hx | 2 +-
66
tests/qemu-iotests/common.filter | 1 +
82
scripts/simplebench/img_bench_templater.py | 95 +++++
67
tests/qemu-iotests/common.rc | 19 ++
83
scripts/simplebench/table_templater.py | 62 ++++
68
33 files changed, 844 insertions(+), 42 deletions(-)
84
tests/qemu-iotests/122 | 2 +-
69
create mode 100644 block/vxhs.c
85
tests/qemu-iotests/271 | 5 +-
86
tests/qemu-iotests/271.out | 4 +-
87
tests/qemu-iotests/297 | 9 +-
88
tests/qemu-iotests/iotests.py | 12 +-
89
.../tests/migrate-bitmaps-postcopy-test | 13 +-
90
tests/qemu-iotests/tests/migrate-bitmaps-test | 43 ++-
91
.../qemu-iotests/tests/migrate-during-backup | 97 ++++++
92
.../tests/migrate-during-backup.out | 5 +
93
tests/qemu-iotests/tests/mirror-top-perms | 2 +-
94
26 files changed, 855 insertions(+), 217 deletions(-)
95
create mode 100755 scripts/simplebench/img_bench_templater.py
96
create mode 100644 scripts/simplebench/table_templater.py
97
create mode 100755 tests/qemu-iotests/tests/migrate-during-backup
98
create mode 100644 tests/qemu-iotests/tests/migrate-during-backup.out
70
99
71
--
100
--
72
2.9.3
101
2.31.1
73
102
74
103
diff view generated by jsdifflib
New patch
1
From: Max Reitz <mreitz@redhat.com>
1
2
3
gluster's block-status implementation is basically a copy of that in
4
block/file-posix.c, there is only one thing missing, and that is
5
aligning trailing data extents to the request alignment (as added by
6
commit 9c3db310ff0).
7
8
Note that 9c3db310ff0 mentions that "there seems to be no other block
9
driver that sets request_alignment and [...]", but while block/gluster.c
10
does indeed not set request_alignment, block/io.c's
11
bdrv_refresh_limits() will still default to an alignment of 512 because
12
block/gluster.c does not provide a byte-aligned read function.
13
Therefore, unaligned tails can conceivably occur, and so we should apply
14
the change from 9c3db310ff0 to gluster's block-status implementation.
15
16
Reported-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
17
Signed-off-by: Max Reitz <mreitz@redhat.com>
18
Message-Id: <20210805143603.59503-1-mreitz@redhat.com>
19
Reviewed-by: Eric Blake <eblake@redhat.com>
20
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
21
---
22
block/gluster.c | 16 ++++++++++++++++
23
1 file changed, 16 insertions(+)
24
25
diff --git a/block/gluster.c b/block/gluster.c
26
index XXXXXXX..XXXXXXX 100644
27
--- a/block/gluster.c
28
+++ b/block/gluster.c
29
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qemu_gluster_co_block_status(BlockDriverState *bs,
30
off_t data = 0, hole = 0;
31
int ret = -EINVAL;
32
33
+ assert(QEMU_IS_ALIGNED(offset | bytes, bs->bl.request_alignment));
34
+
35
if (!s->fd) {
36
return ret;
37
}
38
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qemu_gluster_co_block_status(BlockDriverState *bs,
39
/* On a data extent, compute bytes to the end of the extent,
40
* possibly including a partial sector at EOF. */
41
*pnum = MIN(bytes, hole - offset);
42
+
43
+ /*
44
+ * We are not allowed to return partial sectors, though, so
45
+ * round up if necessary.
46
+ */
47
+ if (!QEMU_IS_ALIGNED(*pnum, bs->bl.request_alignment)) {
48
+ int64_t file_length = qemu_gluster_getlength(bs);
49
+ if (file_length > 0) {
50
+ /* Ignore errors, this is just a safeguard */
51
+ assert(hole == file_length);
52
+ }
53
+ *pnum = ROUND_UP(*pnum, bs->bl.request_alignment);
54
+ }
55
+
56
ret = BDRV_BLOCK_DATA;
57
} else {
58
/* On a hole, compute bytes to the beginning of the next extent. */
59
--
60
2.31.1
61
62
diff view generated by jsdifflib
New patch
1
There is a comment above the BDS definition stating care must be taken
2
to consider handling newly added fields in bdrv_append().
1
3
4
Actually, this comment should have said "bdrv_swap()" as of 4ddc07cac
5
(nine years ago), and in any case, bdrv_swap() was dropped in
6
8e419aefa (six years ago). So no such care is necessary anymore.
7
8
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
10
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
12
Message-Id: <20210812084148.14458-2-hreitz@redhat.com>
13
---
14
include/block/block_int.h | 6 ------
15
1 file changed, 6 deletions(-)
16
17
diff --git a/include/block/block_int.h b/include/block/block_int.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/block/block_int.h
20
+++ b/include/block/block_int.h
21
@@ -XXX,XX +XXX,XX @@ struct BdrvChild {
22
QLIST_ENTRY(BdrvChild) next_parent;
23
};
24
25
-/*
26
- * Note: the function bdrv_append() copies and swaps contents of
27
- * BlockDriverStates, so if you add new fields to this struct, please
28
- * inspect bdrv_append() to determine if the new fields need to be
29
- * copied as well.
30
- */
31
struct BlockDriverState {
32
/* Protected by big QEMU lock or read-only after opening. No special
33
* locking needed during I/O...
34
--
35
2.31.1
36
37
diff view generated by jsdifflib
1
We have a helper wrapper for checking for the BDS read_only flag,
1
As we have attempted before
2
add a helper wrapper to set the read_only flag as well.
2
(https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg06451.html,
3
3
"file-posix: Cache lseek result for data regions";
4
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4
https://lists.nongnu.org/archive/html/qemu-block/2021-02/msg00934.html,
5
Signed-off-by: Jeff Cody <jcody@redhat.com>
5
"file-posix: Cache next hole"), this patch seeks to reduce the number of
6
Reviewed-by: John Snow <jsnow@redhat.com>
6
SEEK_DATA/HOLE operations the file-posix driver has to perform. The
7
Message-id: 9b18972d05f5fa2ac16c014f0af98d680553048d.1491597120.git.jcody@redhat.com
7
main difference is that this time it is implemented as part of the
8
general block layer code.
9
10
The problem we face is that on some filesystems or in some
11
circumstances, SEEK_DATA/HOLE is unreasonably slow. Given the
12
implementation is outside of qemu, there is little we can do about its
13
performance.
14
15
We have already introduced the want_zero parameter to
16
bdrv_co_block_status() to reduce the number of SEEK_DATA/HOLE calls
17
unless we really want zero information; but sometimes we do want that
18
information, because for files that consist largely of zero areas,
19
special-casing those areas can give large performance boosts. So the
20
real problem is with files that consist largely of data, so that
21
inquiring the block status does not gain us much performance, but where
22
such an inquiry itself takes a lot of time.
23
24
To address this, we want to cache data regions. Most of the time, when
25
bad performance is reported, it is in places where the image is iterated
26
over from start to end (qemu-img convert or the mirror job), so a simple
27
yet effective solution is to cache only the current data region.
28
29
(Note that only caching data regions but not zero regions means that
30
returning false information from the cache is not catastrophic: Treating
31
zeroes as data is fine. While we try to invalidate the cache on zero
32
writes and discards, such incongruences may still occur when there are
33
other processes writing to the image.)
34
35
We only use the cache for nodes without children (i.e. protocol nodes),
36
because that is where the problem is: Drivers that rely on block-status
37
implementations outside of qemu (e.g. SEEK_DATA/HOLE).
38
39
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/307
40
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
41
Message-Id: <20210812084148.14458-3-hreitz@redhat.com>
42
Reviewed-by: Eric Blake <eblake@redhat.com>
43
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
44
[hreitz: Added `local_file == bs` assertion, as suggested by Vladimir]
45
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
8
---
46
---
9
block.c | 5 +++++
47
include/block/block_int.h | 50 ++++++++++++++++++++++++
10
block/bochs.c | 2 +-
48
block.c | 80 +++++++++++++++++++++++++++++++++++++++
11
block/cloop.c | 2 +-
49
block/io.c | 68 +++++++++++++++++++++++++++++++--
12
block/dmg.c | 2 +-
50
3 files changed, 195 insertions(+), 3 deletions(-)
13
block/rbd.c | 2 +-
51
14
block/vvfat.c | 4 ++--
52
diff --git a/include/block/block_int.h b/include/block/block_int.h
15
include/block/block.h | 1 +
53
index XXXXXXX..XXXXXXX 100644
16
7 files changed, 12 insertions(+), 6 deletions(-)
54
--- a/include/block/block_int.h
17
55
+++ b/include/block/block_int.h
56
@@ -XXX,XX +XXX,XX @@
57
#include "qemu/hbitmap.h"
58
#include "block/snapshot.h"
59
#include "qemu/throttle.h"
60
+#include "qemu/rcu.h"
61
62
#define BLOCK_FLAG_LAZY_REFCOUNTS 8
63
64
@@ -XXX,XX +XXX,XX @@ struct BdrvChild {
65
QLIST_ENTRY(BdrvChild) next_parent;
66
};
67
68
+/*
69
+ * Allows bdrv_co_block_status() to cache one data region for a
70
+ * protocol node.
71
+ *
72
+ * @valid: Whether the cache is valid (should be accessed with atomic
73
+ * functions so this can be reset by RCU readers)
74
+ * @data_start: Offset where we know (or strongly assume) is data
75
+ * @data_end: Offset where the data region ends (which is not necessarily
76
+ * the start of a zeroed region)
77
+ */
78
+typedef struct BdrvBlockStatusCache {
79
+ struct rcu_head rcu;
80
+
81
+ bool valid;
82
+ int64_t data_start;
83
+ int64_t data_end;
84
+} BdrvBlockStatusCache;
85
+
86
struct BlockDriverState {
87
/* Protected by big QEMU lock or read-only after opening. No special
88
* locking needed during I/O...
89
@@ -XXX,XX +XXX,XX @@ struct BlockDriverState {
90
91
/* BdrvChild links to this node may never be frozen */
92
bool never_freeze;
93
+
94
+ /* Lock for block-status cache RCU writers */
95
+ CoMutex bsc_modify_lock;
96
+ /* Always non-NULL, but must only be dereferenced under an RCU read guard */
97
+ BdrvBlockStatusCache *block_status_cache;
98
};
99
100
struct BlockBackendRootState {
101
@@ -XXX,XX +XXX,XX @@ static inline BlockDriverState *bdrv_primary_bs(BlockDriverState *bs)
102
*/
103
void bdrv_drain_all_end_quiesce(BlockDriverState *bs);
104
105
+/**
106
+ * Check whether the given offset is in the cached block-status data
107
+ * region.
108
+ *
109
+ * If it is, and @pnum is not NULL, *pnum is set to
110
+ * `bsc.data_end - offset`, i.e. how many bytes, starting from
111
+ * @offset, are data (according to the cache).
112
+ * Otherwise, *pnum is not touched.
113
+ */
114
+bool bdrv_bsc_is_data(BlockDriverState *bs, int64_t offset, int64_t *pnum);
115
+
116
+/**
117
+ * If [offset, offset + bytes) overlaps with the currently cached
118
+ * block-status region, invalidate the cache.
119
+ *
120
+ * (To be used by I/O paths that cause data regions to be zero or
121
+ * holes.)
122
+ */
123
+void bdrv_bsc_invalidate_range(BlockDriverState *bs,
124
+ int64_t offset, int64_t bytes);
125
+
126
+/**
127
+ * Mark the range [offset, offset + bytes) as a data region.
128
+ */
129
+void bdrv_bsc_fill(BlockDriverState *bs, int64_t offset, int64_t bytes);
130
+
131
#endif /* BLOCK_INT_H */
18
diff --git a/block.c b/block.c
132
diff --git a/block.c b/block.c
19
index XXXXXXX..XXXXXXX 100644
133
index XXXXXXX..XXXXXXX 100644
20
--- a/block.c
134
--- a/block.c
21
+++ b/block.c
135
+++ b/block.c
22
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
136
@@ -XXX,XX +XXX,XX @@
137
#include "qemu/timer.h"
138
#include "qemu/cutils.h"
139
#include "qemu/id.h"
140
+#include "qemu/range.h"
141
+#include "qemu/rcu.h"
142
#include "block/coroutines.h"
143
144
#ifdef CONFIG_BSD
145
@@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_new(void)
146
147
qemu_co_queue_init(&bs->flush_queue);
148
149
+ qemu_co_mutex_init(&bs->bsc_modify_lock);
150
+ bs->block_status_cache = g_new0(BdrvBlockStatusCache, 1);
151
+
152
for (i = 0; i < bdrv_drain_all_count; i++) {
153
bdrv_drained_begin(bs);
23
}
154
}
155
@@ -XXX,XX +XXX,XX @@ static void bdrv_close(BlockDriverState *bs)
156
bs->explicit_options = NULL;
157
qobject_unref(bs->full_open_options);
158
bs->full_open_options = NULL;
159
+ g_free(bs->block_status_cache);
160
+ bs->block_status_cache = NULL;
161
162
bdrv_release_named_dirty_bitmaps(bs);
163
assert(QLIST_EMPTY(&bs->dirty_bitmaps));
164
@@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_backing_chain_next(BlockDriverState *bs)
165
{
166
return bdrv_skip_filters(bdrv_cow_bs(bdrv_skip_filters(bs)));
24
}
167
}
25
168
+
26
+void bdrv_set_read_only(BlockDriverState *bs, bool read_only)
169
+/**
170
+ * Check whether [offset, offset + bytes) overlaps with the cached
171
+ * block-status data region.
172
+ *
173
+ * If so, and @pnum is not NULL, set *pnum to `bsc.data_end - offset`,
174
+ * which is what bdrv_bsc_is_data()'s interface needs.
175
+ * Otherwise, *pnum is not touched.
176
+ */
177
+static bool bdrv_bsc_range_overlaps_locked(BlockDriverState *bs,
178
+ int64_t offset, int64_t bytes,
179
+ int64_t *pnum)
27
+{
180
+{
28
+ bs->read_only = read_only;
181
+ BdrvBlockStatusCache *bsc = qatomic_rcu_read(&bs->block_status_cache);
182
+ bool overlaps;
183
+
184
+ overlaps =
185
+ qatomic_read(&bsc->valid) &&
186
+ ranges_overlap(offset, bytes, bsc->data_start,
187
+ bsc->data_end - bsc->data_start);
188
+
189
+ if (overlaps && pnum) {
190
+ *pnum = bsc->data_end - offset;
191
+ }
192
+
193
+ return overlaps;
29
+}
194
+}
30
+
195
+
31
void bdrv_get_full_backing_filename_from_filename(const char *backed,
196
+/**
32
const char *backing,
197
+ * See block_int.h for this function's documentation.
33
char *dest, size_t sz,
198
+ */
34
diff --git a/block/bochs.c b/block/bochs.c
199
+bool bdrv_bsc_is_data(BlockDriverState *bs, int64_t offset, int64_t *pnum)
200
+{
201
+ RCU_READ_LOCK_GUARD();
202
+
203
+ return bdrv_bsc_range_overlaps_locked(bs, offset, 1, pnum);
204
+}
205
+
206
+/**
207
+ * See block_int.h for this function's documentation.
208
+ */
209
+void bdrv_bsc_invalidate_range(BlockDriverState *bs,
210
+ int64_t offset, int64_t bytes)
211
+{
212
+ RCU_READ_LOCK_GUARD();
213
+
214
+ if (bdrv_bsc_range_overlaps_locked(bs, offset, bytes, NULL)) {
215
+ qatomic_set(&bs->block_status_cache->valid, false);
216
+ }
217
+}
218
+
219
+/**
220
+ * See block_int.h for this function's documentation.
221
+ */
222
+void bdrv_bsc_fill(BlockDriverState *bs, int64_t offset, int64_t bytes)
223
+{
224
+ BdrvBlockStatusCache *new_bsc = g_new(BdrvBlockStatusCache, 1);
225
+ BdrvBlockStatusCache *old_bsc;
226
+
227
+ *new_bsc = (BdrvBlockStatusCache) {
228
+ .valid = true,
229
+ .data_start = offset,
230
+ .data_end = offset + bytes,
231
+ };
232
+
233
+ QEMU_LOCK_GUARD(&bs->bsc_modify_lock);
234
+
235
+ old_bsc = qatomic_rcu_read(&bs->block_status_cache);
236
+ qatomic_rcu_set(&bs->block_status_cache, new_bsc);
237
+ if (old_bsc) {
238
+ g_free_rcu(old_bsc, rcu);
239
+ }
240
+}
241
diff --git a/block/io.c b/block/io.c
35
index XXXXXXX..XXXXXXX 100644
242
index XXXXXXX..XXXXXXX 100644
36
--- a/block/bochs.c
243
--- a/block/io.c
37
+++ b/block/bochs.c
244
+++ b/block/io.c
38
@@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
245
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
39
return -EINVAL;
246
return -ENOTSUP;
40
}
247
}
41
248
42
- bs->read_only = true; /* no write support yet */
249
+ /* Invalidate the cached block-status data range if this write overlaps */
43
+ bdrv_set_read_only(bs, true); /* no write support yet */
250
+ bdrv_bsc_invalidate_range(bs, offset, bytes);
44
251
+
45
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
252
assert(alignment % bs->bl.request_alignment == 0);
46
if (ret < 0) {
253
head = offset % alignment;
47
diff --git a/block/cloop.c b/block/cloop.c
254
tail = (offset + bytes) % alignment;
48
index XXXXXXX..XXXXXXX 100644
255
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
49
--- a/block/cloop.c
256
aligned_bytes = ROUND_UP(offset + bytes, align) - aligned_offset;
50
+++ b/block/cloop.c
257
51
@@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
258
if (bs->drv->bdrv_co_block_status) {
52
return -EINVAL;
259
- ret = bs->drv->bdrv_co_block_status(bs, want_zero, aligned_offset,
260
- aligned_bytes, pnum, &local_map,
261
- &local_file);
262
+ /*
263
+ * Use the block-status cache only for protocol nodes: Format
264
+ * drivers are generally quick to inquire the status, but protocol
265
+ * drivers often need to get information from outside of qemu, so
266
+ * we do not have control over the actual implementation. There
267
+ * have been cases where inquiring the status took an unreasonably
268
+ * long time, and we can do nothing in qemu to fix it.
269
+ * This is especially problematic for images with large data areas,
270
+ * because finding the few holes in them and giving them special
271
+ * treatment does not gain much performance. Therefore, we try to
272
+ * cache the last-identified data region.
273
+ *
274
+ * Second, limiting ourselves to protocol nodes allows us to assume
275
+ * the block status for data regions to be DATA | OFFSET_VALID, and
276
+ * that the host offset is the same as the guest offset.
277
+ *
278
+ * Note that it is possible that external writers zero parts of
279
+ * the cached regions without the cache being invalidated, and so
280
+ * we may report zeroes as data. This is not catastrophic,
281
+ * however, because reporting zeroes as data is fine.
282
+ */
283
+ if (QLIST_EMPTY(&bs->children) &&
284
+ bdrv_bsc_is_data(bs, aligned_offset, pnum))
285
+ {
286
+ ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID;
287
+ local_file = bs;
288
+ local_map = aligned_offset;
289
+ } else {
290
+ ret = bs->drv->bdrv_co_block_status(bs, want_zero, aligned_offset,
291
+ aligned_bytes, pnum, &local_map,
292
+ &local_file);
293
+
294
+ /*
295
+ * Note that checking QLIST_EMPTY(&bs->children) is also done when
296
+ * the cache is queried above. Technically, we do not need to check
297
+ * it here; the worst that can happen is that we fill the cache for
298
+ * non-protocol nodes, and then it is never used. However, filling
299
+ * the cache requires an RCU update, so double check here to avoid
300
+ * such an update if possible.
301
+ */
302
+ if (ret == (BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID) &&
303
+ QLIST_EMPTY(&bs->children))
304
+ {
305
+ /*
306
+ * When a protocol driver reports BLOCK_OFFSET_VALID, the
307
+ * returned local_map value must be the same as the offset we
308
+ * have passed (aligned_offset), and local_bs must be the node
309
+ * itself.
310
+ * Assert this, because we follow this rule when reading from
311
+ * the cache (see the `local_file = bs` and
312
+ * `local_map = aligned_offset` assignments above), and the
313
+ * result the cache delivers must be the same as the driver
314
+ * would deliver.
315
+ */
316
+ assert(local_file == bs);
317
+ assert(local_map == aligned_offset);
318
+ bdrv_bsc_fill(bs, aligned_offset, *pnum);
319
+ }
320
+ }
321
} else {
322
/* Default code for filters */
323
324
@@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset,
325
return 0;
53
}
326
}
54
327
55
- bs->read_only = true;
328
+ /* Invalidate the cached block-status data range if this discard overlaps */
56
+ bdrv_set_read_only(bs, true);
329
+ bdrv_bsc_invalidate_range(bs, offset, bytes);
57
330
+
58
/* read header */
331
/* Discard is advisory, but some devices track and coalesce
59
ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
332
* unaligned requests, so we must pass everything down rather than
60
diff --git a/block/dmg.c b/block/dmg.c
333
* round here. Still, most devices will just silently ignore
61
index XXXXXXX..XXXXXXX 100644
62
--- a/block/dmg.c
63
+++ b/block/dmg.c
64
@@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
65
}
66
67
block_module_load_one("dmg-bz2");
68
- bs->read_only = true;
69
+ bdrv_set_read_only(bs, true);
70
71
s->n_chunks = 0;
72
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
73
diff --git a/block/rbd.c b/block/rbd.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/block/rbd.c
76
+++ b/block/rbd.c
77
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
78
goto failed_open;
79
}
80
81
- bs->read_only = (s->snap != NULL);
82
+ bdrv_set_read_only(bs, (s->snap != NULL));
83
84
qemu_opts_del(opts);
85
return 0;
86
diff --git a/block/vvfat.c b/block/vvfat.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/block/vvfat.c
89
+++ b/block/vvfat.c
90
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
91
s->current_cluster=0xffffffff;
92
93
/* read only is the default for safety */
94
- bs->read_only = true;
95
+ bdrv_set_read_only(bs, true);
96
s->qcow = NULL;
97
s->qcow_filename = NULL;
98
s->fat2 = NULL;
99
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
100
if (ret < 0) {
101
goto fail;
102
}
103
- bs->read_only = false;
104
+ bdrv_set_read_only(bs, false);
105
}
106
107
bs->total_sectors = cyls * heads * secs;
108
diff --git a/include/block/block.h b/include/block/block.h
109
index XXXXXXX..XXXXXXX 100644
110
--- a/include/block/block.h
111
+++ b/include/block/block.h
112
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
113
int64_t sector_num, int nb_sectors, int *pnum);
114
115
bool bdrv_is_read_only(BlockDriverState *bs);
116
+void bdrv_set_read_only(BlockDriverState *bs, bool read_only);
117
bool bdrv_is_sg(BlockDriverState *bs);
118
bool bdrv_is_inserted(BlockDriverState *bs);
119
int bdrv_media_changed(BlockDriverState *bs);
120
--
334
--
121
2.9.3
335
2.31.1
122
336
123
337
diff view generated by jsdifflib
New patch
1
.bdrv_co_block_status() implementations are free to return a *pnum that
2
exceeds @bytes, because bdrv_co_block_status() in block/io.c will clamp
3
*pnum as necessary.
1
4
5
On the other hand, if drivers' implementations return values for *pnum
6
that are as large as possible, our recently introduced block-status
7
cache will become more effective.
8
9
So, make a note in block_int.h that @bytes is no upper limit for *pnum.
10
11
Suggested-by: Eric Blake <eblake@redhat.com>
12
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
13
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
14
Message-Id: <20210812084148.14458-4-hreitz@redhat.com>
15
Reviewed-by: Eric Blake <eblake@redhat.com>
16
---
17
include/block/block_int.h | 9 +++++++++
18
1 file changed, 9 insertions(+)
19
20
diff --git a/include/block/block_int.h b/include/block/block_int.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/include/block/block_int.h
23
+++ b/include/block/block_int.h
24
@@ -XXX,XX +XXX,XX @@ struct BlockDriver {
25
* clamped to bdrv_getlength() and aligned to request_alignment,
26
* as well as non-NULL pnum, map, and file; in turn, the driver
27
* must return an error or set pnum to an aligned non-zero value.
28
+ *
29
+ * Note that @bytes is just a hint on how big of a region the
30
+ * caller wants to inspect. It is not a limit on *pnum.
31
+ * Implementations are free to return larger values of *pnum if
32
+ * doing so does not incur a performance penalty.
33
+ *
34
+ * block/io.c's bdrv_co_block_status() will utilize an unclamped
35
+ * *pnum value for the block-status cache on protocol nodes, prior
36
+ * to clamping *pnum for return to its caller.
37
*/
38
int coroutine_fn (*bdrv_co_block_status)(BlockDriverState *bs,
39
bool want_zero, int64_t offset, int64_t bytes, int64_t *pnum,
40
--
41
2.31.1
42
43
diff view generated by jsdifflib
New patch
1
bdrv_co_block_status() does it for us, we do not need to do it here.
1
2
3
The advantage of not capping *pnum is that bdrv_co_block_status() can
4
cache larger data regions than requested by its caller.
5
6
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
10
Message-Id: <20210812084148.14458-5-hreitz@redhat.com>
11
---
12
block/file-posix.c | 7 ++++---
13
1 file changed, 4 insertions(+), 3 deletions(-)
14
15
diff --git a/block/file-posix.c b/block/file-posix.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/file-posix.c
18
+++ b/block/file-posix.c
19
@@ -XXX,XX +XXX,XX @@ static int find_allocation(BlockDriverState *bs, off_t start,
20
* the specified offset) that are known to be in the same
21
* allocated/unallocated state.
22
*
23
- * 'bytes' is the max value 'pnum' should be set to.
24
+ * 'bytes' is a soft cap for 'pnum'. If the information is free, 'pnum' may
25
+ * well exceed it.
26
*/
27
static int coroutine_fn raw_co_block_status(BlockDriverState *bs,
28
bool want_zero,
29
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_block_status(BlockDriverState *bs,
30
} else if (data == offset) {
31
/* On a data extent, compute bytes to the end of the extent,
32
* possibly including a partial sector at EOF. */
33
- *pnum = MIN(bytes, hole - offset);
34
+ *pnum = hole - offset;
35
36
/*
37
* We are not allowed to return partial sectors, though, so
38
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_block_status(BlockDriverState *bs,
39
} else {
40
/* On a hole, compute bytes to the beginning of the next extent. */
41
assert(hole == offset);
42
- *pnum = MIN(bytes, data - offset);
43
+ *pnum = data - offset;
44
ret = BDRV_BLOCK_ZERO;
45
}
46
*map = offset;
47
--
48
2.31.1
49
50
diff view generated by jsdifflib
New patch
1
bdrv_co_block_status() does it for us, we do not need to do it here.
1
2
3
The advantage of not capping *pnum is that bdrv_co_block_status() can
4
cache larger data regions than requested by its caller.
5
6
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
10
Message-Id: <20210812084148.14458-6-hreitz@redhat.com>
11
---
12
block/gluster.c | 7 ++++---
13
1 file changed, 4 insertions(+), 3 deletions(-)
14
15
diff --git a/block/gluster.c b/block/gluster.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/gluster.c
18
+++ b/block/gluster.c
19
@@ -XXX,XX +XXX,XX @@ exit:
20
* the specified offset) that are known to be in the same
21
* allocated/unallocated state.
22
*
23
- * 'bytes' is the max value 'pnum' should be set to.
24
+ * 'bytes' is a soft cap for 'pnum'. If the information is free, 'pnum' may
25
+ * well exceed it.
26
*
27
* (Based on raw_co_block_status() from file-posix.c.)
28
*/
29
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qemu_gluster_co_block_status(BlockDriverState *bs,
30
} else if (data == offset) {
31
/* On a data extent, compute bytes to the end of the extent,
32
* possibly including a partial sector at EOF. */
33
- *pnum = MIN(bytes, hole - offset);
34
+ *pnum = hole - offset;
35
36
/*
37
* We are not allowed to return partial sectors, though, so
38
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn qemu_gluster_co_block_status(BlockDriverState *bs,
39
} else {
40
/* On a hole, compute bytes to the beginning of the next extent. */
41
assert(hole == offset);
42
- *pnum = MIN(bytes, data - offset);
43
+ *pnum = data - offset;
44
ret = BDRV_BLOCK_ZERO;
45
}
46
47
--
48
2.31.1
49
50
diff view generated by jsdifflib
New patch
1
bdrv_co_block_status() does it for us, we do not need to do it here.
1
2
3
The advantage of not capping *pnum is that bdrv_co_block_status() can
4
cache larger data regions than requested by its caller.
5
6
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
10
Message-Id: <20210812084148.14458-7-hreitz@redhat.com>
11
---
12
block/iscsi.c | 3 ---
13
1 file changed, 3 deletions(-)
14
15
diff --git a/block/iscsi.c b/block/iscsi.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/iscsi.c
18
+++ b/block/iscsi.c
19
@@ -XXX,XX +XXX,XX @@ retry:
20
iscsi_allocmap_set_allocated(iscsilun, offset, *pnum);
21
}
22
23
- if (*pnum > bytes) {
24
- *pnum = bytes;
25
- }
26
out_unlock:
27
qemu_mutex_unlock(&iscsilun->mutex);
28
g_free(iTask.err_str);
29
--
30
2.31.1
31
32
diff view generated by jsdifflib
New patch
1
As of recently, pylint complains when `open()` calls are missing an
2
`encoding=` specified. Everything we have should be UTF-8 (and in fact,
3
everything should be UTF-8, period (exceptions apply)), so use that.
1
4
5
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
6
Message-Id: <20210824153540.177128-2-hreitz@redhat.com>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: John Snow <jsnow@redhat.com>
9
---
10
tests/qemu-iotests/297 | 2 +-
11
tests/qemu-iotests/iotests.py | 8 +++++---
12
2 files changed, 6 insertions(+), 4 deletions(-)
13
14
diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297
15
index XXXXXXX..XXXXXXX 100755
16
--- a/tests/qemu-iotests/297
17
+++ b/tests/qemu-iotests/297
18
@@ -XXX,XX +XXX,XX @@ def is_python_file(filename):
19
if filename.endswith('.py'):
20
return True
21
22
- with open(filename) as f:
23
+ with open(filename, encoding='utf-8') as f:
24
try:
25
first_line = f.readline()
26
return re.match('^#!.*python', first_line) is not None
27
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
28
index XXXXXXX..XXXXXXX 100644
29
--- a/tests/qemu-iotests/iotests.py
30
+++ b/tests/qemu-iotests/iotests.py
31
@@ -XXX,XX +XXX,XX @@ def _post_shutdown(self) -> None:
32
return
33
valgrind_filename = f"{test_dir}/{self._popen.pid}.valgrind"
34
if self.exitcode() == 99:
35
- with open(valgrind_filename) as f:
36
+ with open(valgrind_filename, encoding='utf-8') as f:
37
print(f.read())
38
else:
39
os.remove(valgrind_filename)
40
@@ -XXX,XX +XXX,XX @@ def notrun(reason):
41
# Each test in qemu-iotests has a number ("seq")
42
seq = os.path.basename(sys.argv[0])
43
44
- with open('%s/%s.notrun' % (output_dir, seq), 'w') as outfile:
45
+ with open('%s/%s.notrun' % (output_dir, seq), 'w', encoding='utf-8') \
46
+ as outfile:
47
outfile.write(reason + '\n')
48
logger.warning("%s not run: %s", seq, reason)
49
sys.exit(0)
50
@@ -XXX,XX +XXX,XX @@ def case_notrun(reason):
51
# Each test in qemu-iotests has a number ("seq")
52
seq = os.path.basename(sys.argv[0])
53
54
- with open('%s/%s.casenotrun' % (output_dir, seq), 'a') as outfile:
55
+ with open('%s/%s.casenotrun' % (output_dir, seq), 'a', encoding='utf-8') \
56
+ as outfile:
57
outfile.write(' [case not run] ' + reason + '\n')
58
59
def _verify_image_format(supported_fmts: Sequence[str] = (),
60
--
61
2.31.1
62
63
diff view generated by jsdifflib
New patch
1
pylint proposes using `[]` instead of `list()` and `{}` instead of
2
`dict()`, because it is faster. That seems simple enough, so heed its
3
advice.
1
4
5
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
6
Message-Id: <20210824153540.177128-3-hreitz@redhat.com>
7
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
---
9
tests/qemu-iotests/iotests.py | 4 ++--
10
1 file changed, 2 insertions(+), 2 deletions(-)
11
12
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
13
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/qemu-iotests/iotests.py
15
+++ b/tests/qemu-iotests/iotests.py
16
@@ -XXX,XX +XXX,XX @@ def hmp_qemu_io(self, drive: str, cmd: str,
17
18
def flatten_qmp_object(self, obj, output=None, basestr=''):
19
if output is None:
20
- output = dict()
21
+ output = {}
22
if isinstance(obj, list):
23
for i, item in enumerate(obj):
24
self.flatten_qmp_object(item, output, basestr + str(i) + '.')
25
@@ -XXX,XX +XXX,XX @@ def flatten_qmp_object(self, obj, output=None, basestr=''):
26
27
def qmp_to_opts(self, obj):
28
obj = self.flatten_qmp_object(obj)
29
- output_list = list()
30
+ output_list = []
31
for key in obj:
32
output_list += [key + '=' + obj[key]]
33
return ','.join(output_list)
34
--
35
2.31.1
36
37
diff view generated by jsdifflib
New patch
1
169 and 199 have been renamed and moved to tests/ (commit a44be0334be:
2
"iotests: rename and move 169 and 199 tests"), so we can drop them from
3
the skip list.
1
4
5
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
6
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
7
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
9
Message-Id: <20210902094017.32902-2-hreitz@redhat.com>
10
---
11
tests/qemu-iotests/297 | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
14
diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297
15
index XXXXXXX..XXXXXXX 100755
16
--- a/tests/qemu-iotests/297
17
+++ b/tests/qemu-iotests/297
18
@@ -XXX,XX +XXX,XX @@ import iotests
19
SKIP_FILES = (
20
'030', '040', '041', '044', '045', '055', '056', '057', '065', '093',
21
'096', '118', '124', '132', '136', '139', '147', '148', '149',
22
- '151', '152', '155', '163', '165', '169', '194', '196', '199', '202',
23
+ '151', '152', '155', '163', '165', '194', '196', '202',
24
'203', '205', '206', '207', '208', '210', '211', '212', '213', '216',
25
'218', '219', '224', '228', '234', '235', '236', '237', '238',
26
'240', '242', '245', '246', '248', '255', '256', '257', '258', '260',
27
--
28
2.31.1
29
30
diff view generated by jsdifflib
New patch
1
pylint complains that discards1_sha256 and all_discards_sha256 are first
2
set in non-__init__ methods.
1
3
4
These variables are not really class-variables anyway, so let them
5
instead be returned by start_postcopy(), thus silencing pylint.
6
7
Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
9
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
Message-Id: <20210902094017.32902-3-hreitz@redhat.com>
11
---
12
.../tests/migrate-bitmaps-postcopy-test | 13 +++++++------
13
1 file changed, 7 insertions(+), 6 deletions(-)
14
15
diff --git a/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test b/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test
16
index XXXXXXX..XXXXXXX 100755
17
--- a/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test
18
+++ b/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test
19
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
20
21
result = self.vm_a.qmp('x-debug-block-dirty-bitmap-sha256',
22
node='drive0', name='bitmap0')
23
- self.discards1_sha256 = result['return']['sha256']
24
+ discards1_sha256 = result['return']['sha256']
25
26
# Check, that updating the bitmap by discards works
27
- assert self.discards1_sha256 != empty_sha256
28
+ assert discards1_sha256 != empty_sha256
29
30
# We want to calculate resulting sha256. Do it in bitmap0, so, disable
31
# other bitmaps
32
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
33
34
result = self.vm_a.qmp('x-debug-block-dirty-bitmap-sha256',
35
node='drive0', name='bitmap0')
36
- self.all_discards_sha256 = result['return']['sha256']
37
+ all_discards_sha256 = result['return']['sha256']
38
39
# Now, enable some bitmaps, to be updated during migration
40
for i in range(2, nb_bitmaps, 2):
41
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
42
43
event_resume = self.vm_b.event_wait('RESUME')
44
self.vm_b_events.append(event_resume)
45
- return event_resume
46
+ return (event_resume, discards1_sha256, all_discards_sha256)
47
48
def test_postcopy_success(self):
49
- event_resume = self.start_postcopy()
50
+ event_resume, discards1_sha256, all_discards_sha256 = \
51
+ self.start_postcopy()
52
53
# enabled bitmaps should be updated
54
apply_discards(self.vm_b, discards2)
55
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
56
for i in range(0, nb_bitmaps, 5):
57
result = self.vm_b.qmp('x-debug-block-dirty-bitmap-sha256',
58
node='drive0', name='bitmap{}'.format(i))
59
- sha = self.discards1_sha256 if i % 2 else self.all_discards_sha256
60
+ sha = discards1_sha256 if i % 2 else all_discards_sha256
61
self.assert_qmp(result, 'return/sha256', sha)
62
63
def test_early_shutdown_destination(self):
64
--
65
2.31.1
66
67
diff view generated by jsdifflib
New patch
1
There are a couple of things pylint takes issue with:
2
- The "time" import is unused
3
- The import order (iotests should come last)
4
- get_bitmap_hash() doesn't use @self and so should be a function
5
- Semicolons at the end of some lines
6
- Parentheses after "if"
7
- Some lines are too long (80 characters instead of 79)
8
- inject_test_case()'s @name parameter shadows a top-level @name
9
variable
10
- "lambda self: mc(self)" were equivalent to just "mc", but in
11
inject_test_case(), it is not equivalent, so add a comment and disable
12
the warning locally
13
- Always put two empty lines after a function
14
- f'exec: cat > /dev/null' does not need to be an f-string
1
15
16
Fix them.
17
18
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
19
Message-Id: <20210902094017.32902-4-hreitz@redhat.com>
20
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
21
---
22
tests/qemu-iotests/tests/migrate-bitmaps-test | 43 +++++++++++--------
23
1 file changed, 25 insertions(+), 18 deletions(-)
24
25
diff --git a/tests/qemu-iotests/tests/migrate-bitmaps-test b/tests/qemu-iotests/tests/migrate-bitmaps-test
26
index XXXXXXX..XXXXXXX 100755
27
--- a/tests/qemu-iotests/tests/migrate-bitmaps-test
28
+++ b/tests/qemu-iotests/tests/migrate-bitmaps-test
29
@@ -XXX,XX +XXX,XX @@
30
#
31
32
import os
33
-import iotests
34
-import time
35
import itertools
36
import operator
37
import re
38
+import iotests
39
from iotests import qemu_img, qemu_img_create, Timeout
40
41
42
@@ -XXX,XX +XXX,XX @@ mig_cmd = 'exec: cat > ' + mig_file
43
incoming_cmd = 'exec: cat ' + mig_file
44
45
46
+def get_bitmap_hash(vm):
47
+ result = vm.qmp('x-debug-block-dirty-bitmap-sha256',
48
+ node='drive0', name='bitmap0')
49
+ return result['return']['sha256']
50
+
51
+
52
class TestDirtyBitmapMigration(iotests.QMPTestCase):
53
def tearDown(self):
54
self.vm_a.shutdown()
55
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
56
params['persistent'] = True
57
58
result = vm.qmp('block-dirty-bitmap-add', **params)
59
- self.assert_qmp(result, 'return', {});
60
-
61
- def get_bitmap_hash(self, vm):
62
- result = vm.qmp('x-debug-block-dirty-bitmap-sha256',
63
- node='drive0', name='bitmap0')
64
- return result['return']['sha256']
65
+ self.assert_qmp(result, 'return', {})
66
67
def check_bitmap(self, vm, sha256):
68
result = vm.qmp('x-debug-block-dirty-bitmap-sha256',
69
node='drive0', name='bitmap0')
70
if sha256:
71
- self.assert_qmp(result, 'return/sha256', sha256);
72
+ self.assert_qmp(result, 'return/sha256', sha256)
73
else:
74
self.assert_qmp(result, 'error/desc',
75
- "Dirty bitmap 'bitmap0' not found");
76
+ "Dirty bitmap 'bitmap0' not found")
77
78
def do_test_migration_resume_source(self, persistent, migrate_bitmaps):
79
granularity = 512
80
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
81
self.add_bitmap(self.vm_a, granularity, persistent)
82
for r in regions:
83
self.vm_a.hmp_qemu_io('drive0', 'write %d %d' % r)
84
- sha256 = self.get_bitmap_hash(self.vm_a)
85
+ sha256 = get_bitmap_hash(self.vm_a)
86
87
result = self.vm_a.qmp('migrate', uri=mig_cmd)
88
while True:
89
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
90
break
91
while True:
92
result = self.vm_a.qmp('query-status')
93
- if (result['return']['status'] == 'postmigrate'):
94
+ if result['return']['status'] == 'postmigrate':
95
break
96
97
# test that bitmap is still here
98
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
99
self.add_bitmap(self.vm_a, granularity, persistent)
100
for r in regions:
101
self.vm_a.hmp_qemu_io('drive0', 'write %d %d' % r)
102
- sha256 = self.get_bitmap_hash(self.vm_a)
103
+ sha256 = get_bitmap_hash(self.vm_a)
104
105
if pre_shutdown:
106
self.vm_a.shutdown()
107
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
108
self.check_bitmap(self.vm_b, sha256 if persistent else False)
109
110
111
-def inject_test_case(klass, name, method, *args, **kwargs):
112
+def inject_test_case(klass, suffix, method, *args, **kwargs):
113
mc = operator.methodcaller(method, *args, **kwargs)
114
- setattr(klass, 'test_' + method + name, lambda self: mc(self))
115
+ # We want to add a function attribute to `klass`, so that it is
116
+ # correctly converted to a method on instantiation. The
117
+ # methodcaller object `mc` is a callable, not a function, so we
118
+ # need the lambda to turn it into a function.
119
+ # pylint: disable=unnecessary-lambda
120
+ setattr(klass, 'test_' + method + suffix, lambda self: mc(self))
121
+
122
123
for cmb in list(itertools.product((True, False), repeat=5)):
124
name = ('_' if cmb[0] else '_not_') + 'persistent_'
125
name += ('_' if cmb[1] else '_not_') + 'migbitmap_'
126
name += '_online' if cmb[2] else '_offline'
127
name += '_shared' if cmb[3] else '_nonshared'
128
- if (cmb[4]):
129
+ if cmb[4]:
130
name += '__pre_shutdown'
131
132
inject_test_case(TestDirtyBitmapMigration, name, 'do_test_migration',
133
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapBackingMigration(iotests.QMPTestCase):
134
self.assert_qmp(result, 'return', {})
135
136
# Check that the bitmaps are there
137
- for node in self.vm.qmp('query-named-block-nodes', flat=True)['return']:
138
+ nodes = self.vm.qmp('query-named-block-nodes', flat=True)['return']
139
+ for node in nodes:
140
if 'node0' in node['node-name']:
141
self.assert_qmp(node, 'dirty-bitmaps[0]/name', 'bmap0')
142
143
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapBackingMigration(iotests.QMPTestCase):
144
"""
145
Continue the source after migration.
146
"""
147
- result = self.vm.qmp('migrate', uri=f'exec: cat > /dev/null')
148
+ result = self.vm.qmp('migrate', uri='exec: cat > /dev/null')
149
self.assert_qmp(result, 'return', {})
150
151
with Timeout(10, 'Migration timeout'):
152
--
153
2.31.1
154
155
diff view generated by jsdifflib
New patch
1
The AbnormalShutdown exception class is not in qemu.machine, but in
2
qemu.machine.machine. (qemu.machine.AbnormalShutdown was enough for
3
Python to find it in order to run this test, but pylint complains about
4
it.)
1
5
6
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
7
Message-Id: <20210902094017.32902-5-hreitz@redhat.com>
8
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
---
10
tests/qemu-iotests/tests/mirror-top-perms | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
12
13
diff --git a/tests/qemu-iotests/tests/mirror-top-perms b/tests/qemu-iotests/tests/mirror-top-perms
14
index XXXXXXX..XXXXXXX 100755
15
--- a/tests/qemu-iotests/tests/mirror-top-perms
16
+++ b/tests/qemu-iotests/tests/mirror-top-perms
17
@@ -XXX,XX +XXX,XX @@ class TestMirrorTopPerms(iotests.QMPTestCase):
18
def tearDown(self):
19
try:
20
self.vm.shutdown()
21
- except qemu.machine.AbnormalShutdown:
22
+ except qemu.machine.machine.AbnormalShutdown:
23
pass
24
25
if self.vm_b is not None:
26
--
27
2.31.1
28
29
diff view generated by jsdifflib
New patch
1
297 so far does not check the named tests, which reside in the tests/
2
directory (i.e. full path tests/qemu-iotests/tests). Fix it.
1
3
4
Thanks to the previous two commits, all named tests pass its scrutiny,
5
so we do not have to add anything to SKIP_FILES.
6
7
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
8
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
9
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
11
Message-Id: <20210902094017.32902-6-hreitz@redhat.com>
12
---
13
tests/qemu-iotests/297 | 5 +++--
14
1 file changed, 3 insertions(+), 2 deletions(-)
15
16
diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297
17
index XXXXXXX..XXXXXXX 100755
18
--- a/tests/qemu-iotests/297
19
+++ b/tests/qemu-iotests/297
20
@@ -XXX,XX +XXX,XX @@ def is_python_file(filename):
21
22
23
def run_linters():
24
- files = [filename for filename in (set(os.listdir('.')) - set(SKIP_FILES))
25
- if is_python_file(filename)]
26
+ named_tests = [f'tests/{entry}' for entry in os.listdir('tests')]
27
+ check_tests = set(os.listdir('.') + named_tests) - set(SKIP_FILES)
28
+ files = [filename for filename in check_tests if is_python_file(filename)]
29
30
iotests.logger.debug('Files to be checked:')
31
iotests.logger.debug(', '.join(sorted(files)))
32
--
33
2.31.1
34
35
diff view generated by jsdifflib
New patch
1
From: Stefano Garzarella <sgarzare@redhat.com>
1
2
3
In mirror_iteration() we call mirror_wait_on_conflicts() with
4
`self` parameter set to NULL.
5
6
Starting from commit d44dae1a7c we dereference `self` pointer in
7
mirror_wait_on_conflicts() without checks if it is not NULL.
8
9
Backtrace:
10
Program terminated with signal SIGSEGV, Segmentation fault.
11
#0 mirror_wait_on_conflicts (self=0x0, s=<optimized out>, offset=<optimized out>, bytes=<optimized out>)
12
at ../block/mirror.c:172
13
172     self->waiting_for_op = op;
14
[Current thread is 1 (Thread 0x7f0908931ec0 (LWP 380249))]
15
(gdb) bt
16
#0 mirror_wait_on_conflicts (self=0x0, s=<optimized out>, offset=<optimized out>, bytes=<optimized out>)
17
at ../block/mirror.c:172
18
#1 0x00005610c5d9d631 in mirror_run (job=0x5610c76a2c00, errp=<optimized out>) at ../block/mirror.c:491
19
#2 0x00005610c5d58726 in job_co_entry (opaque=0x5610c76a2c00) at ../job.c:917
20
#3 0x00005610c5f046c6 in coroutine_trampoline (i0=<optimized out>, i1=<optimized out>)
21
at ../util/coroutine-ucontext.c:173
22
#4 0x00007f0909975820 in ?? () at ../sysdeps/unix/sysv/linux/x86_64/__start_context.S:91
23
from /usr/lib64/libc.so.6
24
25
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2001404
26
Fixes: d44dae1a7c ("block/mirror: fix active mirror dead-lock in mirror_wait_on_conflicts")
27
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
28
Message-Id: <20210910124533.288318-1-sgarzare@redhat.com>
29
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
30
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
31
---
32
block/mirror.c | 25 ++++++++++++++++---------
33
1 file changed, 16 insertions(+), 9 deletions(-)
34
35
diff --git a/block/mirror.c b/block/mirror.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/block/mirror.c
38
+++ b/block/mirror.c
39
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn mirror_wait_on_conflicts(MirrorOp *self,
40
if (ranges_overlap(self_start_chunk, self_nb_chunks,
41
op_start_chunk, op_nb_chunks))
42
{
43
- /*
44
- * If the operation is already (indirectly) waiting for us, or
45
- * will wait for us as soon as it wakes up, then just go on
46
- * (instead of producing a deadlock in the former case).
47
- */
48
- if (op->waiting_for_op) {
49
- continue;
50
+ if (self) {
51
+ /*
52
+ * If the operation is already (indirectly) waiting for us,
53
+ * or will wait for us as soon as it wakes up, then just go
54
+ * on (instead of producing a deadlock in the former case).
55
+ */
56
+ if (op->waiting_for_op) {
57
+ continue;
58
+ }
59
+
60
+ self->waiting_for_op = op;
61
}
62
63
- self->waiting_for_op = op;
64
qemu_co_queue_wait(&op->waiting_requests, NULL);
65
- self->waiting_for_op = NULL;
66
+
67
+ if (self) {
68
+ self->waiting_for_op = NULL;
69
+ }
70
+
71
break;
72
}
73
}
74
--
75
2.31.1
76
77
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Add a simple test which tries to run migration during backup.
4
bdrv_inactivate_all() should fail. But due to bug (see next commit with
5
fix) it doesn't, nodes are inactivated and continued backup crashes
6
on assertion "assert(!(bs->open_flags & BDRV_O_INACTIVE));" in
7
bdrv_co_write_req_prepare().
8
9
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
Message-Id: <20210911120027.8063-2-vsementsov@virtuozzo.com>
11
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
13
.../qemu-iotests/tests/migrate-during-backup | 97 +++++++++++++++++++
14
.../tests/migrate-during-backup.out | 5 +
15
2 files changed, 102 insertions(+)
16
create mode 100755 tests/qemu-iotests/tests/migrate-during-backup
17
create mode 100644 tests/qemu-iotests/tests/migrate-during-backup.out
18
19
diff --git a/tests/qemu-iotests/tests/migrate-during-backup b/tests/qemu-iotests/tests/migrate-during-backup
20
new file mode 100755
21
index XXXXXXX..XXXXXXX
22
--- /dev/null
23
+++ b/tests/qemu-iotests/tests/migrate-during-backup
24
@@ -XXX,XX +XXX,XX @@
25
+#!/usr/bin/env python3
26
+# group: migration disabled
27
+#
28
+# Copyright (c) 2021 Virtuozzo International GmbH
29
+#
30
+# This program is free software; you can redistribute it and/or modify
31
+# it under the terms of the GNU General Public License as published by
32
+# the Free Software Foundation; either version 2 of the License, or
33
+# (at your option) any later version.
34
+#
35
+# This program is distributed in the hope that it will be useful,
36
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
37
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38
+# GNU General Public License for more details.
39
+#
40
+# You should have received a copy of the GNU General Public License
41
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
42
+#
43
+
44
+import os
45
+import iotests
46
+from iotests import qemu_img_create, qemu_io
47
+
48
+
49
+disk_a = os.path.join(iotests.test_dir, 'disk_a')
50
+disk_b = os.path.join(iotests.test_dir, 'disk_b')
51
+size = '1M'
52
+mig_file = os.path.join(iotests.test_dir, 'mig_file')
53
+mig_cmd = 'exec: cat > ' + mig_file
54
+
55
+
56
+class TestMigrateDuringBackup(iotests.QMPTestCase):
57
+ def tearDown(self):
58
+ self.vm.shutdown()
59
+ os.remove(disk_a)
60
+ os.remove(disk_b)
61
+ os.remove(mig_file)
62
+
63
+ def setUp(self):
64
+ qemu_img_create('-f', iotests.imgfmt, disk_a, size)
65
+ qemu_img_create('-f', iotests.imgfmt, disk_b, size)
66
+ qemu_io('-c', f'write 0 {size}', disk_a)
67
+
68
+ self.vm = iotests.VM().add_drive(disk_a)
69
+ self.vm.launch()
70
+ result = self.vm.qmp('blockdev-add', {
71
+ 'node-name': 'target',
72
+ 'driver': iotests.imgfmt,
73
+ 'file': {
74
+ 'driver': 'file',
75
+ 'filename': disk_b
76
+ }
77
+ })
78
+ self.assert_qmp(result, 'return', {})
79
+
80
+ def test_migrate(self):
81
+ result = self.vm.qmp('blockdev-backup', device='drive0',
82
+ target='target', sync='full',
83
+ speed=1, x_perf={
84
+ 'max-workers': 1,
85
+ 'max-chunk': 64 * 1024
86
+ })
87
+ self.assert_qmp(result, 'return', {})
88
+
89
+ result = self.vm.qmp('job-pause', id='drive0')
90
+ self.assert_qmp(result, 'return', {})
91
+
92
+ result = self.vm.qmp('migrate-set-capabilities',
93
+ capabilities=[{'capability': 'events',
94
+ 'state': True}])
95
+ self.assert_qmp(result, 'return', {})
96
+ result = self.vm.qmp('migrate', uri=mig_cmd)
97
+ self.assert_qmp(result, 'return', {})
98
+
99
+ e = self.vm.events_wait((('MIGRATION',
100
+ {'data': {'status': 'completed'}}),
101
+ ('MIGRATION',
102
+ {'data': {'status': 'failed'}})))
103
+
104
+ # Don't assert that e is 'failed' now: this way we'll miss
105
+ # possible crash when backup continues :)
106
+
107
+ result = self.vm.qmp('block-job-set-speed', device='drive0',
108
+ speed=0)
109
+ self.assert_qmp(result, 'return', {})
110
+ result = self.vm.qmp('job-resume', id='drive0')
111
+ self.assert_qmp(result, 'return', {})
112
+
113
+ # For future: if something changes so that both migration
114
+ # and backup pass, let's not miss that moment, as it may
115
+ # be a bug as well as improvement.
116
+ self.assert_qmp(e, 'data/status', 'failed')
117
+
118
+
119
+if __name__ == '__main__':
120
+ iotests.main(supported_fmts=['qcow2'],
121
+ supported_protocols=['file'])
122
diff --git a/tests/qemu-iotests/tests/migrate-during-backup.out b/tests/qemu-iotests/tests/migrate-during-backup.out
123
new file mode 100644
124
index XXXXXXX..XXXXXXX
125
--- /dev/null
126
+++ b/tests/qemu-iotests/tests/migrate-during-backup.out
127
@@ -XXX,XX +XXX,XX @@
128
+.
129
+----------------------------------------------------------------------
130
+Ran 1 tests
131
+
132
+OK
133
--
134
2.31.1
135
136
diff view generated by jsdifflib
1
The BDRV_O_ALLOW_RDWR flag allows / prohibits the changing of
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
the BDS 'read_only' state, but there are a few places where it
3
is ignored. In the bdrv_set_read_only() helper, make sure to
4
honor the flag.
5
2
6
Signed-off-by: Jeff Cody <jcody@redhat.com>
3
We must not inactivate child when parent has write permissions on
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4
it.
8
Reviewed-by: John Snow <jsnow@redhat.com>
5
9
Message-id: be2e5fb2d285cbece2b6d06bed54a6f56520d251.1491597120.git.jcody@redhat.com
6
Calling .bdrv_inactivate() doesn't help: actually only qcow2 has this
7
handler and it is used to flush caches, not for permission
8
manipulations.
9
10
So, let's simply check cumulative parent permissions before
11
inactivating the node.
12
13
This commit fixes a crash when we do migration during backup: prior to
14
the commit nothing prevents all nodes inactivation at migration finish
15
and following backup write to the target crashes on assertion
16
"assert(!(bs->open_flags & BDRV_O_INACTIVE));" in
17
bdrv_co_write_req_prepare().
18
19
After the commit, we rely on the fact that copy-before-write filter
20
keeps write permission on target node to be able to write to it. So
21
inactivation fails and migration fails as expected.
22
23
Corresponding test now passes, so, enable it.
24
25
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
26
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
27
Message-Id: <20210911120027.8063-3-vsementsov@virtuozzo.com>
28
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
10
---
29
---
11
block.c | 7 +++++++
30
block.c | 8 ++++++++
12
1 file changed, 7 insertions(+)
31
tests/qemu-iotests/tests/migrate-during-backup | 2 +-
32
2 files changed, 9 insertions(+), 1 deletion(-)
13
33
14
diff --git a/block.c b/block.c
34
diff --git a/block.c b/block.c
15
index XXXXXXX..XXXXXXX 100644
35
index XXXXXXX..XXXXXXX 100644
16
--- a/block.c
36
--- a/block.c
17
+++ b/block.c
37
+++ b/block.c
18
@@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
38
@@ -XXX,XX +XXX,XX @@ static int bdrv_inactivate_recurse(BlockDriverState *bs)
19
return -EINVAL;
39
{
40
BdrvChild *child, *parent;
41
int ret;
42
+ uint64_t cumulative_perms, cumulative_shared_perms;
43
44
if (!bs->drv) {
45
return -ENOMEDIUM;
46
@@ -XXX,XX +XXX,XX @@ static int bdrv_inactivate_recurse(BlockDriverState *bs)
47
}
20
}
48
}
21
49
22
+ /* Do not clear read_only if it is prohibited */
50
+ bdrv_get_cumulative_perm(bs, &cumulative_perms,
23
+ if (!read_only && !(bs->open_flags & BDRV_O_ALLOW_RDWR)) {
51
+ &cumulative_shared_perms);
24
+ error_setg(errp, "Node '%s' is read only",
52
+ if (cumulative_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) {
25
+ bdrv_get_device_or_node_name(bs));
53
+ /* Our inactive parents still need write access. Inactivation failed. */
26
+ return -EPERM;
54
+ return -EPERM;
27
+ }
55
+ }
28
+
56
+
29
bs->read_only = read_only;
57
bs->open_flags |= BDRV_O_INACTIVE;
30
return 0;
58
31
}
59
/*
60
diff --git a/tests/qemu-iotests/tests/migrate-during-backup b/tests/qemu-iotests/tests/migrate-during-backup
61
index XXXXXXX..XXXXXXX 100755
62
--- a/tests/qemu-iotests/tests/migrate-during-backup
63
+++ b/tests/qemu-iotests/tests/migrate-during-backup
64
@@ -XXX,XX +XXX,XX @@
65
#!/usr/bin/env python3
66
-# group: migration disabled
67
+# group: migration
68
#
69
# Copyright (c) 2021 Virtuozzo International GmbH
70
#
32
--
71
--
33
2.9.3
72
2.31.1
34
73
35
74
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Add simple grammar-parsing template benchmark. New tool consume test
4
template written in bash with some special grammar injections and
5
produces multiple tests, run them and finally print a performance
6
comparison table of different tests produced from one template.
7
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Message-Id: <20210824101517.59802-2-vsementsov@virtuozzo.com>
10
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
11
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
13
scripts/simplebench/img_bench_templater.py | 95 ++++++++++++++++++++++
14
scripts/simplebench/table_templater.py | 62 ++++++++++++++
15
2 files changed, 157 insertions(+)
16
create mode 100755 scripts/simplebench/img_bench_templater.py
17
create mode 100644 scripts/simplebench/table_templater.py
18
19
diff --git a/scripts/simplebench/img_bench_templater.py b/scripts/simplebench/img_bench_templater.py
20
new file mode 100755
21
index XXXXXXX..XXXXXXX
22
--- /dev/null
23
+++ b/scripts/simplebench/img_bench_templater.py
24
@@ -XXX,XX +XXX,XX @@
25
+#!/usr/bin/env python3
26
+#
27
+# Process img-bench test templates
28
+#
29
+# Copyright (c) 2021 Virtuozzo International GmbH.
30
+#
31
+# This program is free software; you can redistribute it and/or modify
32
+# it under the terms of the GNU General Public License as published by
33
+# the Free Software Foundation; either version 2 of the License, or
34
+# (at your option) any later version.
35
+#
36
+# This program is distributed in the hope that it will be useful,
37
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
38
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39
+# GNU General Public License for more details.
40
+#
41
+# You should have received a copy of the GNU General Public License
42
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
43
+#
44
+
45
+
46
+import sys
47
+import subprocess
48
+import re
49
+import json
50
+
51
+import simplebench
52
+from results_to_text import results_to_text
53
+from table_templater import Templater
54
+
55
+
56
+def bench_func(env, case):
57
+ test = templater.gen(env['data'], case['data'])
58
+
59
+ p = subprocess.run(test, shell=True, stdout=subprocess.PIPE,
60
+ stderr=subprocess.STDOUT, universal_newlines=True)
61
+
62
+ if p.returncode == 0:
63
+ try:
64
+ m = re.search(r'Run completed in (\d+.\d+) seconds.', p.stdout)
65
+ return {'seconds': float(m.group(1))}
66
+ except Exception:
67
+ return {'error': f'failed to parse qemu-img output: {p.stdout}'}
68
+ else:
69
+ return {'error': f'qemu-img failed: {p.returncode}: {p.stdout}'}
70
+
71
+
72
+if __name__ == '__main__':
73
+ if len(sys.argv) > 1:
74
+ print("""
75
+Usage: img_bench_templater.py < path/to/test-template.sh
76
+
77
+This script generates performance tests from a test template (example below),
78
+runs them, and displays the results in a table. The template is read from
79
+stdin. It must be written in bash and end with a `qemu-img bench` invocation
80
+(whose result is parsed to get the test instance’s result).
81
+
82
+Use the following syntax in the template to create the various different test
83
+instances:
84
+
85
+ column templating: {var1|var2|...} - test will use different values in
86
+ different columns. You may use several {} constructions in the test, in this
87
+ case product of all choice-sets will be used.
88
+
89
+ row templating: [var1|var2|...] - similar thing to define rows (test-cases)
90
+
91
+Test template example:
92
+
93
+Assume you want to compare two qemu-img binaries, called qemu-img-old and
94
+qemu-img-new in your build directory in two test-cases with 4K writes and 64K
95
+writes. The template may look like this:
96
+
97
+qemu_img=/path/to/qemu/build/qemu-img-{old|new}
98
+$qemu_img create -f qcow2 /ssd/x.qcow2 1G
99
+$qemu_img bench -c 100 -d 8 [-s 4K|-s 64K] -w -t none -n /ssd/x.qcow2
100
+
101
+When passing this to stdin of img_bench_templater.py, the resulting comparison
102
+table will contain two columns (for two binaries) and two rows (for two
103
+test-cases).
104
+
105
+In addition to displaying the results, script also stores results in JSON
106
+format into results.json file in current directory.
107
+""")
108
+ sys.exit()
109
+
110
+ templater = Templater(sys.stdin.read())
111
+
112
+ envs = [{'id': ' / '.join(x), 'data': x} for x in templater.columns]
113
+ cases = [{'id': ' / '.join(x), 'data': x} for x in templater.rows]
114
+
115
+ result = simplebench.bench(bench_func, envs, cases, count=5,
116
+ initial_run=False)
117
+ print(results_to_text(result))
118
+ with open('results.json', 'w') as f:
119
+ json.dump(result, f, indent=4)
120
diff --git a/scripts/simplebench/table_templater.py b/scripts/simplebench/table_templater.py
121
new file mode 100644
122
index XXXXXXX..XXXXXXX
123
--- /dev/null
124
+++ b/scripts/simplebench/table_templater.py
125
@@ -XXX,XX +XXX,XX @@
126
+# Parser for test templates
127
+#
128
+# Copyright (c) 2021 Virtuozzo International GmbH.
129
+#
130
+# This program is free software; you can redistribute it and/or modify
131
+# it under the terms of the GNU General Public License as published by
132
+# the Free Software Foundation; either version 2 of the License, or
133
+# (at your option) any later version.
134
+#
135
+# This program is distributed in the hope that it will be useful,
136
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
137
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
138
+# GNU General Public License for more details.
139
+#
140
+# You should have received a copy of the GNU General Public License
141
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
142
+#
143
+
144
+import itertools
145
+from lark import Lark
146
+
147
+grammar = """
148
+start: ( text | column_switch | row_switch )+
149
+
150
+column_switch: "{" text ["|" text]+ "}"
151
+row_switch: "[" text ["|" text]+ "]"
152
+text: /[^|{}\[\]]+/
153
+"""
154
+
155
+parser = Lark(grammar)
156
+
157
+class Templater:
158
+ def __init__(self, template):
159
+ self.tree = parser.parse(template)
160
+
161
+ c_switches = []
162
+ r_switches = []
163
+ for x in self.tree.children:
164
+ if x.data == 'column_switch':
165
+ c_switches.append([el.children[0].value for el in x.children])
166
+ elif x.data == 'row_switch':
167
+ r_switches.append([el.children[0].value for el in x.children])
168
+
169
+ self.columns = list(itertools.product(*c_switches))
170
+ self.rows = list(itertools.product(*r_switches))
171
+
172
+ def gen(self, column, row):
173
+ i = 0
174
+ j = 0
175
+ result = []
176
+
177
+ for x in self.tree.children:
178
+ if x.data == 'text':
179
+ result.append(x.children[0].value)
180
+ elif x.data == 'column_switch':
181
+ result.append(column[i])
182
+ i += 1
183
+ elif x.data == 'row_switch':
184
+ result.append(row[j])
185
+ j += 1
186
+
187
+ return ''.join(result)
188
--
189
2.31.1
190
191
diff view generated by jsdifflib
1
Update 'clientname' to be 'user', which tracks better with both
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
the QAPI and rados variable naming.
3
2
4
Update 'name' to be 'image_name', as it indicates the rbd image.
3
No logic change, just prepare for the following commit. While being
5
Naming it 'image' would have been ideal, but we are using that for
4
here do also small grammar fix in a comment.
6
the rados_image_t value returned by rbd_open().
7
5
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Signed-off-by: Jeff Cody <jcody@redhat.com>
7
Reviewed-by: Eric Blake <eblake@redhat.com>
10
Reviewed-by: John Snow <jsnow@redhat.com>
8
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
11
Message-id: b7ec1fb2e1cf36f9b6911631447a5b0422590b7d.1491597120.git.jcody@redhat.com
9
Message-Id: <20210824101517.59802-3-vsementsov@virtuozzo.com>
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
11
---
13
block/rbd.c | 33 +++++++++++++++++----------------
12
block/qcow2-cluster.c | 49 ++++++++++++++++++++++++-------------------
14
1 file changed, 17 insertions(+), 16 deletions(-)
13
1 file changed, 28 insertions(+), 21 deletions(-)
15
14
16
diff --git a/block/rbd.c b/block/rbd.c
15
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/block/rbd.c
17
--- a/block/qcow2-cluster.c
19
+++ b/block/rbd.c
18
+++ b/block/qcow2-cluster.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVRBDState {
19
@@ -XXX,XX +XXX,XX @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
21
rados_t cluster;
20
22
rados_ioctx_t io_ctx;
21
if (end <= old_start || start >= old_end) {
23
rbd_image_t image;
22
/* No intersection */
24
- char *name;
23
- } else {
25
+ char *image_name;
24
- if (start < old_start) {
26
char *snap;
25
- /* Stop at the start of a running allocation */
27
} BDRVRBDState;
26
- bytes = old_start - start;
28
27
- } else {
29
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
28
- bytes = 0;
30
int64_t bytes = 0;
29
- }
31
int64_t objsize;
30
+ continue;
32
int obj_order = 0;
31
+ }
33
- const char *pool, *name, *conf, *clientname, *keypairs;
32
34
+ const char *pool, *image_name, *conf, *user, *keypairs;
33
- /* Stop if already an l2meta exists. After yielding, it wouldn't
35
const char *secretid;
34
- * be valid any more, so we'd have to clean up the old L2Metas
36
rados_t cluster;
35
- * and deal with requests depending on them before starting to
37
rados_ioctx_t io_ctx;
36
- * gather new ones. Not worth the trouble. */
38
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
37
- if (bytes == 0 && *m) {
39
*/
38
- *cur_bytes = 0;
40
pool = qdict_get_try_str(options, "pool");
39
- return 0;
41
conf = qdict_get_try_str(options, "conf");
40
- }
42
- clientname = qdict_get_try_str(options, "user");
41
+ /* Conflict */
43
- name = qdict_get_try_str(options, "image");
42
44
+ user = qdict_get_try_str(options, "user");
43
- if (bytes == 0) {
45
+ image_name = qdict_get_try_str(options, "image");
44
- /* Wait for the dependency to complete. We need to recheck
46
keypairs = qdict_get_try_str(options, "=keyvalue-pairs");
45
- * the free/allocated clusters when we continue. */
47
46
- qemu_co_queue_wait(&old_alloc->dependent_requests, &s->lock);
48
- ret = rados_create(&cluster, clientname);
47
- return -EAGAIN;
49
+ ret = rados_create(&cluster, user);
48
- }
50
if (ret < 0) {
49
+ if (start < old_start) {
51
error_setg_errno(errp, -ret, "error initializing");
50
+ /* Stop at the start of a running allocation */
52
goto exit;
51
+ bytes = old_start - start;
53
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
52
+ } else {
54
goto shutdown;
53
+ bytes = 0;
54
+ }
55
+
56
+ /*
57
+ * Stop if an l2meta already exists. After yielding, it wouldn't
58
+ * be valid any more, so we'd have to clean up the old L2Metas
59
+ * and deal with requests depending on them before starting to
60
+ * gather new ones. Not worth the trouble.
61
+ */
62
+ if (bytes == 0 && *m) {
63
+ *cur_bytes = 0;
64
+ return 0;
65
+ }
66
+
67
+ if (bytes == 0) {
68
+ /*
69
+ * Wait for the dependency to complete. We need to recheck
70
+ * the free/allocated clusters when we continue.
71
+ */
72
+ qemu_co_queue_wait(&old_alloc->dependent_requests, &s->lock);
73
+ return -EAGAIN;
74
}
55
}
75
}
56
76
57
- ret = rbd_create(io_ctx, name, bytes, &obj_order);
58
+ ret = rbd_create(io_ctx, image_name, bytes, &obj_order);
59
if (ret < 0) {
60
error_setg_errno(errp, -ret, "error rbd create");
61
}
62
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
63
Error **errp)
64
{
65
BDRVRBDState *s = bs->opaque;
66
- const char *pool, *snap, *conf, *clientname, *name, *keypairs;
67
+ const char *pool, *snap, *conf, *user, *image_name, *keypairs;
68
const char *secretid;
69
QemuOpts *opts;
70
Error *local_err = NULL;
71
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
72
pool = qemu_opt_get(opts, "pool");
73
conf = qemu_opt_get(opts, "conf");
74
snap = qemu_opt_get(opts, "snapshot");
75
- clientname = qemu_opt_get(opts, "user");
76
- name = qemu_opt_get(opts, "image");
77
+ user = qemu_opt_get(opts, "user");
78
+ image_name = qemu_opt_get(opts, "image");
79
keypairs = qemu_opt_get(opts, "=keyvalue-pairs");
80
81
- if (!pool || !name) {
82
+ if (!pool || !image_name) {
83
error_setg(errp, "Parameters 'pool' and 'image' are required");
84
r = -EINVAL;
85
goto failed_opts;
86
}
87
88
- r = rados_create(&s->cluster, clientname);
89
+ r = rados_create(&s->cluster, user);
90
if (r < 0) {
91
error_setg_errno(errp, -r, "error initializing");
92
goto failed_opts;
93
}
94
95
s->snap = g_strdup(snap);
96
- s->name = g_strdup(name);
97
+ s->image_name = g_strdup(image_name);
98
99
/* try default location when conf=NULL, but ignore failure */
100
r = rados_conf_read_file(s->cluster, conf);
101
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
102
}
103
104
/* rbd_open is always r/w */
105
- r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
106
+ r = rbd_open(s->io_ctx, s->image_name, &s->image, s->snap);
107
if (r < 0) {
108
- error_setg_errno(errp, -r, "error reading header from %s", s->name);
109
+ error_setg_errno(errp, -r, "error reading header from %s",
110
+ s->image_name);
111
goto failed_open;
112
}
113
114
@@ -XXX,XX +XXX,XX @@ failed_open:
115
failed_shutdown:
116
rados_shutdown(s->cluster);
117
g_free(s->snap);
118
- g_free(s->name);
119
+ g_free(s->image_name);
120
failed_opts:
121
qemu_opts_del(opts);
122
g_free(mon_host);
123
@@ -XXX,XX +XXX,XX @@ static void qemu_rbd_close(BlockDriverState *bs)
124
rbd_close(s->image);
125
rados_ioctx_destroy(s->io_ctx);
126
g_free(s->snap);
127
- g_free(s->name);
128
+ g_free(s->image_name);
129
rados_shutdown(s->cluster);
130
}
131
132
--
77
--
133
2.9.3
78
2.31.1
134
79
135
80
diff view generated by jsdifflib
1
For the tests that use the common.qemu functions for running a QEMU
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
process, _cleanup_qemu must be called in the exit function.
3
2
4
If it is not, if the qemu process aborts, then not all of the droppings
3
There is no conflict and no dependency if we have parallel writes to
5
are cleaned up (e.g. pidfile, fifos).
4
different subclusters of one cluster when the cluster itself is already
5
allocated. So, relax extra dependency.
6
6
7
This updates those tests that did not have a cleanup in qemu-iotests.
7
Measure performance:
8
First, prepare build/qemu-img-old and build/qemu-img-new images.
8
9
9
(I swapped spaces for tabs in test 102 as well)
10
cd scripts/simplebench
11
./img_bench_templater.py
10
12
11
Reported-by: Eric Blake <eblake@redhat.com>
13
Paste the following to stdin of running script:
14
15
qemu_img=../../build/qemu-img-{old|new}
16
$qemu_img create -f qcow2 -o extended_l2=on /ssd/x.qcow2 1G
17
$qemu_img bench -c 100000 -d 8 [-s 2K|-s 2K -o 512|-s $((1024*2+512))] \
18
-w -t none -n /ssd/x.qcow2
19
20
The result:
21
22
All results are in seconds
23
24
------------------ --------- ---------
25
old new
26
-s 2K 6.7 ± 15% 6.2 ± 12%
27
-7%
28
-s 2K -o 512 13 ± 3% 11 ± 5%
29
-16%
30
-s $((1024*2+512)) 9.5 ± 4% 8.4
31
-12%
32
------------------ --------- ---------
33
34
So small writes are more independent now and that helps to keep deeper
35
io queue which improves performance.
36
37
271 iotest output becomes racy for three allocation in one cluster.
38
Second and third writes may finish in different order. Second and
39
third requests don't depend on each other any more. Still they both
40
depend on first request anyway. Filter out second and third write
41
offsets to cover both possible outputs.
42
43
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
44
Message-Id: <20210824101517.59802-4-vsementsov@virtuozzo.com>
12
Reviewed-by: Eric Blake <eblake@redhat.com>
45
Reviewed-by: Eric Blake <eblake@redhat.com>
13
Signed-off-by: Jeff Cody <jcody@redhat.com>
46
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
14
Message-id: d59c2f6ad6c1da8b9b3c7f357c94a7122ccfc55a.1492544096.git.jcody@redhat.com
47
[hreitz: s/ an / and /]
48
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
15
---
49
---
16
tests/qemu-iotests/028 | 1 +
50
block/qcow2-cluster.c | 11 +++++++++++
17
tests/qemu-iotests/094 | 11 ++++++++---
51
tests/qemu-iotests/271 | 5 ++++-
18
tests/qemu-iotests/102 | 5 +++--
52
tests/qemu-iotests/271.out | 4 ++--
19
tests/qemu-iotests/109 | 1 +
53
3 files changed, 17 insertions(+), 3 deletions(-)
20
tests/qemu-iotests/117 | 1 +
21
tests/qemu-iotests/130 | 1 +
22
tests/qemu-iotests/140 | 1 +
23
tests/qemu-iotests/141 | 1 +
24
tests/qemu-iotests/143 | 1 +
25
tests/qemu-iotests/156 | 1 +
26
10 files changed, 19 insertions(+), 5 deletions(-)
27
54
28
diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028
55
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/block/qcow2-cluster.c
58
+++ b/block/qcow2-cluster.c
59
@@ -XXX,XX +XXX,XX @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
60
continue;
61
}
62
63
+ if (old_alloc->keep_old_clusters &&
64
+ (end <= l2meta_cow_start(old_alloc) ||
65
+ start >= l2meta_cow_end(old_alloc)))
66
+ {
67
+ /*
68
+ * Clusters intersect but COW areas don't. And cluster itself is
69
+ * already allocated. So, there is no actual conflict.
70
+ */
71
+ continue;
72
+ }
73
+
74
/* Conflict */
75
76
if (start < old_start) {
77
diff --git a/tests/qemu-iotests/271 b/tests/qemu-iotests/271
29
index XXXXXXX..XXXXXXX 100755
78
index XXXXXXX..XXXXXXX 100755
30
--- a/tests/qemu-iotests/028
79
--- a/tests/qemu-iotests/271
31
+++ b/tests/qemu-iotests/028
80
+++ b/tests/qemu-iotests/271
32
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
81
@@ -XXX,XX +XXX,XX @@ EOF
33
34
_cleanup()
35
{
36
+ _cleanup_qemu
37
rm -f "${TEST_IMG}.copy"
38
_cleanup_test_img
39
}
82
}
40
diff --git a/tests/qemu-iotests/094 b/tests/qemu-iotests/094
83
41
index XXXXXXX..XXXXXXX 100755
84
_make_test_img -o extended_l2=on 1M
42
--- a/tests/qemu-iotests/094
85
-_concurrent_io | $QEMU_IO | _filter_qemu_io
43
+++ b/tests/qemu-iotests/094
86
+# Second and third writes in _concurrent_io() are independent and may finish in
44
@@ -XXX,XX +XXX,XX @@ echo "QA output created by $seq"
87
+# different order. So, filter offset out to match both possible variants.
45
here="$PWD"
88
+_concurrent_io | $QEMU_IO | _filter_qemu_io | \
46
status=1    # failure is the default!
89
+ $SED -e 's/\(20480\|40960\)/OFFSET/'
47
90
_concurrent_verify | $QEMU_IO | _filter_qemu_io
48
-trap "exit \$status" 0 1 2 3 15
49
+_cleanup()
50
+{
51
+ _cleanup_qemu
52
+ _cleanup_test_img
53
+ rm -f "$TEST_DIR/source.$IMGFMT"
54
+}
55
+
56
+trap "_cleanup; exit \$status" 0 1 2 3 15
57
58
# get standard environment, filters and checks
59
. ./common.rc
60
@@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $QEMU_HANDLE \
61
62
wait=1 _cleanup_qemu
63
64
-_cleanup_test_img
65
-rm -f "$TEST_DIR/source.$IMGFMT"
66
91
67
# success, all done
92
# success, all done
68
echo '*** done'
93
diff --git a/tests/qemu-iotests/271.out b/tests/qemu-iotests/271.out
69
diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102
94
index XXXXXXX..XXXXXXX 100644
70
index XXXXXXX..XXXXXXX 100755
95
--- a/tests/qemu-iotests/271.out
71
--- a/tests/qemu-iotests/102
96
+++ b/tests/qemu-iotests/271.out
72
+++ b/tests/qemu-iotests/102
97
@@ -XXX,XX +XXX,XX @@ blkdebug: Suspended request 'A'
73
@@ -XXX,XX +XXX,XX @@ seq=$(basename $0)
98
blkdebug: Resuming request 'A'
74
echo "QA output created by $seq"
99
wrote 2048/2048 bytes at offset 30720
75
100
2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
76
here=$PWD
101
-wrote 2048/2048 bytes at offset 20480
77
-status=1    # failure is the default!
102
+wrote 2048/2048 bytes at offset OFFSET
78
+status=1 # failure is the default!
103
2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
79
104
-wrote 2048/2048 bytes at offset 40960
80
_cleanup()
105
+wrote 2048/2048 bytes at offset OFFSET
81
{
106
2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
82
-    _cleanup_test_img
107
*** done
83
+ _cleanup_qemu
84
+ _cleanup_test_img
85
}
86
trap "_cleanup; exit \$status" 0 1 2 3 15
87
88
diff --git a/tests/qemu-iotests/109 b/tests/qemu-iotests/109
89
index XXXXXXX..XXXXXXX 100755
90
--- a/tests/qemu-iotests/109
91
+++ b/tests/qemu-iotests/109
92
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
93
94
_cleanup()
95
{
96
+ _cleanup_qemu
97
rm -f $TEST_IMG.src
98
    _cleanup_test_img
99
}
100
diff --git a/tests/qemu-iotests/117 b/tests/qemu-iotests/117
101
index XXXXXXX..XXXXXXX 100755
102
--- a/tests/qemu-iotests/117
103
+++ b/tests/qemu-iotests/117
104
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
105
106
_cleanup()
107
{
108
+ _cleanup_qemu
109
    _cleanup_test_img
110
}
111
trap "_cleanup; exit \$status" 0 1 2 3 15
112
diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130
113
index XXXXXXX..XXXXXXX 100755
114
--- a/tests/qemu-iotests/130
115
+++ b/tests/qemu-iotests/130
116
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
117
118
_cleanup()
119
{
120
+ _cleanup_qemu
121
_cleanup_test_img
122
}
123
trap "_cleanup; exit \$status" 0 1 2 3 15
124
diff --git a/tests/qemu-iotests/140 b/tests/qemu-iotests/140
125
index XXXXXXX..XXXXXXX 100755
126
--- a/tests/qemu-iotests/140
127
+++ b/tests/qemu-iotests/140
128
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
129
130
_cleanup()
131
{
132
+ _cleanup_qemu
133
_cleanup_test_img
134
rm -f "$TEST_DIR/nbd"
135
}
136
diff --git a/tests/qemu-iotests/141 b/tests/qemu-iotests/141
137
index XXXXXXX..XXXXXXX 100755
138
--- a/tests/qemu-iotests/141
139
+++ b/tests/qemu-iotests/141
140
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
141
142
_cleanup()
143
{
144
+ _cleanup_qemu
145
_cleanup_test_img
146
rm -f "$TEST_DIR/{b,m,o}.$IMGFMT"
147
}
148
diff --git a/tests/qemu-iotests/143 b/tests/qemu-iotests/143
149
index XXXXXXX..XXXXXXX 100755
150
--- a/tests/qemu-iotests/143
151
+++ b/tests/qemu-iotests/143
152
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
153
154
_cleanup()
155
{
156
+ _cleanup_qemu
157
rm -f "$TEST_DIR/nbd"
158
}
159
trap "_cleanup; exit \$status" 0 1 2 3 15
160
diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156
161
index XXXXXXX..XXXXXXX 100755
162
--- a/tests/qemu-iotests/156
163
+++ b/tests/qemu-iotests/156
164
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
165
166
_cleanup()
167
{
168
+ _cleanup_qemu
169
rm -f "$TEST_IMG{,.target}{,.backing,.overlay}"
170
}
171
trap "_cleanup; exit \$status" 0 1 2 3 15
172
--
108
--
173
2.9.3
109
2.31.1
174
110
175
111
diff view generated by jsdifflib
1
Introduce check function for setting read_only flags. Will return < 0 on
1
We cannot write to images opened with O_DIRECT unless we allow them to
2
error, with appropriate Error value set. Does not alter any flags.
2
be resized so they are aligned to the sector size: Since 9c60a5d1978,
3
bdrv_node_refresh_perm() ensures that for nodes whose length is not
4
aligned to the request alignment and where someone has taken a WRITE
5
permission, the RESIZE permission is taken, too).
3
6
4
Signed-off-by: Jeff Cody <jcody@redhat.com>
7
Let qemu-img convert pass the BDRV_O_RESIZE flag (which causes
5
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
blk_new_open() to take the RESIZE permission) when using cache=none for
6
Reviewed-by: John Snow <jsnow@redhat.com>
9
the target, so that when writing to it, it can be aligned to the target
7
Message-id: e2bba34ac3bc76a0c42adc390413f358ae0566e8.1491597120.git.jcody@redhat.com
10
sector size.
11
12
Without this patch, an error is returned:
13
14
$ qemu-img convert -f raw -O raw -t none foo.img /mnt/tmp/foo.img
15
qemu-img: Could not open '/mnt/tmp/foo.img': Cannot get 'write'
16
permission without 'resize': Image size is not a multiple of request
17
alignment
18
19
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1994266
20
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
21
Message-Id: <20210819101200.64235-1-hreitz@redhat.com>
22
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
---
23
---
9
block.c | 14 +++++++++++++-
24
qemu-img.c | 8 ++++++++
10
include/block/block.h | 1 +
25
1 file changed, 8 insertions(+)
11
2 files changed, 14 insertions(+), 1 deletion(-)
12
26
13
diff --git a/block.c b/block.c
27
diff --git a/qemu-img.c b/qemu-img.c
14
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
15
--- a/block.c
29
--- a/qemu-img.c
16
+++ b/block.c
30
+++ b/qemu-img.c
17
@@ -XXX,XX +XXX,XX @@ bool bdrv_is_read_only(BlockDriverState *bs)
31
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
18
return bs->read_only;
32
goto out;
19
}
20
21
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
22
+int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
23
{
24
/* Do not set read_only if copy_on_read is enabled */
25
if (bs->copy_on_read && read_only) {
26
@@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
27
return -EPERM;
28
}
33
}
29
34
30
+ return 0;
35
+ if (flags & BDRV_O_NOCACHE) {
31
+}
36
+ /*
32
+
37
+ * If we open the target with O_DIRECT, it may be necessary to
33
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
38
+ * extend its size to align to the physical sector size.
34
+{
39
+ */
35
+ int ret = 0;
40
+ flags |= BDRV_O_RESIZE;
36
+
37
+ ret = bdrv_can_set_read_only(bs, read_only, errp);
38
+ if (ret < 0) {
39
+ return ret;
40
+ }
41
+ }
41
+
42
+
42
bs->read_only = read_only;
43
if (skip_create) {
43
return 0;
44
s.target = img_open(tgt_image_opts, out_filename, out_fmt,
44
}
45
flags, writethrough, s.quiet, false);
45
diff --git a/include/block/block.h b/include/block/block.h
46
index XXXXXXX..XXXXXXX 100644
47
--- a/include/block/block.h
48
+++ b/include/block/block.h
49
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
50
int64_t sector_num, int nb_sectors, int *pnum);
51
52
bool bdrv_is_read_only(BlockDriverState *bs);
53
+int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
54
int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
55
bool bdrv_is_sg(BlockDriverState *bs);
56
bool bdrv_is_inserted(BlockDriverState *bs);
57
--
46
--
58
2.9.3
47
2.31.1
59
48
60
49
diff view generated by jsdifflib
1
Signed-off-by: Jeff Cody <jcody@redhat.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2
3
Reviewed-by: John Snow <jsnow@redhat.com>
3
- don't use same name for size in bytes and in entries
4
Message-id: 00aed7ffdd7be4b9ed9ce1007d50028a72b34ebe.1491597120.git.jcody@redhat.com
4
- use g_autofree for l2_table
5
- add whitespace
6
- fix block comment style
7
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
10
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
11
Message-Id: <20210914122454.141075-2-vsementsov@virtuozzo.com>
12
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
5
---
13
---
6
block.c | 14 ++++++++------
14
block/qcow2-refcount.c | 47 +++++++++++++++++++++---------------------
7
1 file changed, 8 insertions(+), 6 deletions(-)
15
1 file changed, 24 insertions(+), 23 deletions(-)
8
16
9
diff --git a/block.c b/block.c
17
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
10
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
11
--- a/block.c
19
--- a/block/qcow2-refcount.c
12
+++ b/block.c
20
+++ b/block/qcow2-refcount.c
13
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
21
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
14
BlockDriver *drv;
22
int flags, BdrvCheckMode fix, bool active)
15
QemuOpts *opts;
23
{
16
const char *value;
24
BDRVQcow2State *s = bs->opaque;
17
+ bool read_only;
25
- uint64_t *l2_table, l2_entry;
18
26
+ uint64_t l2_entry;
19
assert(reopen_state != NULL);
27
uint64_t next_contiguous_offset = 0;
20
assert(reopen_state->bs->drv != NULL);
28
- int i, l2_size, nb_csectors, ret;
21
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
29
+ int i, nb_csectors, ret;
22
qdict_put(reopen_state->options, "driver", qstring_from_str(value));
30
+ size_t l2_size_bytes = s->l2_size * l2_entry_size(s);
31
+ g_autofree uint64_t *l2_table = g_malloc(l2_size_bytes);
32
33
/* Read L2 table from disk */
34
- l2_size = s->l2_size * l2_entry_size(s);
35
- l2_table = g_malloc(l2_size);
36
-
37
- ret = bdrv_pread(bs->file, l2_offset, l2_table, l2_size);
38
+ ret = bdrv_pread(bs->file, l2_offset, l2_table, l2_size_bytes);
39
if (ret < 0) {
40
fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n");
41
res->check_errors++;
42
- goto fail;
43
+ return ret;
23
}
44
}
24
45
25
- /* if we are to stay read-only, do not allow permission change
46
/* Do the actual checks */
26
- * to r/w */
47
- for(i = 0; i < s->l2_size; i++) {
27
- if (!(reopen_state->bs->open_flags & BDRV_O_ALLOW_RDWR) &&
48
+ for (i = 0; i < s->l2_size; i++) {
28
- reopen_state->flags & BDRV_O_RDWR) {
49
l2_entry = get_l2_entry(s, l2_table, i);
29
- error_setg(errp, "Node '%s' is read only",
50
30
- bdrv_get_device_or_node_name(reopen_state->bs));
51
switch (qcow2_get_cluster_type(bs, l2_entry)) {
31
+ /* If we are to stay read-only, do not allow permission change
52
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
32
+ * to r/w. Attempting to set to r/w may fail if either BDRV_O_ALLOW_RDWR is
53
l2_entry & QCOW2_COMPRESSED_SECTOR_MASK,
33
+ * not set, or if the BDS still has copy_on_read enabled */
54
nb_csectors * QCOW2_COMPRESSED_SECTOR_SIZE);
34
+ read_only = !(reopen_state->flags & BDRV_O_RDWR);
55
if (ret < 0) {
35
+ ret = bdrv_can_set_read_only(reopen_state->bs, read_only, &local_err);
56
- goto fail;
36
+ if (local_err) {
57
+ return ret;
37
+ error_propagate(errp, local_err);
58
}
38
goto error;
59
60
if (flags & CHECK_FRAG_INFO) {
61
res->bfi.allocated_clusters++;
62
res->bfi.compressed_clusters++;
63
64
- /* Compressed clusters are fragmented by nature. Since they
65
+ /*
66
+ * Compressed clusters are fragmented by nature. Since they
67
* take up sub-sector space but we only have sector granularity
68
* I/O we need to re-read the same sectors even for adjacent
69
* compressed clusters.
70
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
71
if (ret < 0) {
72
fprintf(stderr, "ERROR: Overlap check failed\n");
73
res->check_errors++;
74
- /* Something is seriously wrong, so abort checking
75
- * this L2 table */
76
- goto fail;
77
+ /*
78
+ * Something is seriously wrong, so abort checking
79
+ * this L2 table.
80
+ */
81
+ return ret;
82
}
83
84
ret = bdrv_pwrite_sync(bs->file, l2e_offset,
85
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
86
fprintf(stderr, "ERROR: Failed to overwrite L2 "
87
"table entry: %s\n", strerror(-ret));
88
res->check_errors++;
89
- /* Do not abort, continue checking the rest of this
90
- * L2 table's entries */
91
+ /*
92
+ * Do not abort, continue checking the rest of this
93
+ * L2 table's entries.
94
+ */
95
} else {
96
res->corruptions--;
97
res->corruptions_fixed++;
98
- /* Skip marking the cluster as used
99
- * (it is unused now) */
100
+ /*
101
+ * Skip marking the cluster as used
102
+ * (it is unused now).
103
+ */
104
continue;
105
}
106
}
107
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
108
refcount_table_size,
109
offset, s->cluster_size);
110
if (ret < 0) {
111
- goto fail;
112
+ return ret;
113
}
114
}
115
break;
116
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
117
}
39
}
118
}
40
119
120
- g_free(l2_table);
121
return 0;
122
-
123
-fail:
124
- g_free(l2_table);
125
- return ret;
126
}
127
128
/*
41
--
129
--
42
2.9.3
130
2.31.1
43
131
44
132
diff view generated by jsdifflib
1
The protocol VXHS does not support image creation. Some tests expect
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
to be able to create images through the protocol. Exclude VXHS from
3
these tests.
4
2
5
Signed-off-by: Jeff Cody <jcody@redhat.com>
3
Let's pass the whole L2 entry and not bother with
4
L2E_COMPRESSED_OFFSET_SIZE_MASK.
5
6
It also helps further refactoring that adds generic
7
qcow2_parse_compressed_l2_entry() helper.
8
9
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
Reviewed-by: Eric Blake <eblake@redhat.com>
11
Reviewed-by: Alberto Garcia <berto@igalia.com>
12
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
13
Message-Id: <20210914122454.141075-3-vsementsov@virtuozzo.com>
14
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
6
---
15
---
7
tests/qemu-iotests/017 | 1 +
16
block/qcow2.h | 1 -
8
tests/qemu-iotests/020 | 1 +
17
block/qcow2-cluster.c | 5 ++---
9
tests/qemu-iotests/029 | 1 +
18
block/qcow2.c | 12 +++++++-----
10
tests/qemu-iotests/073 | 1 +
19
3 files changed, 9 insertions(+), 9 deletions(-)
11
tests/qemu-iotests/114 | 1 +
12
tests/qemu-iotests/130 | 1 +
13
tests/qemu-iotests/134 | 1 +
14
tests/qemu-iotests/156 | 1 +
15
tests/qemu-iotests/158 | 1 +
16
9 files changed, 9 insertions(+)
17
20
18
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
21
diff --git a/block/qcow2.h b/block/qcow2.h
19
index XXXXXXX..XXXXXXX 100755
22
index XXXXXXX..XXXXXXX 100644
20
--- a/tests/qemu-iotests/017
23
--- a/block/qcow2.h
21
+++ b/tests/qemu-iotests/017
24
+++ b/block/qcow2.h
22
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
25
@@ -XXX,XX +XXX,XX @@ typedef enum QCow2MetadataOverlap {
23
# Any format supporting backing files
26
24
_supported_fmt qcow qcow2 vmdk qed
27
#define L1E_OFFSET_MASK 0x00fffffffffffe00ULL
25
_supported_proto generic
28
#define L2E_OFFSET_MASK 0x00fffffffffffe00ULL
26
+_unsupported_proto vxhs
29
-#define L2E_COMPRESSED_OFFSET_SIZE_MASK 0x3fffffffffffffffULL
27
_supported_os Linux
30
28
_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
31
#define REFT_OFFSET_MASK 0xfffffffffffffe00ULL
29
32
30
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
33
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
31
index XXXXXXX..XXXXXXX 100755
34
index XXXXXXX..XXXXXXX 100644
32
--- a/tests/qemu-iotests/020
35
--- a/block/qcow2-cluster.c
33
+++ b/tests/qemu-iotests/020
36
+++ b/block/qcow2-cluster.c
34
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
37
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn do_perform_cow_write(BlockDriverState *bs,
35
# Any format supporting backing files
38
* offset needs to be aligned to a cluster boundary.
36
_supported_fmt qcow qcow2 vmdk qed
39
*
37
_supported_proto generic
40
* If the cluster is unallocated then *host_offset will be 0.
38
+_unsupported_proto vxhs
41
- * If the cluster is compressed then *host_offset will contain the
39
_supported_os Linux
42
- * complete compressed cluster descriptor.
40
_unsupported_imgopts "subformat=monolithicFlat" \
43
+ * If the cluster is compressed then *host_offset will contain the l2 entry.
41
"subformat=twoGbMaxExtentFlat" \
44
*
42
diff --git a/tests/qemu-iotests/029 b/tests/qemu-iotests/029
45
* On entry, *bytes is the maximum number of contiguous bytes starting at
43
index XXXXXXX..XXXXXXX 100755
46
* offset that we are interested in.
44
--- a/tests/qemu-iotests/029
47
@@ -XXX,XX +XXX,XX @@ int qcow2_get_host_offset(BlockDriverState *bs, uint64_t offset,
45
+++ b/tests/qemu-iotests/029
48
ret = -EIO;
46
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
49
goto fail;
47
# Any format supporting intenal snapshots
50
}
48
_supported_fmt qcow2
51
- *host_offset = l2_entry & L2E_COMPRESSED_OFFSET_SIZE_MASK;
49
_supported_proto generic
52
+ *host_offset = l2_entry;
50
+_unsupported_proto vxhs
53
break;
51
_supported_os Linux
54
case QCOW2_SUBCLUSTER_ZERO_PLAIN:
52
# Internal snapshots are (currently) impossible with refcount_bits=1
55
case QCOW2_SUBCLUSTER_UNALLOCATED_PLAIN:
53
_unsupported_imgopts 'refcount_bits=1[^0-9]'
56
diff --git a/block/qcow2.c b/block/qcow2.c
54
diff --git a/tests/qemu-iotests/073 b/tests/qemu-iotests/073
57
index XXXXXXX..XXXXXXX 100644
55
index XXXXXXX..XXXXXXX 100755
58
--- a/block/qcow2.c
56
--- a/tests/qemu-iotests/073
59
+++ b/block/qcow2.c
57
+++ b/tests/qemu-iotests/073
60
@@ -XXX,XX +XXX,XX @@ typedef struct {
58
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
61
59
62
static int coroutine_fn
60
_supported_fmt qcow2
63
qcow2_co_preadv_compressed(BlockDriverState *bs,
61
_supported_proto generic
64
- uint64_t cluster_descriptor,
62
+_unsupported_proto vxhs
65
+ uint64_t l2_entry,
63
_supported_os Linux
66
uint64_t offset,
64
67
uint64_t bytes,
65
CLUSTER_SIZE=64k
68
QEMUIOVector *qiov,
66
diff --git a/tests/qemu-iotests/114 b/tests/qemu-iotests/114
69
@@ -XXX,XX +XXX,XX @@ typedef struct Qcow2AioTask {
67
index XXXXXXX..XXXXXXX 100755
70
68
--- a/tests/qemu-iotests/114
71
BlockDriverState *bs;
69
+++ b/tests/qemu-iotests/114
72
QCow2SubclusterType subcluster_type; /* only for read */
70
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
73
- uint64_t host_offset; /* or full descriptor in compressed clusters */
71
74
+ uint64_t host_offset; /* or l2_entry for compressed read */
72
_supported_fmt qcow2
75
uint64_t offset;
73
_supported_proto generic
76
uint64_t bytes;
74
+_unsupported_proto vxhs
77
QEMUIOVector *qiov;
75
_supported_os Linux
78
@@ -XXX,XX +XXX,XX @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs,
76
79
77
80
static int coroutine_fn
78
diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130
81
qcow2_co_preadv_compressed(BlockDriverState *bs,
79
index XXXXXXX..XXXXXXX 100755
82
- uint64_t cluster_descriptor,
80
--- a/tests/qemu-iotests/130
83
+ uint64_t l2_entry,
81
+++ b/tests/qemu-iotests/130
84
uint64_t offset,
82
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
85
uint64_t bytes,
83
86
QEMUIOVector *qiov,
84
_supported_fmt qcow2
87
@@ -XXX,XX +XXX,XX @@ qcow2_co_preadv_compressed(BlockDriverState *bs,
85
_supported_proto generic
88
uint8_t *buf, *out_buf;
86
+_unsupported_proto vxhs
89
int offset_in_cluster = offset_into_cluster(s, offset);
87
_supported_os Linux
90
88
91
- coffset = cluster_descriptor & s->cluster_offset_mask;
89
qemu_comm_method="monitor"
92
- nb_csectors = ((cluster_descriptor >> s->csize_shift) & s->csize_mask) + 1;
90
diff --git a/tests/qemu-iotests/134 b/tests/qemu-iotests/134
93
+ assert(qcow2_get_cluster_type(bs, l2_entry) == QCOW2_CLUSTER_COMPRESSED);
91
index XXXXXXX..XXXXXXX 100755
94
+
92
--- a/tests/qemu-iotests/134
95
+ coffset = l2_entry & s->cluster_offset_mask;
93
+++ b/tests/qemu-iotests/134
96
+ nb_csectors = ((l2_entry >> s->csize_shift) & s->csize_mask) + 1;
94
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
97
csize = nb_csectors * QCOW2_COMPRESSED_SECTOR_SIZE -
95
98
(coffset & ~QCOW2_COMPRESSED_SECTOR_MASK);
96
_supported_fmt qcow2
97
_supported_proto generic
98
+_unsupported_proto vxhs
99
_supported_os Linux
100
101
102
diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156
103
index XXXXXXX..XXXXXXX 100755
104
--- a/tests/qemu-iotests/156
105
+++ b/tests/qemu-iotests/156
106
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
107
108
_supported_fmt qcow2 qed
109
_supported_proto generic
110
+_unsupported_proto vxhs
111
_supported_os Linux
112
113
# Create source disk
114
diff --git a/tests/qemu-iotests/158 b/tests/qemu-iotests/158
115
index XXXXXXX..XXXXXXX 100755
116
--- a/tests/qemu-iotests/158
117
+++ b/tests/qemu-iotests/158
118
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
119
120
_supported_fmt qcow2
121
_supported_proto generic
122
+_unsupported_proto vxhs
123
_supported_os Linux
124
125
99
126
--
100
--
127
2.9.3
101
2.31.1
128
102
129
103
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Add helper to parse compressed l2_entry and use it everywhere instead
4
of open-coding.
5
6
Note, that in most places we move to precise coffset/csize instead of
7
sector-aligned. Still it should work good enough for updating
8
refcounts.
9
10
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11
Reviewed-by: Eric Blake <eblake@redhat.com>
12
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
13
Message-Id: <20210914122454.141075-4-vsementsov@virtuozzo.com>
14
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
15
---
16
block/qcow2.h | 3 ++-
17
block/qcow2-cluster.c | 15 +++++++++++++++
18
block/qcow2-refcount.c | 36 +++++++++++++++++-------------------
19
block/qcow2.c | 9 ++-------
20
4 files changed, 36 insertions(+), 27 deletions(-)
21
22
diff --git a/block/qcow2.h b/block/qcow2.h
23
index XXXXXXX..XXXXXXX 100644
24
--- a/block/qcow2.h
25
+++ b/block/qcow2.h
26
@@ -XXX,XX +XXX,XX @@
27
28
/* Defined in the qcow2 spec (compressed cluster descriptor) */
29
#define QCOW2_COMPRESSED_SECTOR_SIZE 512U
30
-#define QCOW2_COMPRESSED_SECTOR_MASK (~(QCOW2_COMPRESSED_SECTOR_SIZE - 1ULL))
31
32
/* Must be at least 2 to cover COW */
33
#define MIN_L2_CACHE_SIZE 2 /* cache entries */
34
@@ -XXX,XX +XXX,XX @@ int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
35
uint64_t offset,
36
int compressed_size,
37
uint64_t *host_offset);
38
+void qcow2_parse_compressed_l2_entry(BlockDriverState *bs, uint64_t l2_entry,
39
+ uint64_t *coffset, int *csize);
40
41
int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m);
42
void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m);
43
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/block/qcow2-cluster.c
46
+++ b/block/qcow2-cluster.c
47
@@ -XXX,XX +XXX,XX @@ fail:
48
g_free(l1_table);
49
return ret;
50
}
51
+
52
+void qcow2_parse_compressed_l2_entry(BlockDriverState *bs, uint64_t l2_entry,
53
+ uint64_t *coffset, int *csize)
54
+{
55
+ BDRVQcow2State *s = bs->opaque;
56
+ int nb_csectors;
57
+
58
+ assert(qcow2_get_cluster_type(bs, l2_entry) == QCOW2_CLUSTER_COMPRESSED);
59
+
60
+ *coffset = l2_entry & s->cluster_offset_mask;
61
+
62
+ nb_csectors = ((l2_entry >> s->csize_shift) & s->csize_mask) + 1;
63
+ *csize = nb_csectors * QCOW2_COMPRESSED_SECTOR_SIZE -
64
+ (*coffset & (QCOW2_COMPRESSED_SECTOR_SIZE - 1));
65
+}
66
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
67
index XXXXXXX..XXXXXXX 100644
68
--- a/block/qcow2-refcount.c
69
+++ b/block/qcow2-refcount.c
70
@@ -XXX,XX +XXX,XX @@ void qcow2_free_any_cluster(BlockDriverState *bs, uint64_t l2_entry,
71
switch (ctype) {
72
case QCOW2_CLUSTER_COMPRESSED:
73
{
74
- int64_t offset = (l2_entry & s->cluster_offset_mask)
75
- & QCOW2_COMPRESSED_SECTOR_MASK;
76
- int size = QCOW2_COMPRESSED_SECTOR_SIZE *
77
- (((l2_entry >> s->csize_shift) & s->csize_mask) + 1);
78
- qcow2_free_clusters(bs, offset, size, type);
79
+ uint64_t coffset;
80
+ int csize;
81
+
82
+ qcow2_parse_compressed_l2_entry(bs, l2_entry, &coffset, &csize);
83
+ qcow2_free_clusters(bs, coffset, csize, type);
84
}
85
break;
86
case QCOW2_CLUSTER_NORMAL:
87
@@ -XXX,XX +XXX,XX @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
88
bool l1_allocated = false;
89
int64_t old_entry, old_l2_offset;
90
unsigned slice, slice_size2, n_slices;
91
- int i, j, l1_modified = 0, nb_csectors;
92
+ int i, j, l1_modified = 0;
93
int ret;
94
95
assert(addend >= -1 && addend <= 1);
96
@@ -XXX,XX +XXX,XX @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
97
98
switch (qcow2_get_cluster_type(bs, entry)) {
99
case QCOW2_CLUSTER_COMPRESSED:
100
- nb_csectors = ((entry >> s->csize_shift) &
101
- s->csize_mask) + 1;
102
if (addend != 0) {
103
- uint64_t coffset = (entry & s->cluster_offset_mask)
104
- & QCOW2_COMPRESSED_SECTOR_MASK;
105
+ uint64_t coffset;
106
+ int csize;
107
+
108
+ qcow2_parse_compressed_l2_entry(bs, entry,
109
+ &coffset, &csize);
110
ret = update_refcount(
111
- bs, coffset,
112
- nb_csectors * QCOW2_COMPRESSED_SECTOR_SIZE,
113
+ bs, coffset, csize,
114
abs(addend), addend < 0,
115
QCOW2_DISCARD_SNAPSHOT);
116
if (ret < 0) {
117
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
118
BDRVQcow2State *s = bs->opaque;
119
uint64_t l2_entry;
120
uint64_t next_contiguous_offset = 0;
121
- int i, nb_csectors, ret;
122
+ int i, ret;
123
size_t l2_size_bytes = s->l2_size * l2_entry_size(s);
124
g_autofree uint64_t *l2_table = g_malloc(l2_size_bytes);
125
126
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
127
128
/* Do the actual checks */
129
for (i = 0; i < s->l2_size; i++) {
130
+ uint64_t coffset;
131
+ int csize;
132
l2_entry = get_l2_entry(s, l2_table, i);
133
134
switch (qcow2_get_cluster_type(bs, l2_entry)) {
135
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
136
}
137
138
/* Mark cluster as used */
139
- nb_csectors = ((l2_entry >> s->csize_shift) &
140
- s->csize_mask) + 1;
141
- l2_entry &= s->cluster_offset_mask;
142
+ qcow2_parse_compressed_l2_entry(bs, l2_entry, &coffset, &csize);
143
ret = qcow2_inc_refcounts_imrt(
144
- bs, res, refcount_table, refcount_table_size,
145
- l2_entry & QCOW2_COMPRESSED_SECTOR_MASK,
146
- nb_csectors * QCOW2_COMPRESSED_SECTOR_SIZE);
147
+ bs, res, refcount_table, refcount_table_size, coffset, csize);
148
if (ret < 0) {
149
return ret;
150
}
151
diff --git a/block/qcow2.c b/block/qcow2.c
152
index XXXXXXX..XXXXXXX 100644
153
--- a/block/qcow2.c
154
+++ b/block/qcow2.c
155
@@ -XXX,XX +XXX,XX @@ qcow2_co_preadv_compressed(BlockDriverState *bs,
156
size_t qiov_offset)
157
{
158
BDRVQcow2State *s = bs->opaque;
159
- int ret = 0, csize, nb_csectors;
160
+ int ret = 0, csize;
161
uint64_t coffset;
162
uint8_t *buf, *out_buf;
163
int offset_in_cluster = offset_into_cluster(s, offset);
164
165
- assert(qcow2_get_cluster_type(bs, l2_entry) == QCOW2_CLUSTER_COMPRESSED);
166
-
167
- coffset = l2_entry & s->cluster_offset_mask;
168
- nb_csectors = ((l2_entry >> s->csize_shift) & s->csize_mask) + 1;
169
- csize = nb_csectors * QCOW2_COMPRESSED_SECTOR_SIZE -
170
- (coffset & ~QCOW2_COMPRESSED_SECTOR_MASK);
171
+ qcow2_parse_compressed_l2_entry(bs, l2_entry, &coffset, &csize);
172
173
buf = g_try_malloc(csize);
174
if (!buf) {
175
--
176
2.31.1
177
178
diff view generated by jsdifflib
1
From: Ashish Mittal <ashmit602@gmail.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
Source code for the qnio library that this code loads can be downloaded from:
3
Split fix_l2_entry_by_zero() out of check_refcounts_l2() to be
4
https://github.com/VeritasHyperScale/libqnio.git
4
reused in further patch.
5
5
6
Sample command line using JSON syntax:
6
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7
./x86_64-softmmu/qemu-system-x86_64 -name instance-00000008 -S -vnc 0.0.0.0:0
7
Reviewed-by: Eric Blake <eblake@redhat.com>
8
-k en-us -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
8
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
9
-msg timestamp=on
9
Message-Id: <20210914122454.141075-5-vsementsov@virtuozzo.com>
10
'json:{"driver":"vxhs","vdisk-id":"c3e9095a-a5ee-4dce-afeb-2a59fb387410",
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
11
"server":{"host":"172.172.17.4","port":"9999"}}'
11
---
12
block/qcow2-refcount.c | 87 +++++++++++++++++++++++++++++-------------
13
1 file changed, 60 insertions(+), 27 deletions(-)
12
14
13
Sample command line using URI syntax:
15
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
14
qemu-img convert -f raw -O raw -n
15
/var/lib/nova/instances/_base/0c5eacd5ebea5ed914b6a3e7b18f1ce734c386ad
16
vxhs://192.168.0.1:9999/c6718f6b-0401-441d-a8c3-1f0064d75ee0
17
18
Sample command line using TLS credentials (run in secure mode):
19
./qemu-io --object
20
tls-creds-x509,id=tls0,dir=/etc/pki/qemu/vxhs,endpoint=client -c 'read
21
-v 66000 2.5k' 'json:{"server.host": "127.0.0.1", "server.port": "9999",
22
"vdisk-id": "/test.raw", "driver": "vxhs", "tls-creds":"tls0"}'
23
24
Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com>
25
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
26
Reviewed-by: Jeff Cody <jcody@redhat.com>
27
Signed-off-by: Jeff Cody <jcody@redhat.com>
28
Message-id: 1491277689-24949-2-git-send-email-Ashish.Mittal@veritas.com
29
---
30
block/Makefile.objs | 2 +
31
block/trace-events | 17 ++
32
block/vxhs.c | 575 +++++++++++++++++++++++++++++++++++++++++++++++++++
33
configure | 39 ++++
34
qapi/block-core.json | 23 ++-
35
5 files changed, 654 insertions(+), 2 deletions(-)
36
create mode 100644 block/vxhs.c
37
38
diff --git a/block/Makefile.objs b/block/Makefile.objs
39
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
40
--- a/block/Makefile.objs
17
--- a/block/qcow2-refcount.c
41
+++ b/block/Makefile.objs
18
+++ b/block/qcow2-refcount.c
42
@@ -XXX,XX +XXX,XX @@ block-obj-$(CONFIG_LIBNFS) += nfs.o
19
@@ -XXX,XX +XXX,XX @@ enum {
43
block-obj-$(CONFIG_CURL) += curl.o
20
CHECK_FRAG_INFO = 0x2, /* update BlockFragInfo counters */
44
block-obj-$(CONFIG_RBD) += rbd.o
21
};
45
block-obj-$(CONFIG_GLUSTERFS) += gluster.o
22
46
+block-obj-$(CONFIG_VXHS) += vxhs.o
23
+/*
47
block-obj-$(CONFIG_LIBSSH2) += ssh.o
24
+ * Fix L2 entry by making it QCOW2_CLUSTER_ZERO_PLAIN.
48
block-obj-y += accounting.o dirty-bitmap.o
25
+ *
49
block-obj-y += write-threshold.o
26
+ * This function decrements res->corruptions on success, so the caller is
50
@@ -XXX,XX +XXX,XX @@ rbd.o-cflags := $(RBD_CFLAGS)
27
+ * responsible to increment res->corruptions prior to the call.
51
rbd.o-libs := $(RBD_LIBS)
28
+ *
52
gluster.o-cflags := $(GLUSTERFS_CFLAGS)
29
+ * On failure in-memory @l2_table may be modified.
53
gluster.o-libs := $(GLUSTERFS_LIBS)
30
+ */
54
+vxhs.o-libs := $(VXHS_LIBS)
31
+static int fix_l2_entry_by_zero(BlockDriverState *bs, BdrvCheckResult *res,
55
ssh.o-cflags := $(LIBSSH2_CFLAGS)
32
+ uint64_t l2_offset,
56
ssh.o-libs := $(LIBSSH2_LIBS)
33
+ uint64_t *l2_table, int l2_index, bool active,
57
block-obj-$(if $(CONFIG_BZIP2),m,n) += dmg-bz2.o
34
+ bool *metadata_overlap)
58
diff --git a/block/trace-events b/block/trace-events
35
+{
59
index XXXXXXX..XXXXXXX 100644
36
+ BDRVQcow2State *s = bs->opaque;
60
--- a/block/trace-events
37
+ int ret;
61
+++ b/block/trace-events
38
+ int idx = l2_index * (l2_entry_size(s) / sizeof(uint64_t));
62
@@ -XXX,XX +XXX,XX @@ qed_aio_write_data(void *s, void *acb, int ret, uint64_t offset, size_t len) "s
39
+ uint64_t l2e_offset = l2_offset + (uint64_t)l2_index * l2_entry_size(s);
63
qed_aio_write_prefill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64
40
+ int ign = active ? QCOW2_OL_ACTIVE_L2 : QCOW2_OL_INACTIVE_L2;
64
qed_aio_write_postfill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64
41
+ uint64_t l2_entry = has_subclusters(s) ? 0 : QCOW_OFLAG_ZERO;
65
qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu"
66
+
42
+
67
+# block/vxhs.c
43
+ set_l2_entry(s, l2_table, l2_index, l2_entry);
68
+vxhs_iio_callback(int error) "ctx is NULL: error %d"
44
+ ret = qcow2_pre_write_overlap_check(bs, ign, l2e_offset, l2_entry_size(s),
69
+vxhs_iio_callback_chnfail(int err, int error) "QNIO channel failed, no i/o %d, %d"
45
+ false);
70
+vxhs_iio_callback_unknwn(int opcode, int err) "unexpected opcode %d, errno %d"
46
+ if (metadata_overlap) {
71
+vxhs_aio_rw_invalid(int req) "Invalid I/O request iodir %d"
47
+ *metadata_overlap = ret < 0;
72
+vxhs_aio_rw_ioerr(char *guid, int iodir, uint64_t size, uint64_t off, void *acb, int ret, int err) "IO ERROR (vDisk %s) FOR : Read/Write = %d size = %lu offset = %lu ACB = %p. Error = %d, errno = %d"
48
+ }
73
+vxhs_get_vdisk_stat_err(char *guid, int ret, int err) "vDisk (%s) stat ioctl failed, ret = %d, errno = %d"
49
+ if (ret < 0) {
74
+vxhs_get_vdisk_stat(char *vdisk_guid, uint64_t vdisk_size) "vDisk %s stat ioctl returned size %lu"
50
+ fprintf(stderr, "ERROR: Overlap check failed\n");
75
+vxhs_complete_aio(void *acb, uint64_t ret) "aio failed acb %p ret %ld"
51
+ goto fail;
76
+vxhs_parse_uri_filename(const char *filename) "URI passed via bdrv_parse_filename %s"
77
+vxhs_open_vdiskid(const char *vdisk_id) "Opening vdisk-id %s"
78
+vxhs_open_hostinfo(char *of_vsa_addr, int port) "Adding host %s:%d to BDRVVXHSState"
79
+vxhs_open_iio_open(const char *host) "Failed to connect to storage agent on host %s"
80
+vxhs_parse_uri_hostinfo(char *host, int port) "Host: IP %s, Port %d"
81
+vxhs_close(char *vdisk_guid) "Closing vdisk %s"
82
+vxhs_get_creds(const char *cacert, const char *client_key, const char *client_cert) "cacert %s, client_key %s, client_cert %s"
83
diff --git a/block/vxhs.c b/block/vxhs.c
84
new file mode 100644
85
index XXXXXXX..XXXXXXX
86
--- /dev/null
87
+++ b/block/vxhs.c
88
@@ -XXX,XX +XXX,XX @@
89
+/*
90
+ * QEMU Block driver for Veritas HyperScale (VxHS)
91
+ *
92
+ * Copyright (c) 2017 Veritas Technologies LLC.
93
+ *
94
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
95
+ * See the COPYING file in the top-level directory.
96
+ *
97
+ */
98
+
99
+#include "qemu/osdep.h"
100
+#include <qnio/qnio_api.h>
101
+#include <sys/param.h>
102
+#include "block/block_int.h"
103
+#include "qapi/qmp/qerror.h"
104
+#include "qapi/qmp/qdict.h"
105
+#include "qapi/qmp/qstring.h"
106
+#include "trace.h"
107
+#include "qemu/uri.h"
108
+#include "qapi/error.h"
109
+#include "qemu/uuid.h"
110
+#include "crypto/tlscredsx509.h"
111
+
112
+#define VXHS_OPT_FILENAME "filename"
113
+#define VXHS_OPT_VDISK_ID "vdisk-id"
114
+#define VXHS_OPT_SERVER "server"
115
+#define VXHS_OPT_HOST "host"
116
+#define VXHS_OPT_PORT "port"
117
+
118
+/* Only accessed under QEMU global mutex */
119
+static uint32_t vxhs_ref;
120
+
121
+typedef enum {
122
+ VDISK_AIO_READ,
123
+ VDISK_AIO_WRITE,
124
+} VDISKAIOCmd;
125
+
126
+/*
127
+ * HyperScale AIO callbacks structure
128
+ */
129
+typedef struct VXHSAIOCB {
130
+ BlockAIOCB common;
131
+ int err;
132
+} VXHSAIOCB;
133
+
134
+typedef struct VXHSvDiskHostsInfo {
135
+ void *dev_handle; /* Device handle */
136
+ char *host; /* Host name or IP */
137
+ int port; /* Host's port number */
138
+} VXHSvDiskHostsInfo;
139
+
140
+/*
141
+ * Structure per vDisk maintained for state
142
+ */
143
+typedef struct BDRVVXHSState {
144
+ VXHSvDiskHostsInfo vdisk_hostinfo; /* Per host info */
145
+ char *vdisk_guid;
146
+ char *tlscredsid; /* tlscredsid */
147
+} BDRVVXHSState;
148
+
149
+static void vxhs_complete_aio_bh(void *opaque)
150
+{
151
+ VXHSAIOCB *acb = opaque;
152
+ BlockCompletionFunc *cb = acb->common.cb;
153
+ void *cb_opaque = acb->common.opaque;
154
+ int ret = 0;
155
+
156
+ if (acb->err != 0) {
157
+ trace_vxhs_complete_aio(acb, acb->err);
158
+ ret = (-EIO);
159
+ }
52
+ }
160
+
53
+
161
+ qemu_aio_unref(acb);
54
+ ret = bdrv_pwrite_sync(bs->file, l2e_offset, &l2_table[idx],
162
+ cb(cb_opaque, ret);
55
+ l2_entry_size(s));
163
+}
56
+ if (ret < 0) {
164
+
57
+ fprintf(stderr, "ERROR: Failed to overwrite L2 "
165
+/*
58
+ "table entry: %s\n", strerror(-ret));
166
+ * Called from a libqnio thread
59
+ goto fail;
167
+ */
168
+static void vxhs_iio_callback(void *ctx, uint32_t opcode, uint32_t error)
169
+{
170
+ VXHSAIOCB *acb = NULL;
171
+
172
+ switch (opcode) {
173
+ case IRP_READ_REQUEST:
174
+ case IRP_WRITE_REQUEST:
175
+
176
+ /*
177
+ * ctx is VXHSAIOCB*
178
+ * ctx is NULL if error is QNIOERROR_CHANNEL_HUP
179
+ */
180
+ if (ctx) {
181
+ acb = ctx;
182
+ } else {
183
+ trace_vxhs_iio_callback(error);
184
+ goto out;
185
+ }
186
+
187
+ if (error) {
188
+ if (!acb->err) {
189
+ acb->err = error;
190
+ }
191
+ trace_vxhs_iio_callback(error);
192
+ }
193
+
194
+ aio_bh_schedule_oneshot(bdrv_get_aio_context(acb->common.bs),
195
+ vxhs_complete_aio_bh, acb);
196
+ break;
197
+
198
+ default:
199
+ if (error == QNIOERROR_HUP) {
200
+ /*
201
+ * Channel failed, spontaneous notification,
202
+ * not in response to I/O
203
+ */
204
+ trace_vxhs_iio_callback_chnfail(error, errno);
205
+ } else {
206
+ trace_vxhs_iio_callback_unknwn(opcode, error);
207
+ }
208
+ break;
209
+ }
210
+out:
211
+ return;
212
+}
213
+
214
+static QemuOptsList runtime_opts = {
215
+ .name = "vxhs",
216
+ .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
217
+ .desc = {
218
+ {
219
+ .name = VXHS_OPT_FILENAME,
220
+ .type = QEMU_OPT_STRING,
221
+ .help = "URI to the Veritas HyperScale image",
222
+ },
223
+ {
224
+ .name = VXHS_OPT_VDISK_ID,
225
+ .type = QEMU_OPT_STRING,
226
+ .help = "UUID of the VxHS vdisk",
227
+ },
228
+ {
229
+ .name = "tls-creds",
230
+ .type = QEMU_OPT_STRING,
231
+ .help = "ID of the TLS/SSL credentials to use",
232
+ },
233
+ { /* end of list */ }
234
+ },
235
+};
236
+
237
+static QemuOptsList runtime_tcp_opts = {
238
+ .name = "vxhs_tcp",
239
+ .head = QTAILQ_HEAD_INITIALIZER(runtime_tcp_opts.head),
240
+ .desc = {
241
+ {
242
+ .name = VXHS_OPT_HOST,
243
+ .type = QEMU_OPT_STRING,
244
+ .help = "host address (ipv4 addresses)",
245
+ },
246
+ {
247
+ .name = VXHS_OPT_PORT,
248
+ .type = QEMU_OPT_NUMBER,
249
+ .help = "port number on which VxHSD is listening (default 9999)",
250
+ .def_value_str = "9999"
251
+ },
252
+ { /* end of list */ }
253
+ },
254
+};
255
+
256
+/*
257
+ * Parse incoming URI and populate *options with the host
258
+ * and device information
259
+ */
260
+static int vxhs_parse_uri(const char *filename, QDict *options)
261
+{
262
+ URI *uri = NULL;
263
+ char *port;
264
+ int ret = 0;
265
+
266
+ trace_vxhs_parse_uri_filename(filename);
267
+ uri = uri_parse(filename);
268
+ if (!uri || !uri->server || !uri->path) {
269
+ uri_free(uri);
270
+ return -EINVAL;
271
+ }
60
+ }
272
+
61
+
273
+ qdict_put(options, VXHS_OPT_SERVER".host", qstring_from_str(uri->server));
62
+ res->corruptions--;
63
+ res->corruptions_fixed++;
64
+ return 0;
274
+
65
+
275
+ if (uri->port) {
66
+fail:
276
+ port = g_strdup_printf("%d", uri->port);
67
+ res->check_errors++;
277
+ qdict_put(options, VXHS_OPT_SERVER".port", qstring_from_str(port));
278
+ g_free(port);
279
+ }
280
+
281
+ qdict_put(options, "vdisk-id", qstring_from_str(uri->path));
282
+
283
+ trace_vxhs_parse_uri_hostinfo(uri->server, uri->port);
284
+ uri_free(uri);
285
+
286
+ return ret;
68
+ return ret;
287
+}
69
+}
288
+
70
+
289
+static void vxhs_parse_filename(const char *filename, QDict *options,
71
/*
290
+ Error **errp)
72
* Increases the refcount in the given refcount table for the all clusters
291
+{
73
* referenced in the L2 table. While doing so, performs some checks on L2
292
+ if (qdict_haskey(options, "vdisk-id") || qdict_haskey(options, "server")) {
74
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
293
+ error_setg(errp, "vdisk-id/server and a file name may not be specified "
75
int i, ret;
294
+ "at the same time");
76
size_t l2_size_bytes = s->l2_size * l2_entry_size(s);
295
+ return;
77
g_autofree uint64_t *l2_table = g_malloc(l2_size_bytes);
296
+ }
78
+ bool metadata_overlap;
79
80
/* Read L2 table from disk */
81
ret = bdrv_pread(bs->file, l2_offset, l2_table, l2_size_bytes);
82
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
83
fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR",
84
offset);
85
if (fix & BDRV_FIX_ERRORS) {
86
- int idx = i * (l2_entry_size(s) / sizeof(uint64_t));
87
- uint64_t l2e_offset =
88
- l2_offset + (uint64_t)i * l2_entry_size(s);
89
- int ign = active ? QCOW2_OL_ACTIVE_L2 :
90
- QCOW2_OL_INACTIVE_L2;
91
-
92
- l2_entry = has_subclusters(s) ? 0 : QCOW_OFLAG_ZERO;
93
- set_l2_entry(s, l2_table, i, l2_entry);
94
- ret = qcow2_pre_write_overlap_check(bs, ign,
95
- l2e_offset, l2_entry_size(s), false);
96
- if (ret < 0) {
97
- fprintf(stderr, "ERROR: Overlap check failed\n");
98
- res->check_errors++;
99
+ ret = fix_l2_entry_by_zero(bs, res, l2_offset,
100
+ l2_table, i, active,
101
+ &metadata_overlap);
102
+ if (metadata_overlap) {
103
/*
104
* Something is seriously wrong, so abort checking
105
* this L2 table.
106
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
107
return ret;
108
}
109
110
- ret = bdrv_pwrite_sync(bs->file, l2e_offset,
111
- &l2_table[idx],
112
- l2_entry_size(s));
113
- if (ret < 0) {
114
- fprintf(stderr, "ERROR: Failed to overwrite L2 "
115
- "table entry: %s\n", strerror(-ret));
116
- res->check_errors++;
117
- /*
118
- * Do not abort, continue checking the rest of this
119
- * L2 table's entries.
120
- */
121
- } else {
122
- res->corruptions--;
123
- res->corruptions_fixed++;
124
+ if (ret == 0) {
125
/*
126
* Skip marking the cluster as used
127
* (it is unused now).
128
*/
129
continue;
130
}
297
+
131
+
298
+ if (strstr(filename, "://")) {
132
+ /*
299
+ int ret = vxhs_parse_uri(filename, options);
133
+ * Failed to fix.
300
+ if (ret < 0) {
134
+ * Do not abort, continue checking the rest of this
301
+ error_setg(errp, "Invalid URI. URI should be of the form "
135
+ * L2 table's entries.
302
+ " vxhs://<host_ip>:<port>/<vdisk-id>");
136
+ */
303
+ }
137
}
304
+ }
138
} else {
305
+}
139
fprintf(stderr, "ERROR offset=%" PRIx64 ": Data cluster is "
306
+
307
+static int vxhs_init_and_ref(void)
308
+{
309
+ if (vxhs_ref++ == 0) {
310
+ if (iio_init(QNIO_VERSION, vxhs_iio_callback)) {
311
+ return -ENODEV;
312
+ }
313
+ }
314
+ return 0;
315
+}
316
+
317
+static void vxhs_unref(void)
318
+{
319
+ if (--vxhs_ref == 0) {
320
+ iio_fini();
321
+ }
322
+}
323
+
324
+static void vxhs_get_tls_creds(const char *id, char **cacert,
325
+ char **key, char **cert, Error **errp)
326
+{
327
+ Object *obj;
328
+ QCryptoTLSCreds *creds;
329
+ QCryptoTLSCredsX509 *creds_x509;
330
+
331
+ obj = object_resolve_path_component(
332
+ object_get_objects_root(), id);
333
+
334
+ if (!obj) {
335
+ error_setg(errp, "No TLS credentials with id '%s'",
336
+ id);
337
+ return;
338
+ }
339
+
340
+ creds_x509 = (QCryptoTLSCredsX509 *)
341
+ object_dynamic_cast(obj, TYPE_QCRYPTO_TLS_CREDS_X509);
342
+
343
+ if (!creds_x509) {
344
+ error_setg(errp, "Object with id '%s' is not TLS credentials",
345
+ id);
346
+ return;
347
+ }
348
+
349
+ creds = &creds_x509->parent_obj;
350
+
351
+ if (creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) {
352
+ error_setg(errp,
353
+ "Expecting TLS credentials with a client endpoint");
354
+ return;
355
+ }
356
+
357
+ /*
358
+ * Get the cacert, client_cert and client_key file names.
359
+ */
360
+ if (!creds->dir) {
361
+ error_setg(errp, "TLS object missing 'dir' property value");
362
+ return;
363
+ }
364
+
365
+ *cacert = g_strdup_printf("%s/%s", creds->dir,
366
+ QCRYPTO_TLS_CREDS_X509_CA_CERT);
367
+ *cert = g_strdup_printf("%s/%s", creds->dir,
368
+ QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
369
+ *key = g_strdup_printf("%s/%s", creds->dir,
370
+ QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
371
+}
372
+
373
+static int vxhs_open(BlockDriverState *bs, QDict *options,
374
+ int bdrv_flags, Error **errp)
375
+{
376
+ BDRVVXHSState *s = bs->opaque;
377
+ void *dev_handlep;
378
+ QDict *backing_options = NULL;
379
+ QemuOpts *opts = NULL;
380
+ QemuOpts *tcp_opts = NULL;
381
+ char *of_vsa_addr = NULL;
382
+ Error *local_err = NULL;
383
+ const char *vdisk_id_opt;
384
+ const char *server_host_opt;
385
+ int ret = 0;
386
+ char *cacert = NULL;
387
+ char *client_key = NULL;
388
+ char *client_cert = NULL;
389
+
390
+ ret = vxhs_init_and_ref();
391
+ if (ret < 0) {
392
+ ret = -EINVAL;
393
+ goto out;
394
+ }
395
+
396
+ /* Create opts info from runtime_opts and runtime_tcp_opts list */
397
+ opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
398
+ tcp_opts = qemu_opts_create(&runtime_tcp_opts, NULL, 0, &error_abort);
399
+
400
+ qemu_opts_absorb_qdict(opts, options, &local_err);
401
+ if (local_err) {
402
+ ret = -EINVAL;
403
+ goto out;
404
+ }
405
+
406
+ /* vdisk-id is the disk UUID */
407
+ vdisk_id_opt = qemu_opt_get(opts, VXHS_OPT_VDISK_ID);
408
+ if (!vdisk_id_opt) {
409
+ error_setg(&local_err, QERR_MISSING_PARAMETER, VXHS_OPT_VDISK_ID);
410
+ ret = -EINVAL;
411
+ goto out;
412
+ }
413
+
414
+ /* vdisk-id may contain a leading '/' */
415
+ if (strlen(vdisk_id_opt) > UUID_FMT_LEN + 1) {
416
+ error_setg(&local_err, "vdisk-id cannot be more than %d characters",
417
+ UUID_FMT_LEN);
418
+ ret = -EINVAL;
419
+ goto out;
420
+ }
421
+
422
+ s->vdisk_guid = g_strdup(vdisk_id_opt);
423
+ trace_vxhs_open_vdiskid(vdisk_id_opt);
424
+
425
+ /* get the 'server.' arguments */
426
+ qdict_extract_subqdict(options, &backing_options, VXHS_OPT_SERVER".");
427
+
428
+ qemu_opts_absorb_qdict(tcp_opts, backing_options, &local_err);
429
+ if (local_err != NULL) {
430
+ ret = -EINVAL;
431
+ goto out;
432
+ }
433
+
434
+ server_host_opt = qemu_opt_get(tcp_opts, VXHS_OPT_HOST);
435
+ if (!server_host_opt) {
436
+ error_setg(&local_err, QERR_MISSING_PARAMETER,
437
+ VXHS_OPT_SERVER"."VXHS_OPT_HOST);
438
+ ret = -EINVAL;
439
+ goto out;
440
+ }
441
+
442
+ if (strlen(server_host_opt) > MAXHOSTNAMELEN) {
443
+ error_setg(&local_err, "server.host cannot be more than %d characters",
444
+ MAXHOSTNAMELEN);
445
+ ret = -EINVAL;
446
+ goto out;
447
+ }
448
+
449
+ /* check if we got tls-creds via the --object argument */
450
+ s->tlscredsid = g_strdup(qemu_opt_get(opts, "tls-creds"));
451
+ if (s->tlscredsid) {
452
+ vxhs_get_tls_creds(s->tlscredsid, &cacert, &client_key,
453
+ &client_cert, &local_err);
454
+ if (local_err != NULL) {
455
+ ret = -EINVAL;
456
+ goto out;
457
+ }
458
+ trace_vxhs_get_creds(cacert, client_key, client_cert);
459
+ }
460
+
461
+ s->vdisk_hostinfo.host = g_strdup(server_host_opt);
462
+ s->vdisk_hostinfo.port = g_ascii_strtoll(qemu_opt_get(tcp_opts,
463
+ VXHS_OPT_PORT),
464
+ NULL, 0);
465
+
466
+ trace_vxhs_open_hostinfo(s->vdisk_hostinfo.host,
467
+ s->vdisk_hostinfo.port);
468
+
469
+ of_vsa_addr = g_strdup_printf("of://%s:%d",
470
+ s->vdisk_hostinfo.host,
471
+ s->vdisk_hostinfo.port);
472
+
473
+ /*
474
+ * Open qnio channel to storage agent if not opened before
475
+ */
476
+ dev_handlep = iio_open(of_vsa_addr, s->vdisk_guid, 0,
477
+ cacert, client_key, client_cert);
478
+ if (dev_handlep == NULL) {
479
+ trace_vxhs_open_iio_open(of_vsa_addr);
480
+ ret = -ENODEV;
481
+ goto out;
482
+ }
483
+ s->vdisk_hostinfo.dev_handle = dev_handlep;
484
+
485
+out:
486
+ g_free(of_vsa_addr);
487
+ QDECREF(backing_options);
488
+ qemu_opts_del(tcp_opts);
489
+ qemu_opts_del(opts);
490
+ g_free(cacert);
491
+ g_free(client_key);
492
+ g_free(client_cert);
493
+
494
+ if (ret < 0) {
495
+ vxhs_unref();
496
+ error_propagate(errp, local_err);
497
+ g_free(s->vdisk_hostinfo.host);
498
+ g_free(s->vdisk_guid);
499
+ g_free(s->tlscredsid);
500
+ s->vdisk_guid = NULL;
501
+ }
502
+
503
+ return ret;
504
+}
505
+
506
+static const AIOCBInfo vxhs_aiocb_info = {
507
+ .aiocb_size = sizeof(VXHSAIOCB)
508
+};
509
+
510
+/*
511
+ * This allocates QEMU-VXHS callback for each IO
512
+ * and is passed to QNIO. When QNIO completes the work,
513
+ * it will be passed back through the callback.
514
+ */
515
+static BlockAIOCB *vxhs_aio_rw(BlockDriverState *bs, int64_t sector_num,
516
+ QEMUIOVector *qiov, int nb_sectors,
517
+ BlockCompletionFunc *cb, void *opaque,
518
+ VDISKAIOCmd iodir)
519
+{
520
+ VXHSAIOCB *acb = NULL;
521
+ BDRVVXHSState *s = bs->opaque;
522
+ size_t size;
523
+ uint64_t offset;
524
+ int iio_flags = 0;
525
+ int ret = 0;
526
+ void *dev_handle = s->vdisk_hostinfo.dev_handle;
527
+
528
+ offset = sector_num * BDRV_SECTOR_SIZE;
529
+ size = nb_sectors * BDRV_SECTOR_SIZE;
530
+ acb = qemu_aio_get(&vxhs_aiocb_info, bs, cb, opaque);
531
+
532
+ /*
533
+ * Initialize VXHSAIOCB.
534
+ */
535
+ acb->err = 0;
536
+
537
+ iio_flags = IIO_FLAG_ASYNC;
538
+
539
+ switch (iodir) {
540
+ case VDISK_AIO_WRITE:
541
+ ret = iio_writev(dev_handle, acb, qiov->iov, qiov->niov,
542
+ offset, (uint64_t)size, iio_flags);
543
+ break;
544
+ case VDISK_AIO_READ:
545
+ ret = iio_readv(dev_handle, acb, qiov->iov, qiov->niov,
546
+ offset, (uint64_t)size, iio_flags);
547
+ break;
548
+ default:
549
+ trace_vxhs_aio_rw_invalid(iodir);
550
+ goto errout;
551
+ }
552
+
553
+ if (ret != 0) {
554
+ trace_vxhs_aio_rw_ioerr(s->vdisk_guid, iodir, size, offset,
555
+ acb, ret, errno);
556
+ goto errout;
557
+ }
558
+ return &acb->common;
559
+
560
+errout:
561
+ qemu_aio_unref(acb);
562
+ return NULL;
563
+}
564
+
565
+static BlockAIOCB *vxhs_aio_readv(BlockDriverState *bs,
566
+ int64_t sector_num, QEMUIOVector *qiov,
567
+ int nb_sectors,
568
+ BlockCompletionFunc *cb, void *opaque)
569
+{
570
+ return vxhs_aio_rw(bs, sector_num, qiov, nb_sectors, cb,
571
+ opaque, VDISK_AIO_READ);
572
+}
573
+
574
+static BlockAIOCB *vxhs_aio_writev(BlockDriverState *bs,
575
+ int64_t sector_num, QEMUIOVector *qiov,
576
+ int nb_sectors,
577
+ BlockCompletionFunc *cb, void *opaque)
578
+{
579
+ return vxhs_aio_rw(bs, sector_num, qiov, nb_sectors,
580
+ cb, opaque, VDISK_AIO_WRITE);
581
+}
582
+
583
+static void vxhs_close(BlockDriverState *bs)
584
+{
585
+ BDRVVXHSState *s = bs->opaque;
586
+
587
+ trace_vxhs_close(s->vdisk_guid);
588
+
589
+ g_free(s->vdisk_guid);
590
+ s->vdisk_guid = NULL;
591
+
592
+ /*
593
+ * Close vDisk device
594
+ */
595
+ if (s->vdisk_hostinfo.dev_handle) {
596
+ iio_close(s->vdisk_hostinfo.dev_handle);
597
+ s->vdisk_hostinfo.dev_handle = NULL;
598
+ }
599
+
600
+ vxhs_unref();
601
+
602
+ /*
603
+ * Free the dynamically allocated host string etc
604
+ */
605
+ g_free(s->vdisk_hostinfo.host);
606
+ g_free(s->tlscredsid);
607
+ s->tlscredsid = NULL;
608
+ s->vdisk_hostinfo.host = NULL;
609
+ s->vdisk_hostinfo.port = 0;
610
+}
611
+
612
+static int64_t vxhs_get_vdisk_stat(BDRVVXHSState *s)
613
+{
614
+ int64_t vdisk_size = -1;
615
+ int ret = 0;
616
+ void *dev_handle = s->vdisk_hostinfo.dev_handle;
617
+
618
+ ret = iio_ioctl(dev_handle, IOR_VDISK_STAT, &vdisk_size, 0);
619
+ if (ret < 0) {
620
+ trace_vxhs_get_vdisk_stat_err(s->vdisk_guid, ret, errno);
621
+ return -EIO;
622
+ }
623
+
624
+ trace_vxhs_get_vdisk_stat(s->vdisk_guid, vdisk_size);
625
+ return vdisk_size;
626
+}
627
+
628
+/*
629
+ * Returns the size of vDisk in bytes. This is required
630
+ * by QEMU block upper block layer so that it is visible
631
+ * to guest.
632
+ */
633
+static int64_t vxhs_getlength(BlockDriverState *bs)
634
+{
635
+ BDRVVXHSState *s = bs->opaque;
636
+ int64_t vdisk_size;
637
+
638
+ vdisk_size = vxhs_get_vdisk_stat(s);
639
+ if (vdisk_size < 0) {
640
+ return -EIO;
641
+ }
642
+
643
+ return vdisk_size;
644
+}
645
+
646
+static BlockDriver bdrv_vxhs = {
647
+ .format_name = "vxhs",
648
+ .protocol_name = "vxhs",
649
+ .instance_size = sizeof(BDRVVXHSState),
650
+ .bdrv_file_open = vxhs_open,
651
+ .bdrv_parse_filename = vxhs_parse_filename,
652
+ .bdrv_close = vxhs_close,
653
+ .bdrv_getlength = vxhs_getlength,
654
+ .bdrv_aio_readv = vxhs_aio_readv,
655
+ .bdrv_aio_writev = vxhs_aio_writev,
656
+};
657
+
658
+static void bdrv_vxhs_init(void)
659
+{
660
+ bdrv_register(&bdrv_vxhs);
661
+}
662
+
663
+block_init(bdrv_vxhs_init);
664
diff --git a/configure b/configure
665
index XXXXXXX..XXXXXXX 100755
666
--- a/configure
667
+++ b/configure
668
@@ -XXX,XX +XXX,XX @@ numa=""
669
tcmalloc="no"
670
jemalloc="no"
671
replication="yes"
672
+vxhs=""
673
674
supported_cpu="no"
675
supported_os="no"
676
@@ -XXX,XX +XXX,XX @@ for opt do
677
;;
678
--enable-replication) replication="yes"
679
;;
680
+ --disable-vxhs) vxhs="no"
681
+ ;;
682
+ --enable-vxhs) vxhs="yes"
683
+ ;;
684
*)
685
echo "ERROR: unknown option $opt"
686
echo "Try '$0 --help' for more information"
687
@@ -XXX,XX +XXX,XX @@ disabled with --disable-FEATURE, default is enabled if available:
688
xfsctl xfsctl support
689
qom-cast-debug cast debugging support
690
tools build qemu-io, qemu-nbd and qemu-image tools
691
+ vxhs Veritas HyperScale vDisk backend support
692
693
NOTE: The object files are built at the place where configure is launched
694
EOF
695
@@ -XXX,XX +XXX,XX @@ if compile_prog "" "" ; then
696
fi
697
698
##########################################
699
+# Veritas HyperScale block driver VxHS
700
+# Check if libvxhs is installed
701
+
702
+if test "$vxhs" != "no" ; then
703
+ cat > $TMPC <<EOF
704
+#include <stdint.h>
705
+#include <qnio/qnio_api.h>
706
+
707
+void *vxhs_callback;
708
+
709
+int main(void) {
710
+ iio_init(QNIO_VERSION, vxhs_callback);
711
+ return 0;
712
+}
713
+EOF
714
+ vxhs_libs="-lvxhs -lssl"
715
+ if compile_prog "" "$vxhs_libs" ; then
716
+ vxhs=yes
717
+ else
718
+ if test "$vxhs" = "yes" ; then
719
+ feature_not_found "vxhs block device" "Install libvxhs See github"
720
+ fi
721
+ vxhs=no
722
+ fi
723
+fi
724
+
725
+##########################################
726
# End of CC checks
727
# After here, no more $cc or $ld runs
728
729
@@ -XXX,XX +XXX,XX @@ echo "tcmalloc support $tcmalloc"
730
echo "jemalloc support $jemalloc"
731
echo "avx2 optimization $avx2_opt"
732
echo "replication support $replication"
733
+echo "VxHS block device $vxhs"
734
735
if test "$sdl_too_old" = "yes"; then
736
echo "-> Your SDL version is too old - please upgrade to have SDL support"
737
@@ -XXX,XX +XXX,XX @@ if test "$pthread_setname_np" = "yes" ; then
738
echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
739
fi
740
741
+if test "$vxhs" = "yes" ; then
742
+ echo "CONFIG_VXHS=y" >> $config_host_mak
743
+ echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
744
+fi
745
+
746
if test "$tcg_interpreter" = "yes"; then
747
QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
748
elif test "$ARCH" = "sparc64" ; then
749
diff --git a/qapi/block-core.json b/qapi/block-core.json
750
index XXXXXXX..XXXXXXX 100644
751
--- a/qapi/block-core.json
752
+++ b/qapi/block-core.json
753
@@ -XXX,XX +XXX,XX @@
754
#
755
# Drivers that are supported in block device operations.
756
#
757
+# @vxhs: Since 2.10
758
+#
759
# Since: 2.9
760
##
761
{ 'enum': 'BlockdevDriver',
762
@@ -XXX,XX +XXX,XX @@
763
'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs',
764
'null-aio', 'null-co', 'parallels', 'qcow', 'qcow2', 'qed',
765
'quorum', 'raw', 'rbd', 'replication', 'sheepdog', 'ssh',
766
- 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
767
+ 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] }
768
769
##
770
# @BlockdevOptionsFile:
771
@@ -XXX,XX +XXX,XX @@
772
'data': { '*offset': 'int', '*size': 'int' } }
773
774
##
775
+# @BlockdevOptionsVxHS:
776
+#
777
+# Driver specific block device options for VxHS
778
+#
779
+# @vdisk-id: UUID of VxHS volume
780
+# @server: vxhs server IP, port
781
+# @tls-creds: TLS credentials ID
782
+#
783
+# Since: 2.10
784
+##
785
+{ 'struct': 'BlockdevOptionsVxHS',
786
+ 'data': { 'vdisk-id': 'str',
787
+ 'server': 'InetSocketAddressBase',
788
+ '*tls-creds': 'str' } }
789
+
790
+##
791
# @BlockdevOptions:
792
#
793
# Options for creating a block device. Many options are available for all
794
@@ -XXX,XX +XXX,XX @@
795
'vhdx': 'BlockdevOptionsGenericFormat',
796
'vmdk': 'BlockdevOptionsGenericCOWFormat',
797
'vpc': 'BlockdevOptionsGenericFormat',
798
- 'vvfat': 'BlockdevOptionsVVFAT'
799
+ 'vvfat': 'BlockdevOptionsVVFAT',
800
+ 'vxhs': 'BlockdevOptionsVxHS'
801
} }
802
803
##
804
--
140
--
805
2.9.3
141
2.31.1
806
142
807
143
diff view generated by jsdifflib
1
This adds support for reopen in rbd, for changing between r/w and r/o.
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
Note, that this is only a flag change, but we will block a change from
3
We'll reuse the function to fix wrong L2 entry bitmap. Support it now.
4
r/o to r/w if we are using an RBD internal snapshot.
5
4
6
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7
Signed-off-by: Jeff Cody <jcody@redhat.com>
6
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Reviewed-by: John Snow <jsnow@redhat.com>
7
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
9
Message-id: d4e87539167ec6527d44c97b164eabcccf96e4f3.1491597120.git.jcody@redhat.com
8
Message-Id: <20210914122454.141075-6-vsementsov@virtuozzo.com>
9
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
10
---
10
---
11
block/rbd.c | 21 +++++++++++++++++++++
11
block/qcow2-refcount.c | 18 +++++++++++++++---
12
1 file changed, 21 insertions(+)
12
1 file changed, 15 insertions(+), 3 deletions(-)
13
13
14
diff --git a/block/rbd.c b/block/rbd.c
14
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/block/rbd.c
16
--- a/block/qcow2-refcount.c
17
+++ b/block/rbd.c
17
+++ b/block/qcow2-refcount.c
18
@@ -XXX,XX +XXX,XX @@ failed_opts:
18
@@ -XXX,XX +XXX,XX @@ enum {
19
return r;
19
};
20
}
20
21
21
/*
22
- * Fix L2 entry by making it QCOW2_CLUSTER_ZERO_PLAIN.
23
+ * Fix L2 entry by making it QCOW2_CLUSTER_ZERO_PLAIN (or making all its present
24
+ * subclusters QCOW2_SUBCLUSTER_ZERO_PLAIN).
25
*
26
* This function decrements res->corruptions on success, so the caller is
27
* responsible to increment res->corruptions prior to the call.
28
@@ -XXX,XX +XXX,XX @@ static int fix_l2_entry_by_zero(BlockDriverState *bs, BdrvCheckResult *res,
29
int idx = l2_index * (l2_entry_size(s) / sizeof(uint64_t));
30
uint64_t l2e_offset = l2_offset + (uint64_t)l2_index * l2_entry_size(s);
31
int ign = active ? QCOW2_OL_ACTIVE_L2 : QCOW2_OL_INACTIVE_L2;
32
- uint64_t l2_entry = has_subclusters(s) ? 0 : QCOW_OFLAG_ZERO;
33
34
- set_l2_entry(s, l2_table, l2_index, l2_entry);
35
+ if (has_subclusters(s)) {
36
+ uint64_t l2_bitmap = get_l2_bitmap(s, l2_table, l2_index);
22
+
37
+
23
+/* Since RBD is currently always opened R/W via the API,
38
+ /* Allocated subclusters become zero */
24
+ * we just need to check if we are using a snapshot or not, in
39
+ l2_bitmap |= l2_bitmap << 32;
25
+ * order to determine if we will allow it to be R/W */
40
+ l2_bitmap &= QCOW_L2_BITMAP_ALL_ZEROES;
26
+static int qemu_rbd_reopen_prepare(BDRVReopenState *state,
27
+ BlockReopenQueue *queue, Error **errp)
28
+{
29
+ BDRVRBDState *s = state->bs->opaque;
30
+ int ret = 0;
31
+
41
+
32
+ if (s->snap && state->flags & BDRV_O_RDWR) {
42
+ set_l2_bitmap(s, l2_table, l2_index, l2_bitmap);
33
+ error_setg(errp,
43
+ set_l2_entry(s, l2_table, l2_index, 0);
34
+ "Cannot change node '%s' to r/w when using RBD snapshot",
44
+ } else {
35
+ bdrv_get_device_or_node_name(state->bs));
45
+ set_l2_entry(s, l2_table, l2_index, QCOW_OFLAG_ZERO);
36
+ ret = -EINVAL;
37
+ }
46
+ }
38
+
47
+
39
+ return ret;
48
ret = qcow2_pre_write_overlap_check(bs, ign, l2e_offset, l2_entry_size(s),
40
+}
49
false);
41
+
50
if (metadata_overlap) {
42
static void qemu_rbd_close(BlockDriverState *bs)
43
{
44
BDRVRBDState *s = bs->opaque;
45
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_rbd = {
46
.bdrv_parse_filename = qemu_rbd_parse_filename,
47
.bdrv_file_open = qemu_rbd_open,
48
.bdrv_close = qemu_rbd_close,
49
+ .bdrv_reopen_prepare = qemu_rbd_reopen_prepare,
50
.bdrv_create = qemu_rbd_create,
51
.bdrv_has_zero_init = bdrv_has_zero_init_1,
52
.bdrv_get_info = qemu_rbd_getinfo,
53
--
51
--
54
2.9.3
52
2.31.1
55
53
56
54
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Check subcluster bitmap of the l2 entry for different types of
4
clusters:
5
6
- for compressed it must be zero
7
- for allocated check consistency of two parts of the bitmap
8
- for unallocated all subclusters should be unallocated
9
(or zero-plain)
10
11
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
12
Tested-by: Kirill Tkhai <ktkhai@virtuozzo.com>
13
Message-Id: <20210914122454.141075-7-vsementsov@virtuozzo.com>
14
Reviewed-by: Eric Blake <eblake@redhat.com>
15
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
16
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
17
---
18
block/qcow2-refcount.c | 28 ++++++++++++++++++++++++++--
19
1 file changed, 26 insertions(+), 2 deletions(-)
20
21
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/block/qcow2-refcount.c
24
+++ b/block/qcow2-refcount.c
25
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
26
int flags, BdrvCheckMode fix, bool active)
27
{
28
BDRVQcow2State *s = bs->opaque;
29
- uint64_t l2_entry;
30
+ uint64_t l2_entry, l2_bitmap;
31
uint64_t next_contiguous_offset = 0;
32
int i, ret;
33
size_t l2_size_bytes = s->l2_size * l2_entry_size(s);
34
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
35
uint64_t coffset;
36
int csize;
37
l2_entry = get_l2_entry(s, l2_table, i);
38
+ l2_bitmap = get_l2_bitmap(s, l2_table, i);
39
40
switch (qcow2_get_cluster_type(bs, l2_entry)) {
41
case QCOW2_CLUSTER_COMPRESSED:
42
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
43
break;
44
}
45
46
+ if (l2_bitmap) {
47
+ fprintf(stderr, "ERROR compressed cluster %d with non-zero "
48
+ "subcluster allocation bitmap, entry=0x%" PRIx64 "\n",
49
+ i, l2_entry);
50
+ res->corruptions++;
51
+ break;
52
+ }
53
+
54
/* Mark cluster as used */
55
qcow2_parse_compressed_l2_entry(bs, l2_entry, &coffset, &csize);
56
ret = qcow2_inc_refcounts_imrt(
57
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
58
{
59
uint64_t offset = l2_entry & L2E_OFFSET_MASK;
60
61
+ if ((l2_bitmap >> 32) & l2_bitmap) {
62
+ res->corruptions++;
63
+ fprintf(stderr, "ERROR offset=%" PRIx64 ": Allocated "
64
+ "cluster has corrupted subcluster allocation bitmap\n",
65
+ offset);
66
+ }
67
+
68
/* Correct offsets are cluster aligned */
69
if (offset_into_cluster(s, offset)) {
70
bool contains_data;
71
res->corruptions++;
72
73
if (has_subclusters(s)) {
74
- uint64_t l2_bitmap = get_l2_bitmap(s, l2_table, i);
75
contains_data = (l2_bitmap & QCOW_L2_BITMAP_ALL_ALLOC);
76
} else {
77
contains_data = !(l2_entry & QCOW_OFLAG_ZERO);
78
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
79
}
80
81
case QCOW2_CLUSTER_ZERO_PLAIN:
82
+ /* Impossible when image has subclusters */
83
+ assert(!l2_bitmap);
84
+ break;
85
+
86
case QCOW2_CLUSTER_UNALLOCATED:
87
+ if (l2_bitmap & QCOW_L2_BITMAP_ALL_ALLOC) {
88
+ res->corruptions++;
89
+ fprintf(stderr, "ERROR: Unallocated "
90
+ "cluster has non-zero subcluster allocation map\n");
91
+ }
92
break;
93
94
default:
95
--
96
2.31.1
97
98
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
4
Reviewed-by: Eric Blake <eblake@redhat.com>
5
Tested-by: Kirill Tkhai <ktkhai@virtuozzo.com>
6
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
7
Message-Id: <20210914122454.141075-8-vsementsov@virtuozzo.com>
8
[hreitz: Separated `type` declaration from statements]
9
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
10
---
11
block/qcow2.h | 1 +
12
block/qcow2-refcount.c | 14 +++++++++++++-
13
2 files changed, 14 insertions(+), 1 deletion(-)
14
15
diff --git a/block/qcow2.h b/block/qcow2.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/qcow2.h
18
+++ b/block/qcow2.h
19
@@ -XXX,XX +XXX,XX @@ typedef enum QCow2MetadataOverlap {
20
21
#define L1E_OFFSET_MASK 0x00fffffffffffe00ULL
22
#define L2E_OFFSET_MASK 0x00fffffffffffe00ULL
23
+#define L2E_STD_RESERVED_MASK 0x3f000000000001feULL
24
25
#define REFT_OFFSET_MASK 0xfffffffffffffe00ULL
26
27
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/block/qcow2-refcount.c
30
+++ b/block/qcow2-refcount.c
31
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
32
for (i = 0; i < s->l2_size; i++) {
33
uint64_t coffset;
34
int csize;
35
+ QCow2ClusterType type;
36
+
37
l2_entry = get_l2_entry(s, l2_table, i);
38
l2_bitmap = get_l2_bitmap(s, l2_table, i);
39
+ type = qcow2_get_cluster_type(bs, l2_entry);
40
+
41
+ if (type != QCOW2_CLUSTER_COMPRESSED) {
42
+ /* Check reserved bits of Standard Cluster Descriptor */
43
+ if (l2_entry & L2E_STD_RESERVED_MASK) {
44
+ fprintf(stderr, "ERROR found l2 entry with reserved bits set: "
45
+ "%" PRIx64 "\n", l2_entry);
46
+ res->corruptions++;
47
+ }
48
+ }
49
50
- switch (qcow2_get_cluster_type(bs, l2_entry)) {
51
+ switch (type) {
52
case QCOW2_CLUSTER_COMPRESSED:
53
/* Compressed clusters don't have QCOW_OFLAG_COPIED */
54
if (l2_entry & QCOW_OFLAG_COPIED) {
55
--
56
2.31.1
57
58
diff view generated by jsdifflib
1
A few block drivers will set the BDS read_only flag from their
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
.bdrv_open() function. This means the bs->read_only flag could
3
be set after we enable copy_on_read, as the BDRV_O_COPY_ON_READ
4
flag check occurs prior to the call to bdrv->bdrv_open().
5
2
6
This adds an error return to bdrv_set_read_only(), and an error will be
3
- use g_autofree for l1_table
7
return if we try to set the BDS to read_only while copy_on_read is
4
- better name for size in bytes variable
8
enabled.
5
- reduce code blocks nesting
6
- whitespaces, braces, newlines
9
7
10
This patch also changes the behavior of vvfat. Before, vvfat could
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11
override the drive 'readonly' flag with its own, internal 'rw' flag.
9
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
10
Message-Id: <20210914122454.141075-9-vsementsov@virtuozzo.com>
11
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
13
block/qcow2-refcount.c | 98 +++++++++++++++++++++---------------------
14
1 file changed, 50 insertions(+), 48 deletions(-)
12
15
13
For instance, this -drive parameter would result in a writable image:
16
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
14
15
"-drive format=vvfat,dir=/tmp/vvfat,rw,if=virtio,readonly=on"
16
17
This is not correct. Now, attempting to use the above -drive parameter
18
will result in an error (i.e., 'rw' is incompatible with 'readonly=on').
19
20
Signed-off-by: Jeff Cody <jcody@redhat.com>
21
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
22
Reviewed-by: John Snow <jsnow@redhat.com>
23
Message-id: 0c5b4c1cc2c651471b131f21376dfd5ea24d2196.1491597120.git.jcody@redhat.com
24
---
25
block.c | 10 +++++++++-
26
block/bochs.c | 5 ++++-
27
block/cloop.c | 5 ++++-
28
block/dmg.c | 6 +++++-
29
block/rbd.c | 11 ++++++++++-
30
block/vvfat.c | 19 +++++++++++++++----
31
include/block/block.h | 2 +-
32
7 files changed, 48 insertions(+), 10 deletions(-)
33
34
diff --git a/block.c b/block.c
35
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
36
--- a/block.c
18
--- a/block/qcow2-refcount.c
37
+++ b/block.c
19
+++ b/block/qcow2-refcount.c
38
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
20
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l1(BlockDriverState *bs,
39
}
21
int flags, BdrvCheckMode fix, bool active)
40
}
41
42
-void bdrv_set_read_only(BlockDriverState *bs, bool read_only)
43
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
44
{
22
{
45
+ /* Do not set read_only if copy_on_read is enabled */
23
BDRVQcow2State *s = bs->opaque;
46
+ if (bs->copy_on_read && read_only) {
24
- uint64_t *l1_table = NULL, l2_offset, l1_size2;
47
+ error_setg(errp, "Can't set node '%s' to r/o with copy-on-read enabled",
25
+ size_t l1_size_bytes = l1_size * L1E_SIZE;
48
+ bdrv_get_device_or_node_name(bs));
26
+ g_autofree uint64_t *l1_table = NULL;
49
+ return -EINVAL;
27
+ uint64_t l2_offset;
28
int i, ret;
29
30
- l1_size2 = l1_size * L1E_SIZE;
31
+ if (!l1_size) {
32
+ return 0;
50
+ }
33
+ }
51
+
34
52
bs->read_only = read_only;
35
/* Mark L1 table as used */
53
+ return 0;
36
ret = qcow2_inc_refcounts_imrt(bs, res, refcount_table, refcount_table_size,
54
}
37
- l1_table_offset, l1_size2);
55
38
+ l1_table_offset, l1_size_bytes);
56
void bdrv_get_full_backing_filename_from_filename(const char *backed,
57
diff --git a/block/bochs.c b/block/bochs.c
58
index XXXXXXX..XXXXXXX 100644
59
--- a/block/bochs.c
60
+++ b/block/bochs.c
61
@@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
62
return -EINVAL;
63
}
64
65
- bdrv_set_read_only(bs, true); /* no write support yet */
66
+ ret = bdrv_set_read_only(bs, true, errp); /* no write support yet */
67
+ if (ret < 0) {
68
+ return ret;
69
+ }
70
71
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
72
if (ret < 0) {
39
if (ret < 0) {
73
diff --git a/block/cloop.c b/block/cloop.c
40
- goto fail;
74
index XXXXXXX..XXXXXXX 100644
75
--- a/block/cloop.c
76
+++ b/block/cloop.c
77
@@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
78
return -EINVAL;
79
}
80
81
- bdrv_set_read_only(bs, true);
82
+ ret = bdrv_set_read_only(bs, true, errp);
83
+ if (ret < 0) {
84
+ return ret;
85
+ }
86
87
/* read header */
88
ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
89
diff --git a/block/dmg.c b/block/dmg.c
90
index XXXXXXX..XXXXXXX 100644
91
--- a/block/dmg.c
92
+++ b/block/dmg.c
93
@@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
94
return -EINVAL;
95
}
96
97
+ ret = bdrv_set_read_only(bs, true, errp);
98
+ if (ret < 0) {
99
+ return ret;
41
+ return ret;
100
+ }
42
+ }
101
+
43
+
102
block_module_load_one("dmg-bz2");
44
+ l1_table = g_try_malloc(l1_size_bytes);
103
- bdrv_set_read_only(bs, true);
45
+ if (l1_table == NULL) {
104
46
+ res->check_errors++;
105
s->n_chunks = 0;
47
+ return -ENOMEM;
106
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
107
diff --git a/block/rbd.c b/block/rbd.c
108
index XXXXXXX..XXXXXXX 100644
109
--- a/block/rbd.c
110
+++ b/block/rbd.c
111
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
112
goto failed_shutdown;
113
}
48
}
114
49
115
+ /* rbd_open is always r/w */
50
/* Read L1 table entries from disk */
116
r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
51
- if (l1_size2 > 0) {
117
if (r < 0) {
52
- l1_table = g_try_malloc(l1_size2);
118
error_setg_errno(errp, -r, "error reading header from %s", s->name);
53
- if (l1_table == NULL) {
119
goto failed_open;
54
- ret = -ENOMEM;
55
- res->check_errors++;
56
- goto fail;
57
- }
58
- ret = bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2);
59
- if (ret < 0) {
60
- fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n");
61
- res->check_errors++;
62
- goto fail;
63
- }
64
- for(i = 0;i < l1_size; i++)
65
- be64_to_cpus(&l1_table[i]);
66
+ ret = bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size_bytes);
67
+ if (ret < 0) {
68
+ fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n");
69
+ res->check_errors++;
70
+ return ret;
71
+ }
72
+
73
+ for (i = 0; i < l1_size; i++) {
74
+ be64_to_cpus(&l1_table[i]);
120
}
75
}
121
76
122
- bdrv_set_read_only(bs, (s->snap != NULL));
77
/* Do the actual checks */
123
+ /* If we are using an rbd snapshot, we must be r/o, otherwise
78
- for(i = 0; i < l1_size; i++) {
124
+ * leave as-is */
79
- l2_offset = l1_table[i];
125
+ if (s->snap != NULL) {
80
- if (l2_offset) {
126
+ r = bdrv_set_read_only(bs, true, &local_err);
81
- /* Mark L2 table as used */
127
+ if (r < 0) {
82
- l2_offset &= L1E_OFFSET_MASK;
128
+ error_propagate(errp, local_err);
83
- ret = qcow2_inc_refcounts_imrt(bs, res,
129
+ goto failed_open;
84
- refcount_table, refcount_table_size,
85
- l2_offset, s->cluster_size);
86
- if (ret < 0) {
87
- goto fail;
88
- }
89
+ for (i = 0; i < l1_size; i++) {
90
+ if (!l1_table[i]) {
91
+ continue;
130
+ }
92
+ }
131
+ }
93
132
94
- /* L2 tables are cluster aligned */
133
qemu_opts_del(opts);
95
- if (offset_into_cluster(s, l2_offset)) {
134
return 0;
96
- fprintf(stderr, "ERROR l2_offset=%" PRIx64 ": Table is not "
135
diff --git a/block/vvfat.c b/block/vvfat.c
97
- "cluster aligned; L1 entry corrupted\n", l2_offset);
136
index XXXXXXX..XXXXXXX 100644
98
- res->corruptions++;
137
--- a/block/vvfat.c
99
- }
138
+++ b/block/vvfat.c
100
+ l2_offset = l1_table[i] & L1E_OFFSET_MASK;
139
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
101
140
102
- /* Process and check L2 entries */
141
s->current_cluster=0xffffffff;
103
- ret = check_refcounts_l2(bs, res, refcount_table,
142
104
- refcount_table_size, l2_offset, flags,
143
- /* read only is the default for safety */
105
- fix, active);
144
- bdrv_set_read_only(bs, true);
106
- if (ret < 0) {
145
s->qcow = NULL;
107
- goto fail;
146
s->qcow_filename = NULL;
108
- }
147
s->fat2 = NULL;
109
+ /* Mark L2 table as used */
148
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
110
+ ret = qcow2_inc_refcounts_imrt(bs, res,
149
s->sector_count = cyls * heads * secs - (s->first_sectors_number - 1);
111
+ refcount_table, refcount_table_size,
150
112
+ l2_offset, s->cluster_size);
151
if (qemu_opt_get_bool(opts, "rw", false)) {
113
+ if (ret < 0) {
152
- ret = enable_write_target(bs, errp);
114
+ return ret;
153
+ if (!bdrv_is_read_only(bs)) {
154
+ ret = enable_write_target(bs, errp);
155
+ if (ret < 0) {
156
+ goto fail;
157
+ }
158
+ } else {
159
+ ret = -EPERM;
160
+ error_setg(errp,
161
+ "Unable to set VVFAT to 'rw' when drive is read-only");
162
+ goto fail;
163
+ }
115
+ }
164
+ } else {
116
+
165
+ /* read only is the default for safety */
117
+ /* L2 tables are cluster aligned */
166
+ ret = bdrv_set_read_only(bs, true, &local_err);
118
+ if (offset_into_cluster(s, l2_offset)) {
167
if (ret < 0) {
119
+ fprintf(stderr, "ERROR l2_offset=%" PRIx64 ": Table is not "
168
+ error_propagate(errp, local_err);
120
+ "cluster aligned; L1 entry corrupted\n", l2_offset);
169
goto fail;
121
+ res->corruptions++;
122
+ }
123
+
124
+ /* Process and check L2 entries */
125
+ ret = check_refcounts_l2(bs, res, refcount_table,
126
+ refcount_table_size, l2_offset, flags,
127
+ fix, active);
128
+ if (ret < 0) {
129
+ return ret;
170
}
130
}
171
- bdrv_set_read_only(bs, false);
172
}
131
}
173
132
- g_free(l1_table);
174
bs->total_sectors = cyls * heads * secs;
133
- return 0;
175
diff --git a/include/block/block.h b/include/block/block.h
134
176
index XXXXXXX..XXXXXXX 100644
135
-fail:
177
--- a/include/block/block.h
136
- g_free(l1_table);
178
+++ b/include/block/block.h
137
- return ret;
179
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
138
+ return 0;
180
int64_t sector_num, int nb_sectors, int *pnum);
139
}
181
140
182
bool bdrv_is_read_only(BlockDriverState *bs);
141
/*
183
-void bdrv_set_read_only(BlockDriverState *bs, bool read_only);
184
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
185
bool bdrv_is_sg(BlockDriverState *bs);
186
bool bdrv_is_inserted(BlockDriverState *bs);
187
int bdrv_media_changed(BlockDriverState *bs);
188
--
142
--
189
2.9.3
143
2.31.1
190
144
191
145
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
4
Reviewed-by: Eric Blake <eblake@redhat.com>
5
Tested-by: Kirill Tkhai <ktkhai@virtuozzo.com>
6
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
7
Message-Id: <20210914122454.141075-10-vsementsov@virtuozzo.com>
8
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
9
---
10
block/qcow2.h | 1 +
11
block/qcow2-refcount.c | 6 ++++++
12
2 files changed, 7 insertions(+)
13
14
diff --git a/block/qcow2.h b/block/qcow2.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/block/qcow2.h
17
+++ b/block/qcow2.h
18
@@ -XXX,XX +XXX,XX @@ typedef enum QCow2MetadataOverlap {
19
(QCOW2_OL_CACHED | QCOW2_OL_INACTIVE_L2)
20
21
#define L1E_OFFSET_MASK 0x00fffffffffffe00ULL
22
+#define L1E_RESERVED_MASK 0x7f000000000001ffULL
23
#define L2E_OFFSET_MASK 0x00fffffffffffe00ULL
24
#define L2E_STD_RESERVED_MASK 0x3f000000000001feULL
25
26
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/block/qcow2-refcount.c
29
+++ b/block/qcow2-refcount.c
30
@@ -XXX,XX +XXX,XX @@ static int check_refcounts_l1(BlockDriverState *bs,
31
continue;
32
}
33
34
+ if (l1_table[i] & L1E_RESERVED_MASK) {
35
+ fprintf(stderr, "ERROR found L1 entry with reserved bits set: "
36
+ "%" PRIx64 "\n", l1_table[i]);
37
+ res->corruptions++;
38
+ }
39
+
40
l2_offset = l1_table[i] & L1E_OFFSET_MASK;
41
42
/* Mark L2 table as used */
43
--
44
2.31.1
45
46
diff view generated by jsdifflib
1
Move bdrv_is_read_only() up with its friends.
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
3
Split checking for reserved bits out of aligned offset check.
4
Reviewed-by: John Snow <jsnow@redhat.com>
4
5
Signed-off-by: Jeff Cody <jcody@redhat.com>
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
6
Message-id: 73b2399459760c32506f9407efb9dddb3a2789de.1491597120.git.jcody@redhat.com
6
Reviewed-by: Eric Blake <eblake@redhat.com>
7
Tested-by: Kirill Tkhai <ktkhai@virtuozzo.com>
8
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
9
Message-Id: <20210914122454.141075-11-vsementsov@virtuozzo.com>
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
7
---
11
---
8
block.c | 10 +++++-----
12
block/qcow2.h | 1 +
9
1 file changed, 5 insertions(+), 5 deletions(-)
13
block/qcow2-refcount.c | 10 +++++++++-
14
2 files changed, 10 insertions(+), 1 deletion(-)
10
15
11
diff --git a/block.c b/block.c
16
diff --git a/block/qcow2.h b/block/qcow2.h
12
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
13
--- a/block.c
18
--- a/block/qcow2.h
14
+++ b/block.c
19
+++ b/block/qcow2.h
15
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
20
@@ -XXX,XX +XXX,XX @@ typedef enum QCow2MetadataOverlap {
16
}
21
#define L2E_STD_RESERVED_MASK 0x3f000000000001feULL
17
}
22
18
23
#define REFT_OFFSET_MASK 0xfffffffffffffe00ULL
19
+bool bdrv_is_read_only(BlockDriverState *bs)
24
+#define REFT_RESERVED_MASK 0x1ffULL
20
+{
25
21
+ return bs->read_only;
26
#define INV_OFFSET (-1ULL)
22
+}
27
28
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/block/qcow2-refcount.c
31
+++ b/block/qcow2-refcount.c
32
@@ -XXX,XX +XXX,XX @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res,
33
34
for(i = 0; i < s->refcount_table_size; i++) {
35
uint64_t offset, cluster;
36
- offset = s->refcount_table[i];
37
+ offset = s->refcount_table[i] & REFT_OFFSET_MASK;
38
cluster = offset >> s->cluster_bits;
39
40
+ if (s->refcount_table[i] & REFT_RESERVED_MASK) {
41
+ fprintf(stderr, "ERROR refcount table entry %" PRId64 " has "
42
+ "reserved bits set\n", i);
43
+ res->corruptions++;
44
+ *rebuild = true;
45
+ continue;
46
+ }
23
+
47
+
24
int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
48
/* Refcount blocks are cluster aligned */
25
{
49
if (offset_into_cluster(s, offset)) {
26
/* Do not set read_only if copy_on_read is enabled */
50
fprintf(stderr, "ERROR refcount block %" PRId64 " is not "
27
@@ -XXX,XX +XXX,XX @@ void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr)
28
*nb_sectors_ptr = nb_sectors < 0 ? 0 : nb_sectors;
29
}
30
31
-bool bdrv_is_read_only(BlockDriverState *bs)
32
-{
33
- return bs->read_only;
34
-}
35
-
36
bool bdrv_is_sg(BlockDriverState *bs)
37
{
38
return bs->sg;
39
--
51
--
40
2.9.3
52
2.31.1
41
53
42
54
diff view generated by jsdifflib
1
From: Ashish Mittal <ashmit602@gmail.com>
1
From: Eric Blake <eblake@redhat.com>
2
2
3
These changes use a vxhs test server that is a part of the following
3
Although we have long supported 'qemu-img convert -o
4
repository:
4
backing_file=foo,backing_fmt=bar', the fact that we have a shortcut -B
5
https://github.com/VeritasHyperScale/libqnio.git
5
for backing_file but none for backing_fmt has made it more likely that
6
users accidentally run into:
6
7
7
Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com>
8
qemu-img: warning: Deprecated use of backing file without explicit backing format
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
9
Reviewed-by: Jeff Cody <jcody@redhat.com>
10
when using -B instead of -o. For similarity with other qemu-img
10
Signed-off-by: Jeff Cody <jcody@redhat.com>
11
commands, such as create and compare, add '-F $fmt' as the shorthand
11
Message-id: 1491277689-24949-3-git-send-email-Ashish.Mittal@veritas.com
12
for '-o backing_fmt=$fmt'. Update iotest 122 for coverage of both
13
spellings.
14
15
Signed-off-by: Eric Blake <eblake@redhat.com>
16
Message-Id: <20210913131735.1948339-1-eblake@redhat.com>
17
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
18
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
19
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
20
---
13
tests/qemu-iotests/common | 6 ++++++
21
docs/tools/qemu-img.rst | 4 ++--
14
tests/qemu-iotests/common.config | 13 +++++++++++++
22
qemu-img.c | 10 +++++++---
15
tests/qemu-iotests/common.filter | 1 +
23
qemu-img-cmds.hx | 2 +-
16
tests/qemu-iotests/common.rc | 19 +++++++++++++++++++
24
tests/qemu-iotests/122 | 2 +-
17
4 files changed, 39 insertions(+)
25
4 files changed, 11 insertions(+), 7 deletions(-)
18
26
19
diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common
27
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
20
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
21
--- a/tests/qemu-iotests/common
29
--- a/docs/tools/qemu-img.rst
22
+++ b/tests/qemu-iotests/common
30
+++ b/docs/tools/qemu-img.rst
23
@@ -XXX,XX +XXX,XX @@ check options
31
@@ -XXX,XX +XXX,XX @@ Command description:
24
-ssh test ssh
32
4
25
-nfs test nfs
33
Error on reading data
26
-luks test luks
34
27
+ -vxhs test vxhs
35
-.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-opts] [--target-is-zero] [--bitmaps [--skip-broken-bitmaps]] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-O OUTPUT_FMT] [-B BACKING_FILE] [-o OPTIONS] [-l SNAPSHOT_PARAM] [-S SPARSE_SIZE] [-r RATE_LIMIT] [-m NUM_COROUTINES] [-W] FILENAME [FILENAME2 [...]] OUTPUT_FILENAME
28
-xdiff graphical mode diff
36
+.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-opts] [--target-is-zero] [--bitmaps [--skip-broken-bitmaps]] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-O OUTPUT_FMT] [-B BACKING_FILE [-F backing_fmt]] [-o OPTIONS] [-l SNAPSHOT_PARAM] [-S SPARSE_SIZE] [-r RATE_LIMIT] [-m NUM_COROUTINES] [-W] FILENAME [FILENAME2 [...]] OUTPUT_FILENAME
29
-nocache use O_DIRECT on backing file
37
30
-misalign misalign memory allocations
38
Convert the disk image *FILENAME* or a snapshot *SNAPSHOT_PARAM*
31
@@ -XXX,XX +XXX,XX @@ testlist options
39
to disk image *OUTPUT_FILENAME* using format *OUTPUT_FMT*. It can
32
xpand=false
40
@@ -XXX,XX +XXX,XX @@ Command description:
33
;;
41
You can use the *BACKING_FILE* option to force the output image to be
34
42
created as a copy on write image of the specified base image; the
35
+ -vxhs)
43
*BACKING_FILE* should have the same content as the input's base image,
36
+ IMGPROTO=vxhs
44
- however the path, image format, etc may differ.
37
+ xpand=false
45
+ however the path, image format (as given by *BACKING_FMT*), etc may differ.
38
+ ;;
46
39
+
47
If a relative path name is given, the backing file is looked up relative to
40
-ssh)
48
the directory containing *OUTPUT_FILENAME*.
41
IMGPROTO=ssh
49
diff --git a/qemu-img.c b/qemu-img.c
42
xpand=false
43
diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
44
index XXXXXXX..XXXXXXX 100644
50
index XXXXXXX..XXXXXXX 100644
45
--- a/tests/qemu-iotests/common.config
51
--- a/qemu-img.c
46
+++ b/tests/qemu-iotests/common.config
52
+++ b/qemu-img.c
47
@@ -XXX,XX +XXX,XX @@ if [ -z "$QEMU_NBD_PROG" ]; then
53
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
48
export QEMU_NBD_PROG="`set_prog_path qemu-nbd`"
54
int c, bs_i, flags, src_flags = BDRV_O_NO_SHARE;
49
fi
55
const char *fmt = NULL, *out_fmt = NULL, *cache = "unsafe",
50
56
*src_cache = BDRV_DEFAULT_CACHE, *out_baseimg = NULL,
51
+if [ -z "$QEMU_VXHS_PROG" ]; then
57
- *out_filename, *out_baseimg_param, *snapshot_name = NULL;
52
+ export QEMU_VXHS_PROG="`set_prog_path qnio_server`"
58
+ *out_filename, *out_baseimg_param, *snapshot_name = NULL,
53
+fi
59
+ *backing_fmt = NULL;
54
+
60
BlockDriver *drv = NULL, *proto_drv = NULL;
55
_qemu_wrapper()
61
BlockDriverInfo bdi;
56
{
62
BlockDriverState *out_bs;
57
(
63
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
58
@@ -XXX,XX +XXX,XX @@ _qemu_nbd_wrapper()
64
{"skip-broken-bitmaps", no_argument, 0, OPTION_SKIP_BROKEN},
59
)
65
{0, 0, 0, 0}
60
}
66
};
61
67
- c = getopt_long(argc, argv, ":hf:O:B:Cco:l:S:pt:T:qnm:WUr:",
62
+_qemu_vxhs_wrapper()
68
+ c = getopt_long(argc, argv, ":hf:O:B:CcF:o:l:S:pt:T:qnm:WUr:",
63
+{
69
long_options, NULL);
64
+ (
70
if (c == -1) {
65
+ echo $BASHPID > "${TEST_DIR}/qemu-vxhs.pid"
71
break;
66
+ exec "$QEMU_VXHS_PROG" $QEMU_VXHS_OPTIONS "$@"
72
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
67
+ )
73
case 'c':
68
+}
74
s.compressed = true;
69
+
75
break;
70
export QEMU=_qemu_wrapper
76
+ case 'F':
71
export QEMU_IMG=_qemu_img_wrapper
77
+ backing_fmt = optarg;
72
export QEMU_IO=_qemu_io_wrapper
78
+ break;
73
export QEMU_NBD=_qemu_nbd_wrapper
79
case 'o':
74
+export QEMU_VXHS=_qemu_vxhs_wrapper
80
if (accumulate_options(&options, optarg) < 0) {
75
81
goto fail_getopt;
76
QEMU_IMG_EXTRA_ARGS=
82
@@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv)
77
if [ "$IMGOPTSSYNTAX" = "true" ]; then
83
78
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
84
qemu_opt_set_number(opts, BLOCK_OPT_SIZE,
85
s.total_sectors * BDRV_SECTOR_SIZE, &error_abort);
86
- ret = add_old_style_options(out_fmt, opts, out_baseimg, NULL);
87
+ ret = add_old_style_options(out_fmt, opts, out_baseimg, backing_fmt);
88
if (ret < 0) {
89
goto out;
90
}
91
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
79
index XXXXXXX..XXXXXXX 100644
92
index XXXXXXX..XXXXXXX 100644
80
--- a/tests/qemu-iotests/common.filter
93
--- a/qemu-img-cmds.hx
81
+++ b/tests/qemu-iotests/common.filter
94
+++ b/qemu-img-cmds.hx
82
@@ -XXX,XX +XXX,XX @@ _filter_img_info()
95
@@ -XXX,XX +XXX,XX @@ SRST
83
-e "s#$TEST_DIR#TEST_DIR#g" \
96
ERST
84
-e "s#$IMGFMT#IMGFMT#g" \
97
85
-e 's#nbd://127.0.0.1:10810$#TEST_DIR/t.IMGFMT#g' \
98
DEF("convert", img_convert,
86
+ -e 's#json.*vdisk-id.*vxhs"}}#TEST_DIR/t.IMGFMT#' \
99
- "convert [--object objectdef] [--image-opts] [--target-image-opts] [--target-is-zero] [--bitmaps] [-U] [-C] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-B backing_file] [-o options] [-l snapshot_param] [-S sparse_size] [-r rate_limit] [-m num_coroutines] [-W] [--salvage] filename [filename2 [...]] output_filename")
87
-e "/encrypted: yes/d" \
100
+ "convert [--object objectdef] [--image-opts] [--target-image-opts] [--target-is-zero] [--bitmaps] [-U] [-C] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-B backing_file [-F backing_fmt]] [-o options] [-l snapshot_param] [-S sparse_size] [-r rate_limit] [-m num_coroutines] [-W] [--salvage] filename [filename2 [...]] output_filename")
88
-e "/cluster_size: [0-9]\\+/d" \
101
SRST
89
-e "/table_size: [0-9]\\+/d" \
102
.. option:: convert [--object OBJECTDEF] [--image-opts] [--target-image-opts] [--target-is-zero] [--bitmaps] [-U] [-C] [-c] [-p] [-q] [-n] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-O OUTPUT_FMT] [-B BACKING_FILE] [-o OPTIONS] [-l SNAPSHOT_PARAM] [-S SPARSE_SIZE] [-r RATE_LIMIT] [-m NUM_COROUTINES] [-W] [--salvage] FILENAME [FILENAME2 [...]] OUTPUT_FILENAME
90
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
103
ERST
91
index XXXXXXX..XXXXXXX 100644
104
diff --git a/tests/qemu-iotests/122 b/tests/qemu-iotests/122
92
--- a/tests/qemu-iotests/common.rc
105
index XXXXXXX..XXXXXXX 100755
93
+++ b/tests/qemu-iotests/common.rc
106
--- a/tests/qemu-iotests/122
94
@@ -XXX,XX +XXX,XX @@ else
107
+++ b/tests/qemu-iotests/122
95
elif [ "$IMGPROTO" = "nfs" ]; then
108
@@ -XXX,XX +XXX,XX @@ echo
96
TEST_DIR="nfs://127.0.0.1/$TEST_DIR"
109
_make_test_img -b "$TEST_IMG".base -F $IMGFMT
97
TEST_IMG=$TEST_DIR/t.$IMGFMT
110
98
+ elif [ "$IMGPROTO" = "vxhs" ]; then
111
$QEMU_IO -c "write -P 0 0 3M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
99
+ TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
112
-$QEMU_IMG convert -O $IMGFMT -B "$TEST_IMG".base -o backing_fmt=$IMGFMT \
100
+ TEST_IMG="vxhs://127.0.0.1:9999/t.$IMGFMT"
113
+$QEMU_IMG convert -O $IMGFMT -B "$TEST_IMG".base -F $IMGFMT \
101
else
114
"$TEST_IMG" "$TEST_IMG".orig
102
TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT
115
$QEMU_IO -c "read -P 0 0 3M" "$TEST_IMG".orig 2>&1 | _filter_qemu_io | _filter_testdir
103
fi
116
$QEMU_IMG convert -O $IMGFMT -c -B "$TEST_IMG".base -o backing_fmt=$IMGFMT \
104
@@ -XXX,XX +XXX,XX @@ _make_test_img()
105
eval "$QEMU_NBD -v -t -b 127.0.0.1 -p 10810 -f $IMGFMT $TEST_IMG_FILE >/dev/null &"
106
sleep 1 # FIXME: qemu-nbd needs to be listening before we continue
107
fi
108
+
109
+ # Start QNIO server on image directory for vxhs protocol
110
+ if [ $IMGPROTO = "vxhs" ]; then
111
+ eval "$QEMU_VXHS -d $TEST_DIR > /dev/null &"
112
+ sleep 1 # Wait for server to come up.
113
+ fi
114
}
115
116
_rm_test_img()
117
@@ -XXX,XX +XXX,XX @@ _cleanup_test_img()
118
fi
119
rm -f "$TEST_IMG_FILE"
120
;;
121
+ vxhs)
122
+ if [ -f "${TEST_DIR}/qemu-vxhs.pid" ]; then
123
+ local QEMU_VXHS_PID
124
+ read QEMU_VXHS_PID < "${TEST_DIR}/qemu-vxhs.pid"
125
+ kill ${QEMU_VXHS_PID} >/dev/null 2>&1
126
+ rm -f "${TEST_DIR}/qemu-vxhs.pid"
127
+ fi
128
+ rm -f "$TEST_IMG_FILE"
129
+ ;;
130
+
131
file)
132
_rm_test_img "$TEST_DIR/t.$IMGFMT"
133
_rm_test_img "$TEST_DIR/t.$IMGFMT.orig"
134
--
117
--
135
2.9.3
118
2.31.1
136
119
137
120
diff view generated by jsdifflib