1
The following changes since commit 23919ddfd56135cad3cb468a8f54d5a595f024f4:
1
The following changes since commit 19b599f7664b2ebfd0f405fb79c14dd241557452:
2
2
3
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190827' into staging (2019-08-27 15:52:36 +0100)
3
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2018-08-27-v2' into staging (2018-08-27 16:44:20 +0100)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://github.com/XanClic/qemu.git tags/pull-block-2019-08-27
7
https://git.xanclic.moe/XanClic/qemu.git tags/pull-block-2018-08-31-v2
8
8
9
for you to fetch changes up to bb043c056cffcc2f3ce88bfdaf2e76e455c09e2c:
9
for you to fetch changes up to e21a1c9831fc80ae3f3c1affdfa43350035d8588:
10
10
11
iotests: Unify cache mode quoting (2019-08-27 19:48:44 +0200)
11
jobs: remove job_defer_to_main_loop (2018-08-31 16:28:33 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches:
14
Block patches:
15
- qemu-io now accepts a file to read a write pattern from
15
- (Block) job exit refactoring, part 1
16
- Ensure that raw files have their first block allocated so we can probe
16
(removing job_defer_to_main_loop())
17
the O_DIRECT alignment if necessary
17
- test-bdrv-drain leak fix
18
- Various fixes
19
18
20
----------------------------------------------------------------
19
----------------------------------------------------------------
21
Denis Plotnikov (1):
20
John Snow (9):
22
qemu-io: add pattern file for write command
21
jobs: change start callback to run callback
22
jobs: canonize Error object
23
jobs: add exit shim
24
block/commit: utilize job_exit shim
25
block/mirror: utilize job_exit shim
26
jobs: utilize job_exit shim
27
block/backup: make function variables consistently named
28
jobs: remove ret argument to job_completed; privatize it
29
jobs: remove job_defer_to_main_loop
23
30
24
Max Reitz (7):
31
Marc-André Lureau (1):
25
iotests: Fix _filter_img_create()
32
tests: fix bdrv-drain leak
26
vmdk: Use bdrv_dirname() for relative extent paths
27
iotests: Keep testing broken relative extent paths
28
vmdk: Reject invalid compressed writes
29
iotests: Disable broken streamOptimized tests
30
iotests: Disable 110 for vmdk.twoGbMaxExtentSparse
31
iotests: Disable 126 for flat vmdk subformats
32
33
33
Nir Soffer (3):
34
include/qemu/job.h | 70 ++++++++++++++++-----------------
34
block: posix: Always allocate the first block
35
block/backup.c | 81 ++++++++++++++++-----------------------
35
iotests: Test allocate_first_block() with O_DIRECT
36
block/commit.c | 29 +++++---------
36
iotests: Unify cache mode quoting
37
block/create.c | 19 +++------
37
38
block/mirror.c | 39 ++++++++-----------
38
Stefan Hajnoczi (1):
39
block/stream.c | 29 ++++++--------
39
file-posix: fix request_alignment typo
40
job-qmp.c | 5 ++-
40
41
job.c | 73 ++++++++++++-----------------------
41
Thomas Huth (2):
42
tests/test-bdrv-drain.c | 14 +++----
42
iotests: Check for enabled drivers before testing them
43
tests/test-blockjob-txn.c | 25 +++++-------
43
tests/check-block: Skip iotests when sanitizers are enabled
44
tests/test-blockjob.c | 17 ++++----
44
45
trace-events | 2 +-
45
Vladimir Sementsov-Ogievskiy (1):
46
12 files changed, 161 insertions(+), 242 deletions(-)
46
block: fix permission update in bdrv_replace_node
47
48
block.c | 5 +-
49
block/file-posix.c | 53 +++++++++-
50
block/vmdk.c | 64 ++++++++----
51
qemu-io-cmds.c | 99 +++++++++++++++++--
52
tests/check-block.sh | 5 +
53
tests/qemu-iotests/002 | 1 +
54
tests/qemu-iotests/003 | 1 +
55
tests/qemu-iotests/005 | 3 +-
56
tests/qemu-iotests/009 | 1 +
57
tests/qemu-iotests/010 | 1 +
58
tests/qemu-iotests/011 | 1 +
59
tests/qemu-iotests/017 | 3 +-
60
tests/qemu-iotests/018 | 3 +-
61
tests/qemu-iotests/019 | 3 +-
62
tests/qemu-iotests/020 | 3 +-
63
tests/qemu-iotests/026 | 4 +-
64
tests/qemu-iotests/027 | 1 +
65
tests/qemu-iotests/032 | 1 +
66
tests/qemu-iotests/033 | 1 +
67
tests/qemu-iotests/034 | 3 +-
68
tests/qemu-iotests/037 | 3 +-
69
tests/qemu-iotests/039 | 4 +-
70
tests/qemu-iotests/052 | 2 +-
71
tests/qemu-iotests/059 | 34 ++++++-
72
tests/qemu-iotests/059.out | 26 +++--
73
tests/qemu-iotests/063 | 3 +-
74
tests/qemu-iotests/071 | 1 +
75
tests/qemu-iotests/072 | 1 +
76
tests/qemu-iotests/081 | 4 +-
77
tests/qemu-iotests/091 | 4 +-
78
tests/qemu-iotests/099 | 1 +
79
tests/qemu-iotests/105 | 3 +-
80
tests/qemu-iotests/110 | 3 +-
81
tests/qemu-iotests/120 | 1 +
82
tests/qemu-iotests/126 | 2 +
83
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
84
tests/qemu-iotests/150.out.raw | 12 +++
85
tests/qemu-iotests/162 | 4 +-
86
tests/qemu-iotests/175 | 47 +++++++--
87
tests/qemu-iotests/175.out | 16 ++-
88
tests/qemu-iotests/178.out.qcow2 | 4 +-
89
tests/qemu-iotests/184 | 1 +
90
tests/qemu-iotests/186 | 1 +
91
tests/qemu-iotests/197 | 1 +
92
tests/qemu-iotests/215 | 1 +
93
tests/qemu-iotests/221.out | 12 ++-
94
tests/qemu-iotests/251 | 1 +
95
tests/qemu-iotests/253.out | 12 ++-
96
tests/qemu-iotests/common.filter | 4 +-
97
tests/qemu-iotests/common.rc | 14 +++
98
50 files changed, 391 insertions(+), 87 deletions(-)
99
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
100
create mode 100644 tests/qemu-iotests/150.out.raw
101
47
102
--
48
--
103
2.21.0
49
2.17.1
104
50
105
51
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: Marc-André Lureau <marcandre.lureau@redhat.com>
2
2
3
Quoting cache mode is not needed, and most tests use unquoted values.
3
Spotted by ASAN:
4
Unify all test to use the same style.
5
4
6
Message-id: 20190827173432.7656-1-nsoffer@redhat.com
5
=================================================================
7
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
6
==5378==ERROR: LeakSanitizer: detected memory leaks
7
8
Direct leak of 65536 byte(s) in 1 object(s) allocated from:
9
#0 0x7f788f83bc48 in malloc (/lib64/libasan.so.5+0xeec48)
10
#1 0x7f788c9923c5 in g_malloc (/lib64/libglib-2.0.so.0+0x523c5)
11
#2 0x5622a1fe37bc in coroutine_trampoline /home/elmarco/src/qq/util/coroutine-ucontext.c:116
12
#3 0x7f788a15d75f in __correctly_grouped_prefixwc (/lib64/libc.so.6+0x4c75f)
13
14
(Broken in commit 4c8158e359d.)
15
16
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
17
Message-id: 20180809114417.28718-3-marcandre.lureau@redhat.com
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
18
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
19
---
10
tests/qemu-iotests/026 | 4 ++--
20
tests/test-bdrv-drain.c | 1 +
11
tests/qemu-iotests/039 | 4 ++--
21
1 file changed, 1 insertion(+)
12
tests/qemu-iotests/052 | 2 +-
13
tests/qemu-iotests/091 | 4 ++--
14
4 files changed, 7 insertions(+), 7 deletions(-)
15
22
16
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
23
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
17
index XXXXXXX..XXXXXXX 100755
24
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qemu-iotests/026
25
--- a/tests/test-bdrv-drain.c
19
+++ b/tests/qemu-iotests/026
26
+++ b/tests/test-bdrv-drain.c
20
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
27
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn test_co_delete_by_drain(void *opaque)
21
# Currently only qcow2 supports rebasing
28
}
22
_supported_fmt qcow2
29
23
_supported_proto file
30
dbdd->done = true;
24
-_default_cache_mode "writethrough"
31
+ g_free(buffer);
25
-_supported_cache_modes "writethrough" "none"
32
}
26
+_default_cache_mode writethrough
33
27
+_supported_cache_modes writethrough none
34
/**
28
# The refcount table tests expect a certain minimum width for refcount entries
29
# (so that the refcount table actually needs to grow); that minimum is 16 bits,
30
# being the default refcount entry width.
31
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
32
index XXXXXXX..XXXXXXX 100755
33
--- a/tests/qemu-iotests/039
34
+++ b/tests/qemu-iotests/039
35
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
36
_supported_fmt qcow2
37
_supported_proto file
38
_supported_os Linux
39
-_default_cache_mode "writethrough"
40
-_supported_cache_modes "writethrough"
41
+_default_cache_mode writethrough
42
+_supported_cache_modes writethrough
43
44
size=128M
45
46
diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052
47
index XXXXXXX..XXXXXXX 100755
48
--- a/tests/qemu-iotests/052
49
+++ b/tests/qemu-iotests/052
50
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
51
_supported_proto file
52
53
# Don't do O_DIRECT on tmpfs
54
-_supported_cache_modes "writeback" "writethrough" "unsafe"
55
+_supported_cache_modes writeback writethrough unsafe
56
57
size=128M
58
_make_test_img $size
59
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
60
index XXXXXXX..XXXXXXX 100755
61
--- a/tests/qemu-iotests/091
62
+++ b/tests/qemu-iotests/091
63
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
64
_supported_fmt qcow2
65
_supported_proto file
66
_supported_os Linux
67
-_default_cache_mode "none"
68
-_supported_cache_modes "writethrough" "none" "writeback"
69
+_default_cache_mode none
70
+_supported_cache_modes writethrough none writeback
71
72
size=1G
73
74
--
35
--
75
2.21.0
36
2.17.1
76
37
77
38
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
The sanitizers (especially the address sanitizer from Clang) are
3
Presently we codify the entry point for a job as the "start" callback,
4
sometimes printing out warnings or false positives - this spoils
4
but a more apt name would be "run" to clarify the idea that when this
5
the output of the iotests, causing some of the tests to fail.
5
function returns we consider the job to have "finished," except for
6
Thus let's skip the automatic iotests during "make check" when the
6
any cleanup which occurs in separate callbacks later.
7
user configured QEMU with --enable-sanitizers.
7
8
8
As part of this clarification, change the signature to include an error
9
Signed-off-by: Thomas Huth <thuth@redhat.com>
9
object and a return code. The error ptr is not yet used, and the return
10
Message-id: 20190823084203.29734-1-thuth@redhat.com
10
code while captured, will be overwritten by actions in the job_completed
11
function.
12
13
Signed-off-by: John Snow <jsnow@redhat.com>
14
Reviewed-by: Max Reitz <mreitz@redhat.com>
15
Message-id: 20180830015734.19765-2-jsnow@redhat.com
16
Reviewed-by: Jeff Cody <jcody@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
17
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
18
---
13
tests/check-block.sh | 5 +++++
19
include/qemu/job.h | 2 +-
14
1 file changed, 5 insertions(+)
20
block/backup.c | 7 ++++---
15
21
block/commit.c | 7 ++++---
16
diff --git a/tests/check-block.sh b/tests/check-block.sh
22
block/create.c | 8 +++++---
17
index XXXXXXX..XXXXXXX 100755
23
block/mirror.c | 10 ++++++----
18
--- a/tests/check-block.sh
24
block/stream.c | 7 ++++---
19
+++ b/tests/check-block.sh
25
job.c | 6 +++---
20
@@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then
26
tests/test-bdrv-drain.c | 7 ++++---
21
exit 0
27
tests/test-blockjob-txn.c | 16 ++++++++--------
22
fi
28
tests/test-blockjob.c | 7 ++++---
23
29
10 files changed, 43 insertions(+), 34 deletions(-)
24
+if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then
30
25
+ echo "Sanitizers are enabled ==> Not running the qemu-iotests."
31
diff --git a/include/qemu/job.h b/include/qemu/job.h
26
+ exit 0
32
index XXXXXXX..XXXXXXX 100644
27
+fi
33
--- a/include/qemu/job.h
34
+++ b/include/qemu/job.h
35
@@ -XXX,XX +XXX,XX @@ struct JobDriver {
36
JobType job_type;
37
38
/** Mandatory: Entrypoint for the Coroutine. */
39
- CoroutineEntry *start;
40
+ int coroutine_fn (*run)(Job *job, Error **errp);
41
42
/**
43
* If the callback is not NULL, it will be invoked when the job transitions
44
diff --git a/block/backup.c b/block/backup.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/block/backup.c
47
+++ b/block/backup.c
48
@@ -XXX,XX +XXX,XX @@ static void backup_incremental_init_copy_bitmap(BackupBlockJob *job)
49
bdrv_dirty_iter_free(dbi);
50
}
51
52
-static void coroutine_fn backup_run(void *opaque)
53
+static int coroutine_fn backup_run(Job *opaque_job, Error **errp)
54
{
55
- BackupBlockJob *job = opaque;
56
+ BackupBlockJob *job = container_of(opaque_job, BackupBlockJob, common.job);
57
BackupCompleteData *data;
58
BlockDriverState *bs = blk_bs(job->common.blk);
59
int64_t offset, nb_clusters;
60
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn backup_run(void *opaque)
61
data = g_malloc(sizeof(*data));
62
data->ret = ret;
63
job_defer_to_main_loop(&job->common.job, backup_complete, data);
64
+ return ret;
65
}
66
67
static const BlockJobDriver backup_job_driver = {
68
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver backup_job_driver = {
69
.free = block_job_free,
70
.user_resume = block_job_user_resume,
71
.drain = block_job_drain,
72
- .start = backup_run,
73
+ .run = backup_run,
74
.commit = backup_commit,
75
.abort = backup_abort,
76
.clean = backup_clean,
77
diff --git a/block/commit.c b/block/commit.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/block/commit.c
80
+++ b/block/commit.c
81
@@ -XXX,XX +XXX,XX @@ static void commit_complete(Job *job, void *opaque)
82
bdrv_unref(top);
83
}
84
85
-static void coroutine_fn commit_run(void *opaque)
86
+static int coroutine_fn commit_run(Job *job, Error **errp)
87
{
88
- CommitBlockJob *s = opaque;
89
+ CommitBlockJob *s = container_of(job, CommitBlockJob, common.job);
90
CommitCompleteData *data;
91
int64_t offset;
92
uint64_t delay_ns = 0;
93
@@ -XXX,XX +XXX,XX @@ out:
94
data = g_malloc(sizeof(*data));
95
data->ret = ret;
96
job_defer_to_main_loop(&s->common.job, commit_complete, data);
97
+ return ret;
98
}
99
100
static const BlockJobDriver commit_job_driver = {
101
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver commit_job_driver = {
102
.free = block_job_free,
103
.user_resume = block_job_user_resume,
104
.drain = block_job_drain,
105
- .start = commit_run,
106
+ .run = commit_run,
107
},
108
};
109
110
diff --git a/block/create.c b/block/create.c
111
index XXXXXXX..XXXXXXX 100644
112
--- a/block/create.c
113
+++ b/block/create.c
114
@@ -XXX,XX +XXX,XX @@ static void blockdev_create_complete(Job *job, void *opaque)
115
job_completed(job, s->ret, s->err);
116
}
117
118
-static void coroutine_fn blockdev_create_run(void *opaque)
119
+static int coroutine_fn blockdev_create_run(Job *job, Error **errp)
120
{
121
- BlockdevCreateJob *s = opaque;
122
+ BlockdevCreateJob *s = container_of(job, BlockdevCreateJob, common);
123
124
job_progress_set_remaining(&s->common, 1);
125
s->ret = s->drv->bdrv_co_create(s->opts, &s->err);
126
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn blockdev_create_run(void *opaque)
127
128
qapi_free_BlockdevCreateOptions(s->opts);
129
job_defer_to_main_loop(&s->common, blockdev_create_complete, NULL);
28
+
130
+
29
if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then
131
+ return s->ret;
30
echo "No qemu-system binary available ==> Not running the qemu-iotests."
132
}
31
exit 0
133
134
static const JobDriver blockdev_create_job_driver = {
135
.instance_size = sizeof(BlockdevCreateJob),
136
.job_type = JOB_TYPE_CREATE,
137
- .start = blockdev_create_run,
138
+ .run = blockdev_create_run,
139
};
140
141
void qmp_blockdev_create(const char *job_id, BlockdevCreateOptions *options,
142
diff --git a/block/mirror.c b/block/mirror.c
143
index XXXXXXX..XXXXXXX 100644
144
--- a/block/mirror.c
145
+++ b/block/mirror.c
146
@@ -XXX,XX +XXX,XX @@ static int mirror_flush(MirrorBlockJob *s)
147
return ret;
148
}
149
150
-static void coroutine_fn mirror_run(void *opaque)
151
+static int coroutine_fn mirror_run(Job *job, Error **errp)
152
{
153
- MirrorBlockJob *s = opaque;
154
+ MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job);
155
MirrorExitData *data;
156
BlockDriverState *bs = s->mirror_top_bs->backing->bs;
157
BlockDriverState *target_bs = blk_bs(s->target);
158
@@ -XXX,XX +XXX,XX @@ immediate_exit:
159
if (need_drain) {
160
bdrv_drained_begin(bs);
161
}
162
+
163
job_defer_to_main_loop(&s->common.job, mirror_exit, data);
164
+ return ret;
165
}
166
167
static void mirror_complete(Job *job, Error **errp)
168
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver mirror_job_driver = {
169
.free = block_job_free,
170
.user_resume = block_job_user_resume,
171
.drain = block_job_drain,
172
- .start = mirror_run,
173
+ .run = mirror_run,
174
.pause = mirror_pause,
175
.complete = mirror_complete,
176
},
177
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver commit_active_job_driver = {
178
.free = block_job_free,
179
.user_resume = block_job_user_resume,
180
.drain = block_job_drain,
181
- .start = mirror_run,
182
+ .run = mirror_run,
183
.pause = mirror_pause,
184
.complete = mirror_complete,
185
},
186
diff --git a/block/stream.c b/block/stream.c
187
index XXXXXXX..XXXXXXX 100644
188
--- a/block/stream.c
189
+++ b/block/stream.c
190
@@ -XXX,XX +XXX,XX @@ out:
191
g_free(data);
192
}
193
194
-static void coroutine_fn stream_run(void *opaque)
195
+static int coroutine_fn stream_run(Job *job, Error **errp)
196
{
197
- StreamBlockJob *s = opaque;
198
+ StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
199
StreamCompleteData *data;
200
BlockBackend *blk = s->common.blk;
201
BlockDriverState *bs = blk_bs(blk);
202
@@ -XXX,XX +XXX,XX @@ out:
203
data = g_malloc(sizeof(*data));
204
data->ret = ret;
205
job_defer_to_main_loop(&s->common.job, stream_complete, data);
206
+ return ret;
207
}
208
209
static const BlockJobDriver stream_job_driver = {
210
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver stream_job_driver = {
211
.instance_size = sizeof(StreamBlockJob),
212
.job_type = JOB_TYPE_STREAM,
213
.free = block_job_free,
214
- .start = stream_run,
215
+ .run = stream_run,
216
.user_resume = block_job_user_resume,
217
.drain = block_job_drain,
218
},
219
diff --git a/job.c b/job.c
220
index XXXXXXX..XXXXXXX 100644
221
--- a/job.c
222
+++ b/job.c
223
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn job_co_entry(void *opaque)
224
{
225
Job *job = opaque;
226
227
- assert(job && job->driver && job->driver->start);
228
+ assert(job && job->driver && job->driver->run);
229
job_pause_point(job);
230
- job->driver->start(job);
231
+ job->ret = job->driver->run(job, NULL);
232
}
233
234
235
void job_start(Job *job)
236
{
237
assert(job && !job_started(job) && job->paused &&
238
- job->driver && job->driver->start);
239
+ job->driver && job->driver->run);
240
job->co = qemu_coroutine_create(job_co_entry, job);
241
job->pause_count--;
242
job->busy = true;
243
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
244
index XXXXXXX..XXXXXXX 100644
245
--- a/tests/test-bdrv-drain.c
246
+++ b/tests/test-bdrv-drain.c
247
@@ -XXX,XX +XXX,XX @@ static void test_job_completed(Job *job, void *opaque)
248
job_completed(job, 0, NULL);
249
}
250
251
-static void coroutine_fn test_job_start(void *opaque)
252
+static int coroutine_fn test_job_run(Job *job, Error **errp)
253
{
254
- TestBlockJob *s = opaque;
255
+ TestBlockJob *s = container_of(job, TestBlockJob, common.job);
256
257
job_transition_to_ready(&s->common.job);
258
while (!s->should_complete) {
259
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn test_job_start(void *opaque)
260
}
261
262
job_defer_to_main_loop(&s->common.job, test_job_completed, NULL);
263
+ return 0;
264
}
265
266
static void test_job_complete(Job *job, Error **errp)
267
@@ -XXX,XX +XXX,XX @@ BlockJobDriver test_job_driver = {
268
.free = block_job_free,
269
.user_resume = block_job_user_resume,
270
.drain = block_job_drain,
271
- .start = test_job_start,
272
+ .run = test_job_run,
273
.complete = test_job_complete,
274
},
275
};
276
diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c
277
index XXXXXXX..XXXXXXX 100644
278
--- a/tests/test-blockjob-txn.c
279
+++ b/tests/test-blockjob-txn.c
280
@@ -XXX,XX +XXX,XX @@ static void test_block_job_complete(Job *job, void *opaque)
281
bdrv_unref(bs);
282
}
283
284
-static void coroutine_fn test_block_job_run(void *opaque)
285
+static int coroutine_fn test_block_job_run(Job *job, Error **errp)
286
{
287
- TestBlockJob *s = opaque;
288
- BlockJob *job = &s->common;
289
+ TestBlockJob *s = container_of(job, TestBlockJob, common.job);
290
291
while (s->iterations--) {
292
if (s->use_timer) {
293
- job_sleep_ns(&job->job, 0);
294
+ job_sleep_ns(job, 0);
295
} else {
296
- job_yield(&job->job);
297
+ job_yield(job);
298
}
299
300
- if (job_is_cancelled(&job->job)) {
301
+ if (job_is_cancelled(job)) {
302
break;
303
}
304
}
305
306
- job_defer_to_main_loop(&job->job, test_block_job_complete,
307
+ job_defer_to_main_loop(job, test_block_job_complete,
308
(void *)(intptr_t)s->rc);
309
+ return s->rc;
310
}
311
312
typedef struct {
313
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver test_block_job_driver = {
314
.free = block_job_free,
315
.user_resume = block_job_user_resume,
316
.drain = block_job_drain,
317
- .start = test_block_job_run,
318
+ .run = test_block_job_run,
319
},
320
};
321
322
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
323
index XXXXXXX..XXXXXXX 100644
324
--- a/tests/test-blockjob.c
325
+++ b/tests/test-blockjob.c
326
@@ -XXX,XX +XXX,XX @@ static void cancel_job_complete(Job *job, Error **errp)
327
s->should_complete = true;
328
}
329
330
-static void coroutine_fn cancel_job_start(void *opaque)
331
+static int coroutine_fn cancel_job_run(Job *job, Error **errp)
332
{
333
- CancelJob *s = opaque;
334
+ CancelJob *s = container_of(job, CancelJob, common.job);
335
336
while (!s->should_complete) {
337
if (job_is_cancelled(&s->common.job)) {
338
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn cancel_job_start(void *opaque)
339
340
defer:
341
job_defer_to_main_loop(&s->common.job, cancel_job_completed, s);
342
+ return 0;
343
}
344
345
static const BlockJobDriver test_cancel_driver = {
346
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver test_cancel_driver = {
347
.free = block_job_free,
348
.user_resume = block_job_user_resume,
349
.drain = block_job_drain,
350
- .start = cancel_job_start,
351
+ .run = cancel_job_run,
352
.complete = cancel_job_complete,
353
},
354
};
32
--
355
--
33
2.21.0
356
2.17.1
34
357
35
358
diff view generated by jsdifflib
1
From: Stefan Hajnoczi <stefanha@redhat.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
Fixes: a6b257a08e3d72219f03e461a52152672fec0612
3
Jobs presently use both an Error object in the case of the create job,
4
("file-posix: Handle undetectable alignment")
4
and char strings in the case of generic errors elsewhere.
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5
6
Message-id: 20190827101328.4062-1-stefanha@redhat.com
6
Unify the two paths as just j->err, and remove the extra argument from
7
Reviewed-by: Thomas Huth <thuth@redhat.com>
7
job_completed. The integer error code for job_completed is kept for now,
8
to be removed shortly in a separate patch.
9
10
Signed-off-by: John Snow <jsnow@redhat.com>
11
Message-id: 20180830015734.19765-3-jsnow@redhat.com
12
[mreitz: Dropped a superfluous g_strdup()]
13
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
15
---
10
block/file-posix.c | 2 +-
16
include/qemu/job.h | 14 ++++++++------
11
1 file changed, 1 insertion(+), 1 deletion(-)
17
block/backup.c | 2 +-
12
18
block/commit.c | 2 +-
13
diff --git a/block/file-posix.c b/block/file-posix.c
19
block/create.c | 5 ++---
14
index XXXXXXX..XXXXXXX 100644
20
block/mirror.c | 2 +-
15
--- a/block/file-posix.c
21
block/stream.c | 2 +-
16
+++ b/block/file-posix.c
22
job-qmp.c | 5 +++--
17
@@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
23
job.c | 18 ++++++------------
18
for (i = 0; i < ARRAY_SIZE(alignments); i++) {
24
tests/test-bdrv-drain.c | 2 +-
19
align = alignments[i];
25
tests/test-blockjob-txn.c | 2 +-
20
if (raw_is_io_aligned(fd, buf + align, max_align)) {
26
tests/test-blockjob.c | 2 +-
21
- /* Fallback to request_aligment. */
27
11 files changed, 26 insertions(+), 30 deletions(-)
22
+ /* Fallback to request_alignment. */
28
23
s->buf_align = (align != 1) ? align : bs->bl.request_alignment;
29
diff --git a/include/qemu/job.h b/include/qemu/job.h
24
break;
30
index XXXXXXX..XXXXXXX 100644
25
}
31
--- a/include/qemu/job.h
32
+++ b/include/qemu/job.h
33
@@ -XXX,XX +XXX,XX @@ typedef struct Job {
34
/** Estimated progress_current value at the completion of the job */
35
int64_t progress_total;
36
37
- /** Error string for a failed job (NULL if, and only if, job->ret == 0) */
38
- char *error;
39
-
40
/** ret code passed to job_completed. */
41
int ret;
42
43
+ /**
44
+ * Error object for a failed job.
45
+ * If job->ret is nonzero and an error object was not set, it will be set
46
+ * to strerror(-job->ret) during job_completed.
47
+ */
48
+ Error *err;
49
+
50
/** The completion function that will be called when the job completes. */
51
BlockCompletionFunc *cb;
52
53
@@ -XXX,XX +XXX,XX @@ void job_transition_to_ready(Job *job);
54
/**
55
* @job: The job being completed.
56
* @ret: The status code.
57
- * @error: The error message for a failing job (only with @ret < 0). If @ret is
58
- * negative, but NULL is given for @error, strerror() is used.
59
*
60
* Marks @job as completed. If @ret is non-zero, the job transaction it is part
61
* of is aborted. If @ret is zero, the job moves into the WAITING state. If it
62
* is the last job to complete in its transaction, all jobs in the transaction
63
* move from WAITING to PENDING.
64
*/
65
-void job_completed(Job *job, int ret, Error *error);
66
+void job_completed(Job *job, int ret);
67
68
/** Asynchronously complete the specified @job. */
69
void job_complete(Job *job, Error **errp);
70
diff --git a/block/backup.c b/block/backup.c
71
index XXXXXXX..XXXXXXX 100644
72
--- a/block/backup.c
73
+++ b/block/backup.c
74
@@ -XXX,XX +XXX,XX @@ static void backup_complete(Job *job, void *opaque)
75
{
76
BackupCompleteData *data = opaque;
77
78
- job_completed(job, data->ret, NULL);
79
+ job_completed(job, data->ret);
80
g_free(data);
81
}
82
83
diff --git a/block/commit.c b/block/commit.c
84
index XXXXXXX..XXXXXXX 100644
85
--- a/block/commit.c
86
+++ b/block/commit.c
87
@@ -XXX,XX +XXX,XX @@ static void commit_complete(Job *job, void *opaque)
88
* bdrv_set_backing_hd() to fail. */
89
block_job_remove_all_bdrv(bjob);
90
91
- job_completed(job, ret, NULL);
92
+ job_completed(job, ret);
93
g_free(data);
94
95
/* If bdrv_drop_intermediate() didn't already do that, remove the commit
96
diff --git a/block/create.c b/block/create.c
97
index XXXXXXX..XXXXXXX 100644
98
--- a/block/create.c
99
+++ b/block/create.c
100
@@ -XXX,XX +XXX,XX @@ typedef struct BlockdevCreateJob {
101
BlockDriver *drv;
102
BlockdevCreateOptions *opts;
103
int ret;
104
- Error *err;
105
} BlockdevCreateJob;
106
107
static void blockdev_create_complete(Job *job, void *opaque)
108
{
109
BlockdevCreateJob *s = container_of(job, BlockdevCreateJob, common);
110
111
- job_completed(job, s->ret, s->err);
112
+ job_completed(job, s->ret);
113
}
114
115
static int coroutine_fn blockdev_create_run(Job *job, Error **errp)
116
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn blockdev_create_run(Job *job, Error **errp)
117
BlockdevCreateJob *s = container_of(job, BlockdevCreateJob, common);
118
119
job_progress_set_remaining(&s->common, 1);
120
- s->ret = s->drv->bdrv_co_create(s->opts, &s->err);
121
+ s->ret = s->drv->bdrv_co_create(s->opts, errp);
122
job_progress_update(&s->common, 1);
123
124
qapi_free_BlockdevCreateOptions(s->opts);
125
diff --git a/block/mirror.c b/block/mirror.c
126
index XXXXXXX..XXXXXXX 100644
127
--- a/block/mirror.c
128
+++ b/block/mirror.c
129
@@ -XXX,XX +XXX,XX @@ static void mirror_exit(Job *job, void *opaque)
130
blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort);
131
132
bs_opaque->job = NULL;
133
- job_completed(job, data->ret, NULL);
134
+ job_completed(job, data->ret);
135
136
g_free(data);
137
bdrv_drained_end(src);
138
diff --git a/block/stream.c b/block/stream.c
139
index XXXXXXX..XXXXXXX 100644
140
--- a/block/stream.c
141
+++ b/block/stream.c
142
@@ -XXX,XX +XXX,XX @@ out:
143
}
144
145
g_free(s->backing_file_str);
146
- job_completed(job, data->ret, NULL);
147
+ job_completed(job, data->ret);
148
g_free(data);
149
}
150
151
diff --git a/job-qmp.c b/job-qmp.c
152
index XXXXXXX..XXXXXXX 100644
153
--- a/job-qmp.c
154
+++ b/job-qmp.c
155
@@ -XXX,XX +XXX,XX @@ static JobInfo *job_query_single(Job *job, Error **errp)
156
.status = job->status,
157
.current_progress = job->progress_current,
158
.total_progress = job->progress_total,
159
- .has_error = !!job->error,
160
- .error = g_strdup(job->error),
161
+ .has_error = !!job->err,
162
+ .error = job->err ? \
163
+ g_strdup(error_get_pretty(job->err)) : NULL,
164
};
165
166
return info;
167
diff --git a/job.c b/job.c
168
index XXXXXXX..XXXXXXX 100644
169
--- a/job.c
170
+++ b/job.c
171
@@ -XXX,XX +XXX,XX @@ void job_unref(Job *job)
172
173
QLIST_REMOVE(job, job_list);
174
175
- g_free(job->error);
176
+ error_free(job->err);
177
g_free(job->id);
178
g_free(job);
179
}
180
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn job_co_entry(void *opaque)
181
182
assert(job && job->driver && job->driver->run);
183
job_pause_point(job);
184
- job->ret = job->driver->run(job, NULL);
185
+ job->ret = job->driver->run(job, &job->err);
186
}
187
188
189
@@ -XXX,XX +XXX,XX @@ static void job_update_rc(Job *job)
190
job->ret = -ECANCELED;
191
}
192
if (job->ret) {
193
- if (!job->error) {
194
- job->error = g_strdup(strerror(-job->ret));
195
+ if (!job->err) {
196
+ error_setg(&job->err, "%s", strerror(-job->ret));
197
}
198
job_state_transition(job, JOB_STATUS_ABORTING);
199
}
200
@@ -XXX,XX +XXX,XX @@ static void job_completed_txn_success(Job *job)
201
}
202
}
203
204
-void job_completed(Job *job, int ret, Error *error)
205
+void job_completed(Job *job, int ret)
206
{
207
assert(job && job->txn && !job_is_completed(job));
208
209
job->ret = ret;
210
- if (error) {
211
- assert(job->ret < 0);
212
- job->error = g_strdup(error_get_pretty(error));
213
- error_free(error);
214
- }
215
-
216
job_update_rc(job);
217
trace_job_completed(job, ret, job->ret);
218
if (job->ret) {
219
@@ -XXX,XX +XXX,XX @@ void job_cancel(Job *job, bool force)
220
}
221
job_cancel_async(job, force);
222
if (!job_started(job)) {
223
- job_completed(job, -ECANCELED, NULL);
224
+ job_completed(job, -ECANCELED);
225
} else if (job->deferred_to_main_loop) {
226
job_completed_txn_abort(job);
227
} else {
228
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
229
index XXXXXXX..XXXXXXX 100644
230
--- a/tests/test-bdrv-drain.c
231
+++ b/tests/test-bdrv-drain.c
232
@@ -XXX,XX +XXX,XX @@ typedef struct TestBlockJob {
233
234
static void test_job_completed(Job *job, void *opaque)
235
{
236
- job_completed(job, 0, NULL);
237
+ job_completed(job, 0);
238
}
239
240
static int coroutine_fn test_job_run(Job *job, Error **errp)
241
diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c
242
index XXXXXXX..XXXXXXX 100644
243
--- a/tests/test-blockjob-txn.c
244
+++ b/tests/test-blockjob-txn.c
245
@@ -XXX,XX +XXX,XX @@ static void test_block_job_complete(Job *job, void *opaque)
246
rc = -ECANCELED;
247
}
248
249
- job_completed(job, rc, NULL);
250
+ job_completed(job, rc);
251
bdrv_unref(bs);
252
}
253
254
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
255
index XXXXXXX..XXXXXXX 100644
256
--- a/tests/test-blockjob.c
257
+++ b/tests/test-blockjob.c
258
@@ -XXX,XX +XXX,XX @@ static void cancel_job_completed(Job *job, void *opaque)
259
{
260
CancelJob *s = opaque;
261
s->completed = true;
262
- job_completed(job, 0, NULL);
263
+ job_completed(job, 0);
264
}
265
266
static void cancel_job_complete(Job *job, Error **errp)
26
--
267
--
27
2.21.0
268
2.17.1
28
269
29
270
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
It is possible to enable only a subset of the block drivers with the
3
All jobs do the same thing when they leave their running loop:
4
"--block-drv-rw-whitelist" option of the "configure" script. All other
4
- Store the return code in a structure
5
drivers are marked as unusable (or only included as read-only with the
5
- wait to receive this structure in the main thread
6
"--block-drv-ro-whitelist" option). If an iotest is now using such a
6
- signal job completion via job_completed
7
disabled block driver, it is failing - which is bad, since at least the
8
tests in the "auto" group should be able to deal with this situation.
9
Thus let's introduce a "_require_drivers" function that can be used by
10
the shell tests to check for the availability of certain drivers first,
11
and marks the test as "not run" if one of the drivers is missing.
12
7
13
This patch mainly targets the test in the "auto" group which should
8
Few jobs do anything beyond exactly this. Consolidate this exit
14
never fail in such a case, but also improves some of the other tests
9
logic for a net reduction in SLOC.
15
along the way. Note that we also assume that the "qcow2" and "file"
16
drivers are always available - otherwise it does not make sense to
17
run "make check-block" at all (which only tests with qcow2 by default).
18
10
19
Signed-off-by: Thomas Huth <thuth@redhat.com>
11
More seriously, when we utilize job_defer_to_main_loop_bh to call
20
Message-id: 20190823133552.11680-1-thuth@redhat.com
12
a function that calls job_completed, job_finalize_single will run
13
in a context where it has recursively taken the aio_context lock,
14
which can cause hangs if it puts down a reference that causes a flush.
15
16
You can observe this in practice by looking at mirror_exit's careful
17
placement of job_completed and bdrv_unref calls.
18
19
If we centralize job exiting, we can signal job completion from outside
20
of the aio_context, which should allow for job cleanup code to run with
21
only one lock, which makes cleanup callbacks less tricky to write.
22
23
Signed-off-by: John Snow <jsnow@redhat.com>
24
Reviewed-by: Max Reitz <mreitz@redhat.com>
25
Message-id: 20180830015734.19765-4-jsnow@redhat.com
26
Reviewed-by: Jeff Cody <jcody@redhat.com>
21
Signed-off-by: Max Reitz <mreitz@redhat.com>
27
Signed-off-by: Max Reitz <mreitz@redhat.com>
22
---
28
---
23
tests/qemu-iotests/071 | 1 +
29
include/qemu/job.h | 11 +++++++++++
24
tests/qemu-iotests/081 | 4 +---
30
job.c | 18 ++++++++++++++++++
25
tests/qemu-iotests/099 | 1 +
31
2 files changed, 29 insertions(+)
26
tests/qemu-iotests/120 | 1 +
27
tests/qemu-iotests/162 | 4 +---
28
tests/qemu-iotests/184 | 1 +
29
tests/qemu-iotests/186 | 1 +
30
tests/qemu-iotests/common.rc | 14 ++++++++++++++
31
8 files changed, 21 insertions(+), 6 deletions(-)
32
32
33
diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071
33
diff --git a/include/qemu/job.h b/include/qemu/job.h
34
index XXXXXXX..XXXXXXX 100755
34
index XXXXXXX..XXXXXXX 100644
35
--- a/tests/qemu-iotests/071
35
--- a/include/qemu/job.h
36
+++ b/tests/qemu-iotests/071
36
+++ b/include/qemu/job.h
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
37
@@ -XXX,XX +XXX,XX @@ struct JobDriver {
38
38
*/
39
_supported_fmt qcow2
39
void (*drain)(Job *job);
40
_supported_proto file
40
41
+_require_drivers blkdebug blkverify
41
+ /**
42
42
+ * If the callback is not NULL, exit will be invoked from the main thread
43
do_run_qemu()
43
+ * when the job's coroutine has finished, but before transactional
44
{
44
+ * convergence; before @prepare or @abort.
45
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
45
+ *
46
index XXXXXXX..XXXXXXX 100755
46
+ * FIXME TODO: This callback is only temporary to transition remaining jobs
47
--- a/tests/qemu-iotests/081
47
+ * to prepare/commit/abort/clean callbacks and will be removed before 3.1.
48
+++ b/tests/qemu-iotests/081
48
+ * is released.
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
49
+ */
50
_supported_fmt raw
50
+ void (*exit)(Job *job);
51
_supported_proto file
51
+
52
_supported_os Linux
52
/**
53
+_require_drivers quorum
53
* If the callback is not NULL, prepare will be invoked when all the jobs
54
54
* belonging to the same transaction complete; or upon this job's completion
55
do_run_qemu()
55
diff --git a/job.c b/job.c
56
{
56
index XXXXXXX..XXXXXXX 100644
57
@@ -XXX,XX +XXX,XX @@ run_qemu()
57
--- a/job.c
58
| _filter_qemu_io | _filter_generated_node_ids
58
+++ b/job.c
59
@@ -XXX,XX +XXX,XX @@ void job_drain(Job *job)
60
}
59
}
61
}
60
62
61
-test_quorum=$($QEMU_IMG --help|grep quorum)
63
+static void job_exit(void *opaque)
62
-[ "$test_quorum" = "" ] && _supported_fmt quorum
64
+{
63
-
65
+ Job *job = (Job *)opaque;
64
quorum="driver=raw,file.driver=quorum,file.vote-threshold=2"
66
+ AioContext *aio_context = job->aio_context;
65
quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw"
67
+
66
quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw"
68
+ if (job->driver->exit) {
67
diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099
69
+ aio_context_acquire(aio_context);
68
index XXXXXXX..XXXXXXX 100755
70
+ job->driver->exit(job);
69
--- a/tests/qemu-iotests/099
71
+ aio_context_release(aio_context);
70
+++ b/tests/qemu-iotests/099
72
+ }
71
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
73
+ job_completed(job, job->ret);
72
_supported_fmt qcow qcow2 qed vdi vhdx vmdk vpc
74
+}
73
_supported_proto file
75
74
_supported_os Linux
76
/**
75
+_require_drivers blkdebug blkverify
77
* All jobs must allow a pause point before entering their job proper. This
76
_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
78
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn job_co_entry(void *opaque)
77
"subformat=twoGbMaxExtentSparse"
79
assert(job && job->driver && job->driver->run);
78
80
job_pause_point(job);
79
diff --git a/tests/qemu-iotests/120 b/tests/qemu-iotests/120
81
job->ret = job->driver->run(job, &job->err);
80
index XXXXXXX..XXXXXXX 100755
82
+ if (!job->deferred_to_main_loop) {
81
--- a/tests/qemu-iotests/120
83
+ job->deferred_to_main_loop = true;
82
+++ b/tests/qemu-iotests/120
84
+ aio_bh_schedule_oneshot(qemu_get_aio_context(),
83
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
85
+ job_exit,
84
_supported_fmt generic
86
+ job);
85
_supported_proto file
87
+ }
86
_unsupported_fmt luks
87
+_require_drivers raw
88
89
_make_test_img 64M
90
91
diff --git a/tests/qemu-iotests/162 b/tests/qemu-iotests/162
92
index XXXXXXX..XXXXXXX 100755
93
--- a/tests/qemu-iotests/162
94
+++ b/tests/qemu-iotests/162
95
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
96
. ./common.filter
97
98
_supported_fmt generic
99
-
100
-test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)')
101
-[ "$test_ssh" = "" ] && _notrun "ssh support required"
102
+_require_drivers ssh
103
104
echo
105
echo '=== NBD ==='
106
diff --git a/tests/qemu-iotests/184 b/tests/qemu-iotests/184
107
index XXXXXXX..XXXXXXX 100755
108
--- a/tests/qemu-iotests/184
109
+++ b/tests/qemu-iotests/184
110
@@ -XXX,XX +XXX,XX @@ trap "exit \$status" 0 1 2 3 15
111
. ./common.filter
112
113
_supported_os Linux
114
+_require_drivers throttle
115
116
do_run_qemu()
117
{
118
diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186
119
index XXXXXXX..XXXXXXX 100755
120
--- a/tests/qemu-iotests/186
121
+++ b/tests/qemu-iotests/186
122
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
123
124
_supported_fmt qcow2
125
_supported_proto file
126
+_require_drivers null-co
127
128
if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
129
_notrun "Requires a PC machine"
130
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
131
index XXXXXXX..XXXXXXX 100644
132
--- a/tests/qemu-iotests/common.rc
133
+++ b/tests/qemu-iotests/common.rc
134
@@ -XXX,XX +XXX,XX @@ _require_command()
135
[ -x "$c" ] || _notrun "$1 utility required, skipped this test"
136
}
88
}
137
89
138
+# Check that a set of drivers has been whitelisted in the QEMU binary
90
139
+#
140
+_require_drivers()
141
+{
142
+ available=$($QEMU -drive format=help | \
143
+ sed -e '/Supported formats:/!d' -e 's/Supported formats://')
144
+ for driver
145
+ do
146
+ if ! echo "$available" | grep -q " $driver\( \|$\)"; then
147
+ _notrun "$driver not available"
148
+ fi
149
+ done
150
+}
151
+
152
# make sure this script returns success
153
true
154
--
91
--
155
2.21.0
92
2.17.1
156
93
157
94
diff view generated by jsdifflib
1
The error message for the test case where we have a quorum node for
1
From: John Snow <jsnow@redhat.com>
2
which no directory name can be generated is different: For
3
twoGbMaxExtentSparse, it complains that it cannot open the extent file.
4
For other (sub)formats, it just notes that it cannot determine the
5
backing file path. Both are fine, but just disable twoGbMaxExtentSparse
6
for simplicity's sake.
7
2
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
Change the manual deferment to commit_complete into the implicit
9
Reviewed-by: John Snow <jsnow@redhat.com>
4
callback to job_exit, renaming commit_complete to commit_exit.
10
Message-id: 20190815153638.4600-7-mreitz@redhat.com
5
11
Reviewed-by: John Snow <jsnow@redhat.com>
6
This conversion does change the timing of when job_completed is
7
called to after the bdrv_replace_node and bdrv_unref calls, which
8
could have implications for bjob->blk which will now be put down
9
after this cleanup.
10
11
Kevin highlights that we did not take any permissions for that backend
12
at job creation time, so it is safe to reorder these operations.
13
14
Signed-off-by: John Snow <jsnow@redhat.com>
15
Reviewed-by: Max Reitz <mreitz@redhat.com>
16
Message-id: 20180830015734.19765-5-jsnow@redhat.com
17
Reviewed-by: Jeff Cody <jcody@redhat.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
18
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
19
---
14
tests/qemu-iotests/110 | 3 ++-
20
block/commit.c | 22 +++++-----------------
15
1 file changed, 2 insertions(+), 1 deletion(-)
21
1 file changed, 5 insertions(+), 17 deletions(-)
16
22
17
diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110
23
diff --git a/block/commit.c b/block/commit.c
18
index XXXXXXX..XXXXXXX 100755
24
index XXXXXXX..XXXXXXX 100644
19
--- a/tests/qemu-iotests/110
25
--- a/block/commit.c
20
+++ b/tests/qemu-iotests/110
26
+++ b/block/commit.c
21
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
27
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn commit_populate(BlockBackend *bs, BlockBackend *base,
22
# Any format supporting backing files
28
return 0;
23
_supported_fmt qed qcow qcow2 vmdk
29
}
24
_supported_proto file
30
25
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
31
-typedef struct {
26
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
32
- int ret;
27
+ "subformat=twoGbMaxExtentSparse"
33
-} CommitCompleteData;
28
34
-
29
TEST_IMG_REL=$(basename "$TEST_IMG")
35
-static void commit_complete(Job *job, void *opaque)
36
+static void commit_exit(Job *job)
37
{
38
CommitBlockJob *s = container_of(job, CommitBlockJob, common.job);
39
BlockJob *bjob = &s->common;
40
- CommitCompleteData *data = opaque;
41
BlockDriverState *top = blk_bs(s->top);
42
BlockDriverState *base = blk_bs(s->base);
43
BlockDriverState *commit_top_bs = s->commit_top_bs;
44
- int ret = data->ret;
45
bool remove_commit_top_bs = false;
46
47
/* Make sure commit_top_bs and top stay around until bdrv_replace_node() */
48
@@ -XXX,XX +XXX,XX @@ static void commit_complete(Job *job, void *opaque)
49
* the normal backing chain can be restored. */
50
blk_unref(s->base);
51
52
- if (!job_is_cancelled(job) && ret == 0) {
53
+ if (!job_is_cancelled(job) && job->ret == 0) {
54
/* success */
55
- ret = bdrv_drop_intermediate(s->commit_top_bs, base,
56
- s->backing_file_str);
57
+ job->ret = bdrv_drop_intermediate(s->commit_top_bs, base,
58
+ s->backing_file_str);
59
} else {
60
/* XXX Can (or should) we somehow keep 'consistent read' blocked even
61
* after the failed/cancelled commit job is gone? If we already wrote
62
@@ -XXX,XX +XXX,XX @@ static void commit_complete(Job *job, void *opaque)
63
* bdrv_set_backing_hd() to fail. */
64
block_job_remove_all_bdrv(bjob);
65
66
- job_completed(job, ret);
67
- g_free(data);
68
-
69
/* If bdrv_drop_intermediate() didn't already do that, remove the commit
70
* filter driver from the backing chain. Do this as the final step so that
71
* the 'consistent read' permission can be granted. */
72
@@ -XXX,XX +XXX,XX @@ static void commit_complete(Job *job, void *opaque)
73
static int coroutine_fn commit_run(Job *job, Error **errp)
74
{
75
CommitBlockJob *s = container_of(job, CommitBlockJob, common.job);
76
- CommitCompleteData *data;
77
int64_t offset;
78
uint64_t delay_ns = 0;
79
int ret = 0;
80
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn commit_run(Job *job, Error **errp)
81
out:
82
qemu_vfree(buf);
83
84
- data = g_malloc(sizeof(*data));
85
- data->ret = ret;
86
- job_defer_to_main_loop(&s->common.job, commit_complete, data);
87
return ret;
88
}
89
90
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver commit_job_driver = {
91
.user_resume = block_job_user_resume,
92
.drain = block_job_drain,
93
.run = commit_run,
94
+ .exit = commit_exit,
95
},
96
};
30
97
31
--
98
--
32
2.21.0
99
2.17.1
33
100
34
101
diff view generated by jsdifflib
1
This makes iotest 033 pass with e.g. subformat=monolithicFlat. It also
1
From: John Snow <jsnow@redhat.com>
2
turns a former error in 059 into success.
3
2
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
Change the manual deferment to mirror_exit into the implicit
5
Message-id: 20190815153638.4600-3-mreitz@redhat.com
4
callback to job_exit and the mirror_exit callback.
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
6
This does change the order of some bdrv_unref calls and job_completed,
7
but thanks to the new context in which we call .exit, this is safe to
8
defer the possible flushing of any nodes to the job_finalize_single
9
cleanup stage.
10
11
Signed-off-by: John Snow <jsnow@redhat.com>
12
Message-id: 20180830015734.19765-6-jsnow@redhat.com
13
Reviewed-by: Max Reitz <mreitz@redhat.com>
14
Reviewed-by: Jeff Cody <jcody@redhat.com>
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
---
16
---
9
block/vmdk.c | 54 ++++++++++++++++++++++++--------------
17
block/mirror.c | 29 +++++++++++------------------
10
tests/qemu-iotests/059 | 7 +++--
18
1 file changed, 11 insertions(+), 18 deletions(-)
11
tests/qemu-iotests/059.out | 4 ++-
12
3 files changed, 42 insertions(+), 23 deletions(-)
13
19
14
diff --git a/block/vmdk.c b/block/vmdk.c
20
diff --git a/block/mirror.c b/block/mirror.c
15
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
16
--- a/block/vmdk.c
22
--- a/block/mirror.c
17
+++ b/block/vmdk.c
23
+++ b/block/mirror.c
18
@@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s)
24
@@ -XXX,XX +XXX,XX @@ static void mirror_wait_for_all_io(MirrorBlockJob *s)
25
}
19
}
26
}
20
27
21
static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
28
-typedef struct {
22
- const char *desc_file_path, QDict *options,
29
- int ret;
23
- Error **errp)
30
-} MirrorExitData;
24
+ QDict *options, Error **errp)
31
-
32
-static void mirror_exit(Job *job, void *opaque)
33
+static void mirror_exit(Job *job)
25
{
34
{
26
int ret;
35
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job);
27
int matches;
36
BlockJob *bjob = &s->common;
28
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
37
- MirrorExitData *data = opaque;
29
const char *p, *np;
38
MirrorBDSOpaque *bs_opaque = s->mirror_top_bs->opaque;
30
int64_t sectors = 0;
39
AioContext *replace_aio_context = NULL;
31
int64_t flat_offset;
40
BlockDriverState *src = s->mirror_top_bs->backing->bs;
32
+ char *desc_file_dir = NULL;
41
BlockDriverState *target_bs = blk_bs(s->target);
33
char *extent_path;
42
BlockDriverState *mirror_top_bs = s->mirror_top_bs;
34
BdrvChild *extent_file;
43
Error *local_err = NULL;
35
BDRVVmdkState *s = bs->opaque;
44
+ int ret = job->ret;
36
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
45
37
continue;
46
bdrv_release_dirty_bitmap(src, s->dirty_bitmap);
47
48
- /* Make sure that the source BDS doesn't go away before we called
49
- * job_completed(). */
50
+ /* Make sure that the source BDS doesn't go away during bdrv_replace_node,
51
+ * before we can call bdrv_drained_end */
52
bdrv_ref(src);
53
bdrv_ref(mirror_top_bs);
54
bdrv_ref(target_bs);
55
@@ -XXX,XX +XXX,XX @@ static void mirror_exit(Job *job, void *opaque)
56
bdrv_set_backing_hd(target_bs, backing, &local_err);
57
if (local_err) {
58
error_report_err(local_err);
59
- data->ret = -EPERM;
60
+ ret = -EPERM;
61
}
38
}
62
}
39
63
}
40
- if (!path_is_absolute(fname) && !path_has_protocol(fname) &&
64
@@ -XXX,XX +XXX,XX @@ static void mirror_exit(Job *job, void *opaque)
41
- !desc_file_path[0])
65
aio_context_acquire(replace_aio_context);
42
- {
66
}
43
- bdrv_refresh_filename(bs->file->bs);
67
44
- error_setg(errp, "Cannot use relative extent paths with VMDK "
68
- if (s->should_complete && data->ret == 0) {
45
- "descriptor file '%s'", bs->file->bs->filename);
69
+ if (s->should_complete && ret == 0) {
46
- return -EINVAL;
70
BlockDriverState *to_replace = src;
47
- }
71
if (s->to_replace) {
48
+ if (path_is_absolute(fname)) {
72
to_replace = s->to_replace;
49
+ extent_path = g_strdup(fname);
73
@@ -XXX,XX +XXX,XX @@ static void mirror_exit(Job *job, void *opaque)
50
+ } else {
74
bdrv_drained_end(target_bs);
51
+ if (!desc_file_dir) {
52
+ desc_file_dir = bdrv_dirname(bs->file->bs, errp);
53
+ if (!desc_file_dir) {
54
+ bdrv_refresh_filename(bs->file->bs);
55
+ error_prepend(errp, "Cannot use relative paths with VMDK "
56
+ "descriptor file '%s': ",
57
+ bs->file->bs->filename);
58
+ ret = -EINVAL;
59
+ goto out;
60
+ }
61
+ }
62
63
- extent_path = path_combine(desc_file_path, fname);
64
+ extent_path = g_strconcat(desc_file_dir, fname, NULL);
65
+ }
66
67
ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents);
68
assert(ret < 32);
69
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
70
g_free(extent_path);
71
if (local_err) {
75
if (local_err) {
72
error_propagate(errp, local_err);
76
error_report_err(local_err);
73
- return -EINVAL;
77
- data->ret = -EPERM;
74
+ ret = -EINVAL;
78
+ ret = -EPERM;
75
+ goto out;
76
}
79
}
77
78
/* save to extents array */
79
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
80
0, 0, 0, 0, 0, &extent, errp);
81
if (ret < 0) {
82
bdrv_unref_child(bs, extent_file);
83
- return ret;
84
+ goto out;
85
}
86
extent->flat_start_offset = flat_offset << 9;
87
} else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) {
88
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
89
g_free(buf);
90
if (ret) {
91
bdrv_unref_child(bs, extent_file);
92
- return ret;
93
+ goto out;
94
}
95
extent = &s->extents[s->num_extents - 1];
96
} else if (!strcmp(type, "SESPARSE")) {
97
ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp);
98
if (ret) {
99
bdrv_unref_child(bs, extent_file);
100
- return ret;
101
+ goto out;
102
}
103
extent = &s->extents[s->num_extents - 1];
104
} else {
105
error_setg(errp, "Unsupported extent type '%s'", type);
106
bdrv_unref_child(bs, extent_file);
107
- return -ENOTSUP;
108
+ ret = -ENOTSUP;
109
+ goto out;
110
}
111
extent->type = g_strdup(type);
112
}
80
}
113
- return 0;
81
if (s->to_replace) {
82
@@ -XXX,XX +XXX,XX @@ static void mirror_exit(Job *job, void *opaque)
83
blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort);
84
85
bs_opaque->job = NULL;
86
- job_completed(job, data->ret);
87
88
- g_free(data);
89
bdrv_drained_end(src);
90
bdrv_unref(mirror_top_bs);
91
bdrv_unref(src);
114
+
92
+
115
+ ret = 0;
93
+ job->ret = ret;
116
+ goto out;
94
}
117
95
118
invalid:
96
static void mirror_throttle(MirrorBlockJob *s)
119
np = next_line(p);
97
@@ -XXX,XX +XXX,XX @@ static int mirror_flush(MirrorBlockJob *s)
120
@@ -XXX,XX +XXX,XX @@ invalid:
98
static int coroutine_fn mirror_run(Job *job, Error **errp)
121
np--;
99
{
100
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job);
101
- MirrorExitData *data;
102
BlockDriverState *bs = s->mirror_top_bs->backing->bs;
103
BlockDriverState *target_bs = blk_bs(s->target);
104
bool need_drain = true;
105
@@ -XXX,XX +XXX,XX @@ immediate_exit:
106
g_free(s->in_flight_bitmap);
107
bdrv_dirty_iter_free(s->dbi);
108
109
- data = g_malloc(sizeof(*data));
110
- data->ret = ret;
111
-
112
if (need_drain) {
113
bdrv_drained_begin(bs);
122
}
114
}
123
error_setg(errp, "Invalid extent line: %.*s", (int)(np - p), p);
115
124
- return -EINVAL;
116
- job_defer_to_main_loop(&s->common.job, mirror_exit, data);
125
+ ret = -EINVAL;
126
+
127
+out:
128
+ g_free(desc_file_dir);
129
+ return ret;
130
}
131
132
static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
133
@@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
134
}
135
s->create_type = g_strdup(ct);
136
s->desc_offset = 0;
137
- ret = vmdk_parse_extents(buf, bs, bs->file->bs->exact_filename, options,
138
- errp);
139
+ ret = vmdk_parse_extents(buf, bs, options, errp);
140
exit:
141
return ret;
117
return ret;
142
}
118
}
143
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
119
144
index XXXXXXX..XXXXXXX 100755
120
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver mirror_job_driver = {
145
--- a/tests/qemu-iotests/059
121
.user_resume = block_job_user_resume,
146
+++ b/tests/qemu-iotests/059
122
.drain = block_job_drain,
147
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
123
.run = mirror_run,
148
124
+ .exit = mirror_exit,
149
echo
125
.pause = mirror_pause,
150
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
126
.complete = mirror_complete,
151
+# Should work, because bdrv_dirname() works fine with blkdebug
127
},
152
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
128
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver commit_active_job_driver = {
153
-$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" 2>&1 \
129
.user_resume = block_job_user_resume,
154
- | _filter_testdir | _filter_imgfmt
130
.drain = block_job_drain,
155
+$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
131
.run = mirror_run,
156
+ -c info \
132
+ .exit = mirror_exit,
157
+ 2>&1 \
133
.pause = mirror_pause,
158
+ | _filter_testdir | _filter_imgfmt | _filter_img_info
134
.complete = mirror_complete,
159
_cleanup_test_img
135
},
160
161
echo
162
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
163
index XXXXXXX..XXXXXXX 100644
164
--- a/tests/qemu-iotests/059.out
165
+++ b/tests/qemu-iotests/059.out
166
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
167
168
=== Testing monolithicFlat with internally generated JSON file name ===
169
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
170
-qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}'
171
+format name: IMGFMT
172
+cluster size: 0 bytes
173
+vm state offset: 0 bytes
174
175
=== Testing version 3 ===
176
image: TEST_DIR/iotest-version3.IMGFMT
177
--
136
--
178
2.21.0
137
2.17.1
179
138
180
139
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
It's wrong to OR shared permissions. It may lead to crash on further
3
Utilize the job_exit shim by not calling job_defer_to_main_loop, and
4
permission updates.
4
where applicable, converting the deferred callback into the job_exit
5
Also, no needs to consider previously calculated permissions, as at
5
callback.
6
this point we already bind all new parents and bdrv_get_cumulative_perm
6
7
result is enough. So fix the bug by just set permissions by
7
This converts backup, stream, create, and the unit tests all at once.
8
bdrv_get_cumulative_perm result.
8
Most of these jobs do not see any changes to the order in which they
9
9
clean up their resources, except the test-blockjob-txn test, which
10
Bug was introduced in long ago 234ac1a9025, in 2.9.
10
now puts down its bs before job_completed is called.
11
11
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
12
This is safe for the same reason the reordering in the mirror job is
13
Message-id: 20190824100740.61635-1-vsementsov@virtuozzo.com
13
safe, because job_completed no longer runs under two locks, making
14
the unref safe even if it causes a flush.
15
16
Signed-off-by: John Snow <jsnow@redhat.com>
17
Reviewed-by: Max Reitz <mreitz@redhat.com>
18
Message-id: 20180830015734.19765-7-jsnow@redhat.com
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
19
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
20
---
16
block.c | 5 ++---
21
block/backup.c | 16 ----------------
17
1 file changed, 2 insertions(+), 3 deletions(-)
22
block/create.c | 14 +++-----------
18
23
block/stream.c | 22 +++++++---------------
19
diff --git a/block.c b/block.c
24
tests/test-bdrv-drain.c | 6 ------
20
index XXXXXXX..XXXXXXX 100644
25
tests/test-blockjob-txn.c | 11 ++---------
21
--- a/block.c
26
tests/test-blockjob.c | 10 ++++------
22
+++ b/block.c
27
6 files changed, 16 insertions(+), 63 deletions(-)
23
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
28
24
{
29
diff --git a/block/backup.c b/block/backup.c
25
BdrvChild *c, *next;
30
index XXXXXXX..XXXXXXX 100644
26
GSList *list = NULL, *p;
31
--- a/block/backup.c
27
- uint64_t old_perm, old_shared;
32
+++ b/block/backup.c
28
uint64_t perm = 0, shared = BLK_PERM_ALL;
33
@@ -XXX,XX +XXX,XX @@ static BlockErrorAction backup_error_action(BackupBlockJob *job,
29
int ret;
34
}
30
35
}
31
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
36
32
bdrv_unref(from);
37
-typedef struct {
33
}
38
- int ret;
34
39
-} BackupCompleteData;
35
- bdrv_get_cumulative_perm(to, &old_perm, &old_shared);
40
-
36
- bdrv_set_perm(to, old_perm | perm, old_shared | shared);
41
-static void backup_complete(Job *job, void *opaque)
37
+ bdrv_get_cumulative_perm(to, &perm, &shared);
42
-{
38
+ bdrv_set_perm(to, perm, shared);
43
- BackupCompleteData *data = opaque;
44
-
45
- job_completed(job, data->ret);
46
- g_free(data);
47
-}
48
-
49
static bool coroutine_fn yield_and_check(BackupBlockJob *job)
50
{
51
uint64_t delay_ns;
52
@@ -XXX,XX +XXX,XX @@ static void backup_incremental_init_copy_bitmap(BackupBlockJob *job)
53
static int coroutine_fn backup_run(Job *opaque_job, Error **errp)
54
{
55
BackupBlockJob *job = container_of(opaque_job, BackupBlockJob, common.job);
56
- BackupCompleteData *data;
57
BlockDriverState *bs = blk_bs(job->common.blk);
58
int64_t offset, nb_clusters;
59
int ret = 0;
60
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_run(Job *opaque_job, Error **errp)
61
qemu_co_rwlock_unlock(&job->flush_rwlock);
62
hbitmap_free(job->copy_bitmap);
63
64
- data = g_malloc(sizeof(*data));
65
- data->ret = ret;
66
- job_defer_to_main_loop(&job->common.job, backup_complete, data);
67
return ret;
68
}
69
70
diff --git a/block/create.c b/block/create.c
71
index XXXXXXX..XXXXXXX 100644
72
--- a/block/create.c
73
+++ b/block/create.c
74
@@ -XXX,XX +XXX,XX @@ typedef struct BlockdevCreateJob {
75
Job common;
76
BlockDriver *drv;
77
BlockdevCreateOptions *opts;
78
- int ret;
79
} BlockdevCreateJob;
80
81
-static void blockdev_create_complete(Job *job, void *opaque)
82
-{
83
- BlockdevCreateJob *s = container_of(job, BlockdevCreateJob, common);
84
-
85
- job_completed(job, s->ret);
86
-}
87
-
88
static int coroutine_fn blockdev_create_run(Job *job, Error **errp)
89
{
90
BlockdevCreateJob *s = container_of(job, BlockdevCreateJob, common);
91
+ int ret;
92
93
job_progress_set_remaining(&s->common, 1);
94
- s->ret = s->drv->bdrv_co_create(s->opts, errp);
95
+ ret = s->drv->bdrv_co_create(s->opts, errp);
96
job_progress_update(&s->common, 1);
97
98
qapi_free_BlockdevCreateOptions(s->opts);
99
- job_defer_to_main_loop(&s->common, blockdev_create_complete, NULL);
100
101
- return s->ret;
102
+ return ret;
103
}
104
105
static const JobDriver blockdev_create_job_driver = {
106
diff --git a/block/stream.c b/block/stream.c
107
index XXXXXXX..XXXXXXX 100644
108
--- a/block/stream.c
109
+++ b/block/stream.c
110
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn stream_populate(BlockBackend *blk,
111
return blk_co_preadv(blk, offset, qiov.size, &qiov, BDRV_REQ_COPY_ON_READ);
112
}
113
114
-typedef struct {
115
- int ret;
116
-} StreamCompleteData;
117
-
118
-static void stream_complete(Job *job, void *opaque)
119
+static void stream_exit(Job *job)
120
{
121
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
122
BlockJob *bjob = &s->common;
123
- StreamCompleteData *data = opaque;
124
BlockDriverState *bs = blk_bs(bjob->blk);
125
BlockDriverState *base = s->base;
126
Error *local_err = NULL;
127
+ int ret = job->ret;
128
129
- if (!job_is_cancelled(job) && bs->backing && data->ret == 0) {
130
+ if (!job_is_cancelled(job) && bs->backing && ret == 0) {
131
const char *base_id = NULL, *base_fmt = NULL;
132
if (base) {
133
base_id = s->backing_file_str;
134
@@ -XXX,XX +XXX,XX @@ static void stream_complete(Job *job, void *opaque)
135
base_fmt = base->drv->format_name;
136
}
137
}
138
- data->ret = bdrv_change_backing_file(bs, base_id, base_fmt);
139
+ ret = bdrv_change_backing_file(bs, base_id, base_fmt);
140
bdrv_set_backing_hd(bs, base, &local_err);
141
if (local_err) {
142
error_report_err(local_err);
143
- data->ret = -EPERM;
144
+ ret = -EPERM;
145
goto out;
146
}
147
}
148
@@ -XXX,XX +XXX,XX @@ out:
149
}
150
151
g_free(s->backing_file_str);
152
- job_completed(job, data->ret);
153
- g_free(data);
154
+ job->ret = ret;
155
}
156
157
static int coroutine_fn stream_run(Job *job, Error **errp)
158
{
159
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
160
- StreamCompleteData *data;
161
BlockBackend *blk = s->common.blk;
162
BlockDriverState *bs = blk_bs(blk);
163
BlockDriverState *base = s->base;
164
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn stream_run(Job *job, Error **errp)
39
165
40
out:
166
out:
41
g_slist_free(list);
167
/* Modify backing chain and close BDSes in main loop */
168
- data = g_malloc(sizeof(*data));
169
- data->ret = ret;
170
- job_defer_to_main_loop(&s->common.job, stream_complete, data);
171
return ret;
172
}
173
174
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver stream_job_driver = {
175
.job_type = JOB_TYPE_STREAM,
176
.free = block_job_free,
177
.run = stream_run,
178
+ .exit = stream_exit,
179
.user_resume = block_job_user_resume,
180
.drain = block_job_drain,
181
},
182
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
183
index XXXXXXX..XXXXXXX 100644
184
--- a/tests/test-bdrv-drain.c
185
+++ b/tests/test-bdrv-drain.c
186
@@ -XXX,XX +XXX,XX @@ typedef struct TestBlockJob {
187
bool should_complete;
188
} TestBlockJob;
189
190
-static void test_job_completed(Job *job, void *opaque)
191
-{
192
- job_completed(job, 0);
193
-}
194
-
195
static int coroutine_fn test_job_run(Job *job, Error **errp)
196
{
197
TestBlockJob *s = container_of(job, TestBlockJob, common.job);
198
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn test_job_run(Job *job, Error **errp)
199
job_pause_point(&s->common.job);
200
}
201
202
- job_defer_to_main_loop(&s->common.job, test_job_completed, NULL);
203
return 0;
204
}
205
206
diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c
207
index XXXXXXX..XXXXXXX 100644
208
--- a/tests/test-blockjob-txn.c
209
+++ b/tests/test-blockjob-txn.c
210
@@ -XXX,XX +XXX,XX @@ typedef struct {
211
int *result;
212
} TestBlockJob;
213
214
-static void test_block_job_complete(Job *job, void *opaque)
215
+static void test_block_job_exit(Job *job)
216
{
217
BlockJob *bjob = container_of(job, BlockJob, job);
218
BlockDriverState *bs = blk_bs(bjob->blk);
219
- int rc = (intptr_t)opaque;
220
221
- if (job_is_cancelled(job)) {
222
- rc = -ECANCELED;
223
- }
224
-
225
- job_completed(job, rc);
226
bdrv_unref(bs);
227
}
228
229
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn test_block_job_run(Job *job, Error **errp)
230
}
231
}
232
233
- job_defer_to_main_loop(job, test_block_job_complete,
234
- (void *)(intptr_t)s->rc);
235
return s->rc;
236
}
237
238
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver test_block_job_driver = {
239
.user_resume = block_job_user_resume,
240
.drain = block_job_drain,
241
.run = test_block_job_run,
242
+ .exit = test_block_job_exit,
243
},
244
};
245
246
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
247
index XXXXXXX..XXXXXXX 100644
248
--- a/tests/test-blockjob.c
249
+++ b/tests/test-blockjob.c
250
@@ -XXX,XX +XXX,XX @@ typedef struct CancelJob {
251
bool completed;
252
} CancelJob;
253
254
-static void cancel_job_completed(Job *job, void *opaque)
255
+static void cancel_job_exit(Job *job)
256
{
257
- CancelJob *s = opaque;
258
+ CancelJob *s = container_of(job, CancelJob, common.job);
259
s->completed = true;
260
- job_completed(job, 0);
261
}
262
263
static void cancel_job_complete(Job *job, Error **errp)
264
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn cancel_job_run(Job *job, Error **errp)
265
266
while (!s->should_complete) {
267
if (job_is_cancelled(&s->common.job)) {
268
- goto defer;
269
+ return 0;
270
}
271
272
if (!job_is_ready(&s->common.job) && s->should_converge) {
273
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn cancel_job_run(Job *job, Error **errp)
274
job_sleep_ns(&s->common.job, 100000);
275
}
276
277
- defer:
278
- job_defer_to_main_loop(&s->common.job, cancel_job_completed, s);
279
return 0;
280
}
281
282
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver test_cancel_driver = {
283
.user_resume = block_job_user_resume,
284
.drain = block_job_drain,
285
.run = cancel_job_run,
286
+ .exit = cancel_job_exit,
287
.complete = cancel_job_complete,
288
},
289
};
42
--
290
--
43
2.21.0
291
2.17.1
44
292
45
293
diff view generated by jsdifflib
1
From: Denis Plotnikov <dplotnikov@virtuozzo.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
The patch allows to provide a pattern file for write
3
Rename opaque_job to job to be consistent with other job implementations.
4
command. There was no similar ability before.
4
Rename 'job', the BackupBlockJob object, to 's' to also be consistent.
5
5
6
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
6
Suggested-by: Eric Blake <eblake@redhat.com>
7
Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com
7
Signed-off-by: John Snow <jsnow@redhat.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
[mreitz: Keep optstring in alphabetical order]
9
Message-id: 20180830015734.19765-8-jsnow@redhat.com
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
11
---
12
qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++---
12
block/backup.c | 62 +++++++++++++++++++++++++-------------------------
13
1 file changed, 93 insertions(+), 6 deletions(-)
13
1 file changed, 31 insertions(+), 31 deletions(-)
14
14
15
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
15
diff --git a/block/backup.c b/block/backup.c
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/qemu-io-cmds.c
17
--- a/block/backup.c
18
+++ b/qemu-io-cmds.c
18
+++ b/block/backup.c
19
@@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p)
19
@@ -XXX,XX +XXX,XX @@ static void backup_incremental_init_copy_bitmap(BackupBlockJob *job)
20
qemu_vfree(p);
20
bdrv_dirty_iter_free(dbi);
21
}
21
}
22
22
23
+/*
23
-static int coroutine_fn backup_run(Job *opaque_job, Error **errp)
24
+ * qemu_io_alloc_from_file()
24
+static int coroutine_fn backup_run(Job *job, Error **errp)
25
+ *
26
+ * Allocates the buffer and populates it with the content of the given file
27
+ * up to @len bytes. If the file length is less than @len, then the buffer
28
+ * is populated with the file content cyclically.
29
+ *
30
+ * @blk - the block backend where the buffer content is going to be written to
31
+ * @len - the buffer length
32
+ * @file_name - the file to read the content from
33
+ *
34
+ * Returns: the buffer pointer on success
35
+ * NULL on error
36
+ */
37
+static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len,
38
+ const char *file_name)
39
+{
40
+ char *buf, *buf_origin;
41
+ FILE *f = fopen(file_name, "r");
42
+ int pattern_len;
43
+
44
+ if (!f) {
45
+ perror(file_name);
46
+ return NULL;
47
+ }
48
+
49
+ if (qemuio_misalign) {
50
+ len += MISALIGN_OFFSET;
51
+ }
52
+
53
+ buf_origin = buf = blk_blockalign(blk, len);
54
+
55
+ if (qemuio_misalign) {
56
+ buf_origin += MISALIGN_OFFSET;
57
+ buf += MISALIGN_OFFSET;
58
+ len -= MISALIGN_OFFSET;
59
+ }
60
+
61
+ pattern_len = fread(buf_origin, 1, len, f);
62
+
63
+ if (ferror(f)) {
64
+ perror(file_name);
65
+ goto error;
66
+ }
67
+
68
+ if (pattern_len == 0) {
69
+ fprintf(stderr, "%s: file is empty\n", file_name);
70
+ goto error;
71
+ }
72
+
73
+ fclose(f);
74
+
75
+ if (len > pattern_len) {
76
+ len -= pattern_len;
77
+ buf += pattern_len;
78
+
79
+ while (len > 0) {
80
+ size_t len_to_copy = MIN(pattern_len, len);
81
+
82
+ memcpy(buf, buf_origin, len_to_copy);
83
+
84
+ len -= len_to_copy;
85
+ buf += len_to_copy;
86
+ }
87
+ }
88
+
89
+ return buf_origin;
90
+
91
+error:
92
+ qemu_io_free(buf_origin);
93
+ return NULL;
94
+}
95
+
96
static void dump_buffer(const void *buffer, int64_t offset, int64_t len)
97
{
25
{
98
uint64_t i;
26
- BackupBlockJob *job = container_of(opaque_job, BackupBlockJob, common.job);
99
@@ -XXX,XX +XXX,XX @@ static void write_help(void)
27
- BlockDriverState *bs = blk_bs(job->common.blk);
100
" -n, -- with -z, don't allow slow fallback\n"
28
+ BackupBlockJob *s = container_of(job, BackupBlockJob, common.job);
101
" -p, -- ignored for backwards compatibility\n"
29
+ BlockDriverState *bs = blk_bs(s->common.blk);
102
" -P, -- use different pattern to fill file\n"
30
int64_t offset, nb_clusters;
103
+" -s, -- use a pattern file to fill the write buffer\n"
31
int ret = 0;
104
" -C, -- report statistics in a machine parsable format\n"
32
105
" -q, -- quiet mode, do not show I/O statistics\n"
33
- QLIST_INIT(&job->inflight_reqs);
106
" -u, -- with -z, allow unmapping\n"
34
- qemu_co_rwlock_init(&job->flush_rwlock);
107
@@ -XXX,XX +XXX,XX @@ static const cmdinfo_t write_cmd = {
35
+ QLIST_INIT(&s->inflight_reqs);
108
.perm = BLK_PERM_WRITE,
36
+ qemu_co_rwlock_init(&s->flush_rwlock);
109
.argmin = 2,
37
110
.argmax = -1,
38
- nb_clusters = DIV_ROUND_UP(job->len, job->cluster_size);
111
- .args = "[-bcCfnquz] [-P pattern] off len",
39
- job_progress_set_remaining(&job->common.job, job->len);
112
+ .args = "[-bcCfnquz] [-P pattern | -s source_file] off len",
40
+ nb_clusters = DIV_ROUND_UP(s->len, s->cluster_size);
113
.oneline = "writes a number of bytes at a specified offset",
41
+ job_progress_set_remaining(job, s->len);
114
.help = write_help,
42
115
};
43
- job->copy_bitmap = hbitmap_alloc(nb_clusters, 0);
116
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
44
- if (job->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
117
{
45
- backup_incremental_init_copy_bitmap(job);
118
struct timespec t1, t2;
46
+ s->copy_bitmap = hbitmap_alloc(nb_clusters, 0);
119
bool Cflag = false, qflag = false, bflag = false;
47
+ if (s->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
120
- bool Pflag = false, zflag = false, cflag = false;
48
+ backup_incremental_init_copy_bitmap(s);
121
+ bool Pflag = false, zflag = false, cflag = false, sflag = false;
49
} else {
122
int flags = 0;
50
- hbitmap_set(job->copy_bitmap, 0, nb_clusters);
123
int c, cnt, ret;
51
+ hbitmap_set(s->copy_bitmap, 0, nb_clusters);
124
char *buf = NULL;
125
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
126
/* Some compilers get confused and warn if this is not initialized. */
127
int64_t total = 0;
128
int pattern = 0xcd;
129
+ const char *file_name = NULL;
130
131
- while ((c = getopt(argc, argv, "bcCfnpP:quz")) != -1) {
132
+ while ((c = getopt(argc, argv, "bcCfnpP:qs:uz")) != -1) {
133
switch (c) {
134
case 'b':
135
bflag = true;
136
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
137
case 'q':
138
qflag = true;
139
break;
140
+ case 's':
141
+ sflag = true;
142
+ file_name = optarg;
143
+ break;
144
case 'u':
145
flags |= BDRV_REQ_MAY_UNMAP;
146
break;
147
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
148
return -EINVAL;
149
}
52
}
150
53
151
- if (zflag && Pflag) {
54
152
- printf("-z and -P cannot be specified at the same time\n");
55
- job->before_write.notify = backup_before_write_notify;
153
+ if (zflag + Pflag + sflag > 1) {
56
- bdrv_add_before_write_notifier(bs, &job->before_write);
154
+ printf("Only one of -z, -P, and -s "
57
+ s->before_write.notify = backup_before_write_notify;
155
+ "can be specified at the same time\n");
58
+ bdrv_add_before_write_notifier(bs, &s->before_write);
156
return -EINVAL;
59
60
- if (job->sync_mode == MIRROR_SYNC_MODE_NONE) {
61
+ if (s->sync_mode == MIRROR_SYNC_MODE_NONE) {
62
/* All bits are set in copy_bitmap to allow any cluster to be copied.
63
* This does not actually require them to be copied. */
64
- while (!job_is_cancelled(&job->common.job)) {
65
+ while (!job_is_cancelled(job)) {
66
/* Yield until the job is cancelled. We just let our before_write
67
* notify callback service CoW requests. */
68
- job_yield(&job->common.job);
69
+ job_yield(job);
70
}
71
- } else if (job->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
72
- ret = backup_run_incremental(job);
73
+ } else if (s->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
74
+ ret = backup_run_incremental(s);
75
} else {
76
/* Both FULL and TOP SYNC_MODE's require copying.. */
77
- for (offset = 0; offset < job->len;
78
- offset += job->cluster_size) {
79
+ for (offset = 0; offset < s->len;
80
+ offset += s->cluster_size) {
81
bool error_is_read;
82
int alloced = 0;
83
84
- if (yield_and_check(job)) {
85
+ if (yield_and_check(s)) {
86
break;
87
}
88
89
- if (job->sync_mode == MIRROR_SYNC_MODE_TOP) {
90
+ if (s->sync_mode == MIRROR_SYNC_MODE_TOP) {
91
int i;
92
int64_t n;
93
94
/* Check to see if these blocks are already in the
95
* backing file. */
96
97
- for (i = 0; i < job->cluster_size;) {
98
+ for (i = 0; i < s->cluster_size;) {
99
/* bdrv_is_allocated() only returns true/false based
100
* on the first set of sectors it comes across that
101
* are are all in the same state.
102
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_run(Job *opaque_job, Error **errp)
103
* needed but at some point that is always the case. */
104
alloced =
105
bdrv_is_allocated(bs, offset + i,
106
- job->cluster_size - i, &n);
107
+ s->cluster_size - i, &n);
108
i += n;
109
110
if (alloced || n == 0) {
111
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_run(Job *opaque_job, Error **errp)
112
if (alloced < 0) {
113
ret = alloced;
114
} else {
115
- ret = backup_do_cow(job, offset, job->cluster_size,
116
+ ret = backup_do_cow(s, offset, s->cluster_size,
117
&error_is_read, false);
118
}
119
if (ret < 0) {
120
/* Depending on error action, fail now or retry cluster */
121
BlockErrorAction action =
122
- backup_error_action(job, error_is_read, -ret);
123
+ backup_error_action(s, error_is_read, -ret);
124
if (action == BLOCK_ERROR_ACTION_REPORT) {
125
break;
126
} else {
127
- offset -= job->cluster_size;
128
+ offset -= s->cluster_size;
129
continue;
130
}
131
}
132
}
157
}
133
}
158
134
159
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
135
- notifier_with_return_remove(&job->before_write);
160
}
136
+ notifier_with_return_remove(&s->before_write);
161
137
162
if (!zflag) {
138
/* wait until pending backup_do_cow() calls have completed */
163
- buf = qemu_io_alloc(blk, count, pattern);
139
- qemu_co_rwlock_wrlock(&job->flush_rwlock);
164
+ if (sflag) {
140
- qemu_co_rwlock_unlock(&job->flush_rwlock);
165
+ buf = qemu_io_alloc_from_file(blk, count, file_name);
141
- hbitmap_free(job->copy_bitmap);
166
+ if (!buf) {
142
+ qemu_co_rwlock_wrlock(&s->flush_rwlock);
167
+ return -EINVAL;
143
+ qemu_co_rwlock_unlock(&s->flush_rwlock);
168
+ }
144
+ hbitmap_free(s->copy_bitmap);
169
+ } else {
145
170
+ buf = qemu_io_alloc(blk, count, pattern);
146
return ret;
171
+ }
147
}
172
}
173
174
clock_gettime(CLOCK_MONOTONIC, &t1);
175
--
148
--
176
2.21.0
149
2.17.1
177
150
178
151
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
When creating an image with preallocation "off" or "falloc", the first
3
Jobs are now expected to return their retcode on the stack, from the
4
block of the image is typically not allocated. When using Gluster
4
.run callback, so we can remove that argument.
5
storage backed by XFS filesystem, reading this block using direct I/O
6
succeeds regardless of request length, fooling alignment detection.
7
5
8
In this case we fallback to a safe value (4096) instead of the optimal
6
job_cancel does not need to set -ECANCELED because job_completed will
9
value (512), which may lead to unneeded data copying when aligning
7
update the return code itself if the job was canceled.
10
requests. Allocating the first block avoids the fallback.
11
8
12
Since we allocate the first block even with preallocation=off, we no
9
While we're here, make job_completed static to job.c and remove it from
13
longer create images with zero disk size:
10
job.h; move the documentation of return code to the .run() callback and
11
to the job->ret property, accordingly.
14
12
15
$ ./qemu-img create -f raw test.raw 1g
13
Signed-off-by: John Snow <jsnow@redhat.com>
16
Formatting 'test.raw', fmt=raw size=1073741824
14
Message-id: 20180830015734.19765-9-jsnow@redhat.com
17
18
$ ls -lhs test.raw
19
4.0K -rw-r--r--. 1 nsoffer nsoffer 1.0G Aug 16 23:48 test.raw
20
21
And converting the image requires additional cluster:
22
23
$ ./qemu-img measure -f raw -O qcow2 test.raw
24
required size: 458752
25
fully allocated size: 1074135040
26
27
When using format like vmdk with multiple files per image, we allocate
28
one block per file:
29
30
$ ./qemu-img create -f vmdk -o subformat=twoGbMaxExtentFlat test.vmdk 4g
31
Formatting 'test.vmdk', fmt=vmdk size=4294967296 compat6=off hwversion=undefined subformat=twoGbMaxExtentFlat
32
33
$ ls -lhs test*.vmdk
34
4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f001.vmdk
35
4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f002.vmdk
36
4.0K -rw-r--r--. 1 nsoffer nsoffer 353 Aug 27 03:23 test.vmdk
37
38
I did quick performance test for copying disks with qemu-img convert to
39
new raw target image to Gluster storage with sector size of 512 bytes:
40
41
for i in $(seq 10); do
42
rm -f dst.raw
43
sleep 10
44
time ./qemu-img convert -f raw -O raw -t none -T none src.raw dst.raw
45
done
46
47
Here is a table comparing the total time spent:
48
49
Type Before(s) After(s) Diff(%)
50
---------------------------------------
51
real 530.028 469.123 -11.4
52
user 17.204 10.768 -37.4
53
sys 17.881 7.011 -60.7
54
55
We can see very clear improvement in CPU usage.
56
57
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
58
Message-id: 20190827010528.8818-2-nsoffer@redhat.com
59
Reviewed-by: Max Reitz <mreitz@redhat.com>
15
Reviewed-by: Max Reitz <mreitz@redhat.com>
60
Signed-off-by: Max Reitz <mreitz@redhat.com>
16
Signed-off-by: Max Reitz <mreitz@redhat.com>
61
---
17
---
62
block/file-posix.c | 51 +++++++++++++++++++
18
include/qemu/job.h | 28 +++++++++++++++-------------
63
tests/qemu-iotests/059.out | 2 +-
19
job.c | 11 ++++++-----
64
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
20
trace-events | 2 +-
65
tests/qemu-iotests/150.out.raw | 12 +++++
21
3 files changed, 22 insertions(+), 19 deletions(-)
66
tests/qemu-iotests/175 | 19 ++++---
67
tests/qemu-iotests/175.out | 8 +--
68
tests/qemu-iotests/178.out.qcow2 | 4 +-
69
tests/qemu-iotests/221.out | 12 +++--
70
tests/qemu-iotests/253.out | 12 +++--
71
9 files changed, 99 insertions(+), 21 deletions(-)
72
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
73
create mode 100644 tests/qemu-iotests/150.out.raw
74
22
75
diff --git a/block/file-posix.c b/block/file-posix.c
23
diff --git a/include/qemu/job.h b/include/qemu/job.h
76
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
77
--- a/block/file-posix.c
25
--- a/include/qemu/job.h
78
+++ b/block/file-posix.c
26
+++ b/include/qemu/job.h
79
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque)
27
@@ -XXX,XX +XXX,XX @@ typedef struct Job {
80
return ret;
28
/** Estimated progress_current value at the completion of the job */
29
int64_t progress_total;
30
31
- /** ret code passed to job_completed. */
32
+ /**
33
+ * Return code from @run and/or @prepare callback(s).
34
+ * Not final until the job has reached the CONCLUDED status.
35
+ * 0 on success, -errno on failure.
36
+ */
37
int ret;
38
39
/**
40
@@ -XXX,XX +XXX,XX @@ struct JobDriver {
41
/** Enum describing the operation */
42
JobType job_type;
43
44
- /** Mandatory: Entrypoint for the Coroutine. */
45
+ /**
46
+ * Mandatory: Entrypoint for the Coroutine.
47
+ *
48
+ * This callback will be invoked when moving from CREATED to RUNNING.
49
+ *
50
+ * If this callback returns nonzero, the job transaction it is part of is
51
+ * aborted. If it returns zero, the job moves into the WAITING state. If it
52
+ * is the last job to complete in its transaction, all jobs in the
53
+ * transaction move from WAITING to PENDING.
54
+ */
55
int coroutine_fn (*run)(Job *job, Error **errp);
56
57
/**
58
@@ -XXX,XX +XXX,XX @@ void job_early_fail(Job *job);
59
/** Moves the @job from RUNNING to READY */
60
void job_transition_to_ready(Job *job);
61
62
-/**
63
- * @job: The job being completed.
64
- * @ret: The status code.
65
- *
66
- * Marks @job as completed. If @ret is non-zero, the job transaction it is part
67
- * of is aborted. If @ret is zero, the job moves into the WAITING state. If it
68
- * is the last job to complete in its transaction, all jobs in the transaction
69
- * move from WAITING to PENDING.
70
- */
71
-void job_completed(Job *job, int ret);
72
-
73
/** Asynchronously complete the specified @job. */
74
void job_complete(Job *job, Error **errp);
75
76
diff --git a/job.c b/job.c
77
index XXXXXXX..XXXXXXX 100644
78
--- a/job.c
79
+++ b/job.c
80
@@ -XXX,XX +XXX,XX @@ void job_drain(Job *job)
81
}
81
}
82
}
82
83
83
+/*
84
+static void job_completed(Job *job);
84
+ * Help alignment probing by allocating the first block.
85
+ *
86
+ * When reading with direct I/O from unallocated area on Gluster backed by XFS,
87
+ * reading succeeds regardless of request length. In this case we fallback to
88
+ * safe alignment which is not optimal. Allocating the first block avoids this
89
+ * fallback.
90
+ *
91
+ * fd may be opened with O_DIRECT, but we don't know the buffer alignment or
92
+ * request alignment, so we use safe values.
93
+ *
94
+ * Returns: 0 on success, -errno on failure. Since this is an optimization,
95
+ * caller may ignore failures.
96
+ */
97
+static int allocate_first_block(int fd, size_t max_size)
98
+{
99
+ size_t write_size = (max_size < MAX_BLOCKSIZE)
100
+ ? BDRV_SECTOR_SIZE
101
+ : MAX_BLOCKSIZE;
102
+ size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize());
103
+ void *buf;
104
+ ssize_t n;
105
+ int ret;
106
+
85
+
107
+ buf = qemu_memalign(max_align, write_size);
86
static void job_exit(void *opaque)
108
+ memset(buf, 0, write_size);
109
+
110
+ do {
111
+ n = pwrite(fd, buf, write_size, 0);
112
+ } while (n == -1 && errno == EINTR);
113
+
114
+ ret = (n == -1) ? -errno : 0;
115
+
116
+ qemu_vfree(buf);
117
+ return ret;
118
+}
119
+
120
static int handle_aiocb_truncate(void *opaque)
121
{
87
{
122
RawPosixAIOData *aiocb = opaque;
88
Job *job = (Job *)opaque;
123
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
89
@@ -XXX,XX +XXX,XX @@ static void job_exit(void *opaque)
124
/* posix_fallocate() doesn't set errno. */
90
job->driver->exit(job);
125
error_setg_errno(errp, -result,
91
aio_context_release(aio_context);
126
"Could not preallocate new data");
92
}
127
+ } else if (current_length == 0) {
93
- job_completed(job, job->ret);
128
+ /*
94
+ job_completed(job);
129
+ * posix_fallocate() uses fallocate() if the filesystem
95
}
130
+ * supports it, or fallback to manually writing zeroes. If
96
131
+ * fallocate() was used, unaligned reads from the fallocated
97
/**
132
+ * area in raw_probe_alignment() will succeed, hence we need to
98
@@ -XXX,XX +XXX,XX @@ static void job_completed_txn_success(Job *job)
133
+ * allocate the first block.
99
}
134
+ *
100
}
135
+ * Optimize future alignment probing; ignore failures.
101
136
+ */
102
-void job_completed(Job *job, int ret)
137
+ allocate_first_block(fd, offset);
103
+static void job_completed(Job *job)
138
}
104
{
139
} else {
105
assert(job && job->txn && !job_is_completed(job));
140
result = 0;
106
141
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
107
- job->ret = ret;
142
if (ftruncate(fd, offset) != 0) {
108
job_update_rc(job);
143
result = -errno;
109
- trace_job_completed(job, ret, job->ret);
144
error_setg_errno(errp, -result, "Could not resize file");
110
+ trace_job_completed(job, job->ret);
145
+ } else if (current_length == 0 && offset > current_length) {
111
if (job->ret) {
146
+ /* Optimize future alignment probing; ignore failures. */
112
job_completed_txn_abort(job);
147
+ allocate_first_block(fd, offset);
113
} else {
148
}
114
@@ -XXX,XX +XXX,XX @@ void job_cancel(Job *job, bool force)
149
return result;
115
}
150
default:
116
job_cancel_async(job, force);
151
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
117
if (!job_started(job)) {
118
- job_completed(job, -ECANCELED);
119
+ job_completed(job);
120
} else if (job->deferred_to_main_loop) {
121
job_completed_txn_abort(job);
122
} else {
123
diff --git a/trace-events b/trace-events
152
index XXXXXXX..XXXXXXX 100644
124
index XXXXXXX..XXXXXXX 100644
153
--- a/tests/qemu-iotests/059.out
125
--- a/trace-events
154
+++ b/tests/qemu-iotests/059.out
126
+++ b/trace-events
155
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMax
127
@@ -XXX,XX +XXX,XX @@ gdbstub_err_checksum_incorrect(uint8_t expected, uint8_t got) "got command packe
156
image: TEST_DIR/t.vmdk
128
# job.c
157
file format: vmdk
129
job_state_transition(void *job, int ret, const char *legal, const char *s0, const char *s1) "job %p (ret: %d) attempting %s transition (%s-->%s)"
158
virtual size: 0.977 TiB (1073741824000 bytes)
130
job_apply_verb(void *job, const char *state, const char *verb, const char *legal) "job %p in state %s; applying verb %s (%s)"
159
-disk size: 16 KiB
131
-job_completed(void *job, int ret, int jret) "job %p ret %d corrected ret %d"
160
+disk size: 1.97 MiB
132
+job_completed(void *job, int ret) "job %p ret %d"
161
Format specific information:
133
162
cid: XXXXXXXX
134
# job-qmp.c
163
parent cid: XXXXXXXX
135
qmp_job_cancel(void *job) "job %p"
164
diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out.qcow2
165
similarity index 100%
166
rename from tests/qemu-iotests/150.out
167
rename to tests/qemu-iotests/150.out.qcow2
168
diff --git a/tests/qemu-iotests/150.out.raw b/tests/qemu-iotests/150.out.raw
169
new file mode 100644
170
index XXXXXXX..XXXXXXX
171
--- /dev/null
172
+++ b/tests/qemu-iotests/150.out.raw
173
@@ -XXX,XX +XXX,XX @@
174
+QA output created by 150
175
+
176
+=== Mapping sparse conversion ===
177
+
178
+Offset Length File
179
+0 0x1000 TEST_DIR/t.IMGFMT
180
+
181
+=== Mapping non-sparse conversion ===
182
+
183
+Offset Length File
184
+0 0x100000 TEST_DIR/t.IMGFMT
185
+*** done
186
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
187
index XXXXXXX..XXXXXXX 100755
188
--- a/tests/qemu-iotests/175
189
+++ b/tests/qemu-iotests/175
190
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
191
# the file size. This function hides the resulting difference in the
192
# stat -c '%b' output.
193
# Parameter 1: Number of blocks an empty file occupies
194
-# Parameter 2: Image size in bytes
195
+# Parameter 2: Minimal number of blocks in an image
196
+# Parameter 3: Image size in bytes
197
_filter_blocks()
198
{
199
extra_blocks=$1
200
- img_size=$2
201
+ min_blocks=$2
202
+ img_size=$3
203
204
- sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \
205
- -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/everything allocated/"
206
+ sed -e "s/blocks=$min_blocks\\(\$\\|[^0-9]\\)/min allocation/" \
207
+ -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
208
}
209
210
# get standard environment, filters and checks
211
@@ -XXX,XX +XXX,XX @@ size=$((1 * 1024 * 1024))
212
touch "$TEST_DIR/empty"
213
extra_blocks=$(stat -c '%b' "$TEST_DIR/empty")
214
215
+# We always write the first byte; check how many blocks this filesystem
216
+# allocates to match empty image alloation.
217
+printf "\0" > "$TEST_DIR/empty"
218
+min_blocks=$(stat -c '%b' "$TEST_DIR/empty")
219
+
220
echo
221
echo "== creating image with default preallocation =="
222
_make_test_img $size | _filter_imgfmt
223
-stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size
224
+stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
225
226
for mode in off full falloc; do
227
echo
228
echo "== creating image with preallocation $mode =="
229
IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt
230
- stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size
231
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
232
done
233
234
# success, all done
235
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
236
index XXXXXXX..XXXXXXX 100644
237
--- a/tests/qemu-iotests/175.out
238
+++ b/tests/qemu-iotests/175.out
239
@@ -XXX,XX +XXX,XX @@ QA output created by 175
240
241
== creating image with default preallocation ==
242
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
243
-size=1048576, nothing allocated
244
+size=1048576, min allocation
245
246
== creating image with preallocation off ==
247
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=off
248
-size=1048576, nothing allocated
249
+size=1048576, min allocation
250
251
== creating image with preallocation full ==
252
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=full
253
-size=1048576, everything allocated
254
+size=1048576, max allocation
255
256
== creating image with preallocation falloc ==
257
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
258
-size=1048576, everything allocated
259
+size=1048576, max allocation
260
*** done
261
diff --git a/tests/qemu-iotests/178.out.qcow2 b/tests/qemu-iotests/178.out.qcow2
262
index XXXXXXX..XXXXXXX 100644
263
--- a/tests/qemu-iotests/178.out.qcow2
264
+++ b/tests/qemu-iotests/178.out.qcow2
265
@@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608
266
== raw input image with data (human) ==
267
268
Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824
269
-required size: 393216
270
+required size: 458752
271
fully allocated size: 1074135040
272
wrote 512/512 bytes at offset 512
273
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
274
@@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608
275
276
Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824
277
{
278
- "required": 393216,
279
+ "required": 458752,
280
"fully-allocated": 1074135040
281
}
282
wrote 512/512 bytes at offset 512
283
diff --git a/tests/qemu-iotests/221.out b/tests/qemu-iotests/221.out
284
index XXXXXXX..XXXXXXX 100644
285
--- a/tests/qemu-iotests/221.out
286
+++ b/tests/qemu-iotests/221.out
287
@@ -XXX,XX +XXX,XX @@ QA output created by 221
288
=== Check mapping of unaligned raw image ===
289
290
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65537
291
-[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
292
-[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
293
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
294
+{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
295
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
296
+{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
297
wrote 1/1 bytes at offset 65536
298
1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
299
-[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
300
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
301
+{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
302
{ "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
303
{ "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
304
-[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
305
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
306
+{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
307
{ "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
308
{ "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
309
*** done
310
diff --git a/tests/qemu-iotests/253.out b/tests/qemu-iotests/253.out
311
index XXXXXXX..XXXXXXX 100644
312
--- a/tests/qemu-iotests/253.out
313
+++ b/tests/qemu-iotests/253.out
314
@@ -XXX,XX +XXX,XX @@ QA output created by 253
315
=== Check mapping of unaligned raw image ===
316
317
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048575
318
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
319
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
320
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
321
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
322
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
323
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
324
wrote 65535/65535 bytes at offset 983040
325
63.999 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
326
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
327
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
328
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
329
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
330
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
331
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
332
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
333
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
334
*** done
335
--
136
--
336
2.21.0
137
2.17.1
337
138
338
139
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: John Snow <jsnow@redhat.com>
2
2
3
Using block_resize we can test allocate_first_block() with file
3
Now that the job infrastructure is handling the job_completed call for
4
descriptor opened with O_DIRECT, ensuring that it works for any size
4
all implemented jobs, we can remove the interface that allowed jobs to
5
larger than 4096 bytes.
5
schedule their own completion.
6
6
7
Testing smaller sizes is tricky as the result depends on the filesystem
7
Signed-off-by: John Snow <jsnow@redhat.com>
8
used for testing. For example on NFS any size will work since O_DIRECT
9
does not require any alignment.
10
11
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
Message-id: 20190827010528.8818-3-nsoffer@redhat.com
9
Message-id: 20180830015734.19765-10-jsnow@redhat.com
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
11
---
16
tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++
12
include/qemu/job.h | 17 -----------------
17
tests/qemu-iotests/175.out | 8 ++++++++
13
job.c | 40 ++--------------------------------------
18
2 files changed, 36 insertions(+)
14
2 files changed, 2 insertions(+), 55 deletions(-)
19
15
20
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
16
diff --git a/include/qemu/job.h b/include/qemu/job.h
21
index XXXXXXX..XXXXXXX 100755
17
index XXXXXXX..XXXXXXX 100644
22
--- a/tests/qemu-iotests/175
18
--- a/include/qemu/job.h
23
+++ b/tests/qemu-iotests/175
19
+++ b/include/qemu/job.h
24
@@ -XXX,XX +XXX,XX @@ _filter_blocks()
20
@@ -XXX,XX +XXX,XX @@ void job_finalize(Job *job, Error **errp);
25
-e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
21
*/
22
void job_dismiss(Job **job, Error **errp);
23
24
-typedef void JobDeferToMainLoopFn(Job *job, void *opaque);
25
-
26
-/**
27
- * @job: The job
28
- * @fn: The function to run in the main loop
29
- * @opaque: The opaque value that is passed to @fn
30
- *
31
- * This function must be called by the main job coroutine just before it
32
- * returns. @fn is executed in the main loop with the job AioContext acquired.
33
- *
34
- * Block jobs must call bdrv_unref(), bdrv_close(), and anything that uses
35
- * bdrv_drain_all() in the main loop.
36
- *
37
- * The @job AioContext is held while @fn executes.
38
- */
39
-void job_defer_to_main_loop(Job *job, JobDeferToMainLoopFn *fn, void *opaque);
40
-
41
/**
42
* Synchronously finishes the given @job. If @finish is given, it is called to
43
* trigger completion or cancellation of the job.
44
diff --git a/job.c b/job.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/job.c
47
+++ b/job.c
48
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn job_co_entry(void *opaque)
49
assert(job && job->driver && job->driver->run);
50
job_pause_point(job);
51
job->ret = job->driver->run(job, &job->err);
52
- if (!job->deferred_to_main_loop) {
53
- job->deferred_to_main_loop = true;
54
- aio_bh_schedule_oneshot(qemu_get_aio_context(),
55
- job_exit,
56
- job);
57
- }
58
+ job->deferred_to_main_loop = true;
59
+ aio_bh_schedule_oneshot(qemu_get_aio_context(), job_exit, job);
26
}
60
}
27
61
28
+# Resize image using block_resize.
62
29
+# Parameter 1: image path
63
@@ -XXX,XX +XXX,XX @@ void job_complete(Job *job, Error **errp)
30
+# Parameter 2: new size
64
job->driver->complete(job, errp);
31
+_block_resize()
65
}
32
+{
66
33
+ local path=$1
67
-
34
+ local size=$2
68
-typedef struct {
35
+
69
- Job *job;
36
+ $QEMU -qmp stdio -nographic -nodefaults \
70
- JobDeferToMainLoopFn *fn;
37
+ -blockdev file,node-name=file,filename=$path,cache.direct=on \
71
- void *opaque;
38
+ <<EOF
72
-} JobDeferToMainLoopData;
39
+{'execute': 'qmp_capabilities'}
73
-
40
+{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}}
74
-static void job_defer_to_main_loop_bh(void *opaque)
41
+{'execute': 'quit'}
75
-{
42
+EOF
76
- JobDeferToMainLoopData *data = opaque;
43
+}
77
- Job *job = data->job;
44
+
78
- AioContext *aio_context = job->aio_context;
45
# get standard environment, filters and checks
79
-
46
. ./common.rc
80
- aio_context_acquire(aio_context);
47
. ./common.filter
81
- data->fn(data->job, data->opaque);
48
@@ -XXX,XX +XXX,XX @@ _supported_fmt raw
82
- aio_context_release(aio_context);
49
_supported_proto file
83
-
50
_supported_os Linux
84
- g_free(data);
51
85
-}
52
+_default_cache_mode none
86
-
53
+_supported_cache_modes none directsync
87
-void job_defer_to_main_loop(Job *job, JobDeferToMainLoopFn *fn, void *opaque)
54
+
88
-{
55
size=$((1 * 1024 * 1024))
89
- JobDeferToMainLoopData *data = g_malloc(sizeof(*data));
56
90
- data->job = job;
57
touch "$TEST_DIR/empty"
91
- data->fn = fn;
58
@@ -XXX,XX +XXX,XX @@ for mode in off full falloc; do
92
- data->opaque = opaque;
59
stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
93
- job->deferred_to_main_loop = true;
60
done
94
-
61
95
- aio_bh_schedule_oneshot(qemu_get_aio_context(),
62
+for new_size in 4096 1048576; do
96
- job_defer_to_main_loop_bh, data);
63
+ echo
97
-}
64
+ echo "== resize empty image with block_resize =="
98
-
65
+ _make_test_img 0 | _filter_imgfmt
99
int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
66
+ _block_resize $TEST_IMG $new_size >/dev/null
100
{
67
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $new_size
101
Error *local_err = NULL;
68
+done
69
+
70
# success, all done
71
echo "*** done"
72
rm -f $seq.full
73
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
74
index XXXXXXX..XXXXXXX 100644
75
--- a/tests/qemu-iotests/175.out
76
+++ b/tests/qemu-iotests/175.out
77
@@ -XXX,XX +XXX,XX @@ size=1048576, max allocation
78
== creating image with preallocation falloc ==
79
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
80
size=1048576, max allocation
81
+
82
+== resize empty image with block_resize ==
83
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
84
+size=4096, min allocation
85
+
86
+== resize empty image with block_resize ==
87
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
88
+size=1048576, min allocation
89
*** done
90
--
102
--
91
2.21.0
103
2.17.1
92
104
93
105
diff view generated by jsdifflib
Deleted patch
1
fe646693acc changed qemu-img create's output so that it no longer prints
2
single quotes around parameter values. The subformat and adapter_type
3
filters in _filter_img_create() have never been adapted to that change.
4
1
5
Fixes: fe646693acc13ac48b98435d14149ab04dc597bc
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: John Snow <jsnow@redhat.com>
8
Message-id: 20190815153638.4600-2-mreitz@redhat.com
9
Reviewed-by: John Snow <jsnow@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
tests/qemu-iotests/059.out | 16 ++++++++--------
13
tests/qemu-iotests/common.filter | 4 ++--
14
2 files changed, 10 insertions(+), 10 deletions(-)
15
16
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qemu-iotests/059.out
19
+++ b/tests/qemu-iotests/059.out
20
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
21
qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big
22
23
=== Testing monolithicFlat creation and opening ===
24
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
25
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
26
image: TEST_DIR/t.IMGFMT
27
file format: IMGFMT
28
virtual size: 2 GiB (2147483648 bytes)
29
30
=== Testing monolithicFlat with zeroed_grain ===
31
qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain
32
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
33
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
34
35
=== Testing big twoGbMaxExtentFlat ===
36
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMaxExtentFlat
37
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000
38
image: TEST_DIR/t.vmdk
39
file format: vmdk
40
virtual size: 0.977 TiB (1073741824000 bytes)
41
@@ -XXX,XX +XXX,XX @@ Format specific information:
42
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 12582912 VMFS "dummy.IMGFMT" 1
43
44
=== Testing truncated sparse ===
45
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 subformat=monolithicSparse
46
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400
47
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes
48
49
=== Converting to streamOptimized from image with small cluster size===
50
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
51
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
52
53
=== Testing monolithicFlat with internally generated JSON file name ===
54
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 subformat=monolithicFlat
55
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
56
qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}'
57
58
=== Testing version 3 ===
59
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 64931328
60
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
61
62
=== Testing 4TB monolithicFlat creation and IO ===
63
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 subformat=monolithicFlat
64
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104
65
image: TEST_DIR/t.IMGFMT
66
file format: IMGFMT
67
virtual size: 4 TiB (4398046511104 bytes)
68
@@ -XXX,XX +XXX,XX @@ read 1024/1024 bytes at offset 966367641600
69
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
70
71
=== Testing qemu-img map on extents ===
72
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=monolithicSparse
73
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
74
wrote 1024/1024 bytes at offset 65024
75
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
76
wrote 1024/1024 bytes at offset 2147483136
77
@@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File
78
0 0x20000 0x3f0000 TEST_DIR/t.vmdk
79
0x7fff0000 0x20000 0x410000 TEST_DIR/t.vmdk
80
0x140000000 0x10000 0x430000 TEST_DIR/t.vmdk
81
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=twoGbMaxExtentSparse
82
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
83
wrote 1024/1024 bytes at offset 65024
84
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
85
wrote 1024/1024 bytes at offset 2147483136
86
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
87
index XXXXXXX..XXXXXXX 100644
88
--- a/tests/qemu-iotests/common.filter
89
+++ b/tests/qemu-iotests/common.filter
90
@@ -XXX,XX +XXX,XX @@ _filter_img_create()
91
-e "s# compat6=\\(on\\|off\\)##g" \
92
-e "s# static=\\(on\\|off\\)##g" \
93
-e "s# zeroed_grain=\\(on\\|off\\)##g" \
94
- -e "s# subformat='[^']*'##g" \
95
- -e "s# adapter_type='[^']*'##g" \
96
+ -e "s# subformat=[^ ]*##g" \
97
+ -e "s# adapter_type=[^ ]*##g" \
98
-e "s# hwversion=[^ ]*##g" \
99
-e "s# lazy_refcounts=\\(on\\|off\\)##g" \
100
-e "s# block_size=[0-9]\\+##g" \
101
--
102
2.21.0
103
104
diff view generated by jsdifflib
Deleted patch
1
We had a test for a case where relative extent paths did not work, but
2
unfortunately we just fixed the underlying problem, so it works now.
3
This patch adds a new test case that still fails.
4
1
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
Reviewed-by: John Snow <jsnow@redhat.com>
7
Message-id: 20190815153638.4600-4-mreitz@redhat.com
8
Reviewed-by: John Snow <jsnow@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
11
tests/qemu-iotests/059 | 27 +++++++++++++++++++++++++++
12
tests/qemu-iotests/059.out | 4 ++++
13
2 files changed, 31 insertions(+)
14
15
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
16
index XXXXXXX..XXXXXXX 100755
17
--- a/tests/qemu-iotests/059
18
+++ b/tests/qemu-iotests/059
19
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
20
21
echo
22
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
23
+
24
+echo '--- blkdebug ---'
25
# Should work, because bdrv_dirname() works fine with blkdebug
26
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
27
$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
28
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TE
29
| _filter_testdir | _filter_imgfmt | _filter_img_info
30
_cleanup_test_img
31
32
+echo '--- quorum ---'
33
+# Should not work, because bdrv_dirname() does not work with quorum
34
+IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
35
+cp "$TEST_IMG" "$TEST_IMG.orig"
36
+
37
+filename="json:{
38
+ \"driver\": \"$IMGFMT\",
39
+ \"file\": {
40
+ \"driver\": \"quorum\",
41
+ \"children\": [ {
42
+ \"driver\": \"file\",
43
+ \"filename\": \"$TEST_IMG\"
44
+ }, {
45
+ \"driver\": \"file\",
46
+ \"filename\": \"$TEST_IMG.orig\"
47
+ } ],
48
+ \"vote-threshold\": 1
49
+ } }"
50
+
51
+filename=$(echo "$filename" | tr '\n' ' ' | sed -e 's/\s\+/ /g')
52
+$QEMU_IMG info "$filename" 2>&1 \
53
+ | sed -e "s/'json:[^']*'/\$QUORUM_FILE/g" \
54
+ | _filter_testdir | _filter_imgfmt | _filter_img_info
55
+
56
+
57
echo
58
echo "=== Testing version 3 ==="
59
_use_sample_img iotest-version3.vmdk.bz2
60
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
61
index XXXXXXX..XXXXXXX 100644
62
--- a/tests/qemu-iotests/059.out
63
+++ b/tests/qemu-iotests/059.out
64
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
65
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
66
67
=== Testing monolithicFlat with internally generated JSON file name ===
68
+--- blkdebug ---
69
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
70
format name: IMGFMT
71
cluster size: 0 bytes
72
vm state offset: 0 bytes
73
+--- quorum ---
74
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
75
+qemu-img: Could not open $QUORUM_FILE: Cannot use relative paths with VMDK descriptor file $QUORUM_FILE: Cannot generate a base directory for quorum nodes
76
77
=== Testing version 3 ===
78
image: TEST_DIR/iotest-version3.IMGFMT
79
--
80
2.21.0
81
82
diff view generated by jsdifflib
Deleted patch
1
Compressed writes generally have to write full clusters, not just in
2
theory but also in practice when it comes to vmdk's streamOptimized
3
subformat. It currently is just silently broken for writes with
4
non-zero in-cluster offsets:
5
1
6
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
7
$ qemu-io -c 'write 4k 4k' -c 'read 4k 4k' foo.vmdk
8
wrote 4096/4096 bytes at offset 4096
9
4 KiB, 1 ops; 00.01 sec (443.724 KiB/sec and 110.9309 ops/sec)
10
read failed: Invalid argument
11
12
(The technical reason is that vmdk_write_extent() just writes the
13
incomplete compressed data actually to offset 4k. When reading the
14
data, vmdk_read_extent() looks at offset 0 and finds the compressed data
15
size to be 0, because that is what it reads from there. This yields an
16
error.)
17
18
For incomplete writes with zero in-cluster offsets, the error path when
19
reading the rest of the cluster is a bit different, but the result is
20
the same:
21
22
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
23
$ qemu-io -c 'write 0k 4k' -c 'read 4k 4k' foo.vmdk
24
wrote 4096/4096 bytes at offset 0
25
4 KiB, 1 ops; 00.01 sec (362.641 KiB/sec and 90.6603 ops/sec)
26
read failed: Invalid argument
27
28
(Here, vmdk_read_extent() finds the data and then sees that the
29
uncompressed data is short.)
30
31
It is better to reject invalid writes than to make the user believe they
32
might have succeeded and then fail when trying to read it back.
33
34
Signed-off-by: Max Reitz <mreitz@redhat.com>
35
Reviewed-by: John Snow <jsnow@redhat.com>
36
Message-id: 20190815153638.4600-5-mreitz@redhat.com
37
Reviewed-by: John Snow <jsnow@redhat.com>
38
Signed-off-by: Max Reitz <mreitz@redhat.com>
39
---
40
block/vmdk.c | 10 ++++++++++
41
1 file changed, 10 insertions(+)
42
43
diff --git a/block/vmdk.c b/block/vmdk.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/block/vmdk.c
46
+++ b/block/vmdk.c
47
@@ -XXX,XX +XXX,XX @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset,
48
if (extent->compressed) {
49
void *compressed_data;
50
51
+ /* Only whole clusters */
52
+ if (offset_in_cluster ||
53
+ n_bytes > (extent->cluster_sectors * SECTOR_SIZE) ||
54
+ (n_bytes < (extent->cluster_sectors * SECTOR_SIZE) &&
55
+ offset + n_bytes != extent->end_sector * SECTOR_SIZE))
56
+ {
57
+ ret = -EINVAL;
58
+ goto out;
59
+ }
60
+
61
if (!extent->has_marker) {
62
ret = -EINVAL;
63
goto out;
64
--
65
2.21.0
66
67
diff view generated by jsdifflib
Deleted patch
1
streamOptimized does not support writes that do not span exactly one
2
cluster. Furthermore, it cannot rewrite already allocated clusters.
3
As such, many iotests do not work with it. Disable them.
4
1
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
Message-id: 20190815153638.4600-6-mreitz@redhat.com
7
Reviewed-by: John Snow <jsnow@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
tests/qemu-iotests/002 | 1 +
11
tests/qemu-iotests/003 | 1 +
12
tests/qemu-iotests/005 | 3 ++-
13
tests/qemu-iotests/009 | 1 +
14
tests/qemu-iotests/010 | 1 +
15
tests/qemu-iotests/011 | 1 +
16
tests/qemu-iotests/017 | 3 ++-
17
tests/qemu-iotests/018 | 3 ++-
18
tests/qemu-iotests/019 | 3 ++-
19
tests/qemu-iotests/020 | 3 ++-
20
tests/qemu-iotests/027 | 1 +
21
tests/qemu-iotests/032 | 1 +
22
tests/qemu-iotests/033 | 1 +
23
tests/qemu-iotests/034 | 3 ++-
24
tests/qemu-iotests/037 | 3 ++-
25
tests/qemu-iotests/063 | 3 ++-
26
tests/qemu-iotests/072 | 1 +
27
tests/qemu-iotests/105 | 3 ++-
28
tests/qemu-iotests/197 | 1 +
29
tests/qemu-iotests/215 | 1 +
30
tests/qemu-iotests/251 | 1 +
31
21 files changed, 30 insertions(+), 9 deletions(-)
32
33
diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002
34
index XXXXXXX..XXXXXXX 100755
35
--- a/tests/qemu-iotests/002
36
+++ b/tests/qemu-iotests/002
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
38
39
_supported_fmt generic
40
_supported_proto generic
41
+_unsupported_imgopts "subformat=streamOptimized"
42
43
44
size=128M
45
diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003
46
index XXXXXXX..XXXXXXX 100755
47
--- a/tests/qemu-iotests/003
48
+++ b/tests/qemu-iotests/003
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
50
51
_supported_fmt generic
52
_supported_proto generic
53
+_unsupported_imgopts "subformat=streamOptimized"
54
55
size=128M
56
offset=67M
57
diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005
58
index XXXXXXX..XXXXXXX 100755
59
--- a/tests/qemu-iotests/005
60
+++ b/tests/qemu-iotests/005
61
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
62
_supported_proto generic
63
_supported_os Linux
64
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
65
- "subformat=twoGbMaxExtentSparse"
66
+ "subformat=twoGbMaxExtentSparse" \
67
+ "subformat=streamOptimized"
68
69
# vpc is limited to 127GB, so we can't test it here
70
if [ "$IMGFMT" = "vpc" ]; then
71
diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009
72
index XXXXXXX..XXXXXXX 100755
73
--- a/tests/qemu-iotests/009
74
+++ b/tests/qemu-iotests/009
75
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
76
77
_supported_fmt generic
78
_supported_proto generic
79
+_unsupported_imgopts "subformat=streamOptimized"
80
81
82
size=6G
83
diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010
84
index XXXXXXX..XXXXXXX 100755
85
--- a/tests/qemu-iotests/010
86
+++ b/tests/qemu-iotests/010
87
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
88
89
_supported_fmt generic
90
_supported_proto generic
91
+_unsupported_imgopts "subformat=streamOptimized"
92
93
94
size=6G
95
diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011
96
index XXXXXXX..XXXXXXX 100755
97
--- a/tests/qemu-iotests/011
98
+++ b/tests/qemu-iotests/011
99
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
100
101
_supported_fmt generic
102
_supported_proto generic
103
+_unsupported_imgopts "subformat=streamOptimized"
104
105
106
size=6G
107
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
108
index XXXXXXX..XXXXXXX 100755
109
--- a/tests/qemu-iotests/017
110
+++ b/tests/qemu-iotests/017
111
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
112
_supported_fmt qcow qcow2 vmdk qed
113
_supported_proto generic
114
_unsupported_proto vxhs
115
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
116
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
117
+ "subformat=streamOptimized"
118
119
TEST_OFFSETS="0 4294967296"
120
121
diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018
122
index XXXXXXX..XXXXXXX 100755
123
--- a/tests/qemu-iotests/018
124
+++ b/tests/qemu-iotests/018
125
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
126
_supported_fmt qcow qcow2 vmdk qed
127
_supported_proto file
128
_supported_os Linux
129
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
130
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
131
+ "streamOptimized"
132
133
TEST_OFFSETS="0 4294967296"
134
135
diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
136
index XXXXXXX..XXXXXXX 100755
137
--- a/tests/qemu-iotests/019
138
+++ b/tests/qemu-iotests/019
139
@@ -XXX,XX +XXX,XX @@ _supported_proto file
140
_supported_os Linux
141
_unsupported_imgopts "subformat=monolithicFlat" \
142
"subformat=twoGbMaxExtentFlat" \
143
- "subformat=twoGbMaxExtentSparse"
144
+ "subformat=twoGbMaxExtentSparse" \
145
+ "subformat=streamOptimized"
146
147
TEST_OFFSETS="0 4294967296"
148
CLUSTER_SIZE=65536
149
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
150
index XXXXXXX..XXXXXXX 100755
151
--- a/tests/qemu-iotests/020
152
+++ b/tests/qemu-iotests/020
153
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
154
_supported_proto file
155
_unsupported_imgopts "subformat=monolithicFlat" \
156
"subformat=twoGbMaxExtentFlat" \
157
- "subformat=twoGbMaxExtentSparse"
158
+ "subformat=twoGbMaxExtentSparse" \
159
+ "subformat=streamOptimized"
160
161
TEST_OFFSETS="0 4294967296"
162
163
diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027
164
index XXXXXXX..XXXXXXX 100755
165
--- a/tests/qemu-iotests/027
166
+++ b/tests/qemu-iotests/027
167
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
168
169
_supported_fmt vmdk qcow qcow2 qed
170
_supported_proto generic
171
+_unsupported_imgopts "subformat=streamOptimized"
172
173
174
size=128M
175
diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032
176
index XXXXXXX..XXXXXXX 100755
177
--- a/tests/qemu-iotests/032
178
+++ b/tests/qemu-iotests/032
179
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
180
# This works for any image format (though unlikely to segfault for raw)
181
_supported_fmt generic
182
_supported_proto generic
183
+_unsupported_imgopts "subformat=streamOptimized"
184
185
echo
186
echo === Prepare image ===
187
diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033
188
index XXXXXXX..XXXXXXX 100755
189
--- a/tests/qemu-iotests/033
190
+++ b/tests/qemu-iotests/033
191
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
192
193
_supported_fmt generic
194
_supported_proto generic
195
+_unsupported_imgopts "subformat=streamOptimized"
196
197
198
size=128M
199
diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034
200
index XXXXXXX..XXXXXXX 100755
201
--- a/tests/qemu-iotests/034
202
+++ b/tests/qemu-iotests/034
203
@@ -XXX,XX +XXX,XX @@ _supported_proto file
204
_supported_os Linux
205
_unsupported_imgopts "subformat=monolithicFlat" \
206
"subformat=twoGbMaxExtentFlat" \
207
- "subformat=twoGbMaxExtentSparse"
208
+ "subformat=twoGbMaxExtentSparse" \
209
+ "subformat=streamOptimized"
210
211
CLUSTER_SIZE=4k
212
size=128M
213
diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037
214
index XXXXXXX..XXXXXXX 100755
215
--- a/tests/qemu-iotests/037
216
+++ b/tests/qemu-iotests/037
217
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
218
_supported_proto file
219
_unsupported_imgopts "subformat=monolithicFlat" \
220
"subformat=twoGbMaxExtentFlat" \
221
- "subformat=twoGbMaxExtentSparse"
222
+ "subformat=twoGbMaxExtentSparse" \
223
+ "subformat=streamOptimized"
224
225
CLUSTER_SIZE=4k
226
size=128M
227
diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
228
index XXXXXXX..XXXXXXX 100755
229
--- a/tests/qemu-iotests/063
230
+++ b/tests/qemu-iotests/063
231
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed raw
232
_supported_proto file
233
_unsupported_imgopts "subformat=monolithicFlat" \
234
"subformat=twoGbMaxExtentFlat" \
235
- "subformat=twoGbMaxExtentSparse"
236
+ "subformat=twoGbMaxExtentSparse" \
237
+ "subformat=streamOptimized"
238
239
_make_test_img 4M
240
241
diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072
242
index XXXXXXX..XXXXXXX 100755
243
--- a/tests/qemu-iotests/072
244
+++ b/tests/qemu-iotests/072
245
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
246
247
_supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow
248
_supported_proto file
249
+_unsupported_imgopts "subformat=streamOptimized"
250
251
IMG_SIZE=64M
252
253
diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105
254
index XXXXXXX..XXXXXXX 100755
255
--- a/tests/qemu-iotests/105
256
+++ b/tests/qemu-iotests/105
257
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
258
_supported_fmt qcow2 vmdk vhdx qed
259
_supported_proto generic
260
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
261
- "subformat=twoGbMaxExtentSparse"
262
+ "subformat=twoGbMaxExtentSparse" \
263
+ "subformat=streamOptimized"
264
265
echo
266
echo "creating large image"
267
diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197
268
index XXXXXXX..XXXXXXX 100755
269
--- a/tests/qemu-iotests/197
270
+++ b/tests/qemu-iotests/197
271
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
272
_supported_proto generic
273
# LUKS support may be possible, but it complicates things.
274
_unsupported_fmt luks
275
+_unsupported_imgopts "subformat=streamOptimized"
276
277
echo
278
echo '=== Copy-on-read ==='
279
diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215
280
index XXXXXXX..XXXXXXX 100755
281
--- a/tests/qemu-iotests/215
282
+++ b/tests/qemu-iotests/215
283
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
284
_supported_proto generic
285
# LUKS support may be possible, but it complicates things.
286
_unsupported_fmt luks
287
+_unsupported_imgopts "subformat=streamOptimized"
288
289
echo
290
echo '=== Copy-on-read ==='
291
diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251
292
index XXXXXXX..XXXXXXX 100755
293
--- a/tests/qemu-iotests/251
294
+++ b/tests/qemu-iotests/251
295
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
296
_supported_fmt generic
297
_supported_proto file
298
_supported_os Linux
299
+_unsupported_imgopts "subformat=streamOptimized"
300
301
if [ "$IMGOPTSSYNTAX" = "true" ]; then
302
# We use json:{} filenames here, so we cannot work with additional options.
303
--
304
2.21.0
305
306
diff view generated by jsdifflib
Deleted patch
1
iotest 126 requires backing file support, which flat vmdks cannot offer.
2
Skip this test for such subformats.
3
1
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
Message-id: 20190815153638.4600-8-mreitz@redhat.com
6
Reviewed-by: John Snow <jsnow@redhat.com>
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
---
9
tests/qemu-iotests/126 | 2 ++
10
1 file changed, 2 insertions(+)
11
12
diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
13
index XXXXXXX..XXXXXXX 100755
14
--- a/tests/qemu-iotests/126
15
+++ b/tests/qemu-iotests/126
16
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
17
18
# Needs backing file support
19
_supported_fmt qcow qcow2 qed vmdk
20
+_unsupported_imgopts "subformat=monolithicFlat" \
21
+ "subformat=twoGbMaxExtentFlat"
22
# This is the default protocol (and we want to test the difference between
23
# colons which separate a protocol prefix from the rest and colons which are
24
# just part of the filename, so we cannot test protocols which require a prefix)
25
--
26
2.21.0
27
28
diff view generated by jsdifflib