1
The following changes since commit 248b23735645f7cbb503d9be6f5bf825f2a603ab:
1
The following changes since commit 31ee895047bdcf7387e3570cbd2a473c6f744b08:
2
2
3
Update version for v2.10.0-rc4 release (2017-08-24 17:34:26 +0100)
3
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging (2021-01-25 15:56:13 +0000)
4
4
5
are available in the git repository at:
5
are available in the Git repository at:
6
6
7
git://github.com/stefanha/qemu.git tags/block-pull-request
7
https://github.com/XanClic/qemu.git tags/pull-block-2021-01-26
8
8
9
for you to fetch changes up to 3e4c705212abfe8c9882a00beb2d1466a8a53cec:
9
for you to fetch changes up to bb24cdc5efee580e81f71c5ff0fd980f2cc179d0:
10
10
11
qcow2: allocate cluster_cache/cluster_data on demand (2017-08-30 18:02:10 +0100)
11
iotests/178: Pass value to invalid option (2021-01-26 14:36:37 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches:
15
- Make backup block jobs use asynchronous requests with the block-copy
16
module
17
- Use COR filter node for stream block jobs
18
- Make coroutine-sigaltstack’s qemu_coroutine_new() function thread-safe
19
- Report error string when file locking fails with an unexpected errno
20
- iotest fixes, additions, and some refactoring
14
21
15
----------------------------------------------------------------
22
----------------------------------------------------------------
23
Alberto Garcia (1):
24
iotests: Add test for the regression fixed in c8bf9a9169
16
25
17
Alberto Garcia (8):
26
Andrey Shinkevich (10):
18
throttle: Fix wrong variable name in the header documentation
27
copy-on-read: support preadv/pwritev_part functions
19
throttle: Update the throttle_fix_bucket() documentation
28
block: add API function to insert a node
20
throttle: Make throttle_is_valid() a bit less verbose
29
copy-on-read: add filter drop function
21
throttle: Remove throttle_fix_bucket() / throttle_unfix_bucket()
30
qapi: add filter-node-name to block-stream
22
throttle: Make LeakyBucket.avg and LeakyBucket.max integer types
31
qapi: copy-on-read filter: add 'bottom' option
23
throttle: Make burst_length 64bit and add range checks
32
iotests: add #310 to test bottom node in COR driver
24
throttle: Test the valid range of config values
33
block: include supported_read_flags into BDS structure
25
misc: Remove unused Error variables
34
copy-on-read: skip non-guest reads if no copy needed
35
stream: rework backing-file changing
36
block: apply COR-filter to block-stream jobs
26
37
27
Dan Aloni (1):
38
David Edmondson (1):
28
nvme: Fix get/set number of queues feature, again
39
block: report errno when flock fcntl fails
29
40
30
Eduardo Habkost (1):
41
Max Reitz (14):
31
oslib-posix: Print errors before aborting on qemu_alloc_stack()
42
iotests.py: Assume a couple of variables as given
43
iotests/297: Rewrite in Python and extend reach
44
iotests: Move try_remove to iotests.py
45
iotests/129: Remove test images in tearDown()
46
iotests/129: Do not check @busy
47
iotests/129: Use throttle node
48
iotests/129: Actually test a commit job
49
iotests/129: Limit mirror job's buffer size
50
iotests/129: Clean up pylint and mypy complaints
51
iotests/300: Clean up pylint and mypy complaints
52
coroutine-sigaltstack: Add SIGUSR2 mutex
53
iotests/129: Limit backup's max-chunk/max-workers
54
iotests/118: Drop 'change' test
55
iotests/178: Pass value to invalid option
32
56
33
Fred Rolland (1):
57
Vladimir Sementsov-Ogievskiy (27):
34
qemu-doc: Add UUID support in initiator name
58
iotests: fix _check_o_direct
59
qapi: block-stream: add "bottom" argument
60
iotests: 30: prepare to COR filter insertion by stream job
61
block/stream: add s->target_bs
62
qapi: backup: add perf.use-copy-range parameter
63
block/block-copy: More explicit call_state
64
block/block-copy: implement block_copy_async
65
block/block-copy: add max_chunk and max_workers parameters
66
block/block-copy: add list of all call-states
67
block/block-copy: add ratelimit to block-copy
68
block/block-copy: add block_copy_cancel
69
blockjob: add set_speed to BlockJobDriver
70
job: call job_enter from job_pause
71
qapi: backup: add max-chunk and max-workers to x-perf struct
72
iotests: 56: prepare for backup over block-copy
73
iotests: 185: prepare for backup over block-copy
74
iotests: 219: prepare for backup over block-copy
75
iotests: 257: prepare for backup over block-copy
76
block/block-copy: make progress_bytes_callback optional
77
block/backup: drop extra gotos from backup_run()
78
backup: move to block-copy
79
qapi: backup: disable copy_range by default
80
block/block-copy: drop unused block_copy_set_progress_callback()
81
block/block-copy: drop unused argument of block_copy()
82
simplebench/bench_block_job: use correct shebang line with python3
83
simplebench: bench_block_job: add cmd_options argument
84
simplebench: add bench-backup.py
35
85
36
Stefan Hajnoczi (4):
86
qapi/block-core.json | 66 +++++-
37
scripts: add argparse module for Python 2.6 compatibility
87
block/backup-top.h | 1 +
38
docker.py: Python 2.6 argparse compatibility
88
block/copy-on-read.h | 32 +++
39
tests: migration/guestperf Python 2.6 argparse compatibility
89
include/block/block-copy.h | 61 ++++-
40
qcow2: allocate cluster_cache/cluster_data on demand
90
include/block/block.h | 10 +-
41
91
include/block/block_int.h | 15 +-
42
include/qemu/throttle.h | 8 +-
92
include/block/blockjob_int.h | 2 +
43
block/qcow.c | 12 +-
93
block.c | 25 ++
44
block/qcow2-cluster.c | 17 +
94
block/backup-top.c | 6 +-
45
block/qcow2.c | 20 +-
95
block/backup.c | 233 ++++++++++++-------
46
dump.c | 4 +-
96
block/block-copy.c | 227 +++++++++++++++---
47
hw/block/nvme.c | 4 +-
97
block/copy-on-read.c | 184 ++++++++++++++-
48
tests/test-throttle.c | 80 +-
98
block/file-posix.c | 38 ++-
49
util/oslib-posix.c | 2 +
99
block/io.c | 10 +-
50
util/throttle.c | 86 +-
100
block/monitor/block-hmp-cmds.c | 7 +-
51
COPYING.PYTHON | 270 ++++
101
block/replication.c | 2 +
52
qemu-doc.texi | 5 +-
102
block/stream.c | 185 +++++++++------
53
scripts/argparse.py | 2406 ++++++++++++++++++++++++++++++++++++
103
blockdev.c | 83 +++++--
54
tests/docker/docker.py | 4 +-
104
blockjob.c | 6 +
55
tests/migration/guestperf/shell.py | 8 +-
105
job.c | 3 +
56
14 files changed, 2831 insertions(+), 95 deletions(-)
106
util/coroutine-sigaltstack.c | 9 +
57
create mode 100644 COPYING.PYTHON
107
scripts/simplebench/bench-backup.py | 167 ++++++++++++++
58
create mode 100644 scripts/argparse.py
108
scripts/simplebench/bench-example.py | 2 +-
109
scripts/simplebench/bench_block_job.py | 13 +-
110
tests/qemu-iotests/030 | 12 +-
111
tests/qemu-iotests/056 | 9 +-
112
tests/qemu-iotests/109.out | 24 ++
113
tests/qemu-iotests/118 | 20 +-
114
tests/qemu-iotests/118.out | 4 +-
115
tests/qemu-iotests/124 | 8 +-
116
tests/qemu-iotests/129 | 79 ++++---
117
tests/qemu-iotests/141.out | 2 +-
118
tests/qemu-iotests/178 | 2 +-
119
tests/qemu-iotests/178.out.qcow2 | 2 +-
120
tests/qemu-iotests/178.out.raw | 2 +-
121
tests/qemu-iotests/185 | 3 +-
122
tests/qemu-iotests/185.out | 3 +-
123
tests/qemu-iotests/219 | 13 +-
124
tests/qemu-iotests/245 | 20 +-
125
tests/qemu-iotests/257 | 1 +
126
tests/qemu-iotests/257.out | 306 ++++++++++++-------------
127
tests/qemu-iotests/297 | 112 +++++++--
128
tests/qemu-iotests/297.out | 5 +-
129
tests/qemu-iotests/300 | 19 +-
130
tests/qemu-iotests/310 | 117 ++++++++++
131
tests/qemu-iotests/310.out | 15 ++
132
tests/qemu-iotests/313 | 104 +++++++++
133
tests/qemu-iotests/313.out | 29 +++
134
tests/qemu-iotests/common.rc | 7 +-
135
tests/qemu-iotests/group | 2 +
136
tests/qemu-iotests/iotests.py | 37 +--
137
51 files changed, 1797 insertions(+), 547 deletions(-)
138
create mode 100644 block/copy-on-read.h
139
create mode 100755 scripts/simplebench/bench-backup.py
140
create mode 100755 tests/qemu-iotests/310
141
create mode 100644 tests/qemu-iotests/310.out
142
create mode 100755 tests/qemu-iotests/313
143
create mode 100644 tests/qemu-iotests/313.out
59
144
60
--
145
--
61
2.13.5
146
2.29.2
62
147
63
148
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Unfortunately commit "iotests: handle tmpfs" breaks running iotests
4
with -nbd -nocache, as _check_o_direct tries to create
5
$TEST_IMG.test_o_direct, but in case of nbd TEST_IMG is something like
6
nbd+unix:///... , and test fails with message
7
8
qemu-img: nbd+unix:///?socket[...]test_o_direct: Protocol driver
9
'nbd' does not support image creation, and opening the image
10
failed: Failed to connect to '/tmp/tmp.[...]/nbd/test_o_direct': No
11
such file or directory
12
13
Use TEST_DIR instead.
14
15
Fixes: cfdca2b9f9d4ca26bb2b2dfe8de3149092e39170
16
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
17
Message-Id: <20201218182012.47607-1-vsementsov@virtuozzo.com>
18
Signed-off-by: Max Reitz <mreitz@redhat.com>
19
---
20
tests/qemu-iotests/common.rc | 7 ++++---
21
1 file changed, 4 insertions(+), 3 deletions(-)
22
23
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
24
index XXXXXXX..XXXXXXX 100644
25
--- a/tests/qemu-iotests/common.rc
26
+++ b/tests/qemu-iotests/common.rc
27
@@ -XXX,XX +XXX,XX @@ _supported_cache_modes()
28
# Check whether the filesystem supports O_DIRECT
29
_check_o_direct()
30
{
31
- $QEMU_IMG create -f raw "$TEST_IMG".test_o_direct 1M > /dev/null
32
- out=$($QEMU_IO -f raw -t none -c quit "$TEST_IMG".test_o_direct 2>&1)
33
- rm -f "$TEST_IMG".test_o_direct
34
+ testfile="$TEST_DIR"/_check_o_direct
35
+ $QEMU_IMG create -f raw "$testfile" 1M > /dev/null
36
+ out=$($QEMU_IO -f raw -t none -c quit "$testfile" 2>&1)
37
+ rm -f "$testfile"
38
39
[[ "$out" != *"O_DIRECT"* ]]
40
}
41
--
42
2.29.2
43
44
diff view generated by jsdifflib
New patch
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
1
2
3
Add support for the recently introduced functions
4
bdrv_co_preadv_part()
5
and
6
bdrv_co_pwritev_part()
7
to the COR-filter driver.
8
9
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
10
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11
Message-Id: <20201216061703.70908-2-vsementsov@virtuozzo.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
14
block/copy-on-read.c | 28 ++++++++++++++++------------
15
1 file changed, 16 insertions(+), 12 deletions(-)
16
17
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/block/copy-on-read.c
20
+++ b/block/copy-on-read.c
21
@@ -XXX,XX +XXX,XX @@ static int64_t cor_getlength(BlockDriverState *bs)
22
}
23
24
25
-static int coroutine_fn cor_co_preadv(BlockDriverState *bs,
26
- uint64_t offset, uint64_t bytes,
27
- QEMUIOVector *qiov, int flags)
28
+static int coroutine_fn cor_co_preadv_part(BlockDriverState *bs,
29
+ uint64_t offset, uint64_t bytes,
30
+ QEMUIOVector *qiov,
31
+ size_t qiov_offset,
32
+ int flags)
33
{
34
- return bdrv_co_preadv(bs->file, offset, bytes, qiov,
35
- flags | BDRV_REQ_COPY_ON_READ);
36
+ return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset,
37
+ flags | BDRV_REQ_COPY_ON_READ);
38
}
39
40
41
-static int coroutine_fn cor_co_pwritev(BlockDriverState *bs,
42
- uint64_t offset, uint64_t bytes,
43
- QEMUIOVector *qiov, int flags)
44
+static int coroutine_fn cor_co_pwritev_part(BlockDriverState *bs,
45
+ uint64_t offset,
46
+ uint64_t bytes,
47
+ QEMUIOVector *qiov,
48
+ size_t qiov_offset, int flags)
49
{
50
-
51
- return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
52
+ return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset,
53
+ flags);
54
}
55
56
57
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_copy_on_read = {
58
59
.bdrv_getlength = cor_getlength,
60
61
- .bdrv_co_preadv = cor_co_preadv,
62
- .bdrv_co_pwritev = cor_co_pwritev,
63
+ .bdrv_co_preadv_part = cor_co_preadv_part,
64
+ .bdrv_co_pwritev_part = cor_co_pwritev_part,
65
.bdrv_co_pwrite_zeroes = cor_co_pwrite_zeroes,
66
.bdrv_co_pdiscard = cor_co_pdiscard,
67
.bdrv_co_pwritev_compressed = cor_co_pwritev_compressed,
68
--
69
2.29.2
70
71
diff view generated by jsdifflib
New patch
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
1
2
3
Provide API for insertion a node to backing chain.
4
5
Suggested-by: Max Reitz <mreitz@redhat.com>
6
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
7
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Message-Id: <20201216061703.70908-3-vsementsov@virtuozzo.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
include/block/block.h | 2 ++
13
block.c | 25 +++++++++++++++++++++++++
14
2 files changed, 27 insertions(+)
15
16
diff --git a/include/block/block.h b/include/block/block.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/block/block.h
19
+++ b/include/block/block.h
20
@@ -XXX,XX +XXX,XX @@ void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
21
Error **errp);
22
void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
23
Error **errp);
24
+BlockDriverState *bdrv_insert_node(BlockDriverState *bs, QDict *node_options,
25
+ int flags, Error **errp);
26
27
int bdrv_parse_aio(const char *mode, int *flags);
28
int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough);
29
diff --git a/block.c b/block.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/block.c
32
+++ b/block.c
33
@@ -XXX,XX +XXX,XX @@ static void bdrv_delete(BlockDriverState *bs)
34
g_free(bs);
35
}
36
37
+BlockDriverState *bdrv_insert_node(BlockDriverState *bs, QDict *node_options,
38
+ int flags, Error **errp)
39
+{
40
+ BlockDriverState *new_node_bs;
41
+ Error *local_err = NULL;
42
+
43
+ new_node_bs = bdrv_open(NULL, NULL, node_options, flags, errp);
44
+ if (new_node_bs == NULL) {
45
+ error_prepend(errp, "Could not create node: ");
46
+ return NULL;
47
+ }
48
+
49
+ bdrv_drained_begin(bs);
50
+ bdrv_replace_node(bs, new_node_bs, &local_err);
51
+ bdrv_drained_end(bs);
52
+
53
+ if (local_err) {
54
+ bdrv_unref(new_node_bs);
55
+ error_propagate(errp, local_err);
56
+ return NULL;
57
+ }
58
+
59
+ return new_node_bs;
60
+}
61
+
62
/*
63
* Run consistency checks on an image
64
*
65
--
66
2.29.2
67
68
diff view generated by jsdifflib
New patch
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
1
2
3
Provide API for the COR-filter removal. Also, drop the filter child
4
permissions for an inactive state when the filter node is being
5
removed.
6
To insert the filter, the block generic layer function
7
bdrv_insert_node() can be used.
8
The new function bdrv_cor_filter_drop() may be considered as an
9
intermediate solution before the QEMU permission update system has
10
overhauled. Then we are able to implement the API function
11
bdrv_remove_node() on the block generic layer.
12
13
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
14
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
15
Reviewed-by: Max Reitz <mreitz@redhat.com>
16
Message-Id: <20201216061703.70908-4-vsementsov@virtuozzo.com>
17
Signed-off-by: Max Reitz <mreitz@redhat.com>
18
---
19
block/copy-on-read.h | 32 +++++++++++++++++++++++++
20
block/copy-on-read.c | 56 ++++++++++++++++++++++++++++++++++++++++++++
21
2 files changed, 88 insertions(+)
22
create mode 100644 block/copy-on-read.h
23
24
diff --git a/block/copy-on-read.h b/block/copy-on-read.h
25
new file mode 100644
26
index XXXXXXX..XXXXXXX
27
--- /dev/null
28
+++ b/block/copy-on-read.h
29
@@ -XXX,XX +XXX,XX @@
30
+/*
31
+ * Copy-on-read filter block driver
32
+ *
33
+ * The filter driver performs Copy-On-Read (COR) operations
34
+ *
35
+ * Copyright (c) 2018-2020 Virtuozzo International GmbH.
36
+ *
37
+ * Author:
38
+ * Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
39
+ *
40
+ * This program is free software; you can redistribute it and/or modify
41
+ * it under the terms of the GNU General Public License as published by
42
+ * the Free Software Foundation; either version 2 of the License, or
43
+ * (at your option) any later version.
44
+ *
45
+ * This program is distributed in the hope that it will be useful,
46
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
47
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48
+ * GNU General Public License for more details.
49
+ *
50
+ * You should have received a copy of the GNU General Public License
51
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
52
+ */
53
+
54
+#ifndef BLOCK_COPY_ON_READ
55
+#define BLOCK_COPY_ON_READ
56
+
57
+#include "block/block_int.h"
58
+
59
+void bdrv_cor_filter_drop(BlockDriverState *cor_filter_bs);
60
+
61
+#endif /* BLOCK_COPY_ON_READ */
62
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
63
index XXXXXXX..XXXXXXX 100644
64
--- a/block/copy-on-read.c
65
+++ b/block/copy-on-read.c
66
@@ -XXX,XX +XXX,XX @@
67
#include "qemu/osdep.h"
68
#include "block/block_int.h"
69
#include "qemu/module.h"
70
+#include "qapi/error.h"
71
+#include "block/copy-on-read.h"
72
+
73
+
74
+typedef struct BDRVStateCOR {
75
+ bool active;
76
+} BDRVStateCOR;
77
78
79
static int cor_open(BlockDriverState *bs, QDict *options, int flags,
80
Error **errp)
81
{
82
+ BDRVStateCOR *state = bs->opaque;
83
+
84
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
85
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
86
false, errp);
87
@@ -XXX,XX +XXX,XX @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags,
88
((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) &
89
bs->file->bs->supported_zero_flags);
90
91
+ state->active = true;
92
+
93
+ /*
94
+ * We don't need to call bdrv_child_refresh_perms() now as the permissions
95
+ * will be updated later when the filter node gets its parent.
96
+ */
97
+
98
return 0;
99
}
100
101
@@ -XXX,XX +XXX,XX @@ static void cor_child_perm(BlockDriverState *bs, BdrvChild *c,
102
uint64_t perm, uint64_t shared,
103
uint64_t *nperm, uint64_t *nshared)
104
{
105
+ BDRVStateCOR *s = bs->opaque;
106
+
107
+ if (!s->active) {
108
+ /*
109
+ * While the filter is being removed
110
+ */
111
+ *nperm = 0;
112
+ *nshared = BLK_PERM_ALL;
113
+ return;
114
+ }
115
+
116
*nperm = perm & PERM_PASSTHROUGH;
117
*nshared = (shared & PERM_PASSTHROUGH) | PERM_UNCHANGED;
118
119
@@ -XXX,XX +XXX,XX @@ static void cor_lock_medium(BlockDriverState *bs, bool locked)
120
121
static BlockDriver bdrv_copy_on_read = {
122
.format_name = "copy-on-read",
123
+ .instance_size = sizeof(BDRVStateCOR),
124
125
.bdrv_open = cor_open,
126
.bdrv_child_perm = cor_child_perm,
127
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_copy_on_read = {
128
.is_filter = true,
129
};
130
131
+
132
+void bdrv_cor_filter_drop(BlockDriverState *cor_filter_bs)
133
+{
134
+ BdrvChild *child;
135
+ BlockDriverState *bs;
136
+ BDRVStateCOR *s = cor_filter_bs->opaque;
137
+
138
+ child = bdrv_filter_child(cor_filter_bs);
139
+ if (!child) {
140
+ return;
141
+ }
142
+ bs = child->bs;
143
+
144
+ /* Retain the BDS until we complete the graph change. */
145
+ bdrv_ref(bs);
146
+ /* Hold a guest back from writing while permissions are being reset. */
147
+ bdrv_drained_begin(bs);
148
+ /* Drop permissions before the graph change. */
149
+ s->active = false;
150
+ bdrv_child_refresh_perms(cor_filter_bs, child, &error_abort);
151
+ bdrv_replace_node(cor_filter_bs, bs, &error_abort);
152
+
153
+ bdrv_drained_end(bs);
154
+ bdrv_unref(bs);
155
+ bdrv_unref(cor_filter_bs);
156
+}
157
+
158
+
159
static void bdrv_copy_on_read_init(void)
160
{
161
bdrv_register(&bdrv_copy_on_read);
162
--
163
2.29.2
164
165
diff view generated by jsdifflib
New patch
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
1
2
3
Provide the possibility to pass the 'filter-node-name' parameter to the
4
block-stream job as it is done for the commit block job.
5
6
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
7
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
[vsementsov: comment indentation, s/Since: 5.2/Since: 6.0/]
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-Id: <20201216061703.70908-5-vsementsov@virtuozzo.com>
11
[mreitz: s/commit/stream/]
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
14
qapi/block-core.json | 6 ++++++
15
include/block/block_int.h | 7 ++++++-
16
block/monitor/block-hmp-cmds.c | 4 ++--
17
block/stream.c | 4 +++-
18
blockdev.c | 4 +++-
19
5 files changed, 20 insertions(+), 5 deletions(-)
20
21
diff --git a/qapi/block-core.json b/qapi/block-core.json
22
index XXXXXXX..XXXXXXX 100644
23
--- a/qapi/block-core.json
24
+++ b/qapi/block-core.json
25
@@ -XXX,XX +XXX,XX @@
26
# 'stop' and 'enospc' can only be used if the block device
27
# supports io-status (see BlockInfo). Since 1.3.
28
#
29
+# @filter-node-name: the node name that should be assigned to the
30
+# filter driver that the stream job inserts into the graph
31
+# above @device. If this option is not given, a node name is
32
+# autogenerated. (Since: 6.0)
33
+#
34
# @auto-finalize: When false, this job will wait in a PENDING state after it has
35
# finished its work, waiting for @block-job-finalize before
36
# making any block graph changes.
37
@@ -XXX,XX +XXX,XX @@
38
'data': { '*job-id': 'str', 'device': 'str', '*base': 'str',
39
'*base-node': 'str', '*backing-file': 'str', '*speed': 'int',
40
'*on-error': 'BlockdevOnError',
41
+ '*filter-node-name': 'str',
42
'*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
43
44
##
45
diff --git a/include/block/block_int.h b/include/block/block_int.h
46
index XXXXXXX..XXXXXXX 100644
47
--- a/include/block/block_int.h
48
+++ b/include/block/block_int.h
49
@@ -XXX,XX +XXX,XX @@ int is_windows_drive(const char *filename);
50
* See @BlockJobCreateFlags
51
* @speed: The maximum speed, in bytes per second, or 0 for unlimited.
52
* @on_error: The action to take upon error.
53
+ * @filter_node_name: The node name that should be assigned to the filter
54
+ * driver that the stream job inserts into the graph above
55
+ * @bs. NULL means that a node name should be autogenerated.
56
* @errp: Error object.
57
*
58
* Start a streaming operation on @bs. Clusters that are unallocated
59
@@ -XXX,XX +XXX,XX @@ int is_windows_drive(const char *filename);
60
void stream_start(const char *job_id, BlockDriverState *bs,
61
BlockDriverState *base, const char *backing_file_str,
62
int creation_flags, int64_t speed,
63
- BlockdevOnError on_error, Error **errp);
64
+ BlockdevOnError on_error,
65
+ const char *filter_node_name,
66
+ Error **errp);
67
68
/**
69
* commit_start:
70
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
71
index XXXXXXX..XXXXXXX 100644
72
--- a/block/monitor/block-hmp-cmds.c
73
+++ b/block/monitor/block-hmp-cmds.c
74
@@ -XXX,XX +XXX,XX @@ void hmp_block_stream(Monitor *mon, const QDict *qdict)
75
76
qmp_block_stream(true, device, device, base != NULL, base, false, NULL,
77
false, NULL, qdict_haskey(qdict, "speed"), speed, true,
78
- BLOCKDEV_ON_ERROR_REPORT, false, false, false, false,
79
- &error);
80
+ BLOCKDEV_ON_ERROR_REPORT, false, NULL, false, false, false,
81
+ false, &error);
82
83
hmp_handle_error(mon, error);
84
}
85
diff --git a/block/stream.c b/block/stream.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/block/stream.c
88
+++ b/block/stream.c
89
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver stream_job_driver = {
90
void stream_start(const char *job_id, BlockDriverState *bs,
91
BlockDriverState *base, const char *backing_file_str,
92
int creation_flags, int64_t speed,
93
- BlockdevOnError on_error, Error **errp)
94
+ BlockdevOnError on_error,
95
+ const char *filter_node_name,
96
+ Error **errp)
97
{
98
StreamBlockJob *s;
99
BlockDriverState *iter;
100
diff --git a/blockdev.c b/blockdev.c
101
index XXXXXXX..XXXXXXX 100644
102
--- a/blockdev.c
103
+++ b/blockdev.c
104
@@ -XXX,XX +XXX,XX @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
105
bool has_backing_file, const char *backing_file,
106
bool has_speed, int64_t speed,
107
bool has_on_error, BlockdevOnError on_error,
108
+ bool has_filter_node_name, const char *filter_node_name,
109
bool has_auto_finalize, bool auto_finalize,
110
bool has_auto_dismiss, bool auto_dismiss,
111
Error **errp)
112
@@ -XXX,XX +XXX,XX @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
113
}
114
115
stream_start(has_job_id ? job_id : NULL, bs, base_bs, base_name,
116
- job_flags, has_speed ? speed : 0, on_error, &local_err);
117
+ job_flags, has_speed ? speed : 0, on_error,
118
+ filter_node_name, &local_err);
119
if (local_err) {
120
error_propagate(errp, local_err);
121
goto out;
122
--
123
2.29.2
124
125
diff view generated by jsdifflib
New patch
1
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
2
3
Add an option to limit copy-on-read operations to specified sub-chain
4
of backing-chain, to make copy-on-read filter useful for block-stream
5
job.
6
7
Suggested-by: Max Reitz <mreitz@redhat.com>
8
Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
10
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11
[vsementsov: change subject, modified to freeze the chain,
12
do some fixes]
13
Message-Id: <20201216061703.70908-6-vsementsov@virtuozzo.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
qapi/block-core.json | 20 ++++++++-
17
block/copy-on-read.c | 98 +++++++++++++++++++++++++++++++++++++++++++-
18
2 files changed, 115 insertions(+), 3 deletions(-)
19
20
diff --git a/qapi/block-core.json b/qapi/block-core.json
21
index XXXXXXX..XXXXXXX 100644
22
--- a/qapi/block-core.json
23
+++ b/qapi/block-core.json
24
@@ -XXX,XX +XXX,XX @@
25
'data': { 'throttle-group': 'str',
26
'file' : 'BlockdevRef'
27
} }
28
+
29
+##
30
+# @BlockdevOptionsCor:
31
+#
32
+# Driver specific block device options for the copy-on-read driver.
33
+#
34
+# @bottom: The name of a non-filter node (allocation-bearing layer) that
35
+# limits the COR operations in the backing chain (inclusive), so
36
+# that no data below this node will be copied by this filter.
37
+# If option is absent, the limit is not applied, so that data
38
+# from all backing layers may be copied.
39
+#
40
+# Since: 6.0
41
+##
42
+{ 'struct': 'BlockdevOptionsCor',
43
+ 'base': 'BlockdevOptionsGenericFormat',
44
+ 'data': { '*bottom': 'str' } }
45
+
46
##
47
# @BlockdevOptions:
48
#
49
@@ -XXX,XX +XXX,XX @@
50
'bochs': 'BlockdevOptionsGenericFormat',
51
'cloop': 'BlockdevOptionsGenericFormat',
52
'compress': 'BlockdevOptionsGenericFormat',
53
- 'copy-on-read':'BlockdevOptionsGenericFormat',
54
+ 'copy-on-read':'BlockdevOptionsCor',
55
'dmg': 'BlockdevOptionsGenericFormat',
56
'file': 'BlockdevOptionsFile',
57
'ftp': 'BlockdevOptionsCurlFtp',
58
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/block/copy-on-read.c
61
+++ b/block/copy-on-read.c
62
@@ -XXX,XX +XXX,XX @@
63
#include "block/block_int.h"
64
#include "qemu/module.h"
65
#include "qapi/error.h"
66
+#include "qapi/qmp/qdict.h"
67
#include "block/copy-on-read.h"
68
69
70
typedef struct BDRVStateCOR {
71
bool active;
72
+ BlockDriverState *bottom_bs;
73
+ bool chain_frozen;
74
} BDRVStateCOR;
75
76
77
static int cor_open(BlockDriverState *bs, QDict *options, int flags,
78
Error **errp)
79
{
80
+ BlockDriverState *bottom_bs = NULL;
81
BDRVStateCOR *state = bs->opaque;
82
+ /* Find a bottom node name, if any */
83
+ const char *bottom_node = qdict_get_try_str(options, "bottom");
84
85
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
86
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
87
@@ -XXX,XX +XXX,XX @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags,
88
((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) &
89
bs->file->bs->supported_zero_flags);
90
91
+ if (bottom_node) {
92
+ bottom_bs = bdrv_find_node(bottom_node);
93
+ if (!bottom_bs) {
94
+ error_setg(errp, "Bottom node '%s' not found", bottom_node);
95
+ qdict_del(options, "bottom");
96
+ return -EINVAL;
97
+ }
98
+ qdict_del(options, "bottom");
99
+
100
+ if (!bottom_bs->drv) {
101
+ error_setg(errp, "Bottom node '%s' not opened", bottom_node);
102
+ return -EINVAL;
103
+ }
104
+
105
+ if (bottom_bs->drv->is_filter) {
106
+ error_setg(errp, "Bottom node '%s' is a filter", bottom_node);
107
+ return -EINVAL;
108
+ }
109
+
110
+ if (bdrv_freeze_backing_chain(bs, bottom_bs, errp) < 0) {
111
+ return -EINVAL;
112
+ }
113
+ state->chain_frozen = true;
114
+
115
+ /*
116
+ * We do freeze the chain, so it shouldn't be removed. Still, storing a
117
+ * pointer worth bdrv_ref().
118
+ */
119
+ bdrv_ref(bottom_bs);
120
+ }
121
state->active = true;
122
+ state->bottom_bs = bottom_bs;
123
124
/*
125
* We don't need to call bdrv_child_refresh_perms() now as the permissions
126
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn cor_co_preadv_part(BlockDriverState *bs,
127
size_t qiov_offset,
128
int flags)
129
{
130
- return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset,
131
- flags | BDRV_REQ_COPY_ON_READ);
132
+ int64_t n;
133
+ int local_flags;
134
+ int ret;
135
+ BDRVStateCOR *state = bs->opaque;
136
+
137
+ if (!state->bottom_bs) {
138
+ return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset,
139
+ flags | BDRV_REQ_COPY_ON_READ);
140
+ }
141
+
142
+ while (bytes) {
143
+ local_flags = flags;
144
+
145
+ /* In case of failure, try to copy-on-read anyway */
146
+ ret = bdrv_is_allocated(bs->file->bs, offset, bytes, &n);
147
+ if (ret <= 0) {
148
+ ret = bdrv_is_allocated_above(bdrv_backing_chain_next(bs->file->bs),
149
+ state->bottom_bs, true, offset,
150
+ n, &n);
151
+ if (ret > 0 || ret < 0) {
152
+ local_flags |= BDRV_REQ_COPY_ON_READ;
153
+ }
154
+ /* Finish earlier if the end of a backing file has been reached */
155
+ if (n == 0) {
156
+ break;
157
+ }
158
+ }
159
+
160
+ ret = bdrv_co_preadv_part(bs->file, offset, n, qiov, qiov_offset,
161
+ local_flags);
162
+ if (ret < 0) {
163
+ return ret;
164
+ }
165
+
166
+ offset += n;
167
+ qiov_offset += n;
168
+ bytes -= n;
169
+ }
170
+
171
+ return 0;
172
}
173
174
175
@@ -XXX,XX +XXX,XX @@ static void cor_lock_medium(BlockDriverState *bs, bool locked)
176
}
177
178
179
+static void cor_close(BlockDriverState *bs)
180
+{
181
+ BDRVStateCOR *s = bs->opaque;
182
+
183
+ if (s->chain_frozen) {
184
+ s->chain_frozen = false;
185
+ bdrv_unfreeze_backing_chain(bs, s->bottom_bs);
186
+ }
187
+
188
+ bdrv_unref(s->bottom_bs);
189
+}
190
+
191
+
192
static BlockDriver bdrv_copy_on_read = {
193
.format_name = "copy-on-read",
194
.instance_size = sizeof(BDRVStateCOR),
195
196
.bdrv_open = cor_open,
197
+ .bdrv_close = cor_close,
198
.bdrv_child_perm = cor_child_perm,
199
200
.bdrv_getlength = cor_getlength,
201
@@ -XXX,XX +XXX,XX @@ void bdrv_cor_filter_drop(BlockDriverState *cor_filter_bs)
202
bdrv_drained_begin(bs);
203
/* Drop permissions before the graph change. */
204
s->active = false;
205
+ /* unfreeze, as otherwise bdrv_replace_node() will fail */
206
+ if (s->chain_frozen) {
207
+ s->chain_frozen = false;
208
+ bdrv_unfreeze_backing_chain(cor_filter_bs, s->bottom_bs);
209
+ }
210
bdrv_child_refresh_perms(cor_filter_bs, child, &error_abort);
211
bdrv_replace_node(cor_filter_bs, bs, &error_abort);
212
213
--
214
2.29.2
215
216
diff view generated by jsdifflib
New patch
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
1
2
3
The test case #310 is similar to #216 by Max Reitz. The difference is
4
that the test #310 involves a bottom node to the COR filter driver.
5
6
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
7
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
[vsementsov: detach backing to test reads from top, limit to qcow2]
9
Message-Id: <20201216061703.70908-7-vsementsov@virtuozzo.com>
10
[mreitz: Add "# group:" line]
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
tests/qemu-iotests/310 | 117 +++++++++++++++++++++++++++++++++++++
14
tests/qemu-iotests/310.out | 15 +++++
15
tests/qemu-iotests/group | 1 +
16
3 files changed, 133 insertions(+)
17
create mode 100755 tests/qemu-iotests/310
18
create mode 100644 tests/qemu-iotests/310.out
19
20
diff --git a/tests/qemu-iotests/310 b/tests/qemu-iotests/310
21
new file mode 100755
22
index XXXXXXX..XXXXXXX
23
--- /dev/null
24
+++ b/tests/qemu-iotests/310
25
@@ -XXX,XX +XXX,XX @@
26
+#!/usr/bin/env python3
27
+# group: rw quick
28
+#
29
+# Copy-on-read tests using a COR filter with a bottom node
30
+#
31
+# Copyright (C) 2018 Red Hat, Inc.
32
+# Copyright (c) 2020 Virtuozzo International GmbH
33
+#
34
+# This program is free software; you can redistribute it and/or modify
35
+# it under the terms of the GNU General Public License as published by
36
+# the Free Software Foundation; either version 2 of the License, or
37
+# (at your option) any later version.
38
+#
39
+# This program is distributed in the hope that it will be useful,
40
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
41
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42
+# GNU General Public License for more details.
43
+#
44
+# You should have received a copy of the GNU General Public License
45
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
46
+#
47
+
48
+import iotests
49
+from iotests import log, qemu_img, qemu_io_silent
50
+
51
+# Need backing file support
52
+iotests.script_initialize(supported_fmts=['qcow2'],
53
+ supported_platforms=['linux'])
54
+
55
+log('')
56
+log('=== Copy-on-read across nodes ===')
57
+log('')
58
+
59
+# This test is similar to the 216 one by Max Reitz <mreitz@redhat.com>
60
+# The difference is that this test case involves a bottom node to the
61
+# COR filter driver.
62
+
63
+with iotests.FilePath('base.img') as base_img_path, \
64
+ iotests.FilePath('mid.img') as mid_img_path, \
65
+ iotests.FilePath('top.img') as top_img_path, \
66
+ iotests.VM() as vm:
67
+
68
+ log('--- Setting up images ---')
69
+ log('')
70
+
71
+ assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0
72
+ assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0
73
+ assert qemu_io_silent(base_img_path, '-c', 'write -P 1 3M 1M') == 0
74
+ assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
75
+ '-F', iotests.imgfmt, mid_img_path) == 0
76
+ assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 2M 1M') == 0
77
+ assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 4M 1M') == 0
78
+ assert qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
79
+ '-F', iotests.imgfmt, top_img_path) == 0
80
+ assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
81
+
82
+# 0 1 2 3 4
83
+# top 2
84
+# mid 3 3
85
+# base 1 1
86
+
87
+ log('Done')
88
+
89
+ log('')
90
+ log('--- Doing COR ---')
91
+ log('')
92
+
93
+ vm.launch()
94
+
95
+ log(vm.qmp('blockdev-add',
96
+ node_name='node0',
97
+ driver='copy-on-read',
98
+ bottom='node2',
99
+ file={
100
+ 'driver': iotests.imgfmt,
101
+ 'file': {
102
+ 'driver': 'file',
103
+ 'filename': top_img_path
104
+ },
105
+ 'backing': {
106
+ 'node-name': 'node2',
107
+ 'driver': iotests.imgfmt,
108
+ 'file': {
109
+ 'driver': 'file',
110
+ 'filename': mid_img_path
111
+ },
112
+ 'backing': {
113
+ 'driver': iotests.imgfmt,
114
+ 'file': {
115
+ 'driver': 'file',
116
+ 'filename': base_img_path
117
+ }
118
+ },
119
+ }
120
+ }))
121
+
122
+ # Trigger COR
123
+ log(vm.qmp('human-monitor-command',
124
+ command_line='qemu-io node0 "read 0 5M"'))
125
+
126
+ vm.shutdown()
127
+
128
+ log('')
129
+ log('--- Checking COR result ---')
130
+ log('')
131
+
132
+ # Detach backing to check that we can read the data from the top level now
133
+ assert qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt,
134
+ top_img_path) == 0
135
+
136
+ assert qemu_io_silent(top_img_path, '-c', 'read -P 0 0 1M') == 0
137
+ assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0
138
+ assert qemu_io_silent(top_img_path, '-c', 'read -P 3 2M 1M') == 0
139
+ assert qemu_io_silent(top_img_path, '-c', 'read -P 0 3M 1M') == 0
140
+ assert qemu_io_silent(top_img_path, '-c', 'read -P 3 4M 1M') == 0
141
+
142
+ log('Done')
143
diff --git a/tests/qemu-iotests/310.out b/tests/qemu-iotests/310.out
144
new file mode 100644
145
index XXXXXXX..XXXXXXX
146
--- /dev/null
147
+++ b/tests/qemu-iotests/310.out
148
@@ -XXX,XX +XXX,XX @@
149
+
150
+=== Copy-on-read across nodes ===
151
+
152
+--- Setting up images ---
153
+
154
+Done
155
+
156
+--- Doing COR ---
157
+
158
+{"return": {}}
159
+{"return": ""}
160
+
161
+--- Checking COR result ---
162
+
163
+Done
164
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
165
index XXXXXXX..XXXXXXX 100644
166
--- a/tests/qemu-iotests/group
167
+++ b/tests/qemu-iotests/group
168
@@ -XXX,XX +XXX,XX @@
169
307 rw quick export
170
308 rw
171
309 rw auto quick
172
+310 rw quick
173
312 rw quick
174
--
175
2.29.2
176
177
diff view generated by jsdifflib
New patch
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
1
2
3
Add the new member supported_read_flags to the BlockDriverState
4
structure. It will control the flags set for copy-on-read operations.
5
Make the block generic layer evaluate supported read flags before they
6
go to a block driver.
7
8
Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
10
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11
[vsementsov: use assert instead of abort]
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
Message-Id: <20201216061703.70908-8-vsementsov@virtuozzo.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
include/block/block_int.h | 4 ++++
17
block/io.c | 10 ++++++++--
18
2 files changed, 12 insertions(+), 2 deletions(-)
19
20
diff --git a/include/block/block_int.h b/include/block/block_int.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/include/block/block_int.h
23
+++ b/include/block/block_int.h
24
@@ -XXX,XX +XXX,XX @@ struct BlockDriverState {
25
/* I/O Limits */
26
BlockLimits bl;
27
28
+ /*
29
+ * Flags honored during pread
30
+ */
31
+ unsigned int supported_read_flags;
32
/* Flags honored during pwrite (so far: BDRV_REQ_FUA,
33
* BDRV_REQ_WRITE_UNCHANGED).
34
* If a driver does not support BDRV_REQ_WRITE_UNCHANGED, those
35
diff --git a/block/io.c b/block/io.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/block/io.c
38
+++ b/block/io.c
39
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
40
if (flags & BDRV_REQ_COPY_ON_READ) {
41
int64_t pnum;
42
43
+ /* The flag BDRV_REQ_COPY_ON_READ has reached its addressee */
44
+ flags &= ~BDRV_REQ_COPY_ON_READ;
45
+
46
ret = bdrv_is_allocated(bs, offset, bytes, &pnum);
47
if (ret < 0) {
48
goto out;
49
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
50
goto out;
51
}
52
53
+ assert(!(flags & ~bs->supported_read_flags));
54
+
55
max_bytes = ROUND_UP(MAX(0, total_bytes - offset), align);
56
if (bytes <= max_bytes && bytes <= max_transfer) {
57
- ret = bdrv_driver_preadv(bs, offset, bytes, qiov, qiov_offset, 0);
58
+ ret = bdrv_driver_preadv(bs, offset, bytes, qiov, qiov_offset, flags);
59
goto out;
60
}
61
62
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
63
64
ret = bdrv_driver_preadv(bs, offset + bytes - bytes_remaining,
65
num, qiov,
66
- qiov_offset + bytes - bytes_remaining, 0);
67
+ qiov_offset + bytes - bytes_remaining,
68
+ flags);
69
max_bytes -= num;
70
} else {
71
num = bytes_remaining;
72
--
73
2.29.2
74
75
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
2
2
3
Use a pointer to the bucket instead of repeating cfg->buckets[i] all
3
If the flag BDRV_REQ_PREFETCH was set, skip idling read/write
4
the time. This makes the code more concise and will help us expand the
4
operations in COR-driver. It can be taken into account for the
5
checks later and save a few line breaks.
5
COR-algorithms optimization. That check is being made during the
6
block stream job by the moment.
6
7
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
8
Add the BDRV_REQ_PREFETCH flag to the supported_read_flags of the
8
Message-id: 763ffc40a26b17d54cf93f5a999e4656049fcf0c.1503580370.git.berto@igalia.com
9
COR-filter.
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
11
block: Modify the comment for the flag BDRV_REQ_PREFETCH as we are
12
going to use it alone and pass it to the COR-filter driver for further
13
processing.
14
15
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
16
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
17
Reviewed-by: Max Reitz <mreitz@redhat.com>
18
Message-Id: <20201216061703.70908-9-vsementsov@virtuozzo.com>
19
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
20
---
11
util/throttle.c | 15 +++++++--------
21
include/block/block.h | 8 +++++---
12
1 file changed, 7 insertions(+), 8 deletions(-)
22
block/copy-on-read.c | 14 ++++++++++----
23
2 files changed, 15 insertions(+), 7 deletions(-)
13
24
14
diff --git a/util/throttle.c b/util/throttle.c
25
diff --git a/include/block/block.h b/include/block/block.h
15
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
16
--- a/util/throttle.c
27
--- a/include/block/block.h
17
+++ b/util/throttle.c
28
+++ b/include/block/block.h
18
@@ -XXX,XX +XXX,XX @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **errp)
29
@@ -XXX,XX +XXX,XX @@ typedef enum {
30
BDRV_REQ_NO_FALLBACK = 0x100,
31
32
/*
33
- * BDRV_REQ_PREFETCH may be used only together with BDRV_REQ_COPY_ON_READ
34
- * on read request and means that caller doesn't really need data to be
35
- * written to qiov parameter which may be NULL.
36
+ * BDRV_REQ_PREFETCH makes sense only in the context of copy-on-read
37
+ * (i.e., together with the BDRV_REQ_COPY_ON_READ flag or when a COR
38
+ * filter is involved), in which case it signals that the COR operation
39
+ * need not read the data into memory (qiov) but only ensure they are
40
+ * copied to the top layer (i.e., that COR operation is done).
41
*/
42
BDRV_REQ_PREFETCH = 0x200,
43
44
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/block/copy-on-read.c
47
+++ b/block/copy-on-read.c
48
@@ -XXX,XX +XXX,XX @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags,
49
return -EINVAL;
19
}
50
}
20
51
21
for (i = 0; i < BUCKETS_COUNT; i++) {
52
+ bs->supported_read_flags = BDRV_REQ_PREFETCH;
22
- if (cfg->buckets[i].avg < 0 ||
53
+
23
- cfg->buckets[i].max < 0 ||
54
bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
24
- cfg->buckets[i].avg > THROTTLE_VALUE_MAX ||
55
(BDRV_REQ_FUA & bs->file->bs->supported_write_flags);
25
- cfg->buckets[i].max > THROTTLE_VALUE_MAX) {
56
26
+ LeakyBucket *bkt = &cfg->buckets[i];
57
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn cor_co_preadv_part(BlockDriverState *bs,
27
+ if (bkt->avg < 0 || bkt->max < 0 ||
58
}
28
+ bkt->avg > THROTTLE_VALUE_MAX || bkt->max > THROTTLE_VALUE_MAX) {
29
error_setg(errp, "bps/iops/max values must be within [0, %lld]",
30
THROTTLE_VALUE_MAX);
31
return false;
32
}
59
}
33
60
34
- if (!cfg->buckets[i].burst_length) {
61
- ret = bdrv_co_preadv_part(bs->file, offset, n, qiov, qiov_offset,
35
+ if (!bkt->burst_length) {
62
- local_flags);
36
error_setg(errp, "the burst length cannot be 0");
63
- if (ret < 0) {
37
return false;
64
- return ret;
65
+ /* Skip if neither read nor write are needed */
66
+ if ((local_flags & (BDRV_REQ_PREFETCH | BDRV_REQ_COPY_ON_READ)) !=
67
+ BDRV_REQ_PREFETCH) {
68
+ ret = bdrv_co_preadv_part(bs->file, offset, n, qiov, qiov_offset,
69
+ local_flags);
70
+ if (ret < 0) {
71
+ return ret;
72
+ }
38
}
73
}
39
74
40
- if (cfg->buckets[i].burst_length > 1 && !cfg->buckets[i].max) {
75
offset += n;
41
+ if (bkt->burst_length > 1 && !bkt->max) {
42
error_setg(errp, "burst length set without burst rate");
43
return false;
44
}
45
46
- if (cfg->buckets[i].max && !cfg->buckets[i].avg) {
47
+ if (bkt->max && !bkt->avg) {
48
error_setg(errp, "bps_max/iops_max require corresponding"
49
" bps/iops values");
50
return false;
51
}
52
53
- if (cfg->buckets[i].max && cfg->buckets[i].max < cfg->buckets[i].avg) {
54
+ if (bkt->max && bkt->max < bkt->avg) {
55
error_setg(errp, "bps_max/iops_max cannot be lower than bps/iops");
56
return false;
57
}
58
--
76
--
59
2.13.5
77
2.29.2
60
78
61
79
diff view generated by jsdifflib
New patch
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
1
2
3
Stream in stream_prepare calls bdrv_change_backing_file() to change
4
backing-file in the metadata of bs.
5
6
It may use either backing-file parameter given by user or just take
7
filename of base on job start.
8
9
Backing file format is determined by base on job finish.
10
11
There are some problems with this design, we solve only two by this
12
patch:
13
14
1. Consider scenario with backing-file unset. Current concept of stream
15
supports changing of the base during the job (we don't freeze link to
16
the base). So, we should not save base filename at job start,
17
18
- let's determine name of the base on job finish.
19
20
2. Using direct base to determine filename and format is not very good:
21
base node may be a filter, so its filename may be JSON, and format_name
22
is not good for storing into qcow2 metadata as backing file format.
23
24
- let's use unfiltered_base
25
26
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
27
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
28
[vsementsov: change commit subject, change logic in stream_prepare]
29
Message-Id: <20201216061703.70908-10-vsementsov@virtuozzo.com>
30
Reviewed-by: Max Reitz <mreitz@redhat.com>
31
Signed-off-by: Max Reitz <mreitz@redhat.com>
32
---
33
block/stream.c | 9 +++++----
34
blockdev.c | 8 +-------
35
2 files changed, 6 insertions(+), 11 deletions(-)
36
37
diff --git a/block/stream.c b/block/stream.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/block/stream.c
40
+++ b/block/stream.c
41
@@ -XXX,XX +XXX,XX @@ static int stream_prepare(Job *job)
42
BlockDriverState *bs = blk_bs(bjob->blk);
43
BlockDriverState *unfiltered_bs = bdrv_skip_filters(bs);
44
BlockDriverState *base = bdrv_filter_or_cow_bs(s->above_base);
45
+ BlockDriverState *unfiltered_base = bdrv_skip_filters(base);
46
Error *local_err = NULL;
47
int ret = 0;
48
49
@@ -XXX,XX +XXX,XX @@ static int stream_prepare(Job *job)
50
51
if (bdrv_cow_child(unfiltered_bs)) {
52
const char *base_id = NULL, *base_fmt = NULL;
53
- if (base) {
54
- base_id = s->backing_file_str;
55
- if (base->drv) {
56
- base_fmt = base->drv->format_name;
57
+ if (unfiltered_base) {
58
+ base_id = s->backing_file_str ?: unfiltered_base->filename;
59
+ if (unfiltered_base->drv) {
60
+ base_fmt = unfiltered_base->drv->format_name;
61
}
62
}
63
bdrv_set_backing_hd(unfiltered_bs, base, &local_err);
64
diff --git a/blockdev.c b/blockdev.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/blockdev.c
67
+++ b/blockdev.c
68
@@ -XXX,XX +XXX,XX @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
69
BlockDriverState *base_bs = NULL;
70
AioContext *aio_context;
71
Error *local_err = NULL;
72
- const char *base_name = NULL;
73
int job_flags = JOB_DEFAULT;
74
75
if (!has_on_error) {
76
@@ -XXX,XX +XXX,XX @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
77
goto out;
78
}
79
assert(bdrv_get_aio_context(base_bs) == aio_context);
80
- base_name = base;
81
}
82
83
if (has_base_node) {
84
@@ -XXX,XX +XXX,XX @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
85
}
86
assert(bdrv_get_aio_context(base_bs) == aio_context);
87
bdrv_refresh_filename(base_bs);
88
- base_name = base_bs->filename;
89
}
90
91
/* Check for op blockers in the whole chain between bs and base */
92
@@ -XXX,XX +XXX,XX @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
93
goto out;
94
}
95
96
- /* backing_file string overrides base bs filename */
97
- base_name = has_backing_file ? backing_file : base_name;
98
-
99
if (has_auto_finalize && !auto_finalize) {
100
job_flags |= JOB_MANUAL_FINALIZE;
101
}
102
@@ -XXX,XX +XXX,XX @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
103
job_flags |= JOB_MANUAL_DISMISS;
104
}
105
106
- stream_start(has_job_id ? job_id : NULL, bs, base_bs, base_name,
107
+ stream_start(has_job_id ? job_id : NULL, bs, base_bs, backing_file,
108
job_flags, has_speed ? speed : 0, on_error,
109
filter_node_name, &local_err);
110
if (local_err) {
111
--
112
2.29.2
113
114
diff view generated by jsdifflib
New patch
1
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
3
The code already don't freeze base node and we try to make it prepared
4
for the situation when base node is changed during the operation. In
5
other words, block-stream doesn't own base node.
6
7
Let's introduce a new interface which should replace the current one,
8
which will in better relations with the code. Specifying bottom node
9
instead of base, and requiring it to be non-filter gives us the
10
following benefits:
11
12
- drop difference between above_base and base_overlay, which will be
13
renamed to just bottom, when old interface dropped
14
15
- clean way to work with parallel streams/commits on the same backing
16
chain, which otherwise become a problem when we introduce a filter
17
for stream job
18
19
- cleaner interface. Nobody will surprised the fact that base node may
20
disappear during block-stream, when there is no word about "base" in
21
the interface.
22
23
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
24
Message-Id: <20201216061703.70908-11-vsementsov@virtuozzo.com>
25
Reviewed-by: Max Reitz <mreitz@redhat.com>
26
Signed-off-by: Max Reitz <mreitz@redhat.com>
27
---
28
qapi/block-core.json | 12 ++++---
29
include/block/block_int.h | 1 +
30
block/monitor/block-hmp-cmds.c | 3 +-
31
block/stream.c | 50 +++++++++++++++++++---------
32
blockdev.c | 59 ++++++++++++++++++++++++++++------
33
5 files changed, 94 insertions(+), 31 deletions(-)
34
35
diff --git a/qapi/block-core.json b/qapi/block-core.json
36
index XXXXXXX..XXXXXXX 100644
37
--- a/qapi/block-core.json
38
+++ b/qapi/block-core.json
39
@@ -XXX,XX +XXX,XX @@
40
# @device: the device or node name of the top image
41
#
42
# @base: the common backing file name.
43
-# It cannot be set if @base-node is also set.
44
+# It cannot be set if @base-node or @bottom is also set.
45
#
46
# @base-node: the node name of the backing file.
47
-# It cannot be set if @base is also set. (Since 2.8)
48
+# It cannot be set if @base or @bottom is also set. (Since 2.8)
49
+#
50
+# @bottom: the last node in the chain that should be streamed into
51
+# top. It cannot be set if @base or @base-node is also set.
52
+# It cannot be filter node. (Since 6.0)
53
#
54
# @backing-file: The backing file string to write into the top
55
# image. This filename is not validated.
56
@@ -XXX,XX +XXX,XX @@
57
##
58
{ 'command': 'block-stream',
59
'data': { '*job-id': 'str', 'device': 'str', '*base': 'str',
60
- '*base-node': 'str', '*backing-file': 'str', '*speed': 'int',
61
- '*on-error': 'BlockdevOnError',
62
+ '*base-node': 'str', '*backing-file': 'str', '*bottom': 'str',
63
+ '*speed': 'int', '*on-error': 'BlockdevOnError',
64
'*filter-node-name': 'str',
65
'*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
66
67
diff --git a/include/block/block_int.h b/include/block/block_int.h
68
index XXXXXXX..XXXXXXX 100644
69
--- a/include/block/block_int.h
70
+++ b/include/block/block_int.h
71
@@ -XXX,XX +XXX,XX @@ int is_windows_drive(const char *filename);
72
*/
73
void stream_start(const char *job_id, BlockDriverState *bs,
74
BlockDriverState *base, const char *backing_file_str,
75
+ BlockDriverState *bottom,
76
int creation_flags, int64_t speed,
77
BlockdevOnError on_error,
78
const char *filter_node_name,
79
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
80
index XXXXXXX..XXXXXXX 100644
81
--- a/block/monitor/block-hmp-cmds.c
82
+++ b/block/monitor/block-hmp-cmds.c
83
@@ -XXX,XX +XXX,XX @@ void hmp_block_stream(Monitor *mon, const QDict *qdict)
84
int64_t speed = qdict_get_try_int(qdict, "speed", 0);
85
86
qmp_block_stream(true, device, device, base != NULL, base, false, NULL,
87
- false, NULL, qdict_haskey(qdict, "speed"), speed, true,
88
+ false, NULL, false, NULL,
89
+ qdict_haskey(qdict, "speed"), speed, true,
90
BLOCKDEV_ON_ERROR_REPORT, false, NULL, false, false, false,
91
false, &error);
92
93
diff --git a/block/stream.c b/block/stream.c
94
index XXXXXXX..XXXXXXX 100644
95
--- a/block/stream.c
96
+++ b/block/stream.c
97
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver stream_job_driver = {
98
99
void stream_start(const char *job_id, BlockDriverState *bs,
100
BlockDriverState *base, const char *backing_file_str,
101
+ BlockDriverState *bottom,
102
int creation_flags, int64_t speed,
103
BlockdevOnError on_error,
104
const char *filter_node_name,
105
@@ -XXX,XX +XXX,XX @@ void stream_start(const char *job_id, BlockDriverState *bs,
106
BlockDriverState *iter;
107
bool bs_read_only;
108
int basic_flags = BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED;
109
- BlockDriverState *base_overlay = bdrv_find_overlay(bs, base);
110
+ BlockDriverState *base_overlay;
111
BlockDriverState *above_base;
112
113
- if (!base_overlay) {
114
- error_setg(errp, "'%s' is not in the backing chain of '%s'",
115
- base->node_name, bs->node_name);
116
- return;
117
- }
118
+ assert(!(base && bottom));
119
+ assert(!(backing_file_str && bottom));
120
+
121
+ if (bottom) {
122
+ /*
123
+ * New simple interface. The code is written in terms of old interface
124
+ * with @base parameter (still, it doesn't freeze link to base, so in
125
+ * this mean old code is correct for new interface). So, for now, just
126
+ * emulate base_overlay and above_base. Still, when old interface
127
+ * finally removed, we should refactor code to use only "bottom", but
128
+ * not "*base*" things.
129
+ */
130
+ assert(!bottom->drv->is_filter);
131
+ base_overlay = above_base = bottom;
132
+ } else {
133
+ base_overlay = bdrv_find_overlay(bs, base);
134
+ if (!base_overlay) {
135
+ error_setg(errp, "'%s' is not in the backing chain of '%s'",
136
+ base->node_name, bs->node_name);
137
+ return;
138
+ }
139
140
- /*
141
- * Find the node directly above @base. @base_overlay is a COW overlay, so
142
- * it must have a bdrv_cow_child(), but it is the immediate overlay of
143
- * @base, so between the two there can only be filters.
144
- */
145
- above_base = base_overlay;
146
- if (bdrv_cow_bs(above_base) != base) {
147
- above_base = bdrv_cow_bs(above_base);
148
- while (bdrv_filter_bs(above_base) != base) {
149
- above_base = bdrv_filter_bs(above_base);
150
+ /*
151
+ * Find the node directly above @base. @base_overlay is a COW overlay,
152
+ * so it must have a bdrv_cow_child(), but it is the immediate overlay
153
+ * of @base, so between the two there can only be filters.
154
+ */
155
+ above_base = base_overlay;
156
+ if (bdrv_cow_bs(above_base) != base) {
157
+ above_base = bdrv_cow_bs(above_base);
158
+ while (bdrv_filter_bs(above_base) != base) {
159
+ above_base = bdrv_filter_bs(above_base);
160
+ }
161
}
162
}
163
164
diff --git a/blockdev.c b/blockdev.c
165
index XXXXXXX..XXXXXXX 100644
166
--- a/blockdev.c
167
+++ b/blockdev.c
168
@@ -XXX,XX +XXX,XX @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
169
bool has_base, const char *base,
170
bool has_base_node, const char *base_node,
171
bool has_backing_file, const char *backing_file,
172
+ bool has_bottom, const char *bottom,
173
bool has_speed, int64_t speed,
174
bool has_on_error, BlockdevOnError on_error,
175
bool has_filter_node_name, const char *filter_node_name,
176
@@ -XXX,XX +XXX,XX @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
177
bool has_auto_dismiss, bool auto_dismiss,
178
Error **errp)
179
{
180
- BlockDriverState *bs, *iter;
181
+ BlockDriverState *bs, *iter, *iter_end;
182
BlockDriverState *base_bs = NULL;
183
+ BlockDriverState *bottom_bs = NULL;
184
AioContext *aio_context;
185
Error *local_err = NULL;
186
int job_flags = JOB_DEFAULT;
187
188
+ if (has_base && has_base_node) {
189
+ error_setg(errp, "'base' and 'base-node' cannot be specified "
190
+ "at the same time");
191
+ return;
192
+ }
193
+
194
+ if (has_base && has_bottom) {
195
+ error_setg(errp, "'base' and 'bottom' cannot be specified "
196
+ "at the same time");
197
+ return;
198
+ }
199
+
200
+ if (has_bottom && has_base_node) {
201
+ error_setg(errp, "'bottom' and 'base-node' cannot be specified "
202
+ "at the same time");
203
+ return;
204
+ }
205
+
206
if (!has_on_error) {
207
on_error = BLOCKDEV_ON_ERROR_REPORT;
208
}
209
@@ -XXX,XX +XXX,XX @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
210
aio_context = bdrv_get_aio_context(bs);
211
aio_context_acquire(aio_context);
212
213
- if (has_base && has_base_node) {
214
- error_setg(errp, "'base' and 'base-node' cannot be specified "
215
- "at the same time");
216
- goto out;
217
- }
218
-
219
if (has_base) {
220
base_bs = bdrv_find_backing_image(bs, base);
221
if (base_bs == NULL) {
222
@@ -XXX,XX +XXX,XX @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
223
bdrv_refresh_filename(base_bs);
224
}
225
226
- /* Check for op blockers in the whole chain between bs and base */
227
- for (iter = bs; iter && iter != base_bs;
228
+ if (has_bottom) {
229
+ bottom_bs = bdrv_lookup_bs(NULL, bottom, errp);
230
+ if (!bottom_bs) {
231
+ goto out;
232
+ }
233
+ if (!bottom_bs->drv) {
234
+ error_setg(errp, "Node '%s' is not open", bottom);
235
+ goto out;
236
+ }
237
+ if (bottom_bs->drv->is_filter) {
238
+ error_setg(errp, "Node '%s' is a filter, use a non-filter node "
239
+ "as 'bottom'", bottom);
240
+ goto out;
241
+ }
242
+ if (!bdrv_chain_contains(bs, bottom_bs)) {
243
+ error_setg(errp, "Node '%s' is not in a chain starting from '%s'",
244
+ bottom, device);
245
+ goto out;
246
+ }
247
+ assert(bdrv_get_aio_context(bottom_bs) == aio_context);
248
+ }
249
+
250
+ /*
251
+ * Check for op blockers in the whole chain between bs and base (or bottom)
252
+ */
253
+ iter_end = has_bottom ? bdrv_filter_or_cow_bs(bottom_bs) : base_bs;
254
+ for (iter = bs; iter && iter != iter_end;
255
iter = bdrv_filter_or_cow_bs(iter))
256
{
257
if (bdrv_op_is_blocked(iter, BLOCK_OP_TYPE_STREAM, errp)) {
258
@@ -XXX,XX +XXX,XX @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
259
}
260
261
stream_start(has_job_id ? job_id : NULL, bs, base_bs, backing_file,
262
- job_flags, has_speed ? speed : 0, on_error,
263
+ bottom_bs, job_flags, has_speed ? speed : 0, on_error,
264
filter_node_name, &local_err);
265
if (local_err) {
266
error_propagate(errp, local_err);
267
--
268
2.29.2
269
270
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
test_stream_parallel run parallel stream jobs, intersecting so that top
4
of one is base of another. It's OK now, but it would be a problem if
5
insert the filter, as one job will want to use another job's filter as
6
above_base node.
7
8
Correct thing to do is move to new interface: "bottom" argument instead
9
of base. This guarantees that jobs don't intersect by their actions.
10
11
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
Message-Id: <20201216061703.70908-12-vsementsov@virtuozzo.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
tests/qemu-iotests/030 | 4 +++-
17
1 file changed, 3 insertions(+), 1 deletion(-)
18
19
diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
20
index XXXXXXX..XXXXXXX 100755
21
--- a/tests/qemu-iotests/030
22
+++ b/tests/qemu-iotests/030
23
@@ -XXX,XX +XXX,XX @@ class TestParallelOps(iotests.QMPTestCase):
24
node_name = 'node%d' % i
25
job_id = 'stream-%s' % node_name
26
pending_jobs.append(job_id)
27
- result = self.vm.qmp('block-stream', device=node_name, job_id=job_id, base=self.imgs[i-2], speed=1024)
28
+ result = self.vm.qmp('block-stream', device=node_name,
29
+ job_id=job_id, bottom=f'node{i-1}',
30
+ speed=1024)
31
self.assert_qmp(result, 'return', {})
32
33
for job in pending_jobs:
34
--
35
2.29.2
36
37
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
The throttling code can change internally the value of bkt->max if it
3
Add a direct link to target bs for convenience and to simplify
4
hasn't been set by the user. The problem with this is that if we want
4
following commit which will insert COR filter above target bs.
5
to retrieve the original value we have to undo this change first. This
6
is ugly and unnecessary: this patch removes the throttle_fix_bucket()
7
and throttle_unfix_bucket() functions completely and moves the logic
8
to throttle_compute_wait().
9
5
10
Signed-off-by: Alberto Garcia <berto@igalia.com>
6
This is a part of original commit written by Andrey.
11
Reviewed-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
7
12
Message-id: 5b0b9e1ac6eb208d709eddc7b09e7669a523bff3.1503580370.git.berto@igalia.com
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-Id: <20201216061703.70908-13-vsementsov@virtuozzo.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
14
---
12
---
15
util/throttle.c | 62 +++++++++++++++++++++------------------------------------
13
block/stream.c | 23 ++++++++++-------------
16
1 file changed, 23 insertions(+), 39 deletions(-)
14
1 file changed, 10 insertions(+), 13 deletions(-)
17
15
18
diff --git a/util/throttle.c b/util/throttle.c
16
diff --git a/block/stream.c b/block/stream.c
19
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
20
--- a/util/throttle.c
18
--- a/block/stream.c
21
+++ b/util/throttle.c
19
+++ b/block/stream.c
22
@@ -XXX,XX +XXX,XX @@ static int64_t throttle_do_compute_wait(double limit, double extra)
20
@@ -XXX,XX +XXX,XX @@ typedef struct StreamBlockJob {
23
int64_t throttle_compute_wait(LeakyBucket *bkt)
21
BlockJob common;
22
BlockDriverState *base_overlay; /* COW overlay (stream from this) */
23
BlockDriverState *above_base; /* Node directly above the base */
24
+ BlockDriverState *target_bs;
25
BlockdevOnError on_error;
26
char *backing_file_str;
27
bool bs_read_only;
28
@@ -XXX,XX +XXX,XX @@ static void stream_abort(Job *job)
29
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
30
31
if (s->chain_frozen) {
32
- BlockJob *bjob = &s->common;
33
- bdrv_unfreeze_backing_chain(blk_bs(bjob->blk), s->above_base);
34
+ bdrv_unfreeze_backing_chain(s->target_bs, s->above_base);
35
}
36
}
37
38
static int stream_prepare(Job *job)
24
{
39
{
25
double extra; /* the number of extra units blocking the io */
40
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
26
+ double bucket_size; /* I/O before throttling to bkt->avg */
41
- BlockJob *bjob = &s->common;
27
+ double burst_bucket_size; /* Before throttling to bkt->max */
42
- BlockDriverState *bs = blk_bs(bjob->blk);
28
43
- BlockDriverState *unfiltered_bs = bdrv_skip_filters(bs);
29
if (!bkt->avg) {
44
+ BlockDriverState *unfiltered_bs = bdrv_skip_filters(s->target_bs);
45
BlockDriverState *base = bdrv_filter_or_cow_bs(s->above_base);
46
BlockDriverState *unfiltered_base = bdrv_skip_filters(base);
47
Error *local_err = NULL;
48
int ret = 0;
49
50
- bdrv_unfreeze_backing_chain(bs, s->above_base);
51
+ bdrv_unfreeze_backing_chain(s->target_bs, s->above_base);
52
s->chain_frozen = false;
53
54
if (bdrv_cow_child(unfiltered_bs)) {
55
@@ -XXX,XX +XXX,XX @@ static void stream_clean(Job *job)
56
{
57
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
58
BlockJob *bjob = &s->common;
59
- BlockDriverState *bs = blk_bs(bjob->blk);
60
61
/* Reopen the image back in read-only mode if necessary */
62
if (s->bs_read_only) {
63
/* Give up write permissions before making it read-only */
64
blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort);
65
- bdrv_reopen_set_read_only(bs, true, NULL);
66
+ bdrv_reopen_set_read_only(s->target_bs, true, NULL);
67
}
68
69
g_free(s->backing_file_str);
70
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn stream_run(Job *job, Error **errp)
71
{
72
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
73
BlockBackend *blk = s->common.blk;
74
- BlockDriverState *bs = blk_bs(blk);
75
- BlockDriverState *unfiltered_bs = bdrv_skip_filters(bs);
76
+ BlockDriverState *unfiltered_bs = bdrv_skip_filters(s->target_bs);
77
bool enable_cor = !bdrv_cow_child(s->base_overlay);
78
int64_t len;
79
int64_t offset = 0;
80
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn stream_run(Job *job, Error **errp)
30
return 0;
81
return 0;
31
}
82
}
32
83
33
- /* If the bucket is full then we have to wait */
84
- len = bdrv_getlength(bs);
34
- extra = bkt->level - bkt->max * bkt->burst_length;
85
+ len = bdrv_getlength(s->target_bs);
35
+ if (!bkt->max) {
86
if (len < 0) {
36
+ /* If bkt->max is 0 we still want to allow short bursts of I/O
87
return len;
37
+ * from the guest, otherwise every other request will be throttled
38
+ * and performance will suffer considerably. */
39
+ bucket_size = bkt->avg / 10;
40
+ burst_bucket_size = 0;
41
+ } else {
42
+ /* If we have a burst limit then we have to wait until all I/O
43
+ * at burst rate has finished before throttling to bkt->avg */
44
+ bucket_size = bkt->max * bkt->burst_length;
45
+ burst_bucket_size = bkt->max / 10;
46
+ }
47
+
48
+ /* If the main bucket is full then we have to wait */
49
+ extra = bkt->level - bucket_size;
50
if (extra > 0) {
51
return throttle_do_compute_wait(bkt->avg, extra);
52
}
88
}
53
89
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn stream_run(Job *job, Error **errp)
54
- /* If the bucket is not full yet we have to make sure that we
90
* account.
55
- * fulfill the goal of bkt->max units per second. */
91
*/
56
+ /* If the main bucket is not full yet we still have to check the
92
if (enable_cor) {
57
+ * burst bucket in order to enforce the burst limit */
93
- bdrv_enable_copy_on_read(bs);
58
if (bkt->burst_length > 1) {
94
+ bdrv_enable_copy_on_read(s->target_bs);
59
- /* We use 1/10 of the max value to smooth the throttling.
60
- * See throttle_fix_bucket() for more details. */
61
- extra = bkt->burst_level - bkt->max / 10;
62
+ extra = bkt->burst_level - burst_bucket_size;
63
if (extra > 0) {
64
return throttle_do_compute_wait(bkt->max, extra);
65
}
66
@@ -XXX,XX +XXX,XX @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **errp)
67
return true;
68
}
69
70
-/* fix bucket parameters */
71
-static void throttle_fix_bucket(LeakyBucket *bkt)
72
-{
73
- double min;
74
-
75
- /* zero bucket level */
76
- bkt->level = bkt->burst_level = 0;
77
-
78
- /* If bkt->max is 0 we still want to allow short bursts of I/O
79
- * from the guest, otherwise every other request will be throttled
80
- * and performance will suffer considerably. */
81
- min = bkt->avg / 10;
82
- if (bkt->avg && !bkt->max) {
83
- bkt->max = min;
84
- }
85
-}
86
-
87
-/* undo internal bucket parameter changes (see throttle_fix_bucket()) */
88
-static void throttle_unfix_bucket(LeakyBucket *bkt)
89
-{
90
- if (bkt->max < bkt->avg) {
91
- bkt->max = 0;
92
- }
93
-}
94
-
95
/* Used to configure the throttle
96
*
97
* @ts: the throttle state we are working on
98
@@ -XXX,XX +XXX,XX @@ void throttle_config(ThrottleState *ts,
99
100
ts->cfg = *cfg;
101
102
+ /* Zero bucket level */
103
for (i = 0; i < BUCKETS_COUNT; i++) {
104
- throttle_fix_bucket(&ts->cfg.buckets[i]);
105
+ ts->cfg.buckets[i].level = 0;
106
+ ts->cfg.buckets[i].burst_level = 0;
107
}
95
}
108
96
109
ts->previous_leak = qemu_clock_get_ns(clock_type);
97
for ( ; offset < len; offset += n) {
110
@@ -XXX,XX +XXX,XX @@ void throttle_config(ThrottleState *ts,
98
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn stream_run(Job *job, Error **errp)
111
*/
99
}
112
void throttle_get_config(ThrottleState *ts, ThrottleConfig *cfg)
100
113
{
101
if (enable_cor) {
114
- int i;
102
- bdrv_disable_copy_on_read(bs);
115
-
103
+ bdrv_disable_copy_on_read(s->target_bs);
116
*cfg = ts->cfg;
104
}
117
-
105
118
- for (i = 0; i < BUCKETS_COUNT; i++) {
106
/* Do not remove the backing file if an error was there but ignored. */
119
- throttle_unfix_bucket(&cfg->buckets[i]);
107
@@ -XXX,XX +XXX,XX @@ void stream_start(const char *job_id, BlockDriverState *bs,
120
- }
108
s->base_overlay = base_overlay;
121
}
109
s->above_base = above_base;
122
110
s->backing_file_str = g_strdup(backing_file_str);
111
+ s->target_bs = bs;
112
s->bs_read_only = bs_read_only;
113
s->chain_frozen = true;
123
114
124
--
115
--
125
2.13.5
116
2.29.2
126
117
127
118
diff view generated by jsdifflib
New patch
1
1
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
2
3
This patch completes the series with the COR-filter applied to
4
block-stream operations.
5
6
Adding the filter makes it possible in future implement discarding
7
copied regions in backing files during the block-stream job, to reduce
8
the disk overuse (we need control on permissions).
9
10
Also, the filter now is smart enough to do copy-on-read with specified
11
base, so we have benefit on guest reads even when doing block-stream of
12
the part of the backing chain.
13
14
Several iotests are slightly modified due to filter insertion.
15
16
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
17
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
18
Message-Id: <20201216061703.70908-14-vsementsov@virtuozzo.com>
19
Reviewed-by: Max Reitz <mreitz@redhat.com>
20
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
---
22
block/stream.c | 105 ++++++++++++++++++++++---------------
23
tests/qemu-iotests/030 | 8 +--
24
tests/qemu-iotests/141.out | 2 +-
25
tests/qemu-iotests/245 | 20 ++++---
26
4 files changed, 80 insertions(+), 55 deletions(-)
27
28
diff --git a/block/stream.c b/block/stream.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/block/stream.c
31
+++ b/block/stream.c
32
@@ -XXX,XX +XXX,XX @@
33
#include "block/blockjob_int.h"
34
#include "qapi/error.h"
35
#include "qapi/qmp/qerror.h"
36
+#include "qapi/qmp/qdict.h"
37
#include "qemu/ratelimit.h"
38
#include "sysemu/block-backend.h"
39
+#include "block/copy-on-read.h"
40
41
enum {
42
/*
43
@@ -XXX,XX +XXX,XX @@ typedef struct StreamBlockJob {
44
BlockJob common;
45
BlockDriverState *base_overlay; /* COW overlay (stream from this) */
46
BlockDriverState *above_base; /* Node directly above the base */
47
+ BlockDriverState *cor_filter_bs;
48
BlockDriverState *target_bs;
49
BlockdevOnError on_error;
50
char *backing_file_str;
51
bool bs_read_only;
52
- bool chain_frozen;
53
} StreamBlockJob;
54
55
static int coroutine_fn stream_populate(BlockBackend *blk,
56
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn stream_populate(BlockBackend *blk,
57
{
58
assert(bytes < SIZE_MAX);
59
60
- return blk_co_preadv(blk, offset, bytes, NULL,
61
- BDRV_REQ_COPY_ON_READ | BDRV_REQ_PREFETCH);
62
-}
63
-
64
-static void stream_abort(Job *job)
65
-{
66
- StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
67
-
68
- if (s->chain_frozen) {
69
- bdrv_unfreeze_backing_chain(s->target_bs, s->above_base);
70
- }
71
+ return blk_co_preadv(blk, offset, bytes, NULL, BDRV_REQ_PREFETCH);
72
}
73
74
static int stream_prepare(Job *job)
75
@@ -XXX,XX +XXX,XX @@ static int stream_prepare(Job *job)
76
Error *local_err = NULL;
77
int ret = 0;
78
79
- bdrv_unfreeze_backing_chain(s->target_bs, s->above_base);
80
- s->chain_frozen = false;
81
+ /* We should drop filter at this point, as filter hold the backing chain */
82
+ bdrv_cor_filter_drop(s->cor_filter_bs);
83
+ s->cor_filter_bs = NULL;
84
85
if (bdrv_cow_child(unfiltered_bs)) {
86
const char *base_id = NULL, *base_fmt = NULL;
87
@@ -XXX,XX +XXX,XX @@ static void stream_clean(Job *job)
88
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
89
BlockJob *bjob = &s->common;
90
91
+ if (s->cor_filter_bs) {
92
+ bdrv_cor_filter_drop(s->cor_filter_bs);
93
+ s->cor_filter_bs = NULL;
94
+ }
95
+
96
/* Reopen the image back in read-only mode if necessary */
97
if (s->bs_read_only) {
98
/* Give up write permissions before making it read-only */
99
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn stream_run(Job *job, Error **errp)
100
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
101
BlockBackend *blk = s->common.blk;
102
BlockDriverState *unfiltered_bs = bdrv_skip_filters(s->target_bs);
103
- bool enable_cor = !bdrv_cow_child(s->base_overlay);
104
int64_t len;
105
int64_t offset = 0;
106
uint64_t delay_ns = 0;
107
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn stream_run(Job *job, Error **errp)
108
}
109
job_progress_set_remaining(&s->common.job, len);
110
111
- /* Turn on copy-on-read for the whole block device so that guest read
112
- * requests help us make progress. Only do this when copying the entire
113
- * backing chain since the copy-on-read operation does not take base into
114
- * account.
115
- */
116
- if (enable_cor) {
117
- bdrv_enable_copy_on_read(s->target_bs);
118
- }
119
-
120
for ( ; offset < len; offset += n) {
121
bool copy;
122
int ret;
123
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn stream_run(Job *job, Error **errp)
124
}
125
}
126
127
- if (enable_cor) {
128
- bdrv_disable_copy_on_read(s->target_bs);
129
- }
130
-
131
/* Do not remove the backing file if an error was there but ignored. */
132
return error;
133
}
134
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver stream_job_driver = {
135
.free = block_job_free,
136
.run = stream_run,
137
.prepare = stream_prepare,
138
- .abort = stream_abort,
139
.clean = stream_clean,
140
.user_resume = block_job_user_resume,
141
},
142
@@ -XXX,XX +XXX,XX @@ void stream_start(const char *job_id, BlockDriverState *bs,
143
bool bs_read_only;
144
int basic_flags = BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED;
145
BlockDriverState *base_overlay;
146
+ BlockDriverState *cor_filter_bs = NULL;
147
BlockDriverState *above_base;
148
+ QDict *opts;
149
150
assert(!(base && bottom));
151
assert(!(backing_file_str && bottom));
152
@@ -XXX,XX +XXX,XX @@ void stream_start(const char *job_id, BlockDriverState *bs,
153
}
154
}
155
156
- if (bdrv_freeze_backing_chain(bs, above_base, errp) < 0) {
157
- return;
158
- }
159
-
160
/* Make sure that the image is opened in read-write mode */
161
bs_read_only = bdrv_is_read_only(bs);
162
if (bs_read_only) {
163
- if (bdrv_reopen_set_read_only(bs, false, errp) != 0) {
164
- bs_read_only = false;
165
- goto fail;
166
+ int ret;
167
+ /* Hold the chain during reopen */
168
+ if (bdrv_freeze_backing_chain(bs, above_base, errp) < 0) {
169
+ return;
170
+ }
171
+
172
+ ret = bdrv_reopen_set_read_only(bs, false, errp);
173
+
174
+ /* failure, or cor-filter will hold the chain */
175
+ bdrv_unfreeze_backing_chain(bs, above_base);
176
+
177
+ if (ret < 0) {
178
+ return;
179
}
180
}
181
182
- /* Prevent concurrent jobs trying to modify the graph structure here, we
183
- * already have our own plans. Also don't allow resize as the image size is
184
- * queried only at the job start and then cached. */
185
- s = block_job_create(job_id, &stream_job_driver, NULL, bs,
186
- basic_flags | BLK_PERM_GRAPH_MOD,
187
+ opts = qdict_new();
188
+
189
+ qdict_put_str(opts, "driver", "copy-on-read");
190
+ qdict_put_str(opts, "file", bdrv_get_node_name(bs));
191
+ /* Pass the base_overlay node name as 'bottom' to COR driver */
192
+ qdict_put_str(opts, "bottom", base_overlay->node_name);
193
+ if (filter_node_name) {
194
+ qdict_put_str(opts, "node-name", filter_node_name);
195
+ }
196
+
197
+ cor_filter_bs = bdrv_insert_node(bs, opts, BDRV_O_RDWR, errp);
198
+ if (!cor_filter_bs) {
199
+ goto fail;
200
+ }
201
+
202
+ if (!filter_node_name) {
203
+ cor_filter_bs->implicit = true;
204
+ }
205
+
206
+ s = block_job_create(job_id, &stream_job_driver, NULL, cor_filter_bs,
207
+ BLK_PERM_CONSISTENT_READ,
208
basic_flags | BLK_PERM_WRITE,
209
speed, creation_flags, NULL, NULL, errp);
210
if (!s) {
211
goto fail;
212
}
213
214
+ /*
215
+ * Prevent concurrent jobs trying to modify the graph structure here, we
216
+ * already have our own plans. Also don't allow resize as the image size is
217
+ * queried only at the job start and then cached.
218
+ */
219
+ if (block_job_add_bdrv(&s->common, "active node", bs, 0,
220
+ basic_flags | BLK_PERM_WRITE, &error_abort)) {
221
+ goto fail;
222
+ }
223
+
224
/* Block all intermediate nodes between bs and base, because they will
225
* disappear from the chain after this operation. The streaming job reads
226
* every block only once, assuming that it doesn't change, so forbid writes
227
@@ -XXX,XX +XXX,XX @@ void stream_start(const char *job_id, BlockDriverState *bs,
228
s->base_overlay = base_overlay;
229
s->above_base = above_base;
230
s->backing_file_str = g_strdup(backing_file_str);
231
+ s->cor_filter_bs = cor_filter_bs;
232
s->target_bs = bs;
233
s->bs_read_only = bs_read_only;
234
- s->chain_frozen = true;
235
236
s->on_error = on_error;
237
trace_stream_start(bs, base, s);
238
@@ -XXX,XX +XXX,XX @@ void stream_start(const char *job_id, BlockDriverState *bs,
239
return;
240
241
fail:
242
+ if (cor_filter_bs) {
243
+ bdrv_cor_filter_drop(cor_filter_bs);
244
+ }
245
if (bs_read_only) {
246
bdrv_reopen_set_read_only(bs, true, NULL);
247
}
248
- bdrv_unfreeze_backing_chain(bs, above_base);
249
}
250
diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
251
index XXXXXXX..XXXXXXX 100755
252
--- a/tests/qemu-iotests/030
253
+++ b/tests/qemu-iotests/030
254
@@ -XXX,XX +XXX,XX @@ class TestParallelOps(iotests.QMPTestCase):
255
self.assert_no_active_block_jobs()
256
257
# Set a speed limit to make sure that this job blocks the rest
258
- result = self.vm.qmp('block-stream', device='node4', job_id='stream-node4', base=self.imgs[1], speed=1024*1024)
259
+ result = self.vm.qmp('block-stream', device='node4',
260
+ job_id='stream-node4', base=self.imgs[1],
261
+ filter_node_name='stream-filter', speed=1024*1024)
262
self.assert_qmp(result, 'return', {})
263
264
result = self.vm.qmp('block-stream', device='node5', job_id='stream-node5', base=self.imgs[2])
265
self.assert_qmp(result, 'error/desc',
266
- "Node 'node4' is busy: block device is in use by block job: stream")
267
+ "Node 'stream-filter' is busy: block device is in use by block job: stream")
268
269
result = self.vm.qmp('block-stream', device='node3', job_id='stream-node3', base=self.imgs[2])
270
self.assert_qmp(result, 'error/desc',
271
@@ -XXX,XX +XXX,XX @@ class TestParallelOps(iotests.QMPTestCase):
272
# block-commit should also fail if it touches nodes used by the stream job
273
result = self.vm.qmp('block-commit', device='drive0', base=self.imgs[4], job_id='commit-node4')
274
self.assert_qmp(result, 'error/desc',
275
- "Node 'node4' is busy: block device is in use by block job: stream")
276
+ "Node 'stream-filter' is busy: block device is in use by block job: stream")
277
278
result = self.vm.qmp('block-commit', device='drive0', base=self.imgs[1], top=self.imgs[3], job_id='commit-node1')
279
self.assert_qmp(result, 'error/desc',
280
diff --git a/tests/qemu-iotests/141.out b/tests/qemu-iotests/141.out
281
index XXXXXXX..XXXXXXX 100644
282
--- a/tests/qemu-iotests/141.out
283
+++ b/tests/qemu-iotests/141.out
284
@@ -XXX,XX +XXX,XX @@ wrote 1048576/1048576 bytes at offset 0
285
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}}
286
{'execute': 'blockdev-del',
287
'arguments': {'node-name': 'drv0'}}
288
-{"error": {"class": "GenericError", "desc": "Node drv0 is in use"}}
289
+{"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: block device is in use by block job: stream"}}
290
{'execute': 'block-job-cancel',
291
'arguments': {'device': 'job0'}}
292
{"return": {}}
293
diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245
294
index XXXXXXX..XXXXXXX 100755
295
--- a/tests/qemu-iotests/245
296
+++ b/tests/qemu-iotests/245
297
@@ -XXX,XX +XXX,XX @@ class TestBlockdevReopen(iotests.QMPTestCase):
298
299
# hd1 <- hd0
300
result = self.vm.qmp('block-stream', conv_keys = True, job_id = 'stream0',
301
- device = 'hd1', auto_finalize = False)
302
+ device = 'hd1', filter_node_name='cor',
303
+ auto_finalize = False)
304
self.assert_qmp(result, 'return', {})
305
306
- # We can't reopen with the original options because that would
307
- # make hd1 read-only and block-stream requires it to be read-write
308
- # (Which error message appears depends on whether the stream job is
309
- # already done with copying at this point.)
310
+ # We can't reopen with the original options because there is a filter
311
+ # inserted by stream job above hd1.
312
self.reopen(opts, {},
313
- ["Can't set node 'hd1' to r/o with copy-on-read enabled",
314
- "Cannot make block node read-only, there is a writer on it"])
315
+ "Cannot change the option 'backing.backing.file.node-name'")
316
+
317
+ # We can't reopen hd1 to read-only, as block-stream requires it to be
318
+ # read-write
319
+ self.reopen(opts['backing'], {'read-only': True},
320
+ "Cannot make block node read-only, there is a writer on it")
321
322
# We can't remove hd2 while the stream job is ongoing
323
opts['backing']['backing'] = None
324
- self.reopen(opts, {'backing.read-only': False}, "Cannot change 'backing' link from 'hd1' to 'hd2'")
325
+ self.reopen(opts['backing'], {'read-only': False},
326
+ "Cannot change 'backing' link from 'hd1' to 'hd2'")
327
328
# We can detach hd1 from hd0 because it doesn't affect the stream job
329
opts['backing'] = None
330
--
331
2.29.2
332
333
diff view generated by jsdifflib
New patch
1
There are a couple of environment variables that we fetch with
2
os.environ.get() without supplying a default. Clearly they are required
3
and expected to be set by the ./check script (as evidenced by
4
execute_setup_common(), which checks for test_dir and
5
qemu_default_machine to be set, and aborts if they are not).
1
6
7
Using .get() this way has the disadvantage of returning an Optional[str]
8
type, which mypy will complain about when tests just assume these values
9
to be str.
10
11
Use [] instead, which raises a KeyError for environment variables that
12
are not set. When this exception is raised, catch it and move the abort
13
code from execute_setup_common() there.
14
15
Drop the 'assert iotests.sock_dir is not None' from iotest 300, because
16
that sort of thing is precisely what this patch wants to prevent.
17
18
Signed-off-by: Max Reitz <mreitz@redhat.com>
19
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
20
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
21
Message-Id: <20210118105720.14824-2-mreitz@redhat.com>
22
---
23
tests/qemu-iotests/300 | 1 -
24
tests/qemu-iotests/iotests.py | 26 +++++++++++++-------------
25
2 files changed, 13 insertions(+), 14 deletions(-)
26
27
diff --git a/tests/qemu-iotests/300 b/tests/qemu-iotests/300
28
index XXXXXXX..XXXXXXX 100755
29
--- a/tests/qemu-iotests/300
30
+++ b/tests/qemu-iotests/300
31
@@ -XXX,XX +XXX,XX @@ import qemu
32
33
BlockBitmapMapping = List[Dict[str, Union[str, List[Dict[str, str]]]]]
34
35
-assert iotests.sock_dir is not None
36
mig_sock = os.path.join(iotests.sock_dir, 'mig_sock')
37
38
39
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
40
index XXXXXXX..XXXXXXX 100644
41
--- a/tests/qemu-iotests/iotests.py
42
+++ b/tests/qemu-iotests/iotests.py
43
@@ -XXX,XX +XXX,XX @@ qemu_opts = os.environ.get('QEMU_OPTIONS', '').strip().split(' ')
44
45
imgfmt = os.environ.get('IMGFMT', 'raw')
46
imgproto = os.environ.get('IMGPROTO', 'file')
47
-test_dir = os.environ.get('TEST_DIR')
48
-sock_dir = os.environ.get('SOCK_DIR')
49
output_dir = os.environ.get('OUTPUT_DIR', '.')
50
-cachemode = os.environ.get('CACHEMODE')
51
-aiomode = os.environ.get('AIOMODE')
52
-qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE')
53
+
54
+try:
55
+ test_dir = os.environ['TEST_DIR']
56
+ sock_dir = os.environ['SOCK_DIR']
57
+ cachemode = os.environ['CACHEMODE']
58
+ aiomode = os.environ['AIOMODE']
59
+ qemu_default_machine = os.environ['QEMU_DEFAULT_MACHINE']
60
+except KeyError:
61
+ # We are using these variables as proxies to indicate that we're
62
+ # not being run via "check". There may be other things set up by
63
+ # "check" that individual test cases rely on.
64
+ sys.stderr.write('Please run this test via the "check" script\n')
65
+ sys.exit(os.EX_USAGE)
66
67
socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper')
68
69
@@ -XXX,XX +XXX,XX @@ def execute_setup_common(supported_fmts: Sequence[str] = (),
70
"""
71
# Note: Python 3.6 and pylint do not like 'Collection' so use 'Sequence'.
72
73
- # We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to
74
- # indicate that we're not being run via "check". There may be
75
- # other things set up by "check" that individual test cases rely
76
- # on.
77
- if test_dir is None or qemu_default_machine is None:
78
- sys.stderr.write('Please run this test via the "check" script\n')
79
- sys.exit(os.EX_USAGE)
80
-
81
debug = '-d' in sys.argv
82
if debug:
83
sys.argv.remove('-d')
84
--
85
2.29.2
86
87
diff view generated by jsdifflib
New patch
1
Instead of checking iotests.py only, check all Python files in the
2
qemu-iotests/ directory. Of course, most of them do not pass, so there
3
is an extensive skip list for now. (The only files that do pass are
4
209, 254, 283, and iotests.py.)
1
5
6
(Alternatively, we could have the opposite, i.e. an explicit list of
7
files that we do want to check, but I think it is better to check files
8
by default.)
9
10
Unless started in debug mode (./check -d), the output has no information
11
on which files are tested, so we will not have a problem e.g. with
12
backports, where some files may be missing when compared to upstream.
13
14
Besides the technical rewrite, some more things are changed:
15
16
- For the pylint invocation, PYTHONPATH is adjusted. This mirrors
17
setting MYPYPATH for mypy.
18
19
- Also, MYPYPATH is now derived from PYTHONPATH, so that we include
20
paths set by the environment. Maybe at some point we want to let the
21
check script add '../../python/' to PYTHONPATH so that iotests.py does
22
not need to do that.
23
24
- Passing --notes=FIXME,XXX to pylint suppresses warnings for TODO
25
comments. TODO is fine, we do not need 297 to complain about such
26
comments.
27
28
- The "Success" line from mypy's output is suppressed, because (A) it
29
does not add useful information, and (B) it would leak information
30
about the files having been tested to the reference output, which we
31
decidedly do not want.
32
33
Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
34
Signed-off-by: Max Reitz <mreitz@redhat.com>
35
Message-Id: <20210118105720.14824-3-mreitz@redhat.com>
36
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
37
---
38
tests/qemu-iotests/297 | 112 +++++++++++++++++++++++++++++--------
39
tests/qemu-iotests/297.out | 5 +-
40
2 files changed, 92 insertions(+), 25 deletions(-)
41
42
diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297
43
index XXXXXXX..XXXXXXX 100755
44
--- a/tests/qemu-iotests/297
45
+++ b/tests/qemu-iotests/297
46
@@ -XXX,XX +XXX,XX @@
47
-#!/usr/bin/env bash
48
+#!/usr/bin/env python3
49
# group: meta
50
#
51
# Copyright (C) 2020 Red Hat, Inc.
52
@@ -XXX,XX +XXX,XX @@
53
# You should have received a copy of the GNU General Public License
54
# along with this program. If not, see <http://www.gnu.org/licenses/>.
55
56
-seq=$(basename $0)
57
-echo "QA output created by $seq"
58
+import os
59
+import re
60
+import shutil
61
+import subprocess
62
+import sys
63
64
-status=1    # failure is the default!
65
+import iotests
66
67
-# get standard environment
68
-. ./common.rc
69
70
-if ! type -p "pylint-3" > /dev/null; then
71
- _notrun "pylint-3 not found"
72
-fi
73
-if ! type -p "mypy" > /dev/null; then
74
- _notrun "mypy not found"
75
-fi
76
+# TODO: Empty this list!
77
+SKIP_FILES = (
78
+ '030', '040', '041', '044', '045', '055', '056', '057', '065', '093',
79
+ '096', '118', '124', '129', '132', '136', '139', '147', '148', '149',
80
+ '151', '152', '155', '163', '165', '169', '194', '196', '199', '202',
81
+ '203', '205', '206', '207', '208', '210', '211', '212', '213', '216',
82
+ '218', '219', '222', '224', '228', '234', '235', '236', '237', '238',
83
+ '240', '242', '245', '246', '248', '255', '256', '257', '258', '260',
84
+ '262', '264', '266', '274', '277', '280', '281', '295', '296', '298',
85
+ '299', '300', '302', '303', '304', '307',
86
+ 'nbd-fault-injector.py', 'qcow2.py', 'qcow2_format.py', 'qed.py'
87
+)
88
89
-pylint-3 --score=n iotests.py
90
91
-MYPYPATH=../../python/ mypy --warn-unused-configs --disallow-subclassing-any \
92
- --disallow-any-generics --disallow-incomplete-defs \
93
- --disallow-untyped-decorators --no-implicit-optional \
94
- --warn-redundant-casts --warn-unused-ignores \
95
- --no-implicit-reexport iotests.py
96
+def is_python_file(filename):
97
+ if not os.path.isfile(filename):
98
+ return False
99
100
-# success, all done
101
-echo "*** done"
102
-rm -f $seq.full
103
-status=0
104
+ if filename.endswith('.py'):
105
+ return True
106
+
107
+ with open(filename) as f:
108
+ try:
109
+ first_line = f.readline()
110
+ return re.match('^#!.*python', first_line) is not None
111
+ except UnicodeDecodeError: # Ignore binary files
112
+ return False
113
+
114
+
115
+def run_linters():
116
+ files = [filename for filename in (set(os.listdir('.')) - set(SKIP_FILES))
117
+ if is_python_file(filename)]
118
+
119
+ iotests.logger.debug('Files to be checked:')
120
+ iotests.logger.debug(', '.join(sorted(files)))
121
+
122
+ print('=== pylint ===')
123
+ sys.stdout.flush()
124
+
125
+ # Todo notes are fine, but fixme's or xxx's should probably just be
126
+ # fixed (in tests, at least)
127
+ env = os.environ.copy()
128
+ qemu_module_path = os.path.join(os.path.dirname(__file__),
129
+ '..', '..', 'python')
130
+ try:
131
+ env['PYTHONPATH'] += os.pathsep + qemu_module_path
132
+ except KeyError:
133
+ env['PYTHONPATH'] = qemu_module_path
134
+ subprocess.run(('pylint-3', '--score=n', '--notes=FIXME,XXX', *files),
135
+ env=env, check=False)
136
+
137
+ print('=== mypy ===')
138
+ sys.stdout.flush()
139
+
140
+ # We have to call mypy separately for each file. Otherwise, it
141
+ # will interpret all given files as belonging together (i.e., they
142
+ # may not both define the same classes, etc.; most notably, they
143
+ # must not both define the __main__ module).
144
+ env['MYPYPATH'] = env['PYTHONPATH']
145
+ for filename in files:
146
+ p = subprocess.run(('mypy',
147
+ '--warn-unused-configs',
148
+ '--disallow-subclassing-any',
149
+ '--disallow-any-generics',
150
+ '--disallow-incomplete-defs',
151
+ '--disallow-untyped-decorators',
152
+ '--no-implicit-optional',
153
+ '--warn-redundant-casts',
154
+ '--warn-unused-ignores',
155
+ '--no-implicit-reexport',
156
+ filename),
157
+ env=env,
158
+ check=False,
159
+ stdout=subprocess.PIPE,
160
+ stderr=subprocess.STDOUT,
161
+ universal_newlines=True)
162
+
163
+ if p.returncode != 0:
164
+ print(p.stdout)
165
+
166
+
167
+for linter in ('pylint-3', 'mypy'):
168
+ if shutil.which(linter) is None:
169
+ iotests.notrun(f'{linter} not found')
170
+
171
+iotests.script_main(run_linters)
172
diff --git a/tests/qemu-iotests/297.out b/tests/qemu-iotests/297.out
173
index XXXXXXX..XXXXXXX 100644
174
--- a/tests/qemu-iotests/297.out
175
+++ b/tests/qemu-iotests/297.out
176
@@ -XXX,XX +XXX,XX @@
177
-QA output created by 297
178
-Success: no issues found in 1 source file
179
-*** done
180
+=== pylint ===
181
+=== mypy ===
182
--
183
2.29.2
184
185
diff view generated by jsdifflib
New patch
1
Signed-off-by: Max Reitz <mreitz@redhat.com>
2
Reviewed-by: Eric Blake <eblake@redhat.com>
3
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
4
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
5
Message-Id: <20210118105720.14824-4-mreitz@redhat.com>
6
---
7
tests/qemu-iotests/124 | 8 +-------
8
tests/qemu-iotests/iotests.py | 11 +++++++----
9
2 files changed, 8 insertions(+), 11 deletions(-)
1
10
11
diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124
12
index XXXXXXX..XXXXXXX 100755
13
--- a/tests/qemu-iotests/124
14
+++ b/tests/qemu-iotests/124
15
@@ -XXX,XX +XXX,XX @@
16
17
import os
18
import iotests
19
+from iotests import try_remove
20
21
22
def io_write_patterns(img, patterns):
23
@@ -XXX,XX +XXX,XX @@ def io_write_patterns(img, patterns):
24
iotests.qemu_io('-c', 'write -P%s %s %s' % pattern, img)
25
26
27
-def try_remove(img):
28
- try:
29
- os.remove(img)
30
- except OSError:
31
- pass
32
-
33
-
34
def transaction_action(action, **kwargs):
35
return {
36
'type': action,
37
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
38
index XXXXXXX..XXXXXXX 100644
39
--- a/tests/qemu-iotests/iotests.py
40
+++ b/tests/qemu-iotests/iotests.py
41
@@ -XXX,XX +XXX,XX @@ class FilePath:
42
return False
43
44
45
+def try_remove(img):
46
+ try:
47
+ os.remove(img)
48
+ except OSError:
49
+ pass
50
+
51
def file_path_remover():
52
for path in reversed(file_path_remover.paths):
53
- try:
54
- os.remove(path)
55
- except OSError:
56
- pass
57
+ try_remove(path)
58
59
60
def file_path(*names, base_dir=test_dir):
61
--
62
2.29.2
63
64
diff view generated by jsdifflib
New patch
1
Signed-off-by: Max Reitz <mreitz@redhat.com>
2
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
3
Reviewed-by: Eric Blake <eblake@redhat.com>
4
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
5
Message-Id: <20210118105720.14824-5-mreitz@redhat.com>
6
---
7
tests/qemu-iotests/129 | 2 ++
8
1 file changed, 2 insertions(+)
1
9
10
diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129
11
index XXXXXXX..XXXXXXX 100755
12
--- a/tests/qemu-iotests/129
13
+++ b/tests/qemu-iotests/129
14
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
15
result = self.vm.qmp("block_set_io_throttle", conv_keys=False,
16
**params)
17
self.vm.shutdown()
18
+ for img in (self.test_img, self.target_img, self.base_img):
19
+ iotests.try_remove(img)
20
21
def do_test_stop(self, cmd, **args):
22
"""Test 'stop' while block job is running on a throttled drive.
23
--
24
2.29.2
25
26
diff view generated by jsdifflib
New patch
1
@busy is false when the job is paused, which happens all the time
2
because that is how jobs yield (e.g. for mirror at least since commit
3
565ac01f8d3).
1
4
5
Back when 129 was added (2015), perhaps there was no better way of
6
checking whether the job was still actually running. Now we have the
7
@status field (as of 58b295ba52c, i.e. 2018), which can give us exactly
8
that information.
9
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
Reviewed-by: Eric Blake <eblake@redhat.com>
12
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
13
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
14
Message-Id: <20210118105720.14824-6-mreitz@redhat.com>
15
---
16
tests/qemu-iotests/129 | 2 +-
17
1 file changed, 1 insertion(+), 1 deletion(-)
18
19
diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129
20
index XXXXXXX..XXXXXXX 100755
21
--- a/tests/qemu-iotests/129
22
+++ b/tests/qemu-iotests/129
23
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
24
result = self.vm.qmp("stop")
25
self.assert_qmp(result, 'return', {})
26
result = self.vm.qmp("query-block-jobs")
27
- self.assert_qmp(result, 'return[0]/busy', True)
28
+ self.assert_qmp(result, 'return[0]/status', 'running')
29
self.assert_qmp(result, 'return[0]/ready', False)
30
31
def test_drive_mirror(self):
32
--
33
2.29.2
34
35
diff view generated by jsdifflib
New patch
1
Throttling on the BB has not affected block jobs in a while, so it is
2
possible that one of the jobs in 129 finishes before the VM is stopped.
3
We can fix that by running the job from a throttle node.
1
4
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
Reviewed-by: Eric Blake <eblake@redhat.com>
7
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
9
Message-Id: <20210118105720.14824-7-mreitz@redhat.com>
10
---
11
tests/qemu-iotests/129 | 37 +++++++++++++------------------------
12
1 file changed, 13 insertions(+), 24 deletions(-)
13
14
diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129
15
index XXXXXXX..XXXXXXX 100755
16
--- a/tests/qemu-iotests/129
17
+++ b/tests/qemu-iotests/129
18
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
19
iotests.qemu_img('create', '-f', iotests.imgfmt, self.test_img,
20
"-b", self.base_img, '-F', iotests.imgfmt)
21
iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x5d 1M 128M', self.test_img)
22
- self.vm = iotests.VM().add_drive(self.test_img)
23
+ self.vm = iotests.VM()
24
+ self.vm.add_object('throttle-group,id=tg0,x-bps-total=1024')
25
+
26
+ source_drive = 'driver=throttle,' \
27
+ 'throttle-group=tg0,' \
28
+ f'file.driver={iotests.imgfmt},' \
29
+ f'file.file.filename={self.test_img}'
30
+
31
+ self.vm.add_drive(None, source_drive)
32
self.vm.launch()
33
34
def tearDown(self):
35
- params = {"device": "drive0",
36
- "bps": 0,
37
- "bps_rd": 0,
38
- "bps_wr": 0,
39
- "iops": 0,
40
- "iops_rd": 0,
41
- "iops_wr": 0,
42
- }
43
- result = self.vm.qmp("block_set_io_throttle", conv_keys=False,
44
- **params)
45
self.vm.shutdown()
46
for img in (self.test_img, self.target_img, self.base_img):
47
iotests.try_remove(img)
48
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
49
def do_test_stop(self, cmd, **args):
50
"""Test 'stop' while block job is running on a throttled drive.
51
The 'stop' command shouldn't drain the job"""
52
- params = {"device": "drive0",
53
- "bps": 1024,
54
- "bps_rd": 0,
55
- "bps_wr": 0,
56
- "iops": 0,
57
- "iops_rd": 0,
58
- "iops_wr": 0,
59
- }
60
- result = self.vm.qmp("block_set_io_throttle", conv_keys=False,
61
- **params)
62
- self.assert_qmp(result, 'return', {})
63
result = self.vm.qmp(cmd, **args)
64
self.assert_qmp(result, 'return', {})
65
+
66
result = self.vm.qmp("stop")
67
self.assert_qmp(result, 'return', {})
68
result = self.vm.qmp("query-block-jobs")
69
+
70
self.assert_qmp(result, 'return[0]/status', 'running')
71
self.assert_qmp(result, 'return[0]/ready', False)
72
73
def test_drive_mirror(self):
74
self.do_test_stop("drive-mirror", device="drive0",
75
- target=self.target_img,
76
+ target=self.target_img, format=iotests.imgfmt,
77
sync="full")
78
79
def test_drive_backup(self):
80
self.do_test_stop("drive-backup", device="drive0",
81
- target=self.target_img,
82
+ target=self.target_img, format=iotests.imgfmt,
83
sync="full")
84
85
def test_block_commit(self):
86
--
87
2.29.2
88
89
diff view generated by jsdifflib
New patch
1
Before this patch, test_block_commit() performs an active commit, which
2
under the hood is a mirror job. If we want to test various different
3
block jobs, we should perhaps run an actual commit job instead.
1
4
5
Doing so requires adding an overlay above the source node before the
6
commit is done (and then specifying the source node as the top node for
7
the commit job).
8
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Reviewed-by: Eric Blake <eblake@redhat.com>
11
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
12
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
13
Message-Id: <20210118105720.14824-8-mreitz@redhat.com>
14
---
15
tests/qemu-iotests/129 | 27 +++++++++++++++++++++++++--
16
1 file changed, 25 insertions(+), 2 deletions(-)
17
18
diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129
19
index XXXXXXX..XXXXXXX 100755
20
--- a/tests/qemu-iotests/129
21
+++ b/tests/qemu-iotests/129
22
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
23
test_img = os.path.join(iotests.test_dir, 'test.img')
24
target_img = os.path.join(iotests.test_dir, 'target.img')
25
base_img = os.path.join(iotests.test_dir, 'base.img')
26
+ overlay_img = os.path.join(iotests.test_dir, 'overlay.img')
27
28
def setUp(self):
29
iotests.qemu_img('create', '-f', iotests.imgfmt, self.base_img, "1G")
30
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
31
self.vm.add_object('throttle-group,id=tg0,x-bps-total=1024')
32
33
source_drive = 'driver=throttle,' \
34
+ 'node-name=source,' \
35
'throttle-group=tg0,' \
36
f'file.driver={iotests.imgfmt},' \
37
f'file.file.filename={self.test_img}'
38
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
39
40
def tearDown(self):
41
self.vm.shutdown()
42
- for img in (self.test_img, self.target_img, self.base_img):
43
+ for img in (self.test_img, self.target_img, self.base_img,
44
+ self.overlay_img):
45
iotests.try_remove(img)
46
47
def do_test_stop(self, cmd, **args):
48
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
49
sync="full")
50
51
def test_block_commit(self):
52
- self.do_test_stop("block-commit", device="drive0")
53
+ # Add overlay above the source node so that we actually use a
54
+ # commit job instead of a mirror job
55
+
56
+ iotests.qemu_img('create', '-f', iotests.imgfmt, self.overlay_img,
57
+ '1G')
58
+
59
+ result = self.vm.qmp('blockdev-add', **{
60
+ 'node-name': 'overlay',
61
+ 'driver': iotests.imgfmt,
62
+ 'file': {
63
+ 'driver': 'file',
64
+ 'filename': self.overlay_img
65
+ }
66
+ })
67
+ self.assert_qmp(result, 'return', {})
68
+
69
+ result = self.vm.qmp('blockdev-snapshot',
70
+ node='source', overlay='overlay')
71
+ self.assert_qmp(result, 'return', {})
72
+
73
+ self.do_test_stop('block-commit', device='drive0', top_node='source')
74
75
if __name__ == '__main__':
76
iotests.main(supported_fmts=["qcow2"],
77
--
78
2.29.2
79
80
diff view generated by jsdifflib
New patch
1
Issuing 'stop' on the VM drains all nodes. If the mirror job has many
2
large requests in flight, this may lead to significant I/O that looks a
3
bit like 'stop' would make the job try to complete (which is what 129
4
should verify not to happen).
1
5
6
We can limit the I/O in flight by limiting the buffer size, so mirror
7
will make very little progress during the 'stop' drain.
8
9
(We do not need to do anything about commit, which has a buffer size of
10
512 kB by default; or backup, which goes cluster by cluster. Once we
11
have asynchronous requests for backup, that will change, but then we can
12
fine-tune the backup job to only perform a single request on a very
13
small chunk, too.)
14
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
16
Reviewed-by: Eric Blake <eblake@redhat.com>
17
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
18
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
19
Message-Id: <20210118105720.14824-9-mreitz@redhat.com>
20
---
21
tests/qemu-iotests/129 | 2 +-
22
1 file changed, 1 insertion(+), 1 deletion(-)
23
24
diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129
25
index XXXXXXX..XXXXXXX 100755
26
--- a/tests/qemu-iotests/129
27
+++ b/tests/qemu-iotests/129
28
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
29
def test_drive_mirror(self):
30
self.do_test_stop("drive-mirror", device="drive0",
31
target=self.target_img, format=iotests.imgfmt,
32
- sync="full")
33
+ sync="full", buf_size=65536)
34
35
def test_drive_backup(self):
36
self.do_test_stop("drive-backup", device="drive0",
37
--
38
2.29.2
39
40
diff view generated by jsdifflib
1
Add the scripts/ directory to sys.path so Python 2.6 will be able to
1
And consequentially drop it from 297's skip list.
2
import argparse.
3
2
4
Cc: Fam Zheng <famz@redhat.com>
3
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
6
Acked-by: John Snow <jsnow@redhat.com>
5
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7
Acked-by: Fam Zheng <famz@redhat.com>
6
Message-Id: <20210118105720.14824-10-mreitz@redhat.com>
8
Message-id: 20170825155732.15665-3-stefanha@redhat.com
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
---
7
---
11
tests/docker/docker.py | 4 +++-
8
tests/qemu-iotests/129 | 4 ++--
12
1 file changed, 3 insertions(+), 1 deletion(-)
9
tests/qemu-iotests/297 | 2 +-
10
2 files changed, 3 insertions(+), 3 deletions(-)
13
11
14
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
12
diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129
15
index XXXXXXX..XXXXXXX 100755
13
index XXXXXXX..XXXXXXX 100755
16
--- a/tests/docker/docker.py
14
--- a/tests/qemu-iotests/129
17
+++ b/tests/docker/docker.py
15
+++ b/tests/qemu-iotests/129
18
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@
19
17
20
import os
18
import os
21
import sys
19
import iotests
22
+sys.path.append(os.path.join(os.path.dirname(__file__),
20
-import time
23
+ '..', '..', 'scripts'))
21
24
+import argparse
22
class TestStopWithBlockJob(iotests.QMPTestCase):
25
import subprocess
23
test_img = os.path.join(iotests.test_dir, 'test.img')
26
import json
24
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
27
import hashlib
25
iotests.qemu_img('create', '-f', iotests.imgfmt, self.base_img, "1G")
28
import atexit
26
iotests.qemu_img('create', '-f', iotests.imgfmt, self.test_img,
29
import uuid
27
"-b", self.base_img, '-F', iotests.imgfmt)
30
-import argparse
28
- iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x5d 1M 128M', self.test_img)
31
import tempfile
29
+ iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x5d 1M 128M',
32
import re
30
+ self.test_img)
33
import signal
31
self.vm = iotests.VM()
32
self.vm.add_object('throttle-group,id=tg0,x-bps-total=1024')
33
34
diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297
35
index XXXXXXX..XXXXXXX 100755
36
--- a/tests/qemu-iotests/297
37
+++ b/tests/qemu-iotests/297
38
@@ -XXX,XX +XXX,XX @@ import iotests
39
# TODO: Empty this list!
40
SKIP_FILES = (
41
'030', '040', '041', '044', '045', '055', '056', '057', '065', '093',
42
- '096', '118', '124', '129', '132', '136', '139', '147', '148', '149',
43
+ '096', '118', '124', '132', '136', '139', '147', '148', '149',
44
'151', '152', '155', '163', '165', '169', '194', '196', '199', '202',
45
'203', '205', '206', '207', '208', '210', '211', '212', '213', '216',
46
'218', '219', '222', '224', '228', '234', '235', '236', '237', '238',
34
--
47
--
35
2.13.5
48
2.29.2
36
49
37
50
diff view generated by jsdifflib
New patch
1
And consequentially drop it from 297's skip list.
1
2
3
Signed-off-by: Max Reitz <mreitz@redhat.com>
4
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
5
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
6
Message-Id: <20210118105720.14824-11-mreitz@redhat.com>
7
---
8
tests/qemu-iotests/297 | 2 +-
9
tests/qemu-iotests/300 | 18 +++++++++++++++---
10
2 files changed, 16 insertions(+), 4 deletions(-)
11
12
diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297
13
index XXXXXXX..XXXXXXX 100755
14
--- a/tests/qemu-iotests/297
15
+++ b/tests/qemu-iotests/297
16
@@ -XXX,XX +XXX,XX @@ SKIP_FILES = (
17
'218', '219', '222', '224', '228', '234', '235', '236', '237', '238',
18
'240', '242', '245', '246', '248', '255', '256', '257', '258', '260',
19
'262', '264', '266', '274', '277', '280', '281', '295', '296', '298',
20
- '299', '300', '302', '303', '304', '307',
21
+ '299', '302', '303', '304', '307',
22
'nbd-fault-injector.py', 'qcow2.py', 'qcow2_format.py', 'qed.py'
23
)
24
25
diff --git a/tests/qemu-iotests/300 b/tests/qemu-iotests/300
26
index XXXXXXX..XXXXXXX 100755
27
--- a/tests/qemu-iotests/300
28
+++ b/tests/qemu-iotests/300
29
@@ -XXX,XX +XXX,XX @@ import os
30
import random
31
import re
32
from typing import Dict, List, Optional, Union
33
+
34
import iotests
35
+
36
+# Import qemu after iotests.py has amended sys.path
37
+# pylint: disable=wrong-import-order
38
import qemu
39
40
BlockBitmapMapping = List[Dict[str, Union[str, List[Dict[str, str]]]]]
41
@@ -XXX,XX +XXX,XX @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
42
If @msg is None, check that there has not been any error.
43
"""
44
self.vm_b.shutdown()
45
+
46
+ log = self.vm_b.get_log()
47
+ assert log is not None # Loaded after shutdown
48
+
49
if msg is None:
50
- self.assertNotIn('qemu-system-', self.vm_b.get_log())
51
+ self.assertNotIn('qemu-system-', log)
52
else:
53
- self.assertIn(msg, self.vm_b.get_log())
54
+ self.assertIn(msg, log)
55
56
@staticmethod
57
def mapping(node_name: str, node_alias: str,
58
@@ -XXX,XX +XXX,XX @@ class TestBlockBitmapMappingErrors(TestDirtyBitmapMigration):
59
60
# Check for the error in the source's log
61
self.vm_a.shutdown()
62
+
63
+ log = self.vm_a.get_log()
64
+ assert log is not None # Loaded after shutdown
65
+
66
self.assertIn(f"Cannot migrate bitmap '{name}' on node "
67
f"'{self.src_node_name}': Name is longer than 255 bytes",
68
- self.vm_a.get_log())
69
+ log)
70
71
# Expect abnormal shutdown of the destination VM because of
72
# the failed migration
73
--
74
2.29.2
75
76
diff view generated by jsdifflib
New patch
1
Disposition (action) for any given signal is global for the process.
2
When two threads run coroutine-sigaltstack's qemu_coroutine_new()
3
concurrently, they may interfere with each other: One of them may revert
4
the SIGUSR2 handler to SIG_DFL, between the other thread (a) setting up
5
coroutine_trampoline() as the handler and (b) raising SIGUSR2. That
6
SIGUSR2 will then terminate the QEMU process abnormally.
1
7
8
We have to ensure that only one thread at a time can modify the
9
process-global SIGUSR2 handler. To do so, wrap the whole section where
10
that is done in a mutex.
11
12
Alternatively, we could for example have the SIGUSR2 handler always be
13
coroutine_trampoline(), so there would be no need to invoke sigaction()
14
in qemu_coroutine_new(). Laszlo has posted a patch to do so here:
15
16
https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg05962.html
17
18
However, given that coroutine-sigaltstack is more of a fallback
19
implementation for platforms that do not support ucontext, that change
20
may be a bit too invasive to be comfortable with it. The mutex proposed
21
here may negatively impact performance, but the change is much simpler.
22
23
Signed-off-by: Max Reitz <mreitz@redhat.com>
24
Message-Id: <20210125120305.19520-1-mreitz@redhat.com>
25
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
26
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
27
---
28
util/coroutine-sigaltstack.c | 9 +++++++++
29
1 file changed, 9 insertions(+)
30
31
diff --git a/util/coroutine-sigaltstack.c b/util/coroutine-sigaltstack.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/util/coroutine-sigaltstack.c
34
+++ b/util/coroutine-sigaltstack.c
35
@@ -XXX,XX +XXX,XX @@ Coroutine *qemu_coroutine_new(void)
36
sigset_t sigs;
37
sigset_t osigs;
38
sigjmp_buf old_env;
39
+ static pthread_mutex_t sigusr2_mutex = PTHREAD_MUTEX_INITIALIZER;
40
41
/* The way to manipulate stack is with the sigaltstack function. We
42
* prepare a stack, with it delivering a signal to ourselves and then
43
@@ -XXX,XX +XXX,XX @@ Coroutine *qemu_coroutine_new(void)
44
sa.sa_handler = coroutine_trampoline;
45
sigfillset(&sa.sa_mask);
46
sa.sa_flags = SA_ONSTACK;
47
+
48
+ /*
49
+ * sigaction() is a process-global operation. We must not run
50
+ * this code in multiple threads at once.
51
+ */
52
+ pthread_mutex_lock(&sigusr2_mutex);
53
if (sigaction(SIGUSR2, &sa, &osa) != 0) {
54
abort();
55
}
56
@@ -XXX,XX +XXX,XX @@ Coroutine *qemu_coroutine_new(void)
57
* Restore the old SIGUSR2 signal handler and mask
58
*/
59
sigaction(SIGUSR2, &osa, NULL);
60
+ pthread_mutex_unlock(&sigusr2_mutex);
61
+
62
pthread_sigmask(SIG_SETMASK, &osigs, NULL);
63
64
/*
65
--
66
2.29.2
67
68
diff view generated by jsdifflib
New patch
1
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
3
Experiments show, that copy_range is not always making things faster.
4
So, to make experimentation simpler, let's add a parameter. Some more
5
perf parameters will be added soon, so here is a new struct.
6
7
For now, add new backup qmp parameter with x- prefix for the following
8
reasons:
9
10
- We are going to add more performance parameters, some will be
11
related to the whole block-copy process, some only to background
12
copying in backup (ignored for copy-before-write operations).
13
- On the other hand, we are going to use block-copy interface in other
14
block jobs, which will need performance options as well.. And it
15
should be the same structure or at least somehow related.
16
17
So, there are too much unclean things about how the interface and now
18
we need the new options mostly for testing. Let's keep them
19
experimental for a while.
20
21
In do_backup_common() new x-perf parameter handled in a way to
22
make further options addition simpler.
23
24
We add use-copy-range with default=true, and we'll change the default
25
in further patch, after moving backup to use block-copy.
26
27
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
28
Reviewed-by: Max Reitz <mreitz@redhat.com>
29
Message-Id: <20210116214705.822267-2-vsementsov@virtuozzo.com>
30
[mreitz: s/5\.2/6.0/]
31
Signed-off-by: Max Reitz <mreitz@redhat.com>
32
---
33
qapi/block-core.json | 17 ++++++++++++++++-
34
block/backup-top.h | 1 +
35
include/block/block-copy.h | 2 +-
36
include/block/block_int.h | 3 +++
37
block/backup-top.c | 4 +++-
38
block/backup.c | 6 +++++-
39
block/block-copy.c | 4 ++--
40
block/replication.c | 2 ++
41
blockdev.c | 8 ++++++++
42
9 files changed, 41 insertions(+), 6 deletions(-)
43
44
diff --git a/qapi/block-core.json b/qapi/block-core.json
45
index XXXXXXX..XXXXXXX 100644
46
--- a/qapi/block-core.json
47
+++ b/qapi/block-core.json
48
@@ -XXX,XX +XXX,XX @@
49
{ 'struct': 'BlockdevSnapshot',
50
'data': { 'node': 'str', 'overlay': 'str' } }
51
52
+##
53
+# @BackupPerf:
54
+#
55
+# Optional parameters for backup. These parameters don't affect
56
+# functionality, but may significantly affect performance.
57
+#
58
+# @use-copy-range: Use copy offloading. Default true.
59
+#
60
+# Since: 6.0
61
+##
62
+{ 'struct': 'BackupPerf',
63
+ 'data': { '*use-copy-range': 'bool' }}
64
+
65
##
66
# @BackupCommon:
67
#
68
@@ -XXX,XX +XXX,XX @@
69
# above node specified by @drive. If this option is not given,
70
# a node name is autogenerated. (Since: 4.2)
71
#
72
+# @x-perf: Performance options. (Since 6.0)
73
+#
74
# Note: @on-source-error and @on-target-error only affect background
75
# I/O. If an error occurs during a guest write request, the device's
76
# rerror/werror actions will be used.
77
@@ -XXX,XX +XXX,XX @@
78
'*on-source-error': 'BlockdevOnError',
79
'*on-target-error': 'BlockdevOnError',
80
'*auto-finalize': 'bool', '*auto-dismiss': 'bool',
81
- '*filter-node-name': 'str' } }
82
+ '*filter-node-name': 'str', '*x-perf': 'BackupPerf' } }
83
84
##
85
# @DriveBackup:
86
diff --git a/block/backup-top.h b/block/backup-top.h
87
index XXXXXXX..XXXXXXX 100644
88
--- a/block/backup-top.h
89
+++ b/block/backup-top.h
90
@@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source,
91
BlockDriverState *target,
92
const char *filter_node_name,
93
uint64_t cluster_size,
94
+ BackupPerf *perf,
95
BdrvRequestFlags write_flags,
96
BlockCopyState **bcs,
97
Error **errp);
98
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
99
index XXXXXXX..XXXXXXX 100644
100
--- a/include/block/block-copy.h
101
+++ b/include/block/block-copy.h
102
@@ -XXX,XX +XXX,XX @@ typedef void (*ProgressBytesCallbackFunc)(int64_t bytes, void *opaque);
103
typedef struct BlockCopyState BlockCopyState;
104
105
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
106
- int64_t cluster_size,
107
+ int64_t cluster_size, bool use_copy_range,
108
BdrvRequestFlags write_flags,
109
Error **errp);
110
111
diff --git a/include/block/block_int.h b/include/block/block_int.h
112
index XXXXXXX..XXXXXXX 100644
113
--- a/include/block/block_int.h
114
+++ b/include/block/block_int.h
115
@@ -XXX,XX +XXX,XX @@ void mirror_start(const char *job_id, BlockDriverState *bs,
116
* @sync_mode: What parts of the disk image should be copied to the destination.
117
* @sync_bitmap: The dirty bitmap if sync_mode is 'bitmap' or 'incremental'
118
* @bitmap_mode: The bitmap synchronization policy to use.
119
+ * @perf: Performance options. All actual fields assumed to be present,
120
+ * all ".has_*" fields are ignored.
121
* @on_source_error: The action to take upon error reading from the source.
122
* @on_target_error: The action to take upon error writing to the target.
123
* @creation_flags: Flags that control the behavior of the Job lifetime.
124
@@ -XXX,XX +XXX,XX @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
125
BitmapSyncMode bitmap_mode,
126
bool compress,
127
const char *filter_node_name,
128
+ BackupPerf *perf,
129
BlockdevOnError on_source_error,
130
BlockdevOnError on_target_error,
131
int creation_flags,
132
diff --git a/block/backup-top.c b/block/backup-top.c
133
index XXXXXXX..XXXXXXX 100644
134
--- a/block/backup-top.c
135
+++ b/block/backup-top.c
136
@@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source,
137
BlockDriverState *target,
138
const char *filter_node_name,
139
uint64_t cluster_size,
140
+ BackupPerf *perf,
141
BdrvRequestFlags write_flags,
142
BlockCopyState **bcs,
143
Error **errp)
144
@@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source,
145
146
state->cluster_size = cluster_size;
147
state->bcs = block_copy_state_new(top->backing, state->target,
148
- cluster_size, write_flags, &local_err);
149
+ cluster_size, perf->use_copy_range,
150
+ write_flags, &local_err);
151
if (local_err) {
152
error_prepend(&local_err, "Cannot create block-copy-state: ");
153
goto fail;
154
diff --git a/block/backup.c b/block/backup.c
155
index XXXXXXX..XXXXXXX 100644
156
--- a/block/backup.c
157
+++ b/block/backup.c
158
@@ -XXX,XX +XXX,XX @@ typedef struct BackupBlockJob {
159
uint64_t len;
160
uint64_t bytes_read;
161
int64_t cluster_size;
162
+ BackupPerf perf;
163
164
BlockCopyState *bcs;
165
} BackupBlockJob;
166
@@ -XXX,XX +XXX,XX @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
167
BitmapSyncMode bitmap_mode,
168
bool compress,
169
const char *filter_node_name,
170
+ BackupPerf *perf,
171
BlockdevOnError on_source_error,
172
BlockdevOnError on_target_error,
173
int creation_flags,
174
@@ -XXX,XX +XXX,XX @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
175
(compress ? BDRV_REQ_WRITE_COMPRESSED : 0),
176
177
backup_top = bdrv_backup_top_append(bs, target, filter_node_name,
178
- cluster_size, write_flags, &bcs, errp);
179
+ cluster_size, perf,
180
+ write_flags, &bcs, errp);
181
if (!backup_top) {
182
goto error;
183
}
184
@@ -XXX,XX +XXX,XX @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
185
job->bcs = bcs;
186
job->cluster_size = cluster_size;
187
job->len = len;
188
+ job->perf = *perf;
189
190
block_copy_set_progress_callback(bcs, backup_progress_bytes_callback, job);
191
block_copy_set_progress_meter(bcs, &job->common.job.progress);
192
diff --git a/block/block-copy.c b/block/block-copy.c
193
index XXXXXXX..XXXXXXX 100644
194
--- a/block/block-copy.c
195
+++ b/block/block-copy.c
196
@@ -XXX,XX +XXX,XX @@ static uint32_t block_copy_max_transfer(BdrvChild *source, BdrvChild *target)
197
}
198
199
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
200
- int64_t cluster_size,
201
+ int64_t cluster_size, bool use_copy_range,
202
BdrvRequestFlags write_flags, Error **errp)
203
{
204
BlockCopyState *s;
205
@@ -XXX,XX +XXX,XX @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
206
* We enable copy-range, but keep small copy_size, until first
207
* successful copy_range (look at block_copy_do_copy).
208
*/
209
- s->use_copy_range = true;
210
+ s->use_copy_range = use_copy_range;
211
s->copy_size = MAX(s->cluster_size, BLOCK_COPY_MAX_BUFFER);
212
}
213
214
diff --git a/block/replication.c b/block/replication.c
215
index XXXXXXX..XXXXXXX 100644
216
--- a/block/replication.c
217
+++ b/block/replication.c
218
@@ -XXX,XX +XXX,XX @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
219
int64_t active_length, hidden_length, disk_length;
220
AioContext *aio_context;
221
Error *local_err = NULL;
222
+ BackupPerf perf = { .use_copy_range = true };
223
224
aio_context = bdrv_get_aio_context(bs);
225
aio_context_acquire(aio_context);
226
@@ -XXX,XX +XXX,XX @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
227
s->backup_job = backup_job_create(
228
NULL, s->secondary_disk->bs, s->hidden_disk->bs,
229
0, MIRROR_SYNC_MODE_NONE, NULL, 0, false, NULL,
230
+ &perf,
231
BLOCKDEV_ON_ERROR_REPORT,
232
BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL,
233
backup_job_completed, bs, NULL, &local_err);
234
diff --git a/blockdev.c b/blockdev.c
235
index XXXXXXX..XXXXXXX 100644
236
--- a/blockdev.c
237
+++ b/blockdev.c
238
@@ -XXX,XX +XXX,XX @@ static BlockJob *do_backup_common(BackupCommon *backup,
239
{
240
BlockJob *job = NULL;
241
BdrvDirtyBitmap *bmap = NULL;
242
+ BackupPerf perf = { .use_copy_range = true };
243
int job_flags = JOB_DEFAULT;
244
245
if (!backup->has_speed) {
246
@@ -XXX,XX +XXX,XX @@ static BlockJob *do_backup_common(BackupCommon *backup,
247
backup->compress = false;
248
}
249
250
+ if (backup->x_perf) {
251
+ if (backup->x_perf->has_use_copy_range) {
252
+ perf.use_copy_range = backup->x_perf->use_copy_range;
253
+ }
254
+ }
255
+
256
if ((backup->sync == MIRROR_SYNC_MODE_BITMAP) ||
257
(backup->sync == MIRROR_SYNC_MODE_INCREMENTAL)) {
258
/* done before desugaring 'incremental' to print the right message */
259
@@ -XXX,XX +XXX,XX @@ static BlockJob *do_backup_common(BackupCommon *backup,
260
backup->sync, bmap, backup->bitmap_mode,
261
backup->compress,
262
backup->filter_node_name,
263
+ &perf,
264
backup->on_source_error,
265
backup->on_target_error,
266
job_flags, NULL, NULL, txn, errp);
267
--
268
2.29.2
269
270
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Refactor common path to use BlockCopyCallState pointer as parameter, to
4
prepare it for use in asynchronous block-copy (at least, we'll need to
5
run block-copy in a coroutine, passing the whole parameters as one
6
pointer).
7
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-Id: <20210116214705.822267-3-vsementsov@virtuozzo.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
block/block-copy.c | 51 ++++++++++++++++++++++++++++++++++------------
14
1 file changed, 38 insertions(+), 13 deletions(-)
15
16
diff --git a/block/block-copy.c b/block/block-copy.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/block/block-copy.c
19
+++ b/block/block-copy.c
20
@@ -XXX,XX +XXX,XX @@
21
static coroutine_fn int block_copy_task_entry(AioTask *task);
22
23
typedef struct BlockCopyCallState {
24
+ /* IN parameters */
25
+ BlockCopyState *s;
26
+ int64_t offset;
27
+ int64_t bytes;
28
+
29
+ /* State */
30
bool failed;
31
+
32
+ /* OUT parameters */
33
bool error_is_read;
34
} BlockCopyCallState;
35
36
@@ -XXX,XX +XXX,XX @@ int64_t block_copy_reset_unallocated(BlockCopyState *s,
37
* Returns 1 if dirty clusters found and successfully copied, 0 if no dirty
38
* clusters found and -errno on failure.
39
*/
40
-static int coroutine_fn block_copy_dirty_clusters(BlockCopyState *s,
41
- int64_t offset, int64_t bytes,
42
- bool *error_is_read)
43
+static int coroutine_fn
44
+block_copy_dirty_clusters(BlockCopyCallState *call_state)
45
{
46
+ BlockCopyState *s = call_state->s;
47
+ int64_t offset = call_state->offset;
48
+ int64_t bytes = call_state->bytes;
49
+
50
int ret = 0;
51
bool found_dirty = false;
52
int64_t end = offset + bytes;
53
AioTaskPool *aio = NULL;
54
- BlockCopyCallState call_state = {false, false};
55
56
/*
57
* block_copy() user is responsible for keeping source and target in same
58
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn block_copy_dirty_clusters(BlockCopyState *s,
59
BlockCopyTask *task;
60
int64_t status_bytes;
61
62
- task = block_copy_task_create(s, &call_state, offset, bytes);
63
+ task = block_copy_task_create(s, call_state, offset, bytes);
64
if (!task) {
65
/* No more dirty bits in the bitmap */
66
trace_block_copy_skip_range(s, offset, bytes);
67
@@ -XXX,XX +XXX,XX @@ out:
68
69
aio_task_pool_free(aio);
70
}
71
- if (error_is_read && ret < 0) {
72
- *error_is_read = call_state.error_is_read;
73
- }
74
75
return ret < 0 ? ret : found_dirty;
76
}
77
78
/*
79
- * block_copy
80
+ * block_copy_common
81
*
82
* Copy requested region, accordingly to dirty bitmap.
83
* Collaborate with parallel block_copy requests: if they succeed it will help
84
@@ -XXX,XX +XXX,XX @@ out:
85
* it means that some I/O operation failed in context of _this_ block_copy call,
86
* not some parallel operation.
87
*/
88
-int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes,
89
- bool *error_is_read)
90
+static int coroutine_fn block_copy_common(BlockCopyCallState *call_state)
91
{
92
int ret;
93
94
do {
95
- ret = block_copy_dirty_clusters(s, offset, bytes, error_is_read);
96
+ ret = block_copy_dirty_clusters(call_state);
97
98
if (ret == 0) {
99
- ret = block_copy_wait_one(s, offset, bytes);
100
+ ret = block_copy_wait_one(call_state->s, call_state->offset,
101
+ call_state->bytes);
102
}
103
104
/*
105
@@ -XXX,XX +XXX,XX @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes,
106
return ret;
107
}
108
109
+int coroutine_fn block_copy(BlockCopyState *s, int64_t start, int64_t bytes,
110
+ bool *error_is_read)
111
+{
112
+ BlockCopyCallState call_state = {
113
+ .s = s,
114
+ .offset = start,
115
+ .bytes = bytes,
116
+ };
117
+
118
+ int ret = block_copy_common(&call_state);
119
+
120
+ if (error_is_read && ret < 0) {
121
+ *error_is_read = call_state.error_is_read;
122
+ }
123
+
124
+ return ret;
125
+}
126
+
127
BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s)
128
{
129
return s->copy_bitmap;
130
--
131
2.29.2
132
133
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
We'll need async block-copy invocation to use in backup directly.
4
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
7
Message-Id: <20210116214705.822267-4-vsementsov@virtuozzo.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
include/block/block-copy.h | 29 ++++++++++++++
11
block/block-copy.c | 81 ++++++++++++++++++++++++++++++++++++--
12
2 files changed, 106 insertions(+), 4 deletions(-)
13
14
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/include/block/block-copy.h
17
+++ b/include/block/block-copy.h
18
@@ -XXX,XX +XXX,XX @@
19
#include "qemu/co-shared-resource.h"
20
21
typedef void (*ProgressBytesCallbackFunc)(int64_t bytes, void *opaque);
22
+typedef void (*BlockCopyAsyncCallbackFunc)(void *opaque);
23
typedef struct BlockCopyState BlockCopyState;
24
+typedef struct BlockCopyCallState BlockCopyCallState;
25
26
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
27
int64_t cluster_size, bool use_copy_range,
28
@@ -XXX,XX +XXX,XX @@ int64_t block_copy_reset_unallocated(BlockCopyState *s,
29
int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes,
30
bool *error_is_read);
31
32
+/*
33
+ * Run block-copy in a coroutine, create corresponding BlockCopyCallState
34
+ * object and return pointer to it. Never returns NULL.
35
+ *
36
+ * Caller is responsible to call block_copy_call_free() to free
37
+ * BlockCopyCallState object.
38
+ */
39
+BlockCopyCallState *block_copy_async(BlockCopyState *s,
40
+ int64_t offset, int64_t bytes,
41
+ BlockCopyAsyncCallbackFunc cb,
42
+ void *cb_opaque);
43
+
44
+/*
45
+ * Free finished BlockCopyCallState. Trying to free running
46
+ * block-copy will crash.
47
+ */
48
+void block_copy_call_free(BlockCopyCallState *call_state);
49
+
50
+/*
51
+ * Note, that block-copy call is marked finished prior to calling
52
+ * the callback.
53
+ */
54
+bool block_copy_call_finished(BlockCopyCallState *call_state);
55
+bool block_copy_call_succeeded(BlockCopyCallState *call_state);
56
+bool block_copy_call_failed(BlockCopyCallState *call_state);
57
+int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read);
58
+
59
BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s);
60
void block_copy_set_skip_unallocated(BlockCopyState *s, bool skip);
61
62
diff --git a/block/block-copy.c b/block/block-copy.c
63
index XXXXXXX..XXXXXXX 100644
64
--- a/block/block-copy.c
65
+++ b/block/block-copy.c
66
@@ -XXX,XX +XXX,XX @@
67
static coroutine_fn int block_copy_task_entry(AioTask *task);
68
69
typedef struct BlockCopyCallState {
70
- /* IN parameters */
71
+ /* IN parameters. Initialized in block_copy_async() and never changed. */
72
BlockCopyState *s;
73
int64_t offset;
74
int64_t bytes;
75
+ BlockCopyAsyncCallbackFunc cb;
76
+ void *cb_opaque;
77
+
78
+ /* Coroutine where async block-copy is running */
79
+ Coroutine *co;
80
81
/* State */
82
- bool failed;
83
+ int ret;
84
+ bool finished;
85
86
/* OUT parameters */
87
bool error_is_read;
88
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int block_copy_task_entry(AioTask *task)
89
90
ret = block_copy_do_copy(t->s, t->offset, t->bytes, t->zeroes,
91
&error_is_read);
92
- if (ret < 0 && !t->call_state->failed) {
93
- t->call_state->failed = true;
94
+ if (ret < 0 && !t->call_state->ret) {
95
+ t->call_state->ret = ret;
96
t->call_state->error_is_read = error_is_read;
97
} else {
98
progress_work_done(t->s->progress, t->bytes);
99
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state)
100
*/
101
} while (ret > 0);
102
103
+ call_state->finished = true;
104
+
105
+ if (call_state->cb) {
106
+ call_state->cb(call_state->cb_opaque);
107
+ }
108
+
109
return ret;
110
}
111
112
@@ -XXX,XX +XXX,XX @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t start, int64_t bytes,
113
return ret;
114
}
115
116
+static void coroutine_fn block_copy_async_co_entry(void *opaque)
117
+{
118
+ block_copy_common(opaque);
119
+}
120
+
121
+BlockCopyCallState *block_copy_async(BlockCopyState *s,
122
+ int64_t offset, int64_t bytes,
123
+ BlockCopyAsyncCallbackFunc cb,
124
+ void *cb_opaque)
125
+{
126
+ BlockCopyCallState *call_state = g_new(BlockCopyCallState, 1);
127
+
128
+ *call_state = (BlockCopyCallState) {
129
+ .s = s,
130
+ .offset = offset,
131
+ .bytes = bytes,
132
+ .cb = cb,
133
+ .cb_opaque = cb_opaque,
134
+
135
+ .co = qemu_coroutine_create(block_copy_async_co_entry, call_state),
136
+ };
137
+
138
+ qemu_coroutine_enter(call_state->co);
139
+
140
+ return call_state;
141
+}
142
+
143
+void block_copy_call_free(BlockCopyCallState *call_state)
144
+{
145
+ if (!call_state) {
146
+ return;
147
+ }
148
+
149
+ assert(call_state->finished);
150
+ g_free(call_state);
151
+}
152
+
153
+bool block_copy_call_finished(BlockCopyCallState *call_state)
154
+{
155
+ return call_state->finished;
156
+}
157
+
158
+bool block_copy_call_succeeded(BlockCopyCallState *call_state)
159
+{
160
+ return call_state->finished && call_state->ret == 0;
161
+}
162
+
163
+bool block_copy_call_failed(BlockCopyCallState *call_state)
164
+{
165
+ return call_state->finished && call_state->ret < 0;
166
+}
167
+
168
+int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read)
169
+{
170
+ assert(call_state->finished);
171
+ if (error_is_read) {
172
+ *error_is_read = call_state->error_is_read;
173
+ }
174
+ return call_state->ret;
175
+}
176
+
177
BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s)
178
{
179
return s->copy_bitmap;
180
--
181
2.29.2
182
183
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
LeakyBucket.burst_length is defined as an unsigned integer but the
3
They will be used for backup.
4
code never checks for overflows and it only makes sure that the value
5
is not 0.
6
4
7
In practice this means that the user can set something like
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
throttling.iops-total-max-length=4294967300 despite being larger than
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
UINT_MAX and the final value after casting to unsigned int will be 4.
7
Message-Id: <20210116214705.822267-5-vsementsov@virtuozzo.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
include/block/block-copy.h | 6 ++++++
11
block/block-copy.c | 11 +++++++++--
12
2 files changed, 15 insertions(+), 2 deletions(-)
10
13
11
This patch changes the data type to uint64_t. This does not increase
14
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
12
the storage size of LeakyBucket, and allows us to assign the value
13
directly from qemu_opt_get_number() or BlockIOThrottle and then do the
14
checks directly in throttle_is_valid().
15
16
The value of burst_length does not have a specific upper limit,
17
but since the bucket size is defined by max * burst_length we have
18
to prevent overflows. Instead of going for UINT64_MAX or something
19
similar this patch reuses THROTTLE_VALUE_MAX, which allows I/O bursts
20
of 1 GiB/s for 10 days in a row.
21
22
Signed-off-by: Alberto Garcia <berto@igalia.com>
23
Message-id: 1b2e3049803f71cafb2e1fa1be4fb47147a0d398.1503580370.git.berto@igalia.com
24
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
25
---
26
include/qemu/throttle.h | 2 +-
27
util/throttle.c | 5 +++++
28
2 files changed, 6 insertions(+), 1 deletion(-)
29
30
diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
31
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
32
--- a/include/qemu/throttle.h
16
--- a/include/block/block-copy.h
33
+++ b/include/qemu/throttle.h
17
+++ b/include/block/block-copy.h
34
@@ -XXX,XX +XXX,XX @@ typedef struct LeakyBucket {
18
@@ -XXX,XX +XXX,XX @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes,
35
uint64_t max; /* leaky bucket max burst in units */
19
*
36
double level; /* bucket level in units */
20
* Caller is responsible to call block_copy_call_free() to free
37
double burst_level; /* bucket level in units (for computing bursts) */
21
* BlockCopyCallState object.
38
- unsigned burst_length; /* max length of the burst period, in seconds */
22
+ *
39
+ uint64_t burst_length; /* max length of the burst period, in seconds */
23
+ * @max_workers means maximum of parallel coroutines to execute sub-requests,
40
} LeakyBucket;
24
+ * must be > 0.
41
25
+ *
42
/* The following structure is used to configure a ThrottleState
26
+ * @max_chunk means maximum length for one IO operation. Zero means unlimited.
43
diff --git a/util/throttle.c b/util/throttle.c
27
*/
28
BlockCopyCallState *block_copy_async(BlockCopyState *s,
29
int64_t offset, int64_t bytes,
30
+ int max_workers, int64_t max_chunk,
31
BlockCopyAsyncCallbackFunc cb,
32
void *cb_opaque);
33
34
diff --git a/block/block-copy.c b/block/block-copy.c
44
index XXXXXXX..XXXXXXX 100644
35
index XXXXXXX..XXXXXXX 100644
45
--- a/util/throttle.c
36
--- a/block/block-copy.c
46
+++ b/util/throttle.c
37
+++ b/block/block-copy.c
47
@@ -XXX,XX +XXX,XX @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **errp)
38
@@ -XXX,XX +XXX,XX @@ typedef struct BlockCopyCallState {
48
return false;
39
BlockCopyState *s;
40
int64_t offset;
41
int64_t bytes;
42
+ int max_workers;
43
+ int64_t max_chunk;
44
BlockCopyAsyncCallbackFunc cb;
45
void *cb_opaque;
46
47
@@ -XXX,XX +XXX,XX @@ static BlockCopyTask *block_copy_task_create(BlockCopyState *s,
48
int64_t offset, int64_t bytes)
49
{
50
BlockCopyTask *task;
51
+ int64_t max_chunk = MIN_NON_ZERO(s->copy_size, call_state->max_chunk);
52
53
if (!bdrv_dirty_bitmap_next_dirty_area(s->copy_bitmap,
54
offset, offset + bytes,
55
- s->copy_size, &offset, &bytes))
56
+ max_chunk, &offset, &bytes))
57
{
58
return NULL;
59
}
60
@@ -XXX,XX +XXX,XX @@ block_copy_dirty_clusters(BlockCopyCallState *call_state)
61
bytes = end - offset;
62
63
if (!aio && bytes) {
64
- aio = aio_task_pool_new(BLOCK_COPY_MAX_WORKERS);
65
+ aio = aio_task_pool_new(call_state->max_workers);
49
}
66
}
50
67
51
+ if (bkt->max && bkt->burst_length > THROTTLE_VALUE_MAX / bkt->max) {
68
ret = block_copy_task_run(aio, task);
52
+ error_setg(errp, "burst length too high for this burst rate");
69
@@ -XXX,XX +XXX,XX @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t start, int64_t bytes,
53
+ return false;
70
.s = s,
54
+ }
71
.offset = start,
55
+
72
.bytes = bytes,
56
if (bkt->max && !bkt->avg) {
73
+ .max_workers = BLOCK_COPY_MAX_WORKERS,
57
error_setg(errp, "bps_max/iops_max require corresponding"
74
};
58
" bps/iops values");
75
76
int ret = block_copy_common(&call_state);
77
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn block_copy_async_co_entry(void *opaque)
78
79
BlockCopyCallState *block_copy_async(BlockCopyState *s,
80
int64_t offset, int64_t bytes,
81
+ int max_workers, int64_t max_chunk,
82
BlockCopyAsyncCallbackFunc cb,
83
void *cb_opaque)
84
{
85
@@ -XXX,XX +XXX,XX @@ BlockCopyCallState *block_copy_async(BlockCopyState *s,
86
.s = s,
87
.offset = offset,
88
.bytes = bytes,
89
+ .max_workers = max_workers,
90
+ .max_chunk = max_chunk,
91
.cb = cb,
92
.cb_opaque = cb_opaque,
93
59
--
94
--
60
2.13.5
95
2.29.2
61
96
62
97
diff view generated by jsdifflib
1
From: Eduardo Habkost <ehabkost@redhat.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
If QEMU is running on a system that's out of memory and mmap()
3
It simplifies debugging.
4
fails, QEMU aborts with no error message at all, making it hard
5
to debug the reason for the failure.
6
4
7
Add perror() calls that will print error information before
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
aborting.
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
7
Message-Id: <20210116214705.822267-6-vsementsov@virtuozzo.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
block/block-copy.c | 11 ++++++++++-
11
1 file changed, 10 insertions(+), 1 deletion(-)
9
12
10
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
13
diff --git a/block/block-copy.c b/block/block-copy.c
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Message-id: 20170829212053.6003-1-ehabkost@redhat.com
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
15
---
16
util/oslib-posix.c | 2 ++
17
1 file changed, 2 insertions(+)
18
19
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
20
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
21
--- a/util/oslib-posix.c
15
--- a/block/block-copy.c
22
+++ b/util/oslib-posix.c
16
+++ b/block/block-copy.c
23
@@ -XXX,XX +XXX,XX @@ void *qemu_alloc_stack(size_t *sz)
17
@@ -XXX,XX +XXX,XX @@ typedef struct BlockCopyCallState {
24
ptr = mmap(NULL, *sz, PROT_READ | PROT_WRITE,
18
/* Coroutine where async block-copy is running */
25
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
19
Coroutine *co;
26
if (ptr == MAP_FAILED) {
20
27
+ perror("failed to allocate memory for stack");
21
+ /* To reference all call states from BlockCopyState */
28
abort();
22
+ QLIST_ENTRY(BlockCopyCallState) list;
23
+
24
/* State */
25
int ret;
26
bool finished;
27
@@ -XXX,XX +XXX,XX @@ typedef struct BlockCopyState {
28
bool use_copy_range;
29
int64_t copy_size;
30
uint64_t len;
31
- QLIST_HEAD(, BlockCopyTask) tasks;
32
+ QLIST_HEAD(, BlockCopyTask) tasks; /* All tasks from all block-copy calls */
33
+ QLIST_HEAD(, BlockCopyCallState) calls;
34
35
BdrvRequestFlags write_flags;
36
37
@@ -XXX,XX +XXX,XX @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
29
}
38
}
30
39
31
@@ -XXX,XX +XXX,XX @@ void *qemu_alloc_stack(size_t *sz)
40
QLIST_INIT(&s->tasks);
32
guardpage = ptr;
41
+ QLIST_INIT(&s->calls);
33
#endif
42
34
if (mprotect(guardpage, pagesz, PROT_NONE) != 0) {
43
return s;
35
+ perror("failed to set up stack guard page");
44
}
36
abort();
45
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state)
46
{
47
int ret;
48
49
+ QLIST_INSERT_HEAD(&call_state->s->calls, call_state, list);
50
+
51
do {
52
ret = block_copy_dirty_clusters(call_state);
53
54
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state)
55
call_state->cb(call_state->cb_opaque);
37
}
56
}
38
57
58
+ QLIST_REMOVE(call_state, list);
59
+
60
return ret;
61
}
62
39
--
63
--
40
2.13.5
64
2.29.2
41
65
42
66
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
Signed-off-by: Alberto Garcia <berto@igalia.com>
3
We are going to directly use one async block-copy operation for backup
4
Message-id: a57dd6274e1b6dc9c28769fec4c7ea543be5c5e3.1503580370.git.berto@igalia.com
4
job, so we need rate limiter.
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5
6
We want to maintain current backup behavior: only background copying is
7
limited and copy-before-write operations only participate in limit
8
calculation. Therefore we need one rate limiter for block-copy state
9
and boolean flag for block-copy call state for actual limitation.
10
11
Note, that we can't just calculate each chunk in limiter after
12
successful copying: it will not save us from starting a lot of async
13
sub-requests which will exceed limit too much. Instead let's use the
14
following scheme on sub-request creation:
15
1. If at the moment limit is not exceeded, create the request and
16
account it immediately.
17
2. If at the moment limit is already exceeded, drop create sub-request
18
and handle limit instead (by sleep).
19
With this approach we'll never exceed the limit more than by one
20
sub-request (which pretty much matches current backup behavior).
21
22
Note also, that if there is in-flight block-copy async call,
23
block_copy_kick() should be used after set-speed to apply new setup
24
faster. For that block_copy_kick() published in this patch.
25
26
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
27
Reviewed-by: Max Reitz <mreitz@redhat.com>
28
Message-Id: <20210116214705.822267-7-vsementsov@virtuozzo.com>
29
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
---
30
---
7
tests/test-throttle.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++
31
include/block/block-copy.h | 5 ++++-
8
1 file changed, 77 insertions(+)
32
block/backup-top.c | 2 +-
33
block/backup.c | 2 +-
34
block/block-copy.c | 46 +++++++++++++++++++++++++++++++++++++-
35
4 files changed, 51 insertions(+), 4 deletions(-)
9
36
10
diff --git a/tests/test-throttle.c b/tests/test-throttle.c
37
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
11
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
12
--- a/tests/test-throttle.c
39
--- a/include/block/block-copy.h
13
+++ b/tests/test-throttle.c
40
+++ b/include/block/block-copy.h
14
@@ -XXX,XX +XXX,XX @@ static void test_is_valid(void)
41
@@ -XXX,XX +XXX,XX @@ int64_t block_copy_reset_unallocated(BlockCopyState *s,
15
test_is_valid_for_value(1, true);
42
int64_t offset, int64_t *count);
43
44
int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes,
45
- bool *error_is_read);
46
+ bool ignore_ratelimit, bool *error_is_read);
47
48
/*
49
* Run block-copy in a coroutine, create corresponding BlockCopyCallState
50
@@ -XXX,XX +XXX,XX @@ bool block_copy_call_succeeded(BlockCopyCallState *call_state);
51
bool block_copy_call_failed(BlockCopyCallState *call_state);
52
int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read);
53
54
+void block_copy_set_speed(BlockCopyState *s, uint64_t speed);
55
+void block_copy_kick(BlockCopyCallState *call_state);
56
+
57
BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s);
58
void block_copy_set_skip_unallocated(BlockCopyState *s, bool skip);
59
60
diff --git a/block/backup-top.c b/block/backup-top.c
61
index XXXXXXX..XXXXXXX 100644
62
--- a/block/backup-top.c
63
+++ b/block/backup-top.c
64
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int backup_top_cbw(BlockDriverState *bs, uint64_t offset,
65
off = QEMU_ALIGN_DOWN(offset, s->cluster_size);
66
end = QEMU_ALIGN_UP(offset + bytes, s->cluster_size);
67
68
- return block_copy(s->bcs, off, end - off, NULL);
69
+ return block_copy(s->bcs, off, end - off, true, NULL);
16
}
70
}
17
71
18
+static void test_ranges(void)
72
static int coroutine_fn backup_top_co_pdiscard(BlockDriverState *bs,
73
diff --git a/block/backup.c b/block/backup.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/block/backup.c
76
+++ b/block/backup.c
77
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_do_cow(BackupBlockJob *job,
78
79
trace_backup_do_cow_enter(job, start, offset, bytes);
80
81
- ret = block_copy(job->bcs, start, end - start, error_is_read);
82
+ ret = block_copy(job->bcs, start, end - start, true, error_is_read);
83
84
trace_backup_do_cow_return(job, offset, bytes, ret);
85
86
diff --git a/block/block-copy.c b/block/block-copy.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/block/block-copy.c
89
+++ b/block/block-copy.c
90
@@ -XXX,XX +XXX,XX @@
91
#define BLOCK_COPY_MAX_BUFFER (1 * MiB)
92
#define BLOCK_COPY_MAX_MEM (128 * MiB)
93
#define BLOCK_COPY_MAX_WORKERS 64
94
+#define BLOCK_COPY_SLICE_TIME 100000000ULL /* ns */
95
96
static coroutine_fn int block_copy_task_entry(AioTask *task);
97
98
@@ -XXX,XX +XXX,XX @@ typedef struct BlockCopyCallState {
99
int64_t bytes;
100
int max_workers;
101
int64_t max_chunk;
102
+ bool ignore_ratelimit;
103
BlockCopyAsyncCallbackFunc cb;
104
void *cb_opaque;
105
106
@@ -XXX,XX +XXX,XX @@ typedef struct BlockCopyCallState {
107
/* State */
108
int ret;
109
bool finished;
110
+ QemuCoSleepState *sleep_state;
111
112
/* OUT parameters */
113
bool error_is_read;
114
@@ -XXX,XX +XXX,XX @@ typedef struct BlockCopyState {
115
void *progress_opaque;
116
117
SharedResource *mem;
118
+
119
+ uint64_t speed;
120
+ RateLimit rate_limit;
121
} BlockCopyState;
122
123
static BlockCopyTask *find_conflicting_task(BlockCopyState *s,
124
@@ -XXX,XX +XXX,XX @@ block_copy_dirty_clusters(BlockCopyCallState *call_state)
125
}
126
task->zeroes = ret & BDRV_BLOCK_ZERO;
127
128
+ if (s->speed) {
129
+ if (!call_state->ignore_ratelimit) {
130
+ uint64_t ns = ratelimit_calculate_delay(&s->rate_limit, 0);
131
+ if (ns > 0) {
132
+ block_copy_task_end(task, -EAGAIN);
133
+ g_free(task);
134
+ qemu_co_sleep_ns_wakeable(QEMU_CLOCK_REALTIME, ns,
135
+ &call_state->sleep_state);
136
+ continue;
137
+ }
138
+ }
139
+
140
+ ratelimit_calculate_delay(&s->rate_limit, task->bytes);
141
+ }
142
+
143
trace_block_copy_process(s, task->offset);
144
145
co_get_from_shres(s->mem, task->bytes);
146
@@ -XXX,XX +XXX,XX @@ out:
147
return ret < 0 ? ret : found_dirty;
148
}
149
150
+void block_copy_kick(BlockCopyCallState *call_state)
19
+{
151
+{
20
+ int i;
152
+ if (call_state->sleep_state) {
21
+
153
+ qemu_co_sleep_wake(call_state->sleep_state);
22
+ for (i = 0; i < BUCKETS_COUNT; i++) {
23
+ LeakyBucket *b = &cfg.buckets[i];
24
+ throttle_config_init(&cfg);
25
+
26
+ /* avg = 0 means throttling is disabled, but the config is valid */
27
+ b->avg = 0;
28
+ g_assert(throttle_is_valid(&cfg, NULL));
29
+ g_assert(!throttle_enabled(&cfg));
30
+
31
+ /* These are valid configurations (values <= THROTTLE_VALUE_MAX) */
32
+ b->avg = 1;
33
+ g_assert(throttle_is_valid(&cfg, NULL));
34
+
35
+ b->avg = THROTTLE_VALUE_MAX;
36
+ g_assert(throttle_is_valid(&cfg, NULL));
37
+
38
+ b->avg = THROTTLE_VALUE_MAX;
39
+ b->max = THROTTLE_VALUE_MAX;
40
+ g_assert(throttle_is_valid(&cfg, NULL));
41
+
42
+ /* Values over THROTTLE_VALUE_MAX are not allowed */
43
+ b->avg = THROTTLE_VALUE_MAX + 1;
44
+ g_assert(!throttle_is_valid(&cfg, NULL));
45
+
46
+ b->avg = THROTTLE_VALUE_MAX;
47
+ b->max = THROTTLE_VALUE_MAX + 1;
48
+ g_assert(!throttle_is_valid(&cfg, NULL));
49
+
50
+ /* burst_length must be between 1 and THROTTLE_VALUE_MAX */
51
+ b->avg = 1;
52
+ b->max = 1;
53
+ b->burst_length = 0;
54
+ g_assert(!throttle_is_valid(&cfg, NULL));
55
+
56
+ b->avg = 1;
57
+ b->max = 1;
58
+ b->burst_length = 1;
59
+ g_assert(throttle_is_valid(&cfg, NULL));
60
+
61
+ b->avg = 1;
62
+ b->max = 1;
63
+ b->burst_length = THROTTLE_VALUE_MAX;
64
+ g_assert(throttle_is_valid(&cfg, NULL));
65
+
66
+ b->avg = 1;
67
+ b->max = 1;
68
+ b->burst_length = THROTTLE_VALUE_MAX + 1;
69
+ g_assert(!throttle_is_valid(&cfg, NULL));
70
+
71
+ /* burst_length * max cannot exceed THROTTLE_VALUE_MAX */
72
+ b->avg = 1;
73
+ b->max = 2;
74
+ b->burst_length = THROTTLE_VALUE_MAX / 2;
75
+ g_assert(throttle_is_valid(&cfg, NULL));
76
+
77
+ b->avg = 1;
78
+ b->max = 3;
79
+ b->burst_length = THROTTLE_VALUE_MAX / 2;
80
+ g_assert(!throttle_is_valid(&cfg, NULL));
81
+
82
+ b->avg = 1;
83
+ b->max = THROTTLE_VALUE_MAX;
84
+ b->burst_length = 1;
85
+ g_assert(throttle_is_valid(&cfg, NULL));
86
+
87
+ b->avg = 1;
88
+ b->max = THROTTLE_VALUE_MAX;
89
+ b->burst_length = 2;
90
+ g_assert(!throttle_is_valid(&cfg, NULL));
91
+ }
154
+ }
92
+}
155
+}
93
+
156
+
94
static void test_max_is_missing_limit(void)
157
/*
158
* block_copy_common
159
*
160
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state)
161
}
162
163
int coroutine_fn block_copy(BlockCopyState *s, int64_t start, int64_t bytes,
164
- bool *error_is_read)
165
+ bool ignore_ratelimit, bool *error_is_read)
95
{
166
{
96
int i;
167
BlockCopyCallState call_state = {
97
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
168
.s = s,
98
g_test_add_func("/throttle/config/enabled", test_enabled);
169
.offset = start,
99
g_test_add_func("/throttle/config/conflicting", test_conflicting_config);
170
.bytes = bytes,
100
g_test_add_func("/throttle/config/is_valid", test_is_valid);
171
+ .ignore_ratelimit = ignore_ratelimit,
101
+ g_test_add_func("/throttle/config/ranges", test_ranges);
172
.max_workers = BLOCK_COPY_MAX_WORKERS,
102
g_test_add_func("/throttle/config/max", test_max_is_missing_limit);
173
};
103
g_test_add_func("/throttle/config/iops_size",
174
104
test_iops_size_is_missing_limit);
175
@@ -XXX,XX +XXX,XX @@ void block_copy_set_skip_unallocated(BlockCopyState *s, bool skip)
176
{
177
s->skip_unallocated = skip;
178
}
179
+
180
+void block_copy_set_speed(BlockCopyState *s, uint64_t speed)
181
+{
182
+ s->speed = speed;
183
+ if (speed > 0) {
184
+ ratelimit_set_speed(&s->rate_limit, speed, BLOCK_COPY_SLICE_TIME);
185
+ }
186
+
187
+ /*
188
+ * Note: it's good to kick all call states from here, but it should be done
189
+ * only from a coroutine, to not crash if s->calls list changed while
190
+ * entering one call. So for now, the only user of this function kicks its
191
+ * only one call_state by hand.
192
+ */
193
+}
105
--
194
--
106
2.13.5
195
2.29.2
107
196
108
197
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Add function to cancel running async block-copy call. It will be used
4
in backup.
5
6
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
Message-Id: <20210116214705.822267-8-vsementsov@virtuozzo.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
11
include/block/block-copy.h | 13 +++++++++++++
12
block/block-copy.c | 24 +++++++++++++++++++-----
13
2 files changed, 32 insertions(+), 5 deletions(-)
14
15
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/block/block-copy.h
18
+++ b/include/block/block-copy.h
19
@@ -XXX,XX +XXX,XX @@ void block_copy_call_free(BlockCopyCallState *call_state);
20
bool block_copy_call_finished(BlockCopyCallState *call_state);
21
bool block_copy_call_succeeded(BlockCopyCallState *call_state);
22
bool block_copy_call_failed(BlockCopyCallState *call_state);
23
+bool block_copy_call_cancelled(BlockCopyCallState *call_state);
24
int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read);
25
26
void block_copy_set_speed(BlockCopyState *s, uint64_t speed);
27
void block_copy_kick(BlockCopyCallState *call_state);
28
29
+/*
30
+ * Cancel running block-copy call.
31
+ *
32
+ * Cancel leaves block-copy state valid: dirty bits are correct and you may use
33
+ * cancel + <run block_copy with same parameters> to emulate pause/resume.
34
+ *
35
+ * Note also, that the cancel is async: it only marks block-copy call to be
36
+ * cancelled. So, the call may be cancelled (block_copy_call_cancelled() reports
37
+ * true) but not yet finished (block_copy_call_finished() reports false).
38
+ */
39
+void block_copy_call_cancel(BlockCopyCallState *call_state);
40
+
41
BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s);
42
void block_copy_set_skip_unallocated(BlockCopyState *s, bool skip);
43
44
diff --git a/block/block-copy.c b/block/block-copy.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/block/block-copy.c
47
+++ b/block/block-copy.c
48
@@ -XXX,XX +XXX,XX @@ typedef struct BlockCopyCallState {
49
int ret;
50
bool finished;
51
QemuCoSleepState *sleep_state;
52
+ bool cancelled;
53
54
/* OUT parameters */
55
bool error_is_read;
56
@@ -XXX,XX +XXX,XX @@ block_copy_dirty_clusters(BlockCopyCallState *call_state)
57
assert(QEMU_IS_ALIGNED(offset, s->cluster_size));
58
assert(QEMU_IS_ALIGNED(bytes, s->cluster_size));
59
60
- while (bytes && aio_task_pool_status(aio) == 0) {
61
+ while (bytes && aio_task_pool_status(aio) == 0 && !call_state->cancelled) {
62
BlockCopyTask *task;
63
int64_t status_bytes;
64
65
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state)
66
do {
67
ret = block_copy_dirty_clusters(call_state);
68
69
- if (ret == 0) {
70
+ if (ret == 0 && !call_state->cancelled) {
71
ret = block_copy_wait_one(call_state->s, call_state->offset,
72
call_state->bytes);
73
}
74
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state)
75
* 2. We have waited for some intersecting block-copy request
76
* It may have failed and produced new dirty bits.
77
*/
78
- } while (ret > 0);
79
+ } while (ret > 0 && !call_state->cancelled);
80
81
call_state->finished = true;
82
83
@@ -XXX,XX +XXX,XX @@ bool block_copy_call_finished(BlockCopyCallState *call_state)
84
85
bool block_copy_call_succeeded(BlockCopyCallState *call_state)
86
{
87
- return call_state->finished && call_state->ret == 0;
88
+ return call_state->finished && !call_state->cancelled &&
89
+ call_state->ret == 0;
90
}
91
92
bool block_copy_call_failed(BlockCopyCallState *call_state)
93
{
94
- return call_state->finished && call_state->ret < 0;
95
+ return call_state->finished && !call_state->cancelled &&
96
+ call_state->ret < 0;
97
+}
98
+
99
+bool block_copy_call_cancelled(BlockCopyCallState *call_state)
100
+{
101
+ return call_state->cancelled;
102
}
103
104
int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read)
105
@@ -XXX,XX +XXX,XX @@ int block_copy_call_status(BlockCopyCallState *call_state, bool *error_is_read)
106
return call_state->ret;
107
}
108
109
+void block_copy_call_cancel(BlockCopyCallState *call_state)
110
+{
111
+ call_state->cancelled = true;
112
+ block_copy_kick(call_state);
113
+}
114
+
115
BdrvDirtyBitmap *block_copy_dirty_bitmap(BlockCopyState *s)
116
{
117
return s->copy_bitmap;
118
--
119
2.29.2
120
121
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
We are going to use async block-copy call in backup, so we'll need to
4
passthrough setting backup speed to block-copy call.
5
6
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
Message-Id: <20210116214705.822267-9-vsementsov@virtuozzo.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
11
include/block/blockjob_int.h | 2 ++
12
blockjob.c | 6 ++++++
13
2 files changed, 8 insertions(+)
14
15
diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/block/blockjob_int.h
18
+++ b/include/block/blockjob_int.h
19
@@ -XXX,XX +XXX,XX @@ struct BlockJobDriver {
20
* besides job->blk to the new AioContext.
21
*/
22
void (*attached_aio_context)(BlockJob *job, AioContext *new_context);
23
+
24
+ void (*set_speed)(BlockJob *job, int64_t speed);
25
};
26
27
/**
28
diff --git a/blockjob.c b/blockjob.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/blockjob.c
31
+++ b/blockjob.c
32
@@ -XXX,XX +XXX,XX @@ static bool job_timer_pending(Job *job)
33
34
void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
35
{
36
+ const BlockJobDriver *drv = block_job_driver(job);
37
int64_t old_speed = job->speed;
38
39
if (job_apply_verb(&job->job, JOB_VERB_SET_SPEED, errp)) {
40
@@ -XXX,XX +XXX,XX @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
41
ratelimit_set_speed(&job->limit, speed, BLOCK_JOB_SLICE_TIME);
42
43
job->speed = speed;
44
+
45
+ if (drv->set_speed) {
46
+ drv->set_speed(job, speed);
47
+ }
48
+
49
if (speed && speed <= old_speed) {
50
return;
51
}
52
--
53
2.29.2
54
55
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
If main job coroutine called job_yield (while some background process
4
is in progress), we should give it a chance to call job_pause_point().
5
It will be used in backup, when moved on async block-copy.
6
7
Note, that job_user_pause is not enough: we want to handle
8
child_job_drained_begin() as well, which call job_pause().
9
10
Still, if job is already in job_do_yield() in job_pause_point() we
11
should not enter it.
12
13
iotest 109 output is modified: on stop we do bdrv_drain_all() which now
14
triggers job pause immediately (and pause after ready is standby).
15
16
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
17
Message-Id: <20210116214705.822267-10-vsementsov@virtuozzo.com>
18
Reviewed-by: Max Reitz <mreitz@redhat.com>
19
Signed-off-by: Max Reitz <mreitz@redhat.com>
20
---
21
job.c | 3 +++
22
tests/qemu-iotests/109.out | 24 ++++++++++++++++++++++++
23
2 files changed, 27 insertions(+)
24
25
diff --git a/job.c b/job.c
26
index XXXXXXX..XXXXXXX 100644
27
--- a/job.c
28
+++ b/job.c
29
@@ -XXX,XX +XXX,XX @@ static bool job_timer_not_pending(Job *job)
30
void job_pause(Job *job)
31
{
32
job->pause_count++;
33
+ if (!job->paused) {
34
+ job_enter(job);
35
+ }
36
}
37
38
void job_resume(Job *job)
39
diff --git a/tests/qemu-iotests/109.out b/tests/qemu-iotests/109.out
40
index XXXXXXX..XXXXXXX 100644
41
--- a/tests/qemu-iotests/109.out
42
+++ b/tests/qemu-iotests/109.out
43
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
44
{"execute":"quit"}
45
{"return": {}}
46
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
47
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}}
48
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}}
49
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}}
50
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}}
51
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 1024, "offset": 1024, "speed": 0, "type": "mirror"}}
52
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
53
{"execute":"quit"}
54
{"return": {}}
55
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
56
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}}
57
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}}
58
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}}
59
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}}
60
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 197120, "offset": 197120, "speed": 0, "type": "mirror"}}
61
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
62
{"execute":"quit"}
63
{"return": {}}
64
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
65
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}}
66
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}}
67
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}}
68
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}}
69
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 327680, "offset": 327680, "speed": 0, "type": "mirror"}}
70
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
71
{"execute":"quit"}
72
{"return": {}}
73
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
74
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}}
75
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}}
76
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}}
77
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}}
78
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 1024, "offset": 1024, "speed": 0, "type": "mirror"}}
79
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
80
{"execute":"quit"}
81
{"return": {}}
82
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
83
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}}
84
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}}
85
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}}
86
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}}
87
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 65536, "offset": 65536, "speed": 0, "type": "mirror"}}
88
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
89
{"execute":"quit"}
90
{"return": {}}
91
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
92
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}}
93
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}}
94
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}}
95
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}}
96
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2560, "offset": 2560, "speed": 0, "type": "mirror"}}
97
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
98
{"execute":"quit"}
99
{"return": {}}
100
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
101
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}}
102
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}}
103
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}}
104
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}}
105
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2560, "offset": 2560, "speed": 0, "type": "mirror"}}
106
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
107
{"execute":"quit"}
108
{"return": {}}
109
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
110
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}}
111
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}}
112
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}}
113
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}}
114
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 31457280, "offset": 31457280, "speed": 0, "type": "mirror"}}
115
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
116
{"execute":"quit"}
117
{"return": {}}
118
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
119
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}}
120
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}}
121
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}}
122
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}}
123
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 327680, "offset": 327680, "speed": 0, "type": "mirror"}}
124
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0
125
{"execute":"quit"}
126
{"return": {}}
127
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
128
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}}
129
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}}
130
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}}
131
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}}
132
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2048, "offset": 2048, "speed": 0, "type": "mirror"}}
133
@@ -XXX,XX +XXX,XX @@ WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed
134
{"execute":"quit"}
135
{"return": {}}
136
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
137
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}}
138
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}}
139
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}}
140
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}}
141
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 512, "offset": 512, "speed": 0, "type": "mirror"}}
142
@@ -XXX,XX +XXX,XX @@ Images are identical.
143
{"execute":"quit"}
144
{"return": {}}
145
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
146
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "src"}}
147
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "src"}}
148
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "src"}}
149
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "src"}}
150
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 512, "offset": 512, "speed": 0, "type": "mirror"}}
151
--
152
2.29.2
153
154
diff view generated by jsdifflib
1
Most qcow2 files are uncompressed so it is wasteful to allocate (32 + 1)
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
* cluster_size + 512 bytes upfront. Allocate s->cluster_cache and
3
s->cluster_data when the first read operation is performance on a
4
compressed cluster.
5
2
6
The buffers are freed in .bdrv_close(). .bdrv_open() no longer has any
3
Add new parameters to configure future backup features. The patch
7
code paths that can allocate these buffers, so remove the free functions
4
doesn't introduce aio backup requests (so we actually have only one
8
in the error code path.
5
worker) neither requests larger than one cluster. Still, formally we
6
satisfy these maximums anyway, so add the parameters now, to facilitate
7
further patch which will really change backup job behavior.
9
8
10
This patch can result in significant memory savings when many qcow2
9
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11
disks are attached or backing file chains are long:
10
Reviewed-by: Max Reitz <mreitz@redhat.com>
11
Message-Id: <20210116214705.822267-11-vsementsov@virtuozzo.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
14
qapi/block-core.json | 13 ++++++++++++-
15
block/backup.c | 28 +++++++++++++++++++++++-----
16
block/replication.c | 2 +-
17
blockdev.c | 8 +++++++-
18
4 files changed, 43 insertions(+), 8 deletions(-)
12
19
13
Before 12.81% (1,023,193,088B)
20
diff --git a/qapi/block-core.json b/qapi/block-core.json
14
After 5.36% (393,893,888B)
15
16
Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
17
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
18
Reviewed-by: Eric Blake <eblake@redhat.com>
19
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
20
Message-id: 20170821135530.32344-1-stefanha@redhat.com
21
Cc: Kevin Wolf <kwolf@redhat.com>
22
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
23
---
24
block/qcow2-cluster.c | 17 +++++++++++++++++
25
block/qcow2.c | 12 ------------
26
2 files changed, 17 insertions(+), 12 deletions(-)
27
28
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
29
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
30
--- a/block/qcow2-cluster.c
22
--- a/qapi/block-core.json
31
+++ b/block/qcow2-cluster.c
23
+++ b/qapi/block-core.json
32
@@ -XXX,XX +XXX,XX @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset)
24
@@ -XXX,XX +XXX,XX @@
33
nb_csectors = ((cluster_offset >> s->csize_shift) & s->csize_mask) + 1;
25
#
34
sector_offset = coffset & 511;
26
# @use-copy-range: Use copy offloading. Default true.
35
csize = nb_csectors * 512 - sector_offset;
27
#
28
+# @max-workers: Maximum number of parallel requests for the sustained background
29
+# copying process. Doesn't influence copy-before-write operations.
30
+# Default 64.
31
+#
32
+# @max-chunk: Maximum request length for the sustained background copying
33
+# process. Doesn't influence copy-before-write operations.
34
+# 0 means unlimited. If max-chunk is non-zero then it should not be
35
+# less than job cluster size which is calculated as maximum of
36
+# target image cluster size and 64k. Default 0.
37
+#
38
# Since: 6.0
39
##
40
{ 'struct': 'BackupPerf',
41
- 'data': { '*use-copy-range': 'bool' }}
42
+ 'data': { '*use-copy-range': 'bool',
43
+ '*max-workers': 'int', '*max-chunk': 'int64' } }
44
45
##
46
# @BackupCommon:
47
diff --git a/block/backup.c b/block/backup.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/block/backup.c
50
+++ b/block/backup.c
51
@@ -XXX,XX +XXX,XX @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
52
return NULL;
53
}
54
55
+ cluster_size = backup_calculate_cluster_size(target, errp);
56
+ if (cluster_size < 0) {
57
+ goto error;
58
+ }
36
+
59
+
37
+ /* Allocate buffers on first decompress operation, most images are
60
+ if (perf->max_workers < 1) {
38
+ * uncompressed and the memory overhead can be avoided. The buffers
61
+ error_setg(errp, "max-workers must be greater than zero");
39
+ * are freed in .bdrv_close().
62
+ return NULL;
40
+ */
63
+ }
41
+ if (!s->cluster_data) {
42
+ /* one more sector for decompressed data alignment */
43
+ s->cluster_data = qemu_try_blockalign(bs->file->bs,
44
+ QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size + 512);
45
+ if (!s->cluster_data) {
46
+ return -ENOMEM;
47
+ }
48
+ }
49
+ if (!s->cluster_cache) {
50
+ s->cluster_cache = g_malloc(s->cluster_size);
51
+ }
52
+
64
+
53
BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED);
65
+ if (perf->max_chunk < 0) {
54
ret = bdrv_read(bs->file, coffset >> 9, s->cluster_data,
66
+ error_setg(errp, "max-chunk must be zero (which means no limit) or "
55
nb_csectors);
67
+ "positive");
56
diff --git a/block/qcow2.c b/block/qcow2.c
68
+ return NULL;
57
index XXXXXXX..XXXXXXX 100644
69
+ }
58
--- a/block/qcow2.c
70
+
59
+++ b/block/qcow2.c
71
+ if (perf->max_chunk && perf->max_chunk < cluster_size) {
60
@@ -XXX,XX +XXX,XX @@ static int qcow2_do_open(BlockDriverState *bs, QDict *options, int flags,
72
+ error_setg(errp, "Required max-chunk (%" PRIi64 ") is less than backup "
61
goto fail;
73
+ "cluster size (%" PRIi64 ")", perf->max_chunk, cluster_size);
74
+ return NULL;
75
+ }
76
+
77
+
78
if (sync_bitmap) {
79
/* If we need to write to this bitmap, check that we can: */
80
if (bitmap_mode != BITMAP_SYNC_MODE_NEVER &&
81
@@ -XXX,XX +XXX,XX @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
82
goto error;
62
}
83
}
63
84
64
- s->cluster_cache = g_malloc(s->cluster_size);
85
- cluster_size = backup_calculate_cluster_size(target, errp);
65
- /* one more sector for decompressed data alignment */
86
- if (cluster_size < 0) {
66
- s->cluster_data = qemu_try_blockalign(bs->file->bs, QCOW_MAX_CRYPT_CLUSTERS
87
- goto error;
67
- * s->cluster_size + 512);
68
- if (s->cluster_data == NULL) {
69
- error_setg(errp, "Could not allocate temporary cluster buffer");
70
- ret = -ENOMEM;
71
- goto fail;
72
- }
88
- }
73
-
89
-
74
s->cluster_cache_offset = -1;
90
/*
75
s->flags = flags;
91
* If source is in backing chain of target assume that target is going to be
76
92
* used for "image fleecing", i.e. it should represent a kind of snapshot of
77
@@ -XXX,XX +XXX,XX @@ static int qcow2_do_open(BlockDriverState *bs, QDict *options, int flags,
93
diff --git a/block/replication.c b/block/replication.c
78
if (s->refcount_block_cache) {
94
index XXXXXXX..XXXXXXX 100644
79
qcow2_cache_destroy(bs, s->refcount_block_cache);
95
--- a/block/replication.c
96
+++ b/block/replication.c
97
@@ -XXX,XX +XXX,XX @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
98
int64_t active_length, hidden_length, disk_length;
99
AioContext *aio_context;
100
Error *local_err = NULL;
101
- BackupPerf perf = { .use_copy_range = true };
102
+ BackupPerf perf = { .use_copy_range = true, .max_workers = 1 };
103
104
aio_context = bdrv_get_aio_context(bs);
105
aio_context_acquire(aio_context);
106
diff --git a/blockdev.c b/blockdev.c
107
index XXXXXXX..XXXXXXX 100644
108
--- a/blockdev.c
109
+++ b/blockdev.c
110
@@ -XXX,XX +XXX,XX @@ static BlockJob *do_backup_common(BackupCommon *backup,
111
{
112
BlockJob *job = NULL;
113
BdrvDirtyBitmap *bmap = NULL;
114
- BackupPerf perf = { .use_copy_range = true };
115
+ BackupPerf perf = { .use_copy_range = true, .max_workers = 64 };
116
int job_flags = JOB_DEFAULT;
117
118
if (!backup->has_speed) {
119
@@ -XXX,XX +XXX,XX @@ static BlockJob *do_backup_common(BackupCommon *backup,
120
if (backup->x_perf->has_use_copy_range) {
121
perf.use_copy_range = backup->x_perf->use_copy_range;
122
}
123
+ if (backup->x_perf->has_max_workers) {
124
+ perf.max_workers = backup->x_perf->max_workers;
125
+ }
126
+ if (backup->x_perf->has_max_chunk) {
127
+ perf.max_chunk = backup->x_perf->max_chunk;
128
+ }
80
}
129
}
81
- g_free(s->cluster_cache);
130
82
- qemu_vfree(s->cluster_data);
131
if ((backup->sync == MIRROR_SYNC_MODE_BITMAP) ||
83
qcrypto_block_free(s->crypto);
84
qapi_free_QCryptoBlockOpenOptions(s->crypto_opts);
85
return ret;
86
--
132
--
87
2.13.5
133
2.29.2
88
134
89
135
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
After introducing parallel async copy requests instead of plain
4
cluster-by-cluster copying loop, we'll have to wait for paused status,
5
as we need to wait for several parallel request. So, let's gently wait
6
instead of just asserting that job already paused.
7
8
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Reviewed-by: Max Reitz <mreitz@redhat.com>
10
Message-Id: <20210116214705.822267-12-vsementsov@virtuozzo.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
tests/qemu-iotests/056 | 9 +++++++--
14
1 file changed, 7 insertions(+), 2 deletions(-)
15
16
diff --git a/tests/qemu-iotests/056 b/tests/qemu-iotests/056
17
index XXXXXXX..XXXXXXX 100755
18
--- a/tests/qemu-iotests/056
19
+++ b/tests/qemu-iotests/056
20
@@ -XXX,XX +XXX,XX @@ class BackupTest(iotests.QMPTestCase):
21
event = self.vm.event_wait(name="BLOCK_JOB_ERROR",
22
match={'data': {'device': 'drive0'}})
23
self.assertNotEqual(event, None)
24
- # OK, job should be wedged
25
- res = self.vm.qmp('query-block-jobs')
26
+ # OK, job should pause, but it can't do it immediately, as it can't
27
+ # cancel other parallel requests (which didn't fail)
28
+ with iotests.Timeout(60, "Timeout waiting for backup actually paused"):
29
+ while True:
30
+ res = self.vm.qmp('query-block-jobs')
31
+ if res['return'][0]['status'] == 'paused':
32
+ break
33
self.assert_qmp(res, 'return[0]/status', 'paused')
34
res = self.vm.qmp('block-job-dismiss', id='drive0')
35
self.assert_qmp(res, 'error/desc',
36
--
37
2.29.2
38
39
diff view generated by jsdifflib
New patch
1
Right now, this does not change anything, because backup ignores
2
max-chunk and max-workers. However, as soon as backup is switched over
3
to block-copy for the background copying process, we will need it to
4
keep 129 passing.
1
5
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Message-Id: <20210120102043.28346-1-mreitz@redhat.com>
8
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
---
10
tests/qemu-iotests/129 | 7 ++++++-
11
1 file changed, 6 insertions(+), 1 deletion(-)
12
13
diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129
14
index XXXXXXX..XXXXXXX 100755
15
--- a/tests/qemu-iotests/129
16
+++ b/tests/qemu-iotests/129
17
@@ -XXX,XX +XXX,XX @@ class TestStopWithBlockJob(iotests.QMPTestCase):
18
sync="full", buf_size=65536)
19
20
def test_drive_backup(self):
21
+ # Limit max-chunk and max-workers so that block-copy will not
22
+ # launch so many workers working on so much data each that
23
+ # stop's bdrv_drain_all() would finish the job
24
self.do_test_stop("drive-backup", device="drive0",
25
target=self.target_img, format=iotests.imgfmt,
26
- sync="full")
27
+ sync="full",
28
+ x_perf={ 'max-chunk': 65536,
29
+ 'max-workers': 8 })
30
31
def test_block_commit(self):
32
# Add overlay above the source node so that we actually use a
33
--
34
2.29.2
35
36
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
The further change of moving backup to be a one block-copy call will
4
make copying chunk-size and cluster-size two separate things. So, even
5
with 64k cluster sized qcow2 image, default chunk would be 1M.
6
185 test however assumes, that with speed limited to 64K, one iteration
7
would result in offset=64K. It will change, as first iteration would
8
result in offset=1M independently of speed.
9
10
So, let's explicitly specify, what test wants: set max-chunk to 64K, so
11
that one iteration is 64K. Note, that we don't need to limit
12
max-workers, as block-copy rate limiter will handle the situation and
13
wouldn't start new workers when speed limit is obviously reached.
14
15
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
16
Reviewed-by: Max Reitz <mreitz@redhat.com>
17
Message-Id: <20210116214705.822267-13-vsementsov@virtuozzo.com>
18
Signed-off-by: Max Reitz <mreitz@redhat.com>
19
---
20
tests/qemu-iotests/185 | 3 ++-
21
tests/qemu-iotests/185.out | 3 ++-
22
2 files changed, 4 insertions(+), 2 deletions(-)
23
24
diff --git a/tests/qemu-iotests/185 b/tests/qemu-iotests/185
25
index XXXXXXX..XXXXXXX 100755
26
--- a/tests/qemu-iotests/185
27
+++ b/tests/qemu-iotests/185
28
@@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $h \
29
'target': '$TEST_IMG.copy',
30
'format': '$IMGFMT',
31
'sync': 'full',
32
- 'speed': 65536 } }" \
33
+ 'speed': 65536,
34
+ 'x-perf': {'max-chunk': 65536} } }" \
35
"return"
36
37
# If we don't sleep here 'quit' command races with disk I/O
38
diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out
39
index XXXXXXX..XXXXXXX 100644
40
--- a/tests/qemu-iotests/185.out
41
+++ b/tests/qemu-iotests/185.out
42
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 extended_l2=off
43
'target': 'TEST_DIR/t.IMGFMT.copy',
44
'format': 'IMGFMT',
45
'sync': 'full',
46
- 'speed': 65536 } }
47
+ 'speed': 65536,
48
+ 'x-perf': { 'max-chunk': 65536 } } }
49
Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
50
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}}
51
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}}
52
--
53
2.29.2
54
55
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
The further change of moving backup to be a one block-copy call will
4
make copying chunk-size and cluster-size two separate things. So, even
5
with 64k cluster sized qcow2 image, default chunk would be 1M.
6
Test 219 depends on specified chunk-size. Update it for explicit
7
chunk-size for backup as for mirror.
8
9
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
Reviewed-by: Max Reitz <mreitz@redhat.com>
11
Message-Id: <20210116214705.822267-14-vsementsov@virtuozzo.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
14
tests/qemu-iotests/219 | 13 +++++++------
15
1 file changed, 7 insertions(+), 6 deletions(-)
16
17
diff --git a/tests/qemu-iotests/219 b/tests/qemu-iotests/219
18
index XXXXXXX..XXXXXXX 100755
19
--- a/tests/qemu-iotests/219
20
+++ b/tests/qemu-iotests/219
21
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('disk.img') as disk_path, \
22
# but related to this also automatic state transitions like job
23
# completion), but still get pause points often enough to avoid making this
24
# test very slow, it's important to have the right ratio between speed and
25
- # buf_size.
26
+ # copy-chunk-size.
27
#
28
- # For backup, buf_size is hard-coded to the source image cluster size (64k),
29
- # so we'll pick the same for mirror. The slice time, i.e. the granularity
30
- # of the rate limiting is 100ms. With a speed of 256k per second, we can
31
- # get four pause points per second. This gives us 250ms per iteration,
32
- # which should be enough to stay deterministic.
33
+ # Chose 64k copy-chunk-size both for mirror (by buf_size) and backup (by
34
+ # x-max-chunk). The slice time, i.e. the granularity of the rate limiting
35
+ # is 100ms. With a speed of 256k per second, we can get four pause points
36
+ # per second. This gives us 250ms per iteration, which should be enough to
37
+ # stay deterministic.
38
39
test_job_lifecycle(vm, 'drive-mirror', has_ready=True, job_args={
40
'device': 'drive0-node',
41
@@ -XXX,XX +XXX,XX @@ with iotests.FilePath('disk.img') as disk_path, \
42
'target': copy_path,
43
'sync': 'full',
44
'speed': 262144,
45
+ 'x-perf': {'max-chunk': 65536},
46
'auto-finalize': auto_finalize,
47
'auto-dismiss': auto_dismiss,
48
})
49
--
50
2.29.2
51
52
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Iotest 257 dumps a lot of in-progress information of backup job, such
4
as offset and bitmap dirtiness. Further commit will move backup to be
5
one block-copy call, which will introduce async parallel requests
6
instead of plain cluster-by-cluster copying. To keep things
7
deterministic, allow only one worker (only one copy request at a time)
8
for this test.
9
10
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11
Reviewed-by: Max Reitz <mreitz@redhat.com>
12
Message-Id: <20210116214705.822267-15-vsementsov@virtuozzo.com>
13
Signed-off-by: Max Reitz <mreitz@redhat.com>
14
---
15
tests/qemu-iotests/257 | 1 +
16
tests/qemu-iotests/257.out | 306 ++++++++++++++++++-------------------
17
2 files changed, 154 insertions(+), 153 deletions(-)
18
19
diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257
20
index XXXXXXX..XXXXXXX 100755
21
--- a/tests/qemu-iotests/257
22
+++ b/tests/qemu-iotests/257
23
@@ -XXX,XX +XXX,XX @@ def blockdev_backup(vm, device, target, sync, **kwargs):
24
target=target,
25
sync=sync,
26
filter_node_name='backup-top',
27
+ x_perf={'max-workers': 1},
28
**kwargs)
29
return result
30
31
diff --git a/tests/qemu-iotests/257.out b/tests/qemu-iotests/257.out
32
index XXXXXXX..XXXXXXX 100644
33
--- a/tests/qemu-iotests/257.out
34
+++ b/tests/qemu-iotests/257.out
35
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
36
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
37
{"return": {}}
38
{}
39
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
40
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
41
{"return": {}}
42
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
43
44
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
45
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
46
{"return": {}}
47
{}
48
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
49
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
50
{"return": {}}
51
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
52
53
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
54
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
55
{"return": {}}
56
{}
57
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1"}}
58
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
59
{"return": {}}
60
61
--- Write #2 ---
62
@@ -XXX,XX +XXX,XX @@ expecting 15 dirty sectors; have 15. OK!
63
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
64
{"return": {}}
65
{}
66
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
67
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
68
{"return": {}}
69
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
70
71
@@ -XXX,XX +XXX,XX @@ expecting 15 dirty sectors; have 15. OK!
72
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
73
{"return": {}}
74
{}
75
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
76
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
77
{"return": {}}
78
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
79
{"return": {}}
80
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
81
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
82
{"return": {}}
83
{}
84
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
85
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
86
{"return": {}}
87
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
88
89
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
90
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
91
{"return": {}}
92
{}
93
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
94
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
95
{"return": {}}
96
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
97
98
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
99
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
100
{"return": {}}
101
{}
102
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1"}}
103
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
104
{"return": {}}
105
{"data": {"action": "report", "device": "backup_1", "operation": "read"}, "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
106
{"data": {"device": "backup_1", "error": "Input/output error", "len": 393216, "offset": 65536, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
107
@@ -XXX,XX +XXX,XX @@ expecting 14 dirty sectors; have 14. OK!
108
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
109
{"return": {}}
110
{}
111
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
112
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
113
{"return": {}}
114
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
115
116
@@ -XXX,XX +XXX,XX @@ expecting 14 dirty sectors; have 14. OK!
117
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
118
{"return": {}}
119
{}
120
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
121
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
122
{"return": {}}
123
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
124
{"return": {}}
125
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
126
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
127
{"return": {}}
128
{}
129
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
130
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
131
{"return": {}}
132
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
133
134
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
135
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
136
{"return": {}}
137
{}
138
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
139
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
140
{"return": {}}
141
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
142
143
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
144
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
145
{"return": {}}
146
{}
147
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1"}}
148
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
149
{"return": {}}
150
151
--- Write #2 ---
152
@@ -XXX,XX +XXX,XX @@ expecting 15 dirty sectors; have 15. OK!
153
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
154
{"return": {}}
155
{}
156
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
157
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
158
{"return": {}}
159
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
160
161
@@ -XXX,XX +XXX,XX @@ expecting 15 dirty sectors; have 15. OK!
162
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
163
{"return": {}}
164
{}
165
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
166
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
167
{"return": {}}
168
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
169
{"return": {}}
170
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
171
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
172
{"return": {}}
173
{}
174
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
175
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
176
{"return": {}}
177
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
178
179
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
180
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
181
{"return": {}}
182
{}
183
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
184
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
185
{"return": {}}
186
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
187
188
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
189
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
190
{"return": {}}
191
{}
192
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1"}}
193
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
194
{"return": {}}
195
196
--- Write #2 ---
197
@@ -XXX,XX +XXX,XX @@ expecting 15 dirty sectors; have 15. OK!
198
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
199
{"return": {}}
200
{}
201
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
202
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
203
{"return": {}}
204
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
205
206
@@ -XXX,XX +XXX,XX @@ expecting 15 dirty sectors; have 15. OK!
207
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
208
{"return": {}}
209
{}
210
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
211
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
212
{"return": {}}
213
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
214
{"return": {}}
215
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
216
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
217
{"return": {}}
218
{}
219
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
220
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
221
{"return": {}}
222
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
223
224
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
225
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
226
{"return": {}}
227
{}
228
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
229
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
230
{"return": {}}
231
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
232
233
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
234
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
235
{"return": {}}
236
{}
237
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1"}}
238
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
239
{"return": {}}
240
{"data": {"action": "report", "device": "backup_1", "operation": "read"}, "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
241
{"data": {"device": "backup_1", "error": "Input/output error", "len": 393216, "offset": 65536, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
242
@@ -XXX,XX +XXX,XX @@ expecting 14 dirty sectors; have 14. OK!
243
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
244
{"return": {}}
245
{}
246
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
247
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
248
{"return": {}}
249
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
250
251
@@ -XXX,XX +XXX,XX @@ expecting 14 dirty sectors; have 14. OK!
252
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
253
{"return": {}}
254
{}
255
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
256
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
257
{"return": {}}
258
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
259
{"return": {}}
260
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
261
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
262
{"return": {}}
263
{}
264
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
265
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
266
{"return": {}}
267
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
268
269
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
270
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
271
{"return": {}}
272
{}
273
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
274
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
275
{"return": {}}
276
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
277
278
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
279
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
280
{"return": {}}
281
{}
282
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1"}}
283
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
284
{"return": {}}
285
286
--- Write #2 ---
287
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
288
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
289
{"return": {}}
290
{}
291
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
292
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
293
{"return": {}}
294
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
295
296
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
297
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
298
{"return": {}}
299
{}
300
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
301
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
302
{"return": {}}
303
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
304
{"return": {}}
305
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
306
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
307
{"return": {}}
308
{}
309
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
310
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
311
{"return": {}}
312
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
313
314
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
315
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
316
{"return": {}}
317
{}
318
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
319
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
320
{"return": {}}
321
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
322
323
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
324
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
325
{"return": {}}
326
{}
327
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1"}}
328
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
329
{"return": {}}
330
331
--- Write #2 ---
332
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
333
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
334
{"return": {}}
335
{}
336
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
337
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
338
{"return": {}}
339
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
340
341
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
342
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
343
{"return": {}}
344
{}
345
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
346
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
347
{"return": {}}
348
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
349
{"return": {}}
350
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
351
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
352
{"return": {}}
353
{}
354
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
355
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
356
{"return": {}}
357
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
358
359
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
360
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
361
{"return": {}}
362
{}
363
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
364
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
365
{"return": {}}
366
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
367
368
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
369
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
370
{"return": {}}
371
{}
372
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1"}}
373
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
374
{"return": {}}
375
{"data": {"action": "report", "device": "backup_1", "operation": "read"}, "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
376
{"data": {"device": "backup_1", "error": "Input/output error", "len": 393216, "offset": 65536, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
377
@@ -XXX,XX +XXX,XX @@ expecting 13 dirty sectors; have 13. OK!
378
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
379
{"return": {}}
380
{}
381
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
382
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
383
{"return": {}}
384
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
385
386
@@ -XXX,XX +XXX,XX @@ expecting 13 dirty sectors; have 13. OK!
387
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
388
{"return": {}}
389
{}
390
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
391
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
392
{"return": {}}
393
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
394
{"return": {}}
395
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
396
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
397
{"return": {}}
398
{}
399
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
400
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
401
{"return": {}}
402
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
403
404
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
405
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
406
{"return": {}}
407
{}
408
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
409
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
410
{"return": {}}
411
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
412
413
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
414
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
415
{"return": {}}
416
{}
417
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1"}}
418
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "bitmap", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
419
{"return": {}}
420
421
--- Write #2 ---
422
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
423
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
424
{"return": {}}
425
{}
426
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
427
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
428
{"return": {}}
429
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
430
431
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
432
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
433
{"return": {}}
434
{}
435
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
436
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
437
{"return": {}}
438
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
439
{"return": {}}
440
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
441
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
442
{"return": {}}
443
{}
444
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
445
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
446
{"return": {}}
447
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
448
449
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
450
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
451
{"return": {}}
452
{}
453
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
454
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
455
{"return": {}}
456
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
457
458
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
459
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
460
{"return": {}}
461
{}
462
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "full", "target": "backup_target_1"}}
463
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "full", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
464
{"return": {}}
465
466
--- Write #2 ---
467
@@ -XXX,XX +XXX,XX @@ expecting 15 dirty sectors; have 15. OK!
468
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
469
{"return": {}}
470
{}
471
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
472
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
473
{"return": {}}
474
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
475
476
@@ -XXX,XX +XXX,XX @@ expecting 15 dirty sectors; have 15. OK!
477
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
478
{"return": {}}
479
{}
480
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
481
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
482
{"return": {}}
483
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
484
{"return": {}}
485
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
486
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
487
{"return": {}}
488
{}
489
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
490
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
491
{"return": {}}
492
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
493
494
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
495
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
496
{"return": {}}
497
{}
498
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
499
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
500
{"return": {}}
501
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
502
503
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
504
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
505
{"return": {}}
506
{}
507
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "full", "target": "backup_target_1"}}
508
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "full", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
509
{"return": {}}
510
{"data": {"action": "report", "device": "backup_1", "operation": "read"}, "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
511
{"data": {"device": "backup_1", "error": "Input/output error", "len": 67108864, "offset": 983040, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
512
@@ -XXX,XX +XXX,XX @@ expecting 14 dirty sectors; have 14. OK!
513
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
514
{"return": {}}
515
{}
516
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
517
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
518
{"return": {}}
519
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
520
521
@@ -XXX,XX +XXX,XX @@ expecting 14 dirty sectors; have 14. OK!
522
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
523
{"return": {}}
524
{}
525
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
526
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
527
{"return": {}}
528
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
529
{"return": {}}
530
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
531
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
532
{"return": {}}
533
{}
534
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
535
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
536
{"return": {}}
537
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
538
539
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
540
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
541
{"return": {}}
542
{}
543
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
544
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
545
{"return": {}}
546
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
547
548
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
549
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
550
{"return": {}}
551
{}
552
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "full", "target": "backup_target_1"}}
553
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "full", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
554
{"return": {}}
555
556
--- Write #2 ---
557
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
558
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
559
{"return": {}}
560
{}
561
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
562
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
563
{"return": {}}
564
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
565
566
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
567
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
568
{"return": {}}
569
{}
570
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
571
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
572
{"return": {}}
573
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
574
{"return": {}}
575
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
576
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
577
{"return": {}}
578
{}
579
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
580
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
581
{"return": {}}
582
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
583
584
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
585
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
586
{"return": {}}
587
{}
588
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
589
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
590
{"return": {}}
591
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
592
593
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
594
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
595
{"return": {}}
596
{}
597
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "full", "target": "backup_target_1"}}
598
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "full", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
599
{"return": {}}
600
601
--- Write #2 ---
602
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
603
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
604
{"return": {}}
605
{}
606
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
607
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
608
{"return": {}}
609
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
610
611
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
612
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
613
{"return": {}}
614
{}
615
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
616
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
617
{"return": {}}
618
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
619
{"return": {}}
620
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
621
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
622
{"return": {}}
623
{}
624
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
625
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
626
{"return": {}}
627
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
628
629
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
630
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
631
{"return": {}}
632
{}
633
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
634
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
635
{"return": {}}
636
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
637
638
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
639
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
640
{"return": {}}
641
{}
642
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "full", "target": "backup_target_1"}}
643
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "full", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
644
{"return": {}}
645
{"data": {"action": "report", "device": "backup_1", "operation": "read"}, "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
646
{"data": {"device": "backup_1", "error": "Input/output error", "len": 67108864, "offset": 983040, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
647
@@ -XXX,XX +XXX,XX @@ expecting 1014 dirty sectors; have 1014. OK!
648
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
649
{"return": {}}
650
{}
651
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
652
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
653
{"return": {}}
654
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
655
656
@@ -XXX,XX +XXX,XX @@ expecting 1014 dirty sectors; have 1014. OK!
657
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
658
{"return": {}}
659
{}
660
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
661
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
662
{"return": {}}
663
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
664
{"return": {}}
665
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
666
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
667
{"return": {}}
668
{}
669
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
670
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
671
{"return": {}}
672
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
673
674
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
675
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
676
{"return": {}}
677
{}
678
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
679
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
680
{"return": {}}
681
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
682
683
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
684
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
685
{"return": {}}
686
{}
687
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "full", "target": "backup_target_1"}}
688
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "full", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
689
{"return": {}}
690
691
--- Write #2 ---
692
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
693
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
694
{"return": {}}
695
{}
696
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
697
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
698
{"return": {}}
699
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
700
701
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
702
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
703
{"return": {}}
704
{}
705
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
706
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
707
{"return": {}}
708
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
709
{"return": {}}
710
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
711
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
712
{"return": {}}
713
{}
714
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
715
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
716
{"return": {}}
717
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
718
719
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
720
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
721
{"return": {}}
722
{}
723
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
724
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
725
{"return": {}}
726
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
727
728
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
729
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
730
{"return": {}}
731
{}
732
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "top", "target": "backup_target_1"}}
733
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "top", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
734
{"return": {}}
735
736
--- Write #2 ---
737
@@ -XXX,XX +XXX,XX @@ expecting 15 dirty sectors; have 15. OK!
738
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
739
{"return": {}}
740
{}
741
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
742
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
743
{"return": {}}
744
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
745
746
@@ -XXX,XX +XXX,XX @@ expecting 15 dirty sectors; have 15. OK!
747
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
748
{"return": {}}
749
{}
750
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
751
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
752
{"return": {}}
753
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
754
{"return": {}}
755
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
756
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
757
{"return": {}}
758
{}
759
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
760
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
761
{"return": {}}
762
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
763
764
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
765
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
766
{"return": {}}
767
{}
768
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
769
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
770
{"return": {}}
771
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
772
773
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
774
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
775
{"return": {}}
776
{}
777
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "top", "target": "backup_target_1"}}
778
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "top", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
779
{"return": {}}
780
{"data": {"action": "report", "device": "backup_1", "operation": "read"}, "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
781
{"data": {"device": "backup_1", "error": "Input/output error", "len": 458752, "offset": 65536, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
782
@@ -XXX,XX +XXX,XX @@ expecting 14 dirty sectors; have 14. OK!
783
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
784
{"return": {}}
785
{}
786
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
787
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
788
{"return": {}}
789
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
790
791
@@ -XXX,XX +XXX,XX @@ expecting 14 dirty sectors; have 14. OK!
792
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
793
{"return": {}}
794
{}
795
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
796
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
797
{"return": {}}
798
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
799
{"return": {}}
800
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
801
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
802
{"return": {}}
803
{}
804
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
805
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
806
{"return": {}}
807
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
808
809
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
810
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
811
{"return": {}}
812
{}
813
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
814
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
815
{"return": {}}
816
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
817
818
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
819
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
820
{"return": {}}
821
{}
822
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "top", "target": "backup_target_1"}}
823
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "top", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
824
{"return": {}}
825
826
--- Write #2 ---
827
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
828
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
829
{"return": {}}
830
{}
831
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
832
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
833
{"return": {}}
834
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
835
836
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
837
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
838
{"return": {}}
839
{}
840
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
841
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
842
{"return": {}}
843
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
844
{"return": {}}
845
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
846
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
847
{"return": {}}
848
{}
849
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
850
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
851
{"return": {}}
852
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
853
854
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
855
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
856
{"return": {}}
857
{}
858
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
859
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
860
{"return": {}}
861
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
862
863
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
864
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
865
{"return": {}}
866
{}
867
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "top", "target": "backup_target_1"}}
868
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "top", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
869
{"return": {}}
870
871
--- Write #2 ---
872
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
873
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
874
{"return": {}}
875
{}
876
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
877
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
878
{"return": {}}
879
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
880
881
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
882
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
883
{"return": {}}
884
{}
885
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
886
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
887
{"return": {}}
888
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
889
{"return": {}}
890
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
891
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
892
{"return": {}}
893
{}
894
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
895
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
896
{"return": {}}
897
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
898
899
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
900
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
901
{"return": {}}
902
{}
903
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
904
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
905
{"return": {}}
906
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
907
908
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
909
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
910
{"return": {}}
911
{}
912
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "top", "target": "backup_target_1"}}
913
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "top", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
914
{"return": {}}
915
{"data": {"action": "report", "device": "backup_1", "operation": "read"}, "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
916
{"data": {"device": "backup_1", "error": "Input/output error", "len": 458752, "offset": 65536, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
917
@@ -XXX,XX +XXX,XX @@ expecting 14 dirty sectors; have 14. OK!
918
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
919
{"return": {}}
920
{}
921
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
922
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
923
{"return": {}}
924
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
925
926
@@ -XXX,XX +XXX,XX @@ expecting 14 dirty sectors; have 14. OK!
927
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
928
{"return": {}}
929
{}
930
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
931
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
932
{"return": {}}
933
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
934
{"return": {}}
935
@@ -XXX,XX +XXX,XX @@ write -P0x76 0x3ff0000 0x10000
936
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
937
{"return": {}}
938
{}
939
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0"}}
940
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_0", "sync": "full", "target": "ref_target_0", "x-perf": {"max-workers": 1}}}
941
{"return": {}}
942
{"data": {"device": "ref_backup_0", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
943
944
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
945
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
946
{"return": {}}
947
{}
948
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1"}}
949
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_1", "sync": "full", "target": "ref_target_1", "x-perf": {"max-workers": 1}}}
950
{"return": {}}
951
{"data": {"device": "ref_backup_1", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
952
953
@@ -XXX,XX +XXX,XX @@ expecting 6 dirty sectors; have 6. OK!
954
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
955
{"return": {}}
956
{}
957
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "top", "target": "backup_target_1"}}
958
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_1", "sync": "top", "target": "backup_target_1", "x-perf": {"max-workers": 1}}}
959
{"return": {}}
960
961
--- Write #2 ---
962
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
963
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
964
{"return": {}}
965
{}
966
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2"}}
967
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "ref_backup_2", "sync": "full", "target": "ref_target_2", "x-perf": {"max-workers": 1}}}
968
{"return": {}}
969
{"data": {"device": "ref_backup_2", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
970
971
@@ -XXX,XX +XXX,XX @@ expecting 12 dirty sectors; have 12. OK!
972
{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}}
973
{"return": {}}
974
{}
975
-{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2"}}
976
+{"execute": "blockdev-backup", "arguments": {"auto-finalize": false, "bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "backup_2", "sync": "bitmap", "target": "backup_target_2", "x-perf": {"max-workers": 1}}}
977
{"return": {}}
978
{"execute": "job-finalize", "arguments": {"id": "backup_2"}}
979
{"return": {}}
980
@@ -XXX,XX +XXX,XX @@ qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fbackup2" ==> Identical, OK!
981
982
-- Sync mode incremental tests --
983
984
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target"}}
985
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target", "x-perf": {"max-workers": 1}}}
986
{"error": {"class": "GenericError", "desc": "must provide a valid bitmap name for 'incremental' sync mode"}}
987
988
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target"}}
989
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target", "x-perf": {"max-workers": 1}}}
990
{"error": {"class": "GenericError", "desc": "must provide a valid bitmap name for 'incremental' sync mode"}}
991
992
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target"}}
993
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target", "x-perf": {"max-workers": 1}}}
994
{"error": {"class": "GenericError", "desc": "must provide a valid bitmap name for 'incremental' sync mode"}}
995
996
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target"}}
997
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target", "x-perf": {"max-workers": 1}}}
998
{"error": {"class": "GenericError", "desc": "must provide a valid bitmap name for 'incremental' sync mode"}}
999
1000
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target"}}
1001
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1002
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1003
1004
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target"}}
1005
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1006
{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be 'on-success' when using sync mode 'incremental'"}}
1007
1008
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target"}}
1009
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1010
{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be 'on-success' when using sync mode 'incremental'"}}
1011
1012
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target"}}
1013
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1014
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1015
1016
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target"}}
1017
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1018
{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be 'on-success' when using sync mode 'incremental'"}}
1019
1020
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target"}}
1021
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "incremental", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1022
{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be 'on-success' when using sync mode 'incremental'"}}
1023
1024
-- Sync mode bitmap tests --
1025
1026
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target"}}
1027
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1028
{"error": {"class": "GenericError", "desc": "must provide a valid bitmap name for 'bitmap' sync mode"}}
1029
1030
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target"}}
1031
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1032
{"error": {"class": "GenericError", "desc": "must provide a valid bitmap name for 'bitmap' sync mode"}}
1033
1034
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target"}}
1035
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1036
{"error": {"class": "GenericError", "desc": "must provide a valid bitmap name for 'bitmap' sync mode"}}
1037
1038
-{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target"}}
1039
+{"execute": "blockdev-backup", "arguments": {"device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1040
{"error": {"class": "GenericError", "desc": "must provide a valid bitmap name for 'bitmap' sync mode"}}
1041
1042
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target"}}
1043
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1044
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1045
1046
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target"}}
1047
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1048
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1049
1050
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target"}}
1051
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1052
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1053
1054
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target"}}
1055
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1056
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1057
1058
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target"}}
1059
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "bitmap", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1060
{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be given when providing a bitmap"}}
1061
1062
-- Sync mode full tests --
1063
1064
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target"}}
1065
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1066
{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
1067
1068
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target"}}
1069
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1070
{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
1071
1072
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target"}}
1073
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1074
{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
1075
1076
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target"}}
1077
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1078
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1079
1080
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target"}}
1081
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1082
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1083
1084
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target"}}
1085
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1086
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1087
1088
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target"}}
1089
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1090
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1091
1092
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target"}}
1093
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1094
{"error": {"class": "GenericError", "desc": "Bitmap sync mode 'never' has no meaningful effect when combined with sync mode 'full'"}}
1095
1096
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target"}}
1097
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "full", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1098
{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be given when providing a bitmap"}}
1099
1100
-- Sync mode top tests --
1101
1102
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target"}}
1103
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1104
{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
1105
1106
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target"}}
1107
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1108
{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
1109
1110
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target"}}
1111
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1112
{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
1113
1114
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target"}}
1115
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1116
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1117
1118
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target"}}
1119
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1120
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1121
1122
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target"}}
1123
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1124
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1125
1126
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target"}}
1127
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1128
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1129
1130
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target"}}
1131
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1132
{"error": {"class": "GenericError", "desc": "Bitmap sync mode 'never' has no meaningful effect when combined with sync mode 'top'"}}
1133
1134
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target"}}
1135
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "top", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1136
{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be given when providing a bitmap"}}
1137
1138
-- Sync mode none tests --
1139
1140
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target"}}
1141
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1142
{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
1143
1144
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target"}}
1145
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1146
{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
1147
1148
-{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target"}}
1149
+{"execute": "blockdev-backup", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1150
{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
1151
1152
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target"}}
1153
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1154
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1155
1156
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target"}}
1157
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1158
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1159
1160
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target"}}
1161
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1162
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1163
1164
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target"}}
1165
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1166
{"error": {"class": "GenericError", "desc": "Bitmap 'bitmap404' could not be found"}}
1167
1168
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target"}}
1169
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1170
{"error": {"class": "GenericError", "desc": "sync mode 'none' does not produce meaningful bitmap outputs"}}
1171
1172
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target"}}
1173
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1174
{"error": {"class": "GenericError", "desc": "sync mode 'none' does not produce meaningful bitmap outputs"}}
1175
1176
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target"}}
1177
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1178
{"error": {"class": "GenericError", "desc": "sync mode 'none' does not produce meaningful bitmap outputs"}}
1179
1180
-{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target"}}
1181
+{"execute": "blockdev-backup", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "backup-top", "job-id": "api_job", "sync": "none", "target": "backup_target", "x-perf": {"max-workers": 1}}}
1182
{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be given when providing a bitmap"}}
1183
1184
--
1185
2.29.2
1186
1187
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
We are going to stop use of this callback in the following commit.
4
Still the callback handling code will be dropped in a separate commit.
5
So, for now let's make it optional.
6
7
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Message-Id: <20210116214705.822267-16-vsementsov@virtuozzo.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
block/block-copy.c | 4 +++-
13
1 file changed, 3 insertions(+), 1 deletion(-)
14
15
diff --git a/block/block-copy.c b/block/block-copy.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/block-copy.c
18
+++ b/block/block-copy.c
19
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int block_copy_task_entry(AioTask *task)
20
t->call_state->error_is_read = error_is_read;
21
} else {
22
progress_work_done(t->s->progress, t->bytes);
23
- t->s->progress_bytes_callback(t->bytes, t->s->progress_opaque);
24
+ if (t->s->progress_bytes_callback) {
25
+ t->s->progress_bytes_callback(t->bytes, t->s->progress_opaque);
26
+ }
27
}
28
co_put_to_shres(t->s->mem, t->bytes);
29
block_copy_task_end(t, ret);
30
--
31
2.29.2
32
33
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
Both the throttling limits set with the throttling.iops-* and
3
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
4
throttling.bps-* options and their QMP equivalents defined in the
4
Reviewed-by: Max Reitz <mreitz@redhat.com>
5
BlockIOThrottle struct are integer values.
5
Message-Id: <20210116214705.822267-17-vsementsov@virtuozzo.com>
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
---
8
block/backup.c | 12 +++++-------
9
1 file changed, 5 insertions(+), 7 deletions(-)
6
10
7
Those limits are also reported in the BlockDeviceInfo struct and they
11
diff --git a/block/backup.c b/block/backup.c
8
are integers there as well.
9
10
Therefore there's no reason to store them internally as double and do
11
the conversion everytime we're setting or querying them, so this patch
12
uses uint64_t for those types. Let's also use an unsigned type because
13
we don't allow negative values anyway.
14
15
LeakyBucket.level and LeakyBucket.burst_level do however remain double
16
because their value changes depending on the fraction of time elapsed
17
since the previous I/O operation.
18
19
Signed-off-by: Alberto Garcia <berto@igalia.com>
20
Message-id: f29b840422767b5be2c41c2dfdbbbf6c5f8fedf8.1503580370.git.berto@igalia.com
21
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
22
---
23
include/qemu/throttle.h | 4 ++--
24
tests/test-throttle.c | 3 ++-
25
util/throttle.c | 7 +++----
26
3 files changed, 7 insertions(+), 7 deletions(-)
27
28
diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
29
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
30
--- a/include/qemu/throttle.h
13
--- a/block/backup.c
31
+++ b/include/qemu/throttle.h
14
+++ b/block/backup.c
32
@@ -XXX,XX +XXX,XX @@ typedef enum {
15
@@ -XXX,XX +XXX,XX @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
33
*/
16
static int coroutine_fn backup_run(Job *job, Error **errp)
34
17
{
35
typedef struct LeakyBucket {
18
BackupBlockJob *s = container_of(job, BackupBlockJob, common.job);
36
- double avg; /* average goal in units per second */
19
- int ret = 0;
37
- double max; /* leaky bucket max burst in units */
20
+ int ret;
38
+ uint64_t avg; /* average goal in units per second */
21
39
+ uint64_t max; /* leaky bucket max burst in units */
22
backup_init_bcs_bitmap(s);
40
double level; /* bucket level in units */
23
41
double burst_level; /* bucket level in units (for computing bursts) */
24
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_run(Job *job, Error **errp)
42
unsigned burst_length; /* max length of the burst period, in seconds */
25
43
diff --git a/tests/test-throttle.c b/tests/test-throttle.c
26
for (offset = 0; offset < s->len; ) {
44
index XXXXXXX..XXXXXXX 100644
27
if (yield_and_check(s)) {
45
--- a/tests/test-throttle.c
28
- ret = -ECANCELED;
46
+++ b/tests/test-throttle.c
29
- goto out;
47
@@ -XXX,XX +XXX,XX @@ static void test_enabled(void)
30
+ return -ECANCELED;
48
for (i = 0; i < BUCKETS_COUNT; i++) {
31
}
49
throttle_config_init(&cfg);
32
50
set_cfg_value(false, i, 150);
33
ret = block_copy_reset_unallocated(s->bcs, offset, &count);
51
+ g_assert(throttle_is_valid(&cfg, NULL));
34
if (ret < 0) {
52
g_assert(throttle_enabled(&cfg));
35
- goto out;
36
+ return ret;
37
}
38
39
offset += count;
40
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_run(Job *job, Error **errp)
41
job_yield(job);
42
}
43
} else {
44
- ret = backup_loop(s);
45
+ return backup_loop(s);
53
}
46
}
54
47
55
for (i = 0; i < BUCKETS_COUNT; i++) {
48
- out:
56
throttle_config_init(&cfg);
49
- return ret;
57
set_cfg_value(false, i, -150);
50
+ return 0;
58
- g_assert(!throttle_enabled(&cfg));
59
+ g_assert(!throttle_is_valid(&cfg, NULL));
60
}
61
}
51
}
62
52
63
diff --git a/util/throttle.c b/util/throttle.c
53
static const BlockJobDriver backup_job_driver = {
64
index XXXXXXX..XXXXXXX 100644
65
--- a/util/throttle.c
66
+++ b/util/throttle.c
67
@@ -XXX,XX +XXX,XX @@ int64_t throttle_compute_wait(LeakyBucket *bkt)
68
/* If bkt->max is 0 we still want to allow short bursts of I/O
69
* from the guest, otherwise every other request will be throttled
70
* and performance will suffer considerably. */
71
- bucket_size = bkt->avg / 10;
72
+ bucket_size = (double) bkt->avg / 10;
73
burst_bucket_size = 0;
74
} else {
75
/* If we have a burst limit then we have to wait until all I/O
76
* at burst rate has finished before throttling to bkt->avg */
77
bucket_size = bkt->max * bkt->burst_length;
78
- burst_bucket_size = bkt->max / 10;
79
+ burst_bucket_size = (double) bkt->max / 10;
80
}
81
82
/* If the main bucket is full then we have to wait */
83
@@ -XXX,XX +XXX,XX @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **errp)
84
85
for (i = 0; i < BUCKETS_COUNT; i++) {
86
LeakyBucket *bkt = &cfg->buckets[i];
87
- if (bkt->avg < 0 || bkt->max < 0 ||
88
- bkt->avg > THROTTLE_VALUE_MAX || bkt->max > THROTTLE_VALUE_MAX) {
89
+ if (bkt->avg > THROTTLE_VALUE_MAX || bkt->max > THROTTLE_VALUE_MAX) {
90
error_setg(errp, "bps/iops/max values must be within [0, %lld]",
91
THROTTLE_VALUE_MAX);
92
return false;
93
--
54
--
94
2.13.5
55
2.29.2
95
56
96
57
diff view generated by jsdifflib
New patch
1
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
3
This brings async request handling and block-status driven chunk sizes
4
to backup out of the box, which improves backup performance.
5
6
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
Message-Id: <20210116214705.822267-18-vsementsov@virtuozzo.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
11
block/backup.c | 187 +++++++++++++++++++++++++++++++------------------
12
1 file changed, 120 insertions(+), 67 deletions(-)
13
14
diff --git a/block/backup.c b/block/backup.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/block/backup.c
17
+++ b/block/backup.c
18
@@ -XXX,XX +XXX,XX @@
19
#include "block/block-copy.h"
20
#include "qapi/error.h"
21
#include "qapi/qmp/qerror.h"
22
-#include "qemu/ratelimit.h"
23
#include "qemu/cutils.h"
24
#include "sysemu/block-backend.h"
25
#include "qemu/bitmap.h"
26
@@ -XXX,XX +XXX,XX @@ typedef struct BackupBlockJob {
27
BlockdevOnError on_source_error;
28
BlockdevOnError on_target_error;
29
uint64_t len;
30
- uint64_t bytes_read;
31
int64_t cluster_size;
32
BackupPerf perf;
33
34
BlockCopyState *bcs;
35
+
36
+ bool wait;
37
+ BlockCopyCallState *bg_bcs_call;
38
} BackupBlockJob;
39
40
static const BlockJobDriver backup_job_driver;
41
42
-static void backup_progress_bytes_callback(int64_t bytes, void *opaque)
43
-{
44
- BackupBlockJob *s = opaque;
45
-
46
- s->bytes_read += bytes;
47
-}
48
-
49
-static int coroutine_fn backup_do_cow(BackupBlockJob *job,
50
- int64_t offset, uint64_t bytes,
51
- bool *error_is_read)
52
-{
53
- int ret = 0;
54
- int64_t start, end; /* bytes */
55
-
56
- start = QEMU_ALIGN_DOWN(offset, job->cluster_size);
57
- end = QEMU_ALIGN_UP(bytes + offset, job->cluster_size);
58
-
59
- trace_backup_do_cow_enter(job, start, offset, bytes);
60
-
61
- ret = block_copy(job->bcs, start, end - start, true, error_is_read);
62
-
63
- trace_backup_do_cow_return(job, offset, bytes, ret);
64
-
65
- return ret;
66
-}
67
-
68
static void backup_cleanup_sync_bitmap(BackupBlockJob *job, int ret)
69
{
70
BdrvDirtyBitmap *bm;
71
@@ -XXX,XX +XXX,XX @@ static BlockErrorAction backup_error_action(BackupBlockJob *job,
72
}
73
}
74
75
-static bool coroutine_fn yield_and_check(BackupBlockJob *job)
76
+static void coroutine_fn backup_block_copy_callback(void *opaque)
77
{
78
- uint64_t delay_ns;
79
-
80
- if (job_is_cancelled(&job->common.job)) {
81
- return true;
82
- }
83
-
84
- /*
85
- * We need to yield even for delay_ns = 0 so that bdrv_drain_all() can
86
- * return. Without a yield, the VM would not reboot.
87
- */
88
- delay_ns = block_job_ratelimit_get_delay(&job->common, job->bytes_read);
89
- job->bytes_read = 0;
90
- job_sleep_ns(&job->common.job, delay_ns);
91
+ BackupBlockJob *s = opaque;
92
93
- if (job_is_cancelled(&job->common.job)) {
94
- return true;
95
+ if (s->wait) {
96
+ s->wait = false;
97
+ aio_co_wake(s->common.job.co);
98
+ } else {
99
+ job_enter(&s->common.job);
100
}
101
-
102
- return false;
103
}
104
105
static int coroutine_fn backup_loop(BackupBlockJob *job)
106
{
107
- bool error_is_read;
108
- int64_t offset;
109
- BdrvDirtyBitmapIter *bdbi;
110
+ BlockCopyCallState *s = NULL;
111
int ret = 0;
112
+ bool error_is_read;
113
+ BlockErrorAction act;
114
+
115
+ while (true) { /* retry loop */
116
+ job->bg_bcs_call = s = block_copy_async(job->bcs, 0,
117
+ QEMU_ALIGN_UP(job->len, job->cluster_size),
118
+ job->perf.max_workers, job->perf.max_chunk,
119
+ backup_block_copy_callback, job);
120
+
121
+ while (!block_copy_call_finished(s) &&
122
+ !job_is_cancelled(&job->common.job))
123
+ {
124
+ job_yield(&job->common.job);
125
+ }
126
127
- bdbi = bdrv_dirty_iter_new(block_copy_dirty_bitmap(job->bcs));
128
- while ((offset = bdrv_dirty_iter_next(bdbi)) != -1) {
129
- do {
130
- if (yield_and_check(job)) {
131
- goto out;
132
- }
133
- ret = backup_do_cow(job, offset, job->cluster_size, &error_is_read);
134
- if (ret < 0 && backup_error_action(job, error_is_read, -ret) ==
135
- BLOCK_ERROR_ACTION_REPORT)
136
- {
137
- goto out;
138
- }
139
- } while (ret < 0);
140
+ if (!block_copy_call_finished(s)) {
141
+ assert(job_is_cancelled(&job->common.job));
142
+ /*
143
+ * Note that we can't use job_yield() here, as it doesn't work for
144
+ * cancelled job.
145
+ */
146
+ block_copy_call_cancel(s);
147
+ job->wait = true;
148
+ qemu_coroutine_yield();
149
+ assert(block_copy_call_finished(s));
150
+ ret = 0;
151
+ goto out;
152
+ }
153
+
154
+ if (job_is_cancelled(&job->common.job) ||
155
+ block_copy_call_succeeded(s))
156
+ {
157
+ ret = 0;
158
+ goto out;
159
+ }
160
+
161
+ if (block_copy_call_cancelled(s)) {
162
+ /*
163
+ * Job is not cancelled but only block-copy call. This is possible
164
+ * after job pause. Now the pause is finished, start new block-copy
165
+ * iteration.
166
+ */
167
+ block_copy_call_free(s);
168
+ continue;
169
+ }
170
+
171
+ /* The only remaining case is failed block-copy call. */
172
+ assert(block_copy_call_failed(s));
173
+
174
+ ret = block_copy_call_status(s, &error_is_read);
175
+ act = backup_error_action(job, error_is_read, -ret);
176
+ switch (act) {
177
+ case BLOCK_ERROR_ACTION_REPORT:
178
+ goto out;
179
+ case BLOCK_ERROR_ACTION_STOP:
180
+ /*
181
+ * Go to pause prior to starting new block-copy call on the next
182
+ * iteration.
183
+ */
184
+ job_pause_point(&job->common.job);
185
+ break;
186
+ case BLOCK_ERROR_ACTION_IGNORE:
187
+ /* Proceed to new block-copy call to retry. */
188
+ break;
189
+ default:
190
+ abort();
191
+ }
192
+
193
+ block_copy_call_free(s);
194
}
195
196
- out:
197
- bdrv_dirty_iter_free(bdbi);
198
+out:
199
+ block_copy_call_free(s);
200
+ job->bg_bcs_call = NULL;
201
return ret;
202
}
203
204
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_run(Job *job, Error **errp)
205
int64_t count;
206
207
for (offset = 0; offset < s->len; ) {
208
- if (yield_and_check(s)) {
209
+ if (job_is_cancelled(job)) {
210
+ return -ECANCELED;
211
+ }
212
+
213
+ job_pause_point(job);
214
+
215
+ if (job_is_cancelled(job)) {
216
return -ECANCELED;
217
}
218
219
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn backup_run(Job *job, Error **errp)
220
return 0;
221
}
222
223
+static void coroutine_fn backup_pause(Job *job)
224
+{
225
+ BackupBlockJob *s = container_of(job, BackupBlockJob, common.job);
226
+
227
+ if (s->bg_bcs_call && !block_copy_call_finished(s->bg_bcs_call)) {
228
+ block_copy_call_cancel(s->bg_bcs_call);
229
+ s->wait = true;
230
+ qemu_coroutine_yield();
231
+ }
232
+}
233
+
234
+static void coroutine_fn backup_set_speed(BlockJob *job, int64_t speed)
235
+{
236
+ BackupBlockJob *s = container_of(job, BackupBlockJob, common);
237
+
238
+ /*
239
+ * block_job_set_speed() is called first from block_job_create(), when we
240
+ * don't yet have s->bcs.
241
+ */
242
+ if (s->bcs) {
243
+ block_copy_set_speed(s->bcs, speed);
244
+ if (s->bg_bcs_call) {
245
+ block_copy_kick(s->bg_bcs_call);
246
+ }
247
+ }
248
+}
249
+
250
static const BlockJobDriver backup_job_driver = {
251
.job_driver = {
252
.instance_size = sizeof(BackupBlockJob),
253
@@ -XXX,XX +XXX,XX @@ static const BlockJobDriver backup_job_driver = {
254
.commit = backup_commit,
255
.abort = backup_abort,
256
.clean = backup_clean,
257
- }
258
+ .pause = backup_pause,
259
+ },
260
+ .set_speed = backup_set_speed,
261
};
262
263
static int64_t backup_calculate_cluster_size(BlockDriverState *target,
264
@@ -XXX,XX +XXX,XX @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
265
job->len = len;
266
job->perf = *perf;
267
268
- block_copy_set_progress_callback(bcs, backup_progress_bytes_callback, job);
269
block_copy_set_progress_meter(bcs, &job->common.job.progress);
270
+ block_copy_set_speed(bcs, speed);
271
272
/* Required permissions are already taken by backup-top target */
273
block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL,
274
--
275
2.29.2
276
277
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Further commit will add a benchmark
4
(scripts/simplebench/bench-backup.py), which will show that backup
5
works better with async parallel requests (previous commit) and
6
disabled copy_range. So, let's disable copy_range by default.
7
8
Note: the option was added several commits ago with default to true,
9
to follow old behavior (the feature was enabled unconditionally), and
10
only now we are going to change the default behavior.
11
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
13
Reviewed-by: Max Reitz <mreitz@redhat.com>
14
Message-Id: <20210116214705.822267-19-vsementsov@virtuozzo.com>
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
16
---
17
qapi/block-core.json | 2 +-
18
blockdev.c | 2 +-
19
2 files changed, 2 insertions(+), 2 deletions(-)
20
21
diff --git a/qapi/block-core.json b/qapi/block-core.json
22
index XXXXXXX..XXXXXXX 100644
23
--- a/qapi/block-core.json
24
+++ b/qapi/block-core.json
25
@@ -XXX,XX +XXX,XX @@
26
# Optional parameters for backup. These parameters don't affect
27
# functionality, but may significantly affect performance.
28
#
29
-# @use-copy-range: Use copy offloading. Default true.
30
+# @use-copy-range: Use copy offloading. Default false.
31
#
32
# @max-workers: Maximum number of parallel requests for the sustained background
33
# copying process. Doesn't influence copy-before-write operations.
34
diff --git a/blockdev.c b/blockdev.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/blockdev.c
37
+++ b/blockdev.c
38
@@ -XXX,XX +XXX,XX @@ static BlockJob *do_backup_common(BackupCommon *backup,
39
{
40
BlockJob *job = NULL;
41
BdrvDirtyBitmap *bmap = NULL;
42
- BackupPerf perf = { .use_copy_range = true, .max_workers = 64 };
43
+ BackupPerf perf = { .max_workers = 64 };
44
int job_flags = JOB_DEFAULT;
45
46
if (!backup->has_speed) {
47
--
48
2.29.2
49
50
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Drop unused code.
4
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
7
Message-Id: <20210116214705.822267-20-vsementsov@virtuozzo.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
include/block/block-copy.h | 6 ------
11
block/block-copy.c | 15 ---------------
12
2 files changed, 21 deletions(-)
13
14
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/include/block/block-copy.h
17
+++ b/include/block/block-copy.h
18
@@ -XXX,XX +XXX,XX @@
19
#include "block/block.h"
20
#include "qemu/co-shared-resource.h"
21
22
-typedef void (*ProgressBytesCallbackFunc)(int64_t bytes, void *opaque);
23
typedef void (*BlockCopyAsyncCallbackFunc)(void *opaque);
24
typedef struct BlockCopyState BlockCopyState;
25
typedef struct BlockCopyCallState BlockCopyCallState;
26
@@ -XXX,XX +XXX,XX @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
27
BdrvRequestFlags write_flags,
28
Error **errp);
29
30
-void block_copy_set_progress_callback(
31
- BlockCopyState *s,
32
- ProgressBytesCallbackFunc progress_bytes_callback,
33
- void *progress_opaque);
34
-
35
void block_copy_set_progress_meter(BlockCopyState *s, ProgressMeter *pm);
36
37
void block_copy_state_free(BlockCopyState *s);
38
diff --git a/block/block-copy.c b/block/block-copy.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/block/block-copy.c
41
+++ b/block/block-copy.c
42
@@ -XXX,XX +XXX,XX @@ typedef struct BlockCopyState {
43
bool skip_unallocated;
44
45
ProgressMeter *progress;
46
- /* progress_bytes_callback: called when some copying progress is done. */
47
- ProgressBytesCallbackFunc progress_bytes_callback;
48
- void *progress_opaque;
49
50
SharedResource *mem;
51
52
@@ -XXX,XX +XXX,XX @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
53
return s;
54
}
55
56
-void block_copy_set_progress_callback(
57
- BlockCopyState *s,
58
- ProgressBytesCallbackFunc progress_bytes_callback,
59
- void *progress_opaque)
60
-{
61
- s->progress_bytes_callback = progress_bytes_callback;
62
- s->progress_opaque = progress_opaque;
63
-}
64
-
65
void block_copy_set_progress_meter(BlockCopyState *s, ProgressMeter *pm)
66
{
67
s->progress = pm;
68
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int block_copy_task_entry(AioTask *task)
69
t->call_state->error_is_read = error_is_read;
70
} else {
71
progress_work_done(t->s->progress, t->bytes);
72
- if (t->s->progress_bytes_callback) {
73
- t->s->progress_bytes_callback(t->bytes, t->s->progress_opaque);
74
- }
75
}
76
co_put_to_shres(t->s->mem, t->bytes);
77
block_copy_task_end(t, ret);
78
--
79
2.29.2
80
81
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
There's a few cases which we're passing an Error pointer to a function
3
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
4
only to discard it immediately afterwards without checking it. In
4
Reviewed-by: Max Reitz <mreitz@redhat.com>
5
these cases we can simply remove the variable and pass NULL instead.
5
Message-Id: <20210116214705.822267-21-vsementsov@virtuozzo.com>
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
---
8
include/block/block-copy.h | 2 +-
9
block/backup-top.c | 2 +-
10
block/block-copy.c | 10 ++--------
11
3 files changed, 4 insertions(+), 10 deletions(-)
6
12
7
Signed-off-by: Alberto Garcia <berto@igalia.com>
13
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Eric Blake <eblake@redhat.com>
10
Message-id: 20170829120836.16091-1-berto@igalia.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
---
13
block/qcow.c | 12 +++---------
14
block/qcow2.c | 8 ++------
15
dump.c | 4 +---
16
3 files changed, 6 insertions(+), 18 deletions(-)
17
18
diff --git a/block/qcow.c b/block/qcow.c
19
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
20
--- a/block/qcow.c
15
--- a/include/block/block-copy.h
21
+++ b/block/qcow.c
16
+++ b/include/block/block-copy.h
22
@@ -XXX,XX +XXX,XX @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
17
@@ -XXX,XX +XXX,XX @@ int64_t block_copy_reset_unallocated(BlockCopyState *s,
23
start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
18
int64_t offset, int64_t *count);
24
for(i = 0; i < s->cluster_sectors; i++) {
19
25
if (i < n_start || i >= n_end) {
20
int coroutine_fn block_copy(BlockCopyState *s, int64_t offset, int64_t bytes,
26
- Error *err = NULL;
21
- bool ignore_ratelimit, bool *error_is_read);
27
memset(s->cluster_data, 0x00, 512);
22
+ bool ignore_ratelimit);
28
if (qcrypto_block_encrypt(s->crypto, start_sect + i,
23
29
s->cluster_data,
24
/*
30
BDRV_SECTOR_SIZE,
25
* Run block-copy in a coroutine, create corresponding BlockCopyCallState
31
- &err) < 0) {
26
diff --git a/block/backup-top.c b/block/backup-top.c
32
- error_free(err);
27
index XXXXXXX..XXXXXXX 100644
33
+ NULL) < 0) {
28
--- a/block/backup-top.c
34
errno = EIO;
29
+++ b/block/backup-top.c
35
return -1;
30
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int backup_top_cbw(BlockDriverState *bs, uint64_t offset,
36
}
31
off = QEMU_ALIGN_DOWN(offset, s->cluster_size);
37
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow_co_readv(BlockDriverState *bs, int64_t sector_num,
32
end = QEMU_ALIGN_UP(offset + bytes, s->cluster_size);
38
QEMUIOVector hd_qiov;
33
39
uint8_t *buf;
34
- return block_copy(s->bcs, off, end - off, true, NULL);
40
void *orig_buf;
35
+ return block_copy(s->bcs, off, end - off, true);
41
- Error *err = NULL;
42
43
if (qiov->niov > 1) {
44
buf = orig_buf = qemu_try_blockalign(bs, qiov->size);
45
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow_co_readv(BlockDriverState *bs, int64_t sector_num,
46
if (bs->encrypted) {
47
assert(s->crypto);
48
if (qcrypto_block_decrypt(s->crypto, sector_num, buf,
49
- n * BDRV_SECTOR_SIZE, &err) < 0) {
50
+ n * BDRV_SECTOR_SIZE, NULL) < 0) {
51
goto fail;
52
}
53
}
54
@@ -XXX,XX +XXX,XX @@ done:
55
return ret;
56
57
fail:
58
- error_free(err);
59
ret = -EIO;
60
goto done;
61
}
36
}
62
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow_co_writev(BlockDriverState *bs, int64_t sector_num,
37
63
break;
38
static int coroutine_fn backup_top_co_pdiscard(BlockDriverState *bs,
64
}
39
diff --git a/block/block-copy.c b/block/block-copy.c
65
if (bs->encrypted) {
66
- Error *err = NULL;
67
assert(s->crypto);
68
if (qcrypto_block_encrypt(s->crypto, sector_num, buf,
69
- n * BDRV_SECTOR_SIZE, &err) < 0) {
70
- error_free(err);
71
+ n * BDRV_SECTOR_SIZE, NULL) < 0) {
72
ret = -EIO;
73
break;
74
}
75
diff --git a/block/qcow2.c b/block/qcow2.c
76
index XXXXXXX..XXXXXXX 100644
40
index XXXXXXX..XXXXXXX 100644
77
--- a/block/qcow2.c
41
--- a/block/block-copy.c
78
+++ b/block/qcow2.c
42
+++ b/block/block-copy.c
79
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset,
43
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state)
80
assert(s->crypto);
44
}
81
assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
45
82
assert((cur_bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
46
int coroutine_fn block_copy(BlockCopyState *s, int64_t start, int64_t bytes,
83
- Error *err = NULL;
47
- bool ignore_ratelimit, bool *error_is_read)
84
if (qcrypto_block_decrypt(s->crypto,
48
+ bool ignore_ratelimit)
85
(s->crypt_physical_offset ?
86
cluster_offset + offset_in_cluster :
87
offset) >> BDRV_SECTOR_BITS,
88
cluster_data,
89
cur_bytes,
90
- &err) < 0) {
91
- error_free(err);
92
+ NULL) < 0) {
93
ret = -EIO;
94
goto fail;
95
}
96
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset,
97
qemu_iovec_concat(&hd_qiov, qiov, bytes_done, cur_bytes);
98
99
if (bs->encrypted) {
100
- Error *err = NULL;
101
assert(s->crypto);
102
if (!cluster_data) {
103
cluster_data = qemu_try_blockalign(bs->file->bs,
104
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset,
105
cluster_offset + offset_in_cluster :
106
offset) >> BDRV_SECTOR_BITS,
107
cluster_data,
108
- cur_bytes, &err) < 0) {
109
- error_free(err);
110
+ cur_bytes, NULL) < 0) {
111
ret = -EIO;
112
goto fail;
113
}
114
diff --git a/dump.c b/dump.c
115
index XXXXXXX..XXXXXXX 100644
116
--- a/dump.c
117
+++ b/dump.c
118
@@ -XXX,XX +XXX,XX @@ static void dump_process(DumpState *s, Error **errp)
119
120
static void *dump_thread(void *data)
121
{
49
{
122
- Error *err = NULL;
50
BlockCopyCallState call_state = {
123
DumpState *s = (DumpState *)data;
51
.s = s,
124
- dump_process(s, &err);
52
@@ -XXX,XX +XXX,XX @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t start, int64_t bytes,
125
- error_free(err);
53
.max_workers = BLOCK_COPY_MAX_WORKERS,
126
+ dump_process(s, NULL);
54
};
127
return NULL;
55
56
- int ret = block_copy_common(&call_state);
57
-
58
- if (error_is_read && ret < 0) {
59
- *error_is_read = call_state.error_is_read;
60
- }
61
-
62
- return ret;
63
+ return block_copy_common(&call_state);
128
}
64
}
129
65
66
static void coroutine_fn block_copy_async_co_entry(void *opaque)
130
--
67
--
131
2.13.5
68
2.29.2
132
69
133
70
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
The level of the burst bucket is stored in bkt.burst_level, not
3
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
4
bkt.burst_length.
4
Reviewed-by: Max Reitz <mreitz@redhat.com>
5
5
Message-Id: <20210116214705.822267-22-vsementsov@virtuozzo.com>
6
Signed-off-by: Alberto Garcia <berto@igalia.com>
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
8
Message-id: 49aab2711d02f285567f3b3b13a113847af33812.1503580370.git.berto@igalia.com
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
---
7
---
11
include/qemu/throttle.h | 2 +-
8
scripts/simplebench/bench_block_job.py | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
9
1 file changed, 1 insertion(+), 1 deletion(-)
13
10
14
diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
11
diff --git a/scripts/simplebench/bench_block_job.py b/scripts/simplebench/bench_block_job.py
15
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100755
16
--- a/include/qemu/throttle.h
13
--- a/scripts/simplebench/bench_block_job.py
17
+++ b/include/qemu/throttle.h
14
+++ b/scripts/simplebench/bench_block_job.py
18
@@ -XXX,XX +XXX,XX @@ typedef enum {
15
@@ -XXX,XX +XXX,XX @@
19
* - The bkt.avg rate does not apply until the bucket is full,
16
-#!/usr/bin/env python
20
* allowing the user to do bursts until then. The I/O limit during
17
+#!/usr/bin/env python3
21
* bursts is bkt.max. To enforce this limit we keep an additional
18
#
22
- * bucket in bkt.burst_length that leaks at a rate of bkt.max units
19
# Benchmark block jobs
23
+ * bucket in bkt.burst_level that leaks at a rate of bkt.max units
20
#
24
* per second.
25
*
26
* - Because of all of the above, the user can perform I/O at a
27
--
21
--
28
2.13.5
22
2.29.2
29
23
30
24
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
Add argument to allow additional block-job options.
4
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
7
Message-Id: <20210116214705.822267-23-vsementsov@virtuozzo.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
scripts/simplebench/bench-example.py | 2 +-
11
scripts/simplebench/bench_block_job.py | 11 +++++++----
12
2 files changed, 8 insertions(+), 5 deletions(-)
13
14
diff --git a/scripts/simplebench/bench-example.py b/scripts/simplebench/bench-example.py
15
index XXXXXXX..XXXXXXX 100644
16
--- a/scripts/simplebench/bench-example.py
17
+++ b/scripts/simplebench/bench-example.py
18
@@ -XXX,XX +XXX,XX @@ from bench_block_job import bench_block_copy, drv_file, drv_nbd
19
20
def bench_func(env, case):
21
""" Handle one "cell" of benchmarking table. """
22
- return bench_block_copy(env['qemu_binary'], env['cmd'],
23
+ return bench_block_copy(env['qemu_binary'], env['cmd'], {}
24
case['source'], case['target'])
25
26
27
diff --git a/scripts/simplebench/bench_block_job.py b/scripts/simplebench/bench_block_job.py
28
index XXXXXXX..XXXXXXX 100755
29
--- a/scripts/simplebench/bench_block_job.py
30
+++ b/scripts/simplebench/bench_block_job.py
31
@@ -XXX,XX +XXX,XX @@ def bench_block_job(cmd, cmd_args, qemu_args):
32
33
34
# Bench backup or mirror
35
-def bench_block_copy(qemu_binary, cmd, source, target):
36
+def bench_block_copy(qemu_binary, cmd, cmd_options, source, target):
37
"""Helper to run bench_block_job() for mirror or backup"""
38
assert cmd in ('blockdev-backup', 'blockdev-mirror')
39
40
source['node-name'] = 'source'
41
target['node-name'] = 'target'
42
43
- return bench_block_job(cmd,
44
- {'job-id': 'job0', 'device': 'source',
45
- 'target': 'target', 'sync': 'full'},
46
+ cmd_options['job-id'] = 'job0'
47
+ cmd_options['device'] = 'source'
48
+ cmd_options['target'] = 'target'
49
+ cmd_options['sync'] = 'full'
50
+
51
+ return bench_block_job(cmd, cmd_options,
52
[qemu_binary,
53
'-blockdev', json.dumps(source),
54
'-blockdev', json.dumps(target)])
55
--
56
2.29.2
57
58
diff view generated by jsdifflib
1
The minimum Python version supported by QEMU is 2.6. The argparse
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
standard library module was only added in Python 2.7. Many scripts
3
would like to use argparse because it supports command-line
4
sub-commands.
5
2
6
This patch adds argparse. See the top of argparse.py for details.
3
Add script to benchmark new backup architecture.
7
4
8
Suggested-by: Daniel P. Berrange <berrange@redhat.com>
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Message-Id: <20210116214705.822267-24-vsementsov@virtuozzo.com>
10
Acked-by: John Snow <jsnow@redhat.com>
7
[mreitz: s/not unsupported/not supported/]
11
Message-id: 20170825155732.15665-2-stefanha@redhat.com
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
---
9
---
14
COPYING.PYTHON | 270 ++++++
10
scripts/simplebench/bench-backup.py | 167 ++++++++++++++++++++++++++++
15
scripts/argparse.py | 2406 +++++++++++++++++++++++++++++++++++++++++++++++++++
11
1 file changed, 167 insertions(+)
16
2 files changed, 2676 insertions(+)
12
create mode 100755 scripts/simplebench/bench-backup.py
17
create mode 100644 COPYING.PYTHON
18
create mode 100644 scripts/argparse.py
19
13
20
diff --git a/COPYING.PYTHON b/COPYING.PYTHON
14
diff --git a/scripts/simplebench/bench-backup.py b/scripts/simplebench/bench-backup.py
21
new file mode 100644
15
new file mode 100755
22
index XXXXXXX..XXXXXXX
16
index XXXXXXX..XXXXXXX
23
--- /dev/null
17
--- /dev/null
24
+++ b/COPYING.PYTHON
18
+++ b/scripts/simplebench/bench-backup.py
25
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
26
+A. HISTORY OF THE SOFTWARE
20
+#!/usr/bin/env python3
27
+==========================
21
+#
22
+# Bench backup block-job
23
+#
24
+# Copyright (c) 2020 Virtuozzo International GmbH.
25
+#
26
+# This program is free software; you can redistribute it and/or modify
27
+# it under the terms of the GNU General Public License as published by
28
+# the Free Software Foundation; either version 2 of the License, or
29
+# (at your option) any later version.
30
+#
31
+# This program is distributed in the hope that it will be useful,
32
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
33
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34
+# GNU General Public License for more details.
35
+#
36
+# You should have received a copy of the GNU General Public License
37
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
38
+#
28
+
39
+
29
+Python was created in the early 1990s by Guido van Rossum at Stichting
40
+import argparse
30
+Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
41
+import json
31
+as a successor of a language called ABC. Guido remains Python's
32
+principal author, although it includes many contributions from others.
33
+
42
+
34
+In 1995, Guido continued his work on Python at the Corporation for
43
+import simplebench
35
+National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
44
+from results_to_text import results_to_text
36
+in Reston, Virginia where he released several versions of the
45
+from bench_block_job import bench_block_copy, drv_file, drv_nbd
37
+software.
38
+
39
+In May 2000, Guido and the Python core development team moved to
40
+BeOpen.com to form the BeOpen PythonLabs team. In October of the same
41
+year, the PythonLabs team moved to Digital Creations (now Zope
42
+Corporation, see http://www.zope.com). In 2001, the Python Software
43
+Foundation (PSF, see http://www.python.org/psf/) was formed, a
44
+non-profit organization created specifically to own Python-related
45
+Intellectual Property. Zope Corporation is a sponsoring member of
46
+the PSF.
47
+
48
+All Python releases are Open Source (see http://www.opensource.org for
49
+the Open Source Definition). Historically, most, but not all, Python
50
+releases have also been GPL-compatible; the table below summarizes
51
+the various releases.
52
+
53
+ Release Derived Year Owner GPL-
54
+ from compatible? (1)
55
+
56
+ 0.9.0 thru 1.2 1991-1995 CWI yes
57
+ 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
58
+ 1.6 1.5.2 2000 CNRI no
59
+ 2.0 1.6 2000 BeOpen.com no
60
+ 1.6.1 1.6 2001 CNRI yes (2)
61
+ 2.1 2.0+1.6.1 2001 PSF no
62
+ 2.0.1 2.0+1.6.1 2001 PSF yes
63
+ 2.1.1 2.1+2.0.1 2001 PSF yes
64
+ 2.2 2.1.1 2001 PSF yes
65
+ 2.1.2 2.1.1 2002 PSF yes
66
+ 2.1.3 2.1.2 2002 PSF yes
67
+ 2.2.1 2.2 2002 PSF yes
68
+ 2.2.2 2.2.1 2002 PSF yes
69
+ 2.2.3 2.2.2 2003 PSF yes
70
+ 2.3 2.2.2 2002-2003 PSF yes
71
+ 2.3.1 2.3 2002-2003 PSF yes
72
+ 2.3.2 2.3.1 2002-2003 PSF yes
73
+ 2.3.3 2.3.2 2002-2003 PSF yes
74
+ 2.3.4 2.3.3 2004 PSF yes
75
+ 2.3.5 2.3.4 2005 PSF yes
76
+ 2.4 2.3 2004 PSF yes
77
+ 2.4.1 2.4 2005 PSF yes
78
+ 2.4.2 2.4.1 2005 PSF yes
79
+ 2.4.3 2.4.2 2006 PSF yes
80
+ 2.5 2.4 2006 PSF yes
81
+ 2.7 2.6 2010 PSF yes
82
+
83
+Footnotes:
84
+
85
+(1) GPL-compatible doesn't mean that we're distributing Python under
86
+ the GPL. All Python licenses, unlike the GPL, let you distribute
87
+ a modified version without making your changes open source. The
88
+ GPL-compatible licenses make it possible to combine Python with
89
+ other software that is released under the GPL; the others don't.
90
+
91
+(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
92
+ because its license has a choice of law clause. According to
93
+ CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
94
+ is "not incompatible" with the GPL.
95
+
96
+Thanks to the many outside volunteers who have worked under Guido's
97
+direction to make these releases possible.
98
+
46
+
99
+
47
+
100
+B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
48
+def bench_func(env, case):
101
+===============================================================
49
+ """ Handle one "cell" of benchmarking table. """
102
+
50
+ cmd_options = env['cmd-options'] if 'cmd-options' in env else {}
103
+PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
51
+ return bench_block_copy(env['qemu-binary'], env['cmd'],
104
+--------------------------------------------
52
+ cmd_options,
105
+
53
+ case['source'], case['target'])
106
+1. This LICENSE AGREEMENT is between the Python Software Foundation
107
+("PSF"), and the Individual or Organization ("Licensee") accessing and
108
+otherwise using this software ("Python") in source or binary form and
109
+its associated documentation.
110
+
111
+2. Subject to the terms and conditions of this License Agreement, PSF
112
+hereby grants Licensee a nonexclusive, royalty-free, world-wide
113
+license to reproduce, analyze, test, perform and/or display publicly,
114
+prepare derivative works, distribute, and otherwise use Python
115
+alone or in any derivative version, provided, however, that PSF's
116
+License Agreement and PSF's notice of copyright, i.e., "Copyright (c)
117
+2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation; All Rights
118
+Reserved" are retained in Python alone or in any derivative version
119
+prepared by Licensee.
120
+
121
+3. In the event Licensee prepares a derivative work that is based on
122
+or incorporates Python or any part thereof, and wants to make
123
+the derivative work available to others as provided herein, then
124
+Licensee hereby agrees to include in any such work a brief summary of
125
+the changes made to Python.
126
+
127
+4. PSF is making Python available to Licensee on an "AS IS"
128
+basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
129
+IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
130
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
131
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
132
+INFRINGE ANY THIRD PARTY RIGHTS.
133
+
134
+5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
135
+FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
136
+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
137
+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
138
+
139
+6. This License Agreement will automatically terminate upon a material
140
+breach of its terms and conditions.
141
+
142
+7. Nothing in this License Agreement shall be deemed to create any
143
+relationship of agency, partnership, or joint venture between PSF and
144
+Licensee. This License Agreement does not grant permission to use PSF
145
+trademarks or trade name in a trademark sense to endorse or promote
146
+products or services of Licensee, or any third party.
147
+
148
+8. By copying, installing or otherwise using Python, Licensee
149
+agrees to be bound by the terms and conditions of this License
150
+Agreement.
151
+
54
+
152
+
55
+
153
+BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
56
+def bench(args):
154
+-------------------------------------------
57
+ test_cases = []
155
+
58
+
156
+BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
59
+ sources = {}
60
+ targets = {}
61
+ for d in args.dir:
62
+ label, path = d.split(':') # paths with colon not supported
63
+ sources[label] = drv_file(path + '/test-source')
64
+ targets[label] = drv_file(path + '/test-target')
157
+
65
+
158
+1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
66
+ if args.nbd:
159
+office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
67
+ nbd = args.nbd.split(':')
160
+Individual or Organization ("Licensee") accessing and otherwise using
68
+ host = nbd[0]
161
+this software in source or binary form and its associated
69
+ port = '10809' if len(nbd) == 1 else nbd[1]
162
+documentation ("the Software").
70
+ drv = drv_nbd(host, port)
71
+ sources['nbd'] = drv
72
+ targets['nbd'] = drv
163
+
73
+
164
+2. Subject to the terms and conditions of this BeOpen Python License
74
+ for t in args.test:
165
+Agreement, BeOpen hereby grants Licensee a non-exclusive,
75
+ src, dst = t.split(':')
166
+royalty-free, world-wide license to reproduce, analyze, test, perform
167
+and/or display publicly, prepare derivative works, distribute, and
168
+otherwise use the Software alone or in any derivative version,
169
+provided, however, that the BeOpen Python License is retained in the
170
+Software, alone or in any derivative version prepared by Licensee.
171
+
76
+
172
+3. BeOpen is making the Software available to Licensee on an "AS IS"
77
+ test_cases.append({
173
+basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
78
+ 'id': t,
174
+IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
79
+ 'source': sources[src],
175
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
80
+ 'target': targets[dst]
176
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
81
+ })
177
+INFRINGE ANY THIRD PARTY RIGHTS.
178
+
82
+
179
+4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
83
+ binaries = [] # list of (<label>, <path>, [<options>])
180
+SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
84
+ for i, q in enumerate(args.env):
181
+AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
85
+ name_path = q.split(':')
182
+DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
86
+ if len(name_path) == 1:
87
+ label = f'q{i}'
88
+ path_opts = name_path[0].split(',')
89
+ else:
90
+ assert len(name_path) == 2 # paths with colon not supported
91
+ label = name_path[0]
92
+ path_opts = name_path[1].split(',')
183
+
93
+
184
+5. This License Agreement will automatically terminate upon a material
94
+ binaries.append((label, path_opts[0], path_opts[1:]))
185
+breach of its terms and conditions.
186
+
95
+
187
+6. This License Agreement shall be governed by and interpreted in all
96
+ test_envs = []
188
+respects by the law of the State of California, excluding conflict of
189
+law provisions. Nothing in this License Agreement shall be deemed to
190
+create any relationship of agency, partnership, or joint venture
191
+between BeOpen and Licensee. This License Agreement does not grant
192
+permission to use BeOpen trademarks or trade names in a trademark
193
+sense to endorse or promote products or services of Licensee, or any
194
+third party. As an exception, the "BeOpen Python" logos available at
195
+http://www.pythonlabs.com/logos.html may be used according to the
196
+permissions granted on that web page.
197
+
97
+
198
+7. By copying, installing or otherwise using the software, Licensee
98
+ bin_paths = {}
199
+agrees to be bound by the terms and conditions of this License
99
+ for i, q in enumerate(args.env):
200
+Agreement.
100
+ opts = q.split(',')
101
+ label_path = opts[0]
102
+ opts = opts[1:]
103
+
104
+ if ':' in label_path:
105
+ # path with colon inside is not supported
106
+ label, path = label_path.split(':')
107
+ bin_paths[label] = path
108
+ elif label_path in bin_paths:
109
+ label = label_path
110
+ path = bin_paths[label]
111
+ else:
112
+ path = label_path
113
+ label = f'q{i}'
114
+ bin_paths[label] = path
115
+
116
+ x_perf = {}
117
+ is_mirror = False
118
+ for opt in opts:
119
+ if opt == 'mirror':
120
+ is_mirror = True
121
+ elif opt == 'copy-range=on':
122
+ x_perf['use-copy-range'] = True
123
+ elif opt == 'copy-range=off':
124
+ x_perf['use-copy-range'] = False
125
+ elif opt.startswith('max-workers='):
126
+ x_perf['max-workers'] = int(opt.split('=')[1])
127
+
128
+ if is_mirror:
129
+ assert not x_perf
130
+ test_envs.append({
131
+ 'id': f'mirror({label})',
132
+ 'cmd': 'blockdev-mirror',
133
+ 'qemu-binary': path
134
+ })
135
+ else:
136
+ test_envs.append({
137
+ 'id': f'backup({label})\n' + '\n'.join(opts),
138
+ 'cmd': 'blockdev-backup',
139
+ 'cmd-options': {'x-perf': x_perf} if x_perf else {},
140
+ 'qemu-binary': path
141
+ })
142
+
143
+ result = simplebench.bench(bench_func, test_envs, test_cases, count=3)
144
+ with open('results.json', 'w') as f:
145
+ json.dump(result, f, indent=4)
146
+ print(results_to_text(result))
201
+
147
+
202
+
148
+
203
+CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
149
+class ExtendAction(argparse.Action):
204
+---------------------------------------
205
+
206
+1. This LICENSE AGREEMENT is between the Corporation for National
207
+Research Initiatives, having an office at 1895 Preston White Drive,
208
+Reston, VA 20191 ("CNRI"), and the Individual or Organization
209
+("Licensee") accessing and otherwise using Python 1.6.1 software in
210
+source or binary form and its associated documentation.
211
+
212
+2. Subject to the terms and conditions of this License Agreement, CNRI
213
+hereby grants Licensee a nonexclusive, royalty-free, world-wide
214
+license to reproduce, analyze, test, perform and/or display publicly,
215
+prepare derivative works, distribute, and otherwise use Python 1.6.1
216
+alone or in any derivative version, provided, however, that CNRI's
217
+License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
218
+1995-2001 Corporation for National Research Initiatives; All Rights
219
+Reserved" are retained in Python 1.6.1 alone or in any derivative
220
+version prepared by Licensee. Alternately, in lieu of CNRI's License
221
+Agreement, Licensee may substitute the following text (omitting the
222
+quotes): "Python 1.6.1 is made available subject to the terms and
223
+conditions in CNRI's License Agreement. This Agreement together with
224
+Python 1.6.1 may be located on the Internet using the following
225
+unique, persistent identifier (known as a handle): 1895.22/1013. This
226
+Agreement may also be obtained from a proxy server on the Internet
227
+using the following URL: http://hdl.handle.net/1895.22/1013".
228
+
229
+3. In the event Licensee prepares a derivative work that is based on
230
+or incorporates Python 1.6.1 or any part thereof, and wants to make
231
+the derivative work available to others as provided herein, then
232
+Licensee hereby agrees to include in any such work a brief summary of
233
+the changes made to Python 1.6.1.
234
+
235
+4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
236
+basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
237
+IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
238
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
239
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
240
+INFRINGE ANY THIRD PARTY RIGHTS.
241
+
242
+5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
243
+1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
244
+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
245
+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
246
+
247
+6. This License Agreement will automatically terminate upon a material
248
+breach of its terms and conditions.
249
+
250
+7. This License Agreement shall be governed by the federal
251
+intellectual property law of the United States, including without
252
+limitation the federal copyright law, and, to the extent such
253
+U.S. federal law does not apply, by the law of the Commonwealth of
254
+Virginia, excluding Virginia's conflict of law provisions.
255
+Notwithstanding the foregoing, with regard to derivative works based
256
+on Python 1.6.1 that incorporate non-separable material that was
257
+previously distributed under the GNU General Public License (GPL), the
258
+law of the Commonwealth of Virginia shall govern this License
259
+Agreement only as to issues arising under or with respect to
260
+Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
261
+License Agreement shall be deemed to create any relationship of
262
+agency, partnership, or joint venture between CNRI and Licensee. This
263
+License Agreement does not grant permission to use CNRI trademarks or
264
+trade name in a trademark sense to endorse or promote products or
265
+services of Licensee, or any third party.
266
+
267
+8. By clicking on the "ACCEPT" button where indicated, or by copying,
268
+installing or otherwise using Python 1.6.1, Licensee agrees to be
269
+bound by the terms and conditions of this License Agreement.
270
+
271
+ ACCEPT
272
+
273
+
274
+CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
275
+--------------------------------------------------
276
+
277
+Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
278
+The Netherlands. All rights reserved.
279
+
280
+Permission to use, copy, modify, and distribute this software and its
281
+documentation for any purpose and without fee is hereby granted,
282
+provided that the above copyright notice appear in all copies and that
283
+both that copyright notice and this permission notice appear in
284
+supporting documentation, and that the name of Stichting Mathematisch
285
+Centrum or CWI not be used in advertising or publicity pertaining to
286
+distribution of the software without specific, written prior
287
+permission.
288
+
289
+STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
290
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
291
+FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
292
+FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
293
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
294
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
295
+OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
296
diff --git a/scripts/argparse.py b/scripts/argparse.py
297
new file mode 100644
298
index XXXXXXX..XXXXXXX
299
--- /dev/null
300
+++ b/scripts/argparse.py
301
@@ -XXX,XX +XXX,XX @@
302
+# This is a local copy of the standard library argparse module taken from PyPI.
303
+# It is licensed under the Python Software Foundation License. This is a
304
+# fallback for Python 2.6 which does not include this module. Python 2.7+ and
305
+# 3+ will never load this module because built-in modules are loaded before
306
+# anything in sys.path.
307
+#
308
+# If your script is not located in the same directory as this file, import it
309
+# like this:
310
+#
311
+# import os
312
+# import sys
313
+# sys.path.append(os.path.join(os.path.dirname(__file__), ..., 'scripts'))
314
+# import argparse
315
+
316
+# Author: Steven J. Bethard <steven.bethard@gmail.com>.
317
+# Maintainer: Thomas Waldmann <tw@waldmann-edv.de>
318
+
319
+"""Command-line parsing library
320
+
321
+This module is an optparse-inspired command-line parsing library that:
322
+
323
+ - handles both optional and positional arguments
324
+ - produces highly informative usage messages
325
+ - supports parsers that dispatch to sub-parsers
326
+
327
+The following is a simple usage example that sums integers from the
328
+command-line and writes the result to a file::
329
+
330
+ parser = argparse.ArgumentParser(
331
+ description='sum the integers at the command line')
332
+ parser.add_argument(
333
+ 'integers', metavar='int', nargs='+', type=int,
334
+ help='an integer to be summed')
335
+ parser.add_argument(
336
+ '--log', default=sys.stdout, type=argparse.FileType('w'),
337
+ help='the file where the sum should be written')
338
+ args = parser.parse_args()
339
+ args.log.write('%s' % sum(args.integers))
340
+ args.log.close()
341
+
342
+The module contains the following public classes:
343
+
344
+ - ArgumentParser -- The main entry point for command-line parsing. As the
345
+ example above shows, the add_argument() method is used to populate
346
+ the parser with actions for optional and positional arguments. Then
347
+ the parse_args() method is invoked to convert the args at the
348
+ command-line into an object with attributes.
349
+
350
+ - ArgumentError -- The exception raised by ArgumentParser objects when
351
+ there are errors with the parser's actions. Errors raised while
352
+ parsing the command-line are caught by ArgumentParser and emitted
353
+ as command-line messages.
354
+
355
+ - FileType -- A factory for defining types of files to be created. As the
356
+ example above shows, instances of FileType are typically passed as
357
+ the type= argument of add_argument() calls.
358
+
359
+ - Action -- The base class for parser actions. Typically actions are
360
+ selected by passing strings like 'store_true' or 'append_const' to
361
+ the action= argument of add_argument(). However, for greater
362
+ customization of ArgumentParser actions, subclasses of Action may
363
+ be defined and passed as the action= argument.
364
+
365
+ - HelpFormatter, RawDescriptionHelpFormatter, RawTextHelpFormatter,
366
+ ArgumentDefaultsHelpFormatter -- Formatter classes which
367
+ may be passed as the formatter_class= argument to the
368
+ ArgumentParser constructor. HelpFormatter is the default,
369
+ RawDescriptionHelpFormatter and RawTextHelpFormatter tell the parser
370
+ not to change the formatting for help text, and
371
+ ArgumentDefaultsHelpFormatter adds information about argument defaults
372
+ to the help.
373
+
374
+All other classes in this module are considered implementation details.
375
+(Also note that HelpFormatter and RawDescriptionHelpFormatter are only
376
+considered public as object names -- the API of the formatter objects is
377
+still considered an implementation detail.)
378
+"""
379
+
380
+__version__ = '1.4.0' # we use our own version number independant of the
381
+ # one in stdlib and we release this on pypi.
382
+
383
+__external_lib__ = True # to make sure the tests really test THIS lib,
384
+ # not the builtin one in Python stdlib
385
+
386
+__all__ = [
387
+ 'ArgumentParser',
388
+ 'ArgumentError',
389
+ 'ArgumentTypeError',
390
+ 'FileType',
391
+ 'HelpFormatter',
392
+ 'ArgumentDefaultsHelpFormatter',
393
+ 'RawDescriptionHelpFormatter',
394
+ 'RawTextHelpFormatter',
395
+ 'Namespace',
396
+ 'Action',
397
+ 'ONE_OR_MORE',
398
+ 'OPTIONAL',
399
+ 'PARSER',
400
+ 'REMAINDER',
401
+ 'SUPPRESS',
402
+ 'ZERO_OR_MORE',
403
+]
404
+
405
+
406
+import copy as _copy
407
+import os as _os
408
+import re as _re
409
+import sys as _sys
410
+import textwrap as _textwrap
411
+
412
+from gettext import gettext as _
413
+
414
+try:
415
+ set
416
+except NameError:
417
+ # for python < 2.4 compatibility (sets module is there since 2.3):
418
+ from sets import Set as set
419
+
420
+try:
421
+ basestring
422
+except NameError:
423
+ basestring = str
424
+
425
+try:
426
+ sorted
427
+except NameError:
428
+ # for python < 2.4 compatibility:
429
+ def sorted(iterable, reverse=False):
430
+ result = list(iterable)
431
+ result.sort()
432
+ if reverse:
433
+ result.reverse()
434
+ return result
435
+
436
+
437
+def _callable(obj):
438
+ return hasattr(obj, '__call__') or hasattr(obj, '__bases__')
439
+
440
+
441
+SUPPRESS = '==SUPPRESS=='
442
+
443
+OPTIONAL = '?'
444
+ZERO_OR_MORE = '*'
445
+ONE_OR_MORE = '+'
446
+PARSER = 'A...'
447
+REMAINDER = '...'
448
+_UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args'
449
+
450
+# =============================
451
+# Utility functions and classes
452
+# =============================
453
+
454
+class _AttributeHolder(object):
455
+ """Abstract base class that provides __repr__.
456
+
457
+ The __repr__ method returns a string in the format::
458
+ ClassName(attr=name, attr=name, ...)
459
+ The attributes are determined either by a class-level attribute,
460
+ '_kwarg_names', or by inspecting the instance __dict__.
461
+ """
462
+
463
+ def __repr__(self):
464
+ type_name = type(self).__name__
465
+ arg_strings = []
466
+ for arg in self._get_args():
467
+ arg_strings.append(repr(arg))
468
+ for name, value in self._get_kwargs():
469
+ arg_strings.append('%s=%r' % (name, value))
470
+ return '%s(%s)' % (type_name, ', '.join(arg_strings))
471
+
472
+ def _get_kwargs(self):
473
+ return sorted(self.__dict__.items())
474
+
475
+ def _get_args(self):
476
+ return []
477
+
478
+
479
+def _ensure_value(namespace, name, value):
480
+ if getattr(namespace, name, None) is None:
481
+ setattr(namespace, name, value)
482
+ return getattr(namespace, name)
483
+
484
+
485
+# ===============
486
+# Formatting Help
487
+# ===============
488
+
489
+class HelpFormatter(object):
490
+ """Formatter for generating usage messages and argument help strings.
491
+
492
+ Only the name of this class is considered a public API. All the methods
493
+ provided by the class are considered an implementation detail.
494
+ """
495
+
496
+ def __init__(self,
497
+ prog,
498
+ indent_increment=2,
499
+ max_help_position=24,
500
+ width=None):
501
+
502
+ # default setting for width
503
+ if width is None:
504
+ try:
505
+ width = int(_os.environ['COLUMNS'])
506
+ except (KeyError, ValueError):
507
+ width = 80
508
+ width -= 2
509
+
510
+ self._prog = prog
511
+ self._indent_increment = indent_increment
512
+ self._max_help_position = max_help_position
513
+ self._width = width
514
+
515
+ self._current_indent = 0
516
+ self._level = 0
517
+ self._action_max_length = 0
518
+
519
+ self._root_section = self._Section(self, None)
520
+ self._current_section = self._root_section
521
+
522
+ self._whitespace_matcher = _re.compile(r'\s+')
523
+ self._long_break_matcher = _re.compile(r'\n\n\n+')
524
+
525
+ # ===============================
526
+ # Section and indentation methods
527
+ # ===============================
528
+ def _indent(self):
529
+ self._current_indent += self._indent_increment
530
+ self._level += 1
531
+
532
+ def _dedent(self):
533
+ self._current_indent -= self._indent_increment
534
+ assert self._current_indent >= 0, 'Indent decreased below 0.'
535
+ self._level -= 1
536
+
537
+ class _Section(object):
538
+
539
+ def __init__(self, formatter, parent, heading=None):
540
+ self.formatter = formatter
541
+ self.parent = parent
542
+ self.heading = heading
543
+ self.items = []
544
+
545
+ def format_help(self):
546
+ # format the indented section
547
+ if self.parent is not None:
548
+ self.formatter._indent()
549
+ join = self.formatter._join_parts
550
+ for func, args in self.items:
551
+ func(*args)
552
+ item_help = join([func(*args) for func, args in self.items])
553
+ if self.parent is not None:
554
+ self.formatter._dedent()
555
+
556
+ # return nothing if the section was empty
557
+ if not item_help:
558
+ return ''
559
+
560
+ # add the heading if the section was non-empty
561
+ if self.heading is not SUPPRESS and self.heading is not None:
562
+ current_indent = self.formatter._current_indent
563
+ heading = '%*s%s:\n' % (current_indent, '', self.heading)
564
+ else:
565
+ heading = ''
566
+
567
+ # join the section-initial newline, the heading and the help
568
+ return join(['\n', heading, item_help, '\n'])
569
+
570
+ def _add_item(self, func, args):
571
+ self._current_section.items.append((func, args))
572
+
573
+ # ========================
574
+ # Message building methods
575
+ # ========================
576
+ def start_section(self, heading):
577
+ self._indent()
578
+ section = self._Section(self, self._current_section, heading)
579
+ self._add_item(section.format_help, [])
580
+ self._current_section = section
581
+
582
+ def end_section(self):
583
+ self._current_section = self._current_section.parent
584
+ self._dedent()
585
+
586
+ def add_text(self, text):
587
+ if text is not SUPPRESS and text is not None:
588
+ self._add_item(self._format_text, [text])
589
+
590
+ def add_usage(self, usage, actions, groups, prefix=None):
591
+ if usage is not SUPPRESS:
592
+ args = usage, actions, groups, prefix
593
+ self._add_item(self._format_usage, args)
594
+
595
+ def add_argument(self, action):
596
+ if action.help is not SUPPRESS:
597
+
598
+ # find all invocations
599
+ get_invocation = self._format_action_invocation
600
+ invocations = [get_invocation(action)]
601
+ for subaction in self._iter_indented_subactions(action):
602
+ invocations.append(get_invocation(subaction))
603
+
604
+ # update the maximum item length
605
+ invocation_length = max([len(s) for s in invocations])
606
+ action_length = invocation_length + self._current_indent
607
+ self._action_max_length = max(self._action_max_length,
608
+ action_length)
609
+
610
+ # add the item to the list
611
+ self._add_item(self._format_action, [action])
612
+
613
+ def add_arguments(self, actions):
614
+ for action in actions:
615
+ self.add_argument(action)
616
+
617
+ # =======================
618
+ # Help-formatting methods
619
+ # =======================
620
+ def format_help(self):
621
+ help = self._root_section.format_help()
622
+ if help:
623
+ help = self._long_break_matcher.sub('\n\n', help)
624
+ help = help.strip('\n') + '\n'
625
+ return help
626
+
627
+ def _join_parts(self, part_strings):
628
+ return ''.join([part
629
+ for part in part_strings
630
+ if part and part is not SUPPRESS])
631
+
632
+ def _format_usage(self, usage, actions, groups, prefix):
633
+ if prefix is None:
634
+ prefix = _('usage: ')
635
+
636
+ # if usage is specified, use that
637
+ if usage is not None:
638
+ usage = usage % dict(prog=self._prog)
639
+
640
+ # if no optionals or positionals are available, usage is just prog
641
+ elif usage is None and not actions:
642
+ usage = '%(prog)s' % dict(prog=self._prog)
643
+
644
+ # if optionals and positionals are available, calculate usage
645
+ elif usage is None:
646
+ prog = '%(prog)s' % dict(prog=self._prog)
647
+
648
+ # split optionals from positionals
649
+ optionals = []
650
+ positionals = []
651
+ for action in actions:
652
+ if action.option_strings:
653
+ optionals.append(action)
654
+ else:
655
+ positionals.append(action)
656
+
657
+ # build full usage string
658
+ format = self._format_actions_usage
659
+ action_usage = format(optionals + positionals, groups)
660
+ usage = ' '.join([s for s in [prog, action_usage] if s])
661
+
662
+ # wrap the usage parts if it's too long
663
+ text_width = self._width - self._current_indent
664
+ if len(prefix) + len(usage) > text_width:
665
+
666
+ # break usage into wrappable parts
667
+ part_regexp = r'\(.*?\)+|\[.*?\]+|\S+'
668
+ opt_usage = format(optionals, groups)
669
+ pos_usage = format(positionals, groups)
670
+ opt_parts = _re.findall(part_regexp, opt_usage)
671
+ pos_parts = _re.findall(part_regexp, pos_usage)
672
+ assert ' '.join(opt_parts) == opt_usage
673
+ assert ' '.join(pos_parts) == pos_usage
674
+
675
+ # helper for wrapping lines
676
+ def get_lines(parts, indent, prefix=None):
677
+ lines = []
678
+ line = []
679
+ if prefix is not None:
680
+ line_len = len(prefix) - 1
681
+ else:
682
+ line_len = len(indent) - 1
683
+ for part in parts:
684
+ if line_len + 1 + len(part) > text_width:
685
+ lines.append(indent + ' '.join(line))
686
+ line = []
687
+ line_len = len(indent) - 1
688
+ line.append(part)
689
+ line_len += len(part) + 1
690
+ if line:
691
+ lines.append(indent + ' '.join(line))
692
+ if prefix is not None:
693
+ lines[0] = lines[0][len(indent):]
694
+ return lines
695
+
696
+ # if prog is short, follow it with optionals or positionals
697
+ if len(prefix) + len(prog) <= 0.75 * text_width:
698
+ indent = ' ' * (len(prefix) + len(prog) + 1)
699
+ if opt_parts:
700
+ lines = get_lines([prog] + opt_parts, indent, prefix)
701
+ lines.extend(get_lines(pos_parts, indent))
702
+ elif pos_parts:
703
+ lines = get_lines([prog] + pos_parts, indent, prefix)
704
+ else:
705
+ lines = [prog]
706
+
707
+ # if prog is long, put it on its own line
708
+ else:
709
+ indent = ' ' * len(prefix)
710
+ parts = opt_parts + pos_parts
711
+ lines = get_lines(parts, indent)
712
+ if len(lines) > 1:
713
+ lines = []
714
+ lines.extend(get_lines(opt_parts, indent))
715
+ lines.extend(get_lines(pos_parts, indent))
716
+ lines = [prog] + lines
717
+
718
+ # join lines into usage
719
+ usage = '\n'.join(lines)
720
+
721
+ # prefix with 'usage:'
722
+ return '%s%s\n\n' % (prefix, usage)
723
+
724
+ def _format_actions_usage(self, actions, groups):
725
+ # find group indices and identify actions in groups
726
+ group_actions = set()
727
+ inserts = {}
728
+ for group in groups:
729
+ try:
730
+ start = actions.index(group._group_actions[0])
731
+ except ValueError:
732
+ continue
733
+ else:
734
+ end = start + len(group._group_actions)
735
+ if actions[start:end] == group._group_actions:
736
+ for action in group._group_actions:
737
+ group_actions.add(action)
738
+ if not group.required:
739
+ if start in inserts:
740
+ inserts[start] += ' ['
741
+ else:
742
+ inserts[start] = '['
743
+ inserts[end] = ']'
744
+ else:
745
+ if start in inserts:
746
+ inserts[start] += ' ('
747
+ else:
748
+ inserts[start] = '('
749
+ inserts[end] = ')'
750
+ for i in range(start + 1, end):
751
+ inserts[i] = '|'
752
+
753
+ # collect all actions format strings
754
+ parts = []
755
+ for i, action in enumerate(actions):
756
+
757
+ # suppressed arguments are marked with None
758
+ # remove | separators for suppressed arguments
759
+ if action.help is SUPPRESS:
760
+ parts.append(None)
761
+ if inserts.get(i) == '|':
762
+ inserts.pop(i)
763
+ elif inserts.get(i + 1) == '|':
764
+ inserts.pop(i + 1)
765
+
766
+ # produce all arg strings
767
+ elif not action.option_strings:
768
+ part = self._format_args(action, action.dest)
769
+
770
+ # if it's in a group, strip the outer []
771
+ if action in group_actions:
772
+ if part[0] == '[' and part[-1] == ']':
773
+ part = part[1:-1]
774
+
775
+ # add the action string to the list
776
+ parts.append(part)
777
+
778
+ # produce the first way to invoke the option in brackets
779
+ else:
780
+ option_string = action.option_strings[0]
781
+
782
+ # if the Optional doesn't take a value, format is:
783
+ # -s or --long
784
+ if action.nargs == 0:
785
+ part = '%s' % option_string
786
+
787
+ # if the Optional takes a value, format is:
788
+ # -s ARGS or --long ARGS
789
+ else:
790
+ default = action.dest.upper()
791
+ args_string = self._format_args(action, default)
792
+ part = '%s %s' % (option_string, args_string)
793
+
794
+ # make it look optional if it's not required or in a group
795
+ if not action.required and action not in group_actions:
796
+ part = '[%s]' % part
797
+
798
+ # add the action string to the list
799
+ parts.append(part)
800
+
801
+ # insert things at the necessary indices
802
+ for i in sorted(inserts, reverse=True):
803
+ parts[i:i] = [inserts[i]]
804
+
805
+ # join all the action items with spaces
806
+ text = ' '.join([item for item in parts if item is not None])
807
+
808
+ # clean up separators for mutually exclusive groups
809
+ open = r'[\[(]'
810
+ close = r'[\])]'
811
+ text = _re.sub(r'(%s) ' % open, r'\1', text)
812
+ text = _re.sub(r' (%s)' % close, r'\1', text)
813
+ text = _re.sub(r'%s *%s' % (open, close), r'', text)
814
+ text = _re.sub(r'\(([^|]*)\)', r'\1', text)
815
+ text = text.strip()
816
+
817
+ # return the text
818
+ return text
819
+
820
+ def _format_text(self, text):
821
+ if '%(prog)' in text:
822
+ text = text % dict(prog=self._prog)
823
+ text_width = self._width - self._current_indent
824
+ indent = ' ' * self._current_indent
825
+ return self._fill_text(text, text_width, indent) + '\n\n'
826
+
827
+ def _format_action(self, action):
828
+ # determine the required width and the entry label
829
+ help_position = min(self._action_max_length + 2,
830
+ self._max_help_position)
831
+ help_width = self._width - help_position
832
+ action_width = help_position - self._current_indent - 2
833
+ action_header = self._format_action_invocation(action)
834
+
835
+ # ho nelp; start on same line and add a final newline
836
+ if not action.help:
837
+ tup = self._current_indent, '', action_header
838
+ action_header = '%*s%s\n' % tup
839
+
840
+ # short action name; start on the same line and pad two spaces
841
+ elif len(action_header) <= action_width:
842
+ tup = self._current_indent, '', action_width, action_header
843
+ action_header = '%*s%-*s ' % tup
844
+ indent_first = 0
845
+
846
+ # long action name; start on the next line
847
+ else:
848
+ tup = self._current_indent, '', action_header
849
+ action_header = '%*s%s\n' % tup
850
+ indent_first = help_position
851
+
852
+ # collect the pieces of the action help
853
+ parts = [action_header]
854
+
855
+ # if there was help for the action, add lines of help text
856
+ if action.help:
857
+ help_text = self._expand_help(action)
858
+ help_lines = self._split_lines(help_text, help_width)
859
+ parts.append('%*s%s\n' % (indent_first, '', help_lines[0]))
860
+ for line in help_lines[1:]:
861
+ parts.append('%*s%s\n' % (help_position, '', line))
862
+
863
+ # or add a newline if the description doesn't end with one
864
+ elif not action_header.endswith('\n'):
865
+ parts.append('\n')
866
+
867
+ # if there are any sub-actions, add their help as well
868
+ for subaction in self._iter_indented_subactions(action):
869
+ parts.append(self._format_action(subaction))
870
+
871
+ # return a single string
872
+ return self._join_parts(parts)
873
+
874
+ def _format_action_invocation(self, action):
875
+ if not action.option_strings:
876
+ metavar, = self._metavar_formatter(action, action.dest)(1)
877
+ return metavar
878
+
879
+ else:
880
+ parts = []
881
+
882
+ # if the Optional doesn't take a value, format is:
883
+ # -s, --long
884
+ if action.nargs == 0:
885
+ parts.extend(action.option_strings)
886
+
887
+ # if the Optional takes a value, format is:
888
+ # -s ARGS, --long ARGS
889
+ else:
890
+ default = action.dest.upper()
891
+ args_string = self._format_args(action, default)
892
+ for option_string in action.option_strings:
893
+ parts.append('%s %s' % (option_string, args_string))
894
+
895
+ return ', '.join(parts)
896
+
897
+ def _metavar_formatter(self, action, default_metavar):
898
+ if action.metavar is not None:
899
+ result = action.metavar
900
+ elif action.choices is not None:
901
+ choice_strs = [str(choice) for choice in action.choices]
902
+ result = '{%s}' % ','.join(choice_strs)
903
+ else:
904
+ result = default_metavar
905
+
906
+ def format(tuple_size):
907
+ if isinstance(result, tuple):
908
+ return result
909
+ else:
910
+ return (result, ) * tuple_size
911
+ return format
912
+
913
+ def _format_args(self, action, default_metavar):
914
+ get_metavar = self._metavar_formatter(action, default_metavar)
915
+ if action.nargs is None:
916
+ result = '%s' % get_metavar(1)
917
+ elif action.nargs == OPTIONAL:
918
+ result = '[%s]' % get_metavar(1)
919
+ elif action.nargs == ZERO_OR_MORE:
920
+ result = '[%s [%s ...]]' % get_metavar(2)
921
+ elif action.nargs == ONE_OR_MORE:
922
+ result = '%s [%s ...]' % get_metavar(2)
923
+ elif action.nargs == REMAINDER:
924
+ result = '...'
925
+ elif action.nargs == PARSER:
926
+ result = '%s ...' % get_metavar(1)
927
+ else:
928
+ formats = ['%s' for _ in range(action.nargs)]
929
+ result = ' '.join(formats) % get_metavar(action.nargs)
930
+ return result
931
+
932
+ def _expand_help(self, action):
933
+ params = dict(vars(action), prog=self._prog)
934
+ for name in list(params):
935
+ if params[name] is SUPPRESS:
936
+ del params[name]
937
+ for name in list(params):
938
+ if hasattr(params[name], '__name__'):
939
+ params[name] = params[name].__name__
940
+ if params.get('choices') is not None:
941
+ choices_str = ', '.join([str(c) for c in params['choices']])
942
+ params['choices'] = choices_str
943
+ return self._get_help_string(action) % params
944
+
945
+ def _iter_indented_subactions(self, action):
946
+ try:
947
+ get_subactions = action._get_subactions
948
+ except AttributeError:
949
+ pass
950
+ else:
951
+ self._indent()
952
+ for subaction in get_subactions():
953
+ yield subaction
954
+ self._dedent()
955
+
956
+ def _split_lines(self, text, width):
957
+ text = self._whitespace_matcher.sub(' ', text).strip()
958
+ return _textwrap.wrap(text, width)
959
+
960
+ def _fill_text(self, text, width, indent):
961
+ text = self._whitespace_matcher.sub(' ', text).strip()
962
+ return _textwrap.fill(text, width, initial_indent=indent,
963
+ subsequent_indent=indent)
964
+
965
+ def _get_help_string(self, action):
966
+ return action.help
967
+
968
+
969
+class RawDescriptionHelpFormatter(HelpFormatter):
970
+ """Help message formatter which retains any formatting in descriptions.
971
+
972
+ Only the name of this class is considered a public API. All the methods
973
+ provided by the class are considered an implementation detail.
974
+ """
975
+
976
+ def _fill_text(self, text, width, indent):
977
+ return ''.join([indent + line for line in text.splitlines(True)])
978
+
979
+
980
+class RawTextHelpFormatter(RawDescriptionHelpFormatter):
981
+ """Help message formatter which retains formatting of all help text.
982
+
983
+ Only the name of this class is considered a public API. All the methods
984
+ provided by the class are considered an implementation detail.
985
+ """
986
+
987
+ def _split_lines(self, text, width):
988
+ return text.splitlines()
989
+
990
+
991
+class ArgumentDefaultsHelpFormatter(HelpFormatter):
992
+ """Help message formatter which adds default values to argument help.
993
+
994
+ Only the name of this class is considered a public API. All the methods
995
+ provided by the class are considered an implementation detail.
996
+ """
997
+
998
+ def _get_help_string(self, action):
999
+ help = action.help
1000
+ if '%(default)' not in action.help:
1001
+ if action.default is not SUPPRESS:
1002
+ defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
1003
+ if action.option_strings or action.nargs in defaulting_nargs:
1004
+ help += ' (default: %(default)s)'
1005
+ return help
1006
+
1007
+
1008
+# =====================
1009
+# Options and Arguments
1010
+# =====================
1011
+
1012
+def _get_action_name(argument):
1013
+ if argument is None:
1014
+ return None
1015
+ elif argument.option_strings:
1016
+ return '/'.join(argument.option_strings)
1017
+ elif argument.metavar not in (None, SUPPRESS):
1018
+ return argument.metavar
1019
+ elif argument.dest not in (None, SUPPRESS):
1020
+ return argument.dest
1021
+ else:
1022
+ return None
1023
+
1024
+
1025
+class ArgumentError(Exception):
1026
+ """An error from creating or using an argument (optional or positional).
1027
+
1028
+ The string value of this exception is the message, augmented with
1029
+ information about the argument that caused it.
1030
+ """
1031
+
1032
+ def __init__(self, argument, message):
1033
+ self.argument_name = _get_action_name(argument)
1034
+ self.message = message
1035
+
1036
+ def __str__(self):
1037
+ if self.argument_name is None:
1038
+ format = '%(message)s'
1039
+ else:
1040
+ format = 'argument %(argument_name)s: %(message)s'
1041
+ return format % dict(message=self.message,
1042
+ argument_name=self.argument_name)
1043
+
1044
+
1045
+class ArgumentTypeError(Exception):
1046
+ """An error from trying to convert a command line string to a type."""
1047
+ pass
1048
+
1049
+
1050
+# ==============
1051
+# Action classes
1052
+# ==============
1053
+
1054
+class Action(_AttributeHolder):
1055
+ """Information about how to convert command line strings to Python objects.
1056
+
1057
+ Action objects are used by an ArgumentParser to represent the information
1058
+ needed to parse a single argument from one or more strings from the
1059
+ command line. The keyword arguments to the Action constructor are also
1060
+ all attributes of Action instances.
1061
+
1062
+ Keyword Arguments:
1063
+
1064
+ - option_strings -- A list of command-line option strings which
1065
+ should be associated with this action.
1066
+
1067
+ - dest -- The name of the attribute to hold the created object(s)
1068
+
1069
+ - nargs -- The number of command-line arguments that should be
1070
+ consumed. By default, one argument will be consumed and a single
1071
+ value will be produced. Other values include:
1072
+ - N (an integer) consumes N arguments (and produces a list)
1073
+ - '?' consumes zero or one arguments
1074
+ - '*' consumes zero or more arguments (and produces a list)
1075
+ - '+' consumes one or more arguments (and produces a list)
1076
+ Note that the difference between the default and nargs=1 is that
1077
+ with the default, a single value will be produced, while with
1078
+ nargs=1, a list containing a single value will be produced.
1079
+
1080
+ - const -- The value to be produced if the option is specified and the
1081
+ option uses an action that takes no values.
1082
+
1083
+ - default -- The value to be produced if the option is not specified.
1084
+
1085
+ - type -- The type which the command-line arguments should be converted
1086
+ to, should be one of 'string', 'int', 'float', 'complex' or a
1087
+ callable object that accepts a single string argument. If None,
1088
+ 'string' is assumed.
1089
+
1090
+ - choices -- A container of values that should be allowed. If not None,
1091
+ after a command-line argument has been converted to the appropriate
1092
+ type, an exception will be raised if it is not a member of this
1093
+ collection.
1094
+
1095
+ - required -- True if the action must always be specified at the
1096
+ command line. This is only meaningful for optional command-line
1097
+ arguments.
1098
+
1099
+ - help -- The help string describing the argument.
1100
+
1101
+ - metavar -- The name to be used for the option's argument with the
1102
+ help string. If None, the 'dest' value will be used as the name.
1103
+ """
1104
+
1105
+ def __init__(self,
1106
+ option_strings,
1107
+ dest,
1108
+ nargs=None,
1109
+ const=None,
1110
+ default=None,
1111
+ type=None,
1112
+ choices=None,
1113
+ required=False,
1114
+ help=None,
1115
+ metavar=None):
1116
+ self.option_strings = option_strings
1117
+ self.dest = dest
1118
+ self.nargs = nargs
1119
+ self.const = const
1120
+ self.default = default
1121
+ self.type = type
1122
+ self.choices = choices
1123
+ self.required = required
1124
+ self.help = help
1125
+ self.metavar = metavar
1126
+
1127
+ def _get_kwargs(self):
1128
+ names = [
1129
+ 'option_strings',
1130
+ 'dest',
1131
+ 'nargs',
1132
+ 'const',
1133
+ 'default',
1134
+ 'type',
1135
+ 'choices',
1136
+ 'help',
1137
+ 'metavar',
1138
+ ]
1139
+ return [(name, getattr(self, name)) for name in names]
1140
+
1141
+ def __call__(self, parser, namespace, values, option_string=None):
150
+ def __call__(self, parser, namespace, values, option_string=None):
1142
+ raise NotImplementedError(_('.__call__() not defined'))
151
+ items = getattr(namespace, self.dest) or []
1143
+
152
+ items.extend(values)
1144
+
1145
+class _StoreAction(Action):
1146
+
1147
+ def __init__(self,
1148
+ option_strings,
1149
+ dest,
1150
+ nargs=None,
1151
+ const=None,
1152
+ default=None,
1153
+ type=None,
1154
+ choices=None,
1155
+ required=False,
1156
+ help=None,
1157
+ metavar=None):
1158
+ if nargs == 0:
1159
+ raise ValueError('nargs for store actions must be > 0; if you '
1160
+ 'have nothing to store, actions such as store '
1161
+ 'true or store const may be more appropriate')
1162
+ if const is not None and nargs != OPTIONAL:
1163
+ raise ValueError('nargs must be %r to supply const' % OPTIONAL)
1164
+ super(_StoreAction, self).__init__(
1165
+ option_strings=option_strings,
1166
+ dest=dest,
1167
+ nargs=nargs,
1168
+ const=const,
1169
+ default=default,
1170
+ type=type,
1171
+ choices=choices,
1172
+ required=required,
1173
+ help=help,
1174
+ metavar=metavar)
1175
+
1176
+ def __call__(self, parser, namespace, values, option_string=None):
1177
+ setattr(namespace, self.dest, values)
1178
+
1179
+
1180
+class _StoreConstAction(Action):
1181
+
1182
+ def __init__(self,
1183
+ option_strings,
1184
+ dest,
1185
+ const,
1186
+ default=None,
1187
+ required=False,
1188
+ help=None,
1189
+ metavar=None):
1190
+ super(_StoreConstAction, self).__init__(
1191
+ option_strings=option_strings,
1192
+ dest=dest,
1193
+ nargs=0,
1194
+ const=const,
1195
+ default=default,
1196
+ required=required,
1197
+ help=help)
1198
+
1199
+ def __call__(self, parser, namespace, values, option_string=None):
1200
+ setattr(namespace, self.dest, self.const)
1201
+
1202
+
1203
+class _StoreTrueAction(_StoreConstAction):
1204
+
1205
+ def __init__(self,
1206
+ option_strings,
1207
+ dest,
1208
+ default=False,
1209
+ required=False,
1210
+ help=None):
1211
+ super(_StoreTrueAction, self).__init__(
1212
+ option_strings=option_strings,
1213
+ dest=dest,
1214
+ const=True,
1215
+ default=default,
1216
+ required=required,
1217
+ help=help)
1218
+
1219
+
1220
+class _StoreFalseAction(_StoreConstAction):
1221
+
1222
+ def __init__(self,
1223
+ option_strings,
1224
+ dest,
1225
+ default=True,
1226
+ required=False,
1227
+ help=None):
1228
+ super(_StoreFalseAction, self).__init__(
1229
+ option_strings=option_strings,
1230
+ dest=dest,
1231
+ const=False,
1232
+ default=default,
1233
+ required=required,
1234
+ help=help)
1235
+
1236
+
1237
+class _AppendAction(Action):
1238
+
1239
+ def __init__(self,
1240
+ option_strings,
1241
+ dest,
1242
+ nargs=None,
1243
+ const=None,
1244
+ default=None,
1245
+ type=None,
1246
+ choices=None,
1247
+ required=False,
1248
+ help=None,
1249
+ metavar=None):
1250
+ if nargs == 0:
1251
+ raise ValueError('nargs for append actions must be > 0; if arg '
1252
+ 'strings are not supplying the value to append, '
1253
+ 'the append const action may be more appropriate')
1254
+ if const is not None and nargs != OPTIONAL:
1255
+ raise ValueError('nargs must be %r to supply const' % OPTIONAL)
1256
+ super(_AppendAction, self).__init__(
1257
+ option_strings=option_strings,
1258
+ dest=dest,
1259
+ nargs=nargs,
1260
+ const=const,
1261
+ default=default,
1262
+ type=type,
1263
+ choices=choices,
1264
+ required=required,
1265
+ help=help,
1266
+ metavar=metavar)
1267
+
1268
+ def __call__(self, parser, namespace, values, option_string=None):
1269
+ items = _copy.copy(_ensure_value(namespace, self.dest, []))
1270
+ items.append(values)
1271
+ setattr(namespace, self.dest, items)
153
+ setattr(namespace, self.dest, items)
1272
+
154
+
1273
+
155
+
1274
+class _AppendConstAction(Action):
156
+if __name__ == '__main__':
157
+ p = argparse.ArgumentParser('Backup benchmark', epilog='''
158
+ENV format
1275
+
159
+
1276
+ def __init__(self,
160
+ (LABEL:PATH|LABEL|PATH)[,max-workers=N][,use-copy-range=(on|off)][,mirror]
1277
+ option_strings,
1278
+ dest,
1279
+ const,
1280
+ default=None,
1281
+ required=False,
1282
+ help=None,
1283
+ metavar=None):
1284
+ super(_AppendConstAction, self).__init__(
1285
+ option_strings=option_strings,
1286
+ dest=dest,
1287
+ nargs=0,
1288
+ const=const,
1289
+ default=default,
1290
+ required=required,
1291
+ help=help,
1292
+ metavar=metavar)
1293
+
161
+
1294
+ def __call__(self, parser, namespace, values, option_string=None):
162
+ LABEL short name for the binary
1295
+ items = _copy.copy(_ensure_value(namespace, self.dest, []))
163
+ PATH path to the binary
1296
+ items.append(self.const)
164
+ max-workers set x-perf.max-workers of backup job
1297
+ setattr(namespace, self.dest, items)
165
+ use-copy-range set x-perf.use-copy-range of backup job
166
+ mirror use mirror job instead of backup''',
167
+ formatter_class=argparse.RawTextHelpFormatter)
168
+ p.add_argument('--env', nargs='+', help='''\
169
+Qemu binaries with labels and options, see below
170
+"ENV format" section''',
171
+ action=ExtendAction)
172
+ p.add_argument('--dir', nargs='+', help='''\
173
+Directories, each containing "test-source" and/or
174
+"test-target" files, raw images to used in
175
+benchmarking. File path with label, like
176
+label:/path/to/directory''',
177
+ action=ExtendAction)
178
+ p.add_argument('--nbd', help='''\
179
+host:port for remote NBD image, (or just host, for
180
+default port 10809). Use it in tests, label is "nbd"
181
+(but you cannot create test nbd:nbd).''')
182
+ p.add_argument('--test', nargs='+', help='''\
183
+Tests, in form source-dir-label:target-dir-label''',
184
+ action=ExtendAction)
1298
+
185
+
1299
+
186
+ bench(p.parse_args())
1300
+class _CountAction(Action):
1301
+
1302
+ def __init__(self,
1303
+ option_strings,
1304
+ dest,
1305
+ default=None,
1306
+ required=False,
1307
+ help=None):
1308
+ super(_CountAction, self).__init__(
1309
+ option_strings=option_strings,
1310
+ dest=dest,
1311
+ nargs=0,
1312
+ default=default,
1313
+ required=required,
1314
+ help=help)
1315
+
1316
+ def __call__(self, parser, namespace, values, option_string=None):
1317
+ new_count = _ensure_value(namespace, self.dest, 0) + 1
1318
+ setattr(namespace, self.dest, new_count)
1319
+
1320
+
1321
+class _HelpAction(Action):
1322
+
1323
+ def __init__(self,
1324
+ option_strings,
1325
+ dest=SUPPRESS,
1326
+ default=SUPPRESS,
1327
+ help=None):
1328
+ super(_HelpAction, self).__init__(
1329
+ option_strings=option_strings,
1330
+ dest=dest,
1331
+ default=default,
1332
+ nargs=0,
1333
+ help=help)
1334
+
1335
+ def __call__(self, parser, namespace, values, option_string=None):
1336
+ parser.print_help()
1337
+ parser.exit()
1338
+
1339
+
1340
+class _VersionAction(Action):
1341
+
1342
+ def __init__(self,
1343
+ option_strings,
1344
+ version=None,
1345
+ dest=SUPPRESS,
1346
+ default=SUPPRESS,
1347
+ help="show program's version number and exit"):
1348
+ super(_VersionAction, self).__init__(
1349
+ option_strings=option_strings,
1350
+ dest=dest,
1351
+ default=default,
1352
+ nargs=0,
1353
+ help=help)
1354
+ self.version = version
1355
+
1356
+ def __call__(self, parser, namespace, values, option_string=None):
1357
+ version = self.version
1358
+ if version is None:
1359
+ version = parser.version
1360
+ formatter = parser._get_formatter()
1361
+ formatter.add_text(version)
1362
+ parser.exit(message=formatter.format_help())
1363
+
1364
+
1365
+class _SubParsersAction(Action):
1366
+
1367
+ class _ChoicesPseudoAction(Action):
1368
+
1369
+ def __init__(self, name, aliases, help):
1370
+ metavar = dest = name
1371
+ if aliases:
1372
+ metavar += ' (%s)' % ', '.join(aliases)
1373
+ sup = super(_SubParsersAction._ChoicesPseudoAction, self)
1374
+ sup.__init__(option_strings=[], dest=dest, help=help,
1375
+ metavar=metavar)
1376
+
1377
+ def __init__(self,
1378
+ option_strings,
1379
+ prog,
1380
+ parser_class,
1381
+ dest=SUPPRESS,
1382
+ help=None,
1383
+ metavar=None):
1384
+
1385
+ self._prog_prefix = prog
1386
+ self._parser_class = parser_class
1387
+ self._name_parser_map = {}
1388
+ self._choices_actions = []
1389
+
1390
+ super(_SubParsersAction, self).__init__(
1391
+ option_strings=option_strings,
1392
+ dest=dest,
1393
+ nargs=PARSER,
1394
+ choices=self._name_parser_map,
1395
+ help=help,
1396
+ metavar=metavar)
1397
+
1398
+ def add_parser(self, name, **kwargs):
1399
+ # set prog from the existing prefix
1400
+ if kwargs.get('prog') is None:
1401
+ kwargs['prog'] = '%s %s' % (self._prog_prefix, name)
1402
+
1403
+ aliases = kwargs.pop('aliases', ())
1404
+
1405
+ # create a pseudo-action to hold the choice help
1406
+ if 'help' in kwargs:
1407
+ help = kwargs.pop('help')
1408
+ choice_action = self._ChoicesPseudoAction(name, aliases, help)
1409
+ self._choices_actions.append(choice_action)
1410
+
1411
+ # create the parser and add it to the map
1412
+ parser = self._parser_class(**kwargs)
1413
+ self._name_parser_map[name] = parser
1414
+
1415
+ # make parser available under aliases also
1416
+ for alias in aliases:
1417
+ self._name_parser_map[alias] = parser
1418
+
1419
+ return parser
1420
+
1421
+ def _get_subactions(self):
1422
+ return self._choices_actions
1423
+
1424
+ def __call__(self, parser, namespace, values, option_string=None):
1425
+ parser_name = values[0]
1426
+ arg_strings = values[1:]
1427
+
1428
+ # set the parser name if requested
1429
+ if self.dest is not SUPPRESS:
1430
+ setattr(namespace, self.dest, parser_name)
1431
+
1432
+ # select the parser
1433
+ try:
1434
+ parser = self._name_parser_map[parser_name]
1435
+ except KeyError:
1436
+ tup = parser_name, ', '.join(self._name_parser_map)
1437
+ msg = _('unknown parser %r (choices: %s)' % tup)
1438
+ raise ArgumentError(self, msg)
1439
+
1440
+ # parse all the remaining options into the namespace
1441
+ # store any unrecognized options on the object, so that the top
1442
+ # level parser can decide what to do with them
1443
+ namespace, arg_strings = parser.parse_known_args(arg_strings, namespace)
1444
+ if arg_strings:
1445
+ vars(namespace).setdefault(_UNRECOGNIZED_ARGS_ATTR, [])
1446
+ getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).extend(arg_strings)
1447
+
1448
+
1449
+# ==============
1450
+# Type classes
1451
+# ==============
1452
+
1453
+class FileType(object):
1454
+ """Factory for creating file object types
1455
+
1456
+ Instances of FileType are typically passed as type= arguments to the
1457
+ ArgumentParser add_argument() method.
1458
+
1459
+ Keyword Arguments:
1460
+ - mode -- A string indicating how the file is to be opened. Accepts the
1461
+ same values as the builtin open() function.
1462
+ - bufsize -- The file's desired buffer size. Accepts the same values as
1463
+ the builtin open() function.
1464
+ """
1465
+
1466
+ def __init__(self, mode='r', bufsize=None):
1467
+ self._mode = mode
1468
+ self._bufsize = bufsize
1469
+
1470
+ def __call__(self, string):
1471
+ # the special argument "-" means sys.std{in,out}
1472
+ if string == '-':
1473
+ if 'r' in self._mode:
1474
+ return _sys.stdin
1475
+ elif 'w' in self._mode:
1476
+ return _sys.stdout
1477
+ else:
1478
+ msg = _('argument "-" with mode %r' % self._mode)
1479
+ raise ValueError(msg)
1480
+
1481
+ try:
1482
+ # all other arguments are used as file names
1483
+ if self._bufsize:
1484
+ return open(string, self._mode, self._bufsize)
1485
+ else:
1486
+ return open(string, self._mode)
1487
+ except IOError:
1488
+ err = _sys.exc_info()[1]
1489
+ message = _("can't open '%s': %s")
1490
+ raise ArgumentTypeError(message % (string, err))
1491
+
1492
+ def __repr__(self):
1493
+ args = [self._mode, self._bufsize]
1494
+ args_str = ', '.join([repr(arg) for arg in args if arg is not None])
1495
+ return '%s(%s)' % (type(self).__name__, args_str)
1496
+
1497
+# ===========================
1498
+# Optional and Positional Parsing
1499
+# ===========================
1500
+
1501
+class Namespace(_AttributeHolder):
1502
+ """Simple object for storing attributes.
1503
+
1504
+ Implements equality by attribute names and values, and provides a simple
1505
+ string representation.
1506
+ """
1507
+
1508
+ def __init__(self, **kwargs):
1509
+ for name in kwargs:
1510
+ setattr(self, name, kwargs[name])
1511
+
1512
+ __hash__ = None
1513
+
1514
+ def __eq__(self, other):
1515
+ return vars(self) == vars(other)
1516
+
1517
+ def __ne__(self, other):
1518
+ return not (self == other)
1519
+
1520
+ def __contains__(self, key):
1521
+ return key in self.__dict__
1522
+
1523
+
1524
+class _ActionsContainer(object):
1525
+
1526
+ def __init__(self,
1527
+ description,
1528
+ prefix_chars,
1529
+ argument_default,
1530
+ conflict_handler):
1531
+ super(_ActionsContainer, self).__init__()
1532
+
1533
+ self.description = description
1534
+ self.argument_default = argument_default
1535
+ self.prefix_chars = prefix_chars
1536
+ self.conflict_handler = conflict_handler
1537
+
1538
+ # set up registries
1539
+ self._registries = {}
1540
+
1541
+ # register actions
1542
+ self.register('action', None, _StoreAction)
1543
+ self.register('action', 'store', _StoreAction)
1544
+ self.register('action', 'store_const', _StoreConstAction)
1545
+ self.register('action', 'store_true', _StoreTrueAction)
1546
+ self.register('action', 'store_false', _StoreFalseAction)
1547
+ self.register('action', 'append', _AppendAction)
1548
+ self.register('action', 'append_const', _AppendConstAction)
1549
+ self.register('action', 'count', _CountAction)
1550
+ self.register('action', 'help', _HelpAction)
1551
+ self.register('action', 'version', _VersionAction)
1552
+ self.register('action', 'parsers', _SubParsersAction)
1553
+
1554
+ # raise an exception if the conflict handler is invalid
1555
+ self._get_handler()
1556
+
1557
+ # action storage
1558
+ self._actions = []
1559
+ self._option_string_actions = {}
1560
+
1561
+ # groups
1562
+ self._action_groups = []
1563
+ self._mutually_exclusive_groups = []
1564
+
1565
+ # defaults storage
1566
+ self._defaults = {}
1567
+
1568
+ # determines whether an "option" looks like a negative number
1569
+ self._negative_number_matcher = _re.compile(r'^-\d+$|^-\d*\.\d+$')
1570
+
1571
+ # whether or not there are any optionals that look like negative
1572
+ # numbers -- uses a list so it can be shared and edited
1573
+ self._has_negative_number_optionals = []
1574
+
1575
+ # ====================
1576
+ # Registration methods
1577
+ # ====================
1578
+ def register(self, registry_name, value, object):
1579
+ registry = self._registries.setdefault(registry_name, {})
1580
+ registry[value] = object
1581
+
1582
+ def _registry_get(self, registry_name, value, default=None):
1583
+ return self._registries[registry_name].get(value, default)
1584
+
1585
+ # ==================================
1586
+ # Namespace default accessor methods
1587
+ # ==================================
1588
+ def set_defaults(self, **kwargs):
1589
+ self._defaults.update(kwargs)
1590
+
1591
+ # if these defaults match any existing arguments, replace
1592
+ # the previous default on the object with the new one
1593
+ for action in self._actions:
1594
+ if action.dest in kwargs:
1595
+ action.default = kwargs[action.dest]
1596
+
1597
+ def get_default(self, dest):
1598
+ for action in self._actions:
1599
+ if action.dest == dest and action.default is not None:
1600
+ return action.default
1601
+ return self._defaults.get(dest, None)
1602
+
1603
+
1604
+ # =======================
1605
+ # Adding argument actions
1606
+ # =======================
1607
+ def add_argument(self, *args, **kwargs):
1608
+ """
1609
+ add_argument(dest, ..., name=value, ...)
1610
+ add_argument(option_string, option_string, ..., name=value, ...)
1611
+ """
1612
+
1613
+ # if no positional args are supplied or only one is supplied and
1614
+ # it doesn't look like an option string, parse a positional
1615
+ # argument
1616
+ chars = self.prefix_chars
1617
+ if not args or len(args) == 1 and args[0][0] not in chars:
1618
+ if args and 'dest' in kwargs:
1619
+ raise ValueError('dest supplied twice for positional argument')
1620
+ kwargs = self._get_positional_kwargs(*args, **kwargs)
1621
+
1622
+ # otherwise, we're adding an optional argument
1623
+ else:
1624
+ kwargs = self._get_optional_kwargs(*args, **kwargs)
1625
+
1626
+ # if no default was supplied, use the parser-level default
1627
+ if 'default' not in kwargs:
1628
+ dest = kwargs['dest']
1629
+ if dest in self._defaults:
1630
+ kwargs['default'] = self._defaults[dest]
1631
+ elif self.argument_default is not None:
1632
+ kwargs['default'] = self.argument_default
1633
+
1634
+ # create the action object, and add it to the parser
1635
+ action_class = self._pop_action_class(kwargs)
1636
+ if not _callable(action_class):
1637
+ raise ValueError('unknown action "%s"' % action_class)
1638
+ action = action_class(**kwargs)
1639
+
1640
+ # raise an error if the action type is not callable
1641
+ type_func = self._registry_get('type', action.type, action.type)
1642
+ if not _callable(type_func):
1643
+ raise ValueError('%r is not callable' % type_func)
1644
+
1645
+ return self._add_action(action)
1646
+
1647
+ def add_argument_group(self, *args, **kwargs):
1648
+ group = _ArgumentGroup(self, *args, **kwargs)
1649
+ self._action_groups.append(group)
1650
+ return group
1651
+
1652
+ def add_mutually_exclusive_group(self, **kwargs):
1653
+ group = _MutuallyExclusiveGroup(self, **kwargs)
1654
+ self._mutually_exclusive_groups.append(group)
1655
+ return group
1656
+
1657
+ def _add_action(self, action):
1658
+ # resolve any conflicts
1659
+ self._check_conflict(action)
1660
+
1661
+ # add to actions list
1662
+ self._actions.append(action)
1663
+ action.container = self
1664
+
1665
+ # index the action by any option strings it has
1666
+ for option_string in action.option_strings:
1667
+ self._option_string_actions[option_string] = action
1668
+
1669
+ # set the flag if any option strings look like negative numbers
1670
+ for option_string in action.option_strings:
1671
+ if self._negative_number_matcher.match(option_string):
1672
+ if not self._has_negative_number_optionals:
1673
+ self._has_negative_number_optionals.append(True)
1674
+
1675
+ # return the created action
1676
+ return action
1677
+
1678
+ def _remove_action(self, action):
1679
+ self._actions.remove(action)
1680
+
1681
+ def _add_container_actions(self, container):
1682
+ # collect groups by titles
1683
+ title_group_map = {}
1684
+ for group in self._action_groups:
1685
+ if group.title in title_group_map:
1686
+ msg = _('cannot merge actions - two groups are named %r')
1687
+ raise ValueError(msg % (group.title))
1688
+ title_group_map[group.title] = group
1689
+
1690
+ # map each action to its group
1691
+ group_map = {}
1692
+ for group in container._action_groups:
1693
+
1694
+ # if a group with the title exists, use that, otherwise
1695
+ # create a new group matching the container's group
1696
+ if group.title not in title_group_map:
1697
+ title_group_map[group.title] = self.add_argument_group(
1698
+ title=group.title,
1699
+ description=group.description,
1700
+ conflict_handler=group.conflict_handler)
1701
+
1702
+ # map the actions to their new group
1703
+ for action in group._group_actions:
1704
+ group_map[action] = title_group_map[group.title]
1705
+
1706
+ # add container's mutually exclusive groups
1707
+ # NOTE: if add_mutually_exclusive_group ever gains title= and
1708
+ # description= then this code will need to be expanded as above
1709
+ for group in container._mutually_exclusive_groups:
1710
+ mutex_group = self.add_mutually_exclusive_group(
1711
+ required=group.required)
1712
+
1713
+ # map the actions to their new mutex group
1714
+ for action in group._group_actions:
1715
+ group_map[action] = mutex_group
1716
+
1717
+ # add all actions to this container or their group
1718
+ for action in container._actions:
1719
+ group_map.get(action, self)._add_action(action)
1720
+
1721
+ def _get_positional_kwargs(self, dest, **kwargs):
1722
+ # make sure required is not specified
1723
+ if 'required' in kwargs:
1724
+ msg = _("'required' is an invalid argument for positionals")
1725
+ raise TypeError(msg)
1726
+
1727
+ # mark positional arguments as required if at least one is
1728
+ # always required
1729
+ if kwargs.get('nargs') not in [OPTIONAL, ZERO_OR_MORE]:
1730
+ kwargs['required'] = True
1731
+ if kwargs.get('nargs') == ZERO_OR_MORE and 'default' not in kwargs:
1732
+ kwargs['required'] = True
1733
+
1734
+ # return the keyword arguments with no option strings
1735
+ return dict(kwargs, dest=dest, option_strings=[])
1736
+
1737
+ def _get_optional_kwargs(self, *args, **kwargs):
1738
+ # determine short and long option strings
1739
+ option_strings = []
1740
+ long_option_strings = []
1741
+ for option_string in args:
1742
+ # error on strings that don't start with an appropriate prefix
1743
+ if not option_string[0] in self.prefix_chars:
1744
+ msg = _('invalid option string %r: '
1745
+ 'must start with a character %r')
1746
+ tup = option_string, self.prefix_chars
1747
+ raise ValueError(msg % tup)
1748
+
1749
+ # strings starting with two prefix characters are long options
1750
+ option_strings.append(option_string)
1751
+ if option_string[0] in self.prefix_chars:
1752
+ if len(option_string) > 1:
1753
+ if option_string[1] in self.prefix_chars:
1754
+ long_option_strings.append(option_string)
1755
+
1756
+ # infer destination, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
1757
+ dest = kwargs.pop('dest', None)
1758
+ if dest is None:
1759
+ if long_option_strings:
1760
+ dest_option_string = long_option_strings[0]
1761
+ else:
1762
+ dest_option_string = option_strings[0]
1763
+ dest = dest_option_string.lstrip(self.prefix_chars)
1764
+ if not dest:
1765
+ msg = _('dest= is required for options like %r')
1766
+ raise ValueError(msg % option_string)
1767
+ dest = dest.replace('-', '_')
1768
+
1769
+ # return the updated keyword arguments
1770
+ return dict(kwargs, dest=dest, option_strings=option_strings)
1771
+
1772
+ def _pop_action_class(self, kwargs, default=None):
1773
+ action = kwargs.pop('action', default)
1774
+ return self._registry_get('action', action, action)
1775
+
1776
+ def _get_handler(self):
1777
+ # determine function from conflict handler string
1778
+ handler_func_name = '_handle_conflict_%s' % self.conflict_handler
1779
+ try:
1780
+ return getattr(self, handler_func_name)
1781
+ except AttributeError:
1782
+ msg = _('invalid conflict_resolution value: %r')
1783
+ raise ValueError(msg % self.conflict_handler)
1784
+
1785
+ def _check_conflict(self, action):
1786
+
1787
+ # find all options that conflict with this option
1788
+ confl_optionals = []
1789
+ for option_string in action.option_strings:
1790
+ if option_string in self._option_string_actions:
1791
+ confl_optional = self._option_string_actions[option_string]
1792
+ confl_optionals.append((option_string, confl_optional))
1793
+
1794
+ # resolve any conflicts
1795
+ if confl_optionals:
1796
+ conflict_handler = self._get_handler()
1797
+ conflict_handler(action, confl_optionals)
1798
+
1799
+ def _handle_conflict_error(self, action, conflicting_actions):
1800
+ message = _('conflicting option string(s): %s')
1801
+ conflict_string = ', '.join([option_string
1802
+ for option_string, action
1803
+ in conflicting_actions])
1804
+ raise ArgumentError(action, message % conflict_string)
1805
+
1806
+ def _handle_conflict_resolve(self, action, conflicting_actions):
1807
+
1808
+ # remove all conflicting options
1809
+ for option_string, action in conflicting_actions:
1810
+
1811
+ # remove the conflicting option
1812
+ action.option_strings.remove(option_string)
1813
+ self._option_string_actions.pop(option_string, None)
1814
+
1815
+ # if the option now has no option string, remove it from the
1816
+ # container holding it
1817
+ if not action.option_strings:
1818
+ action.container._remove_action(action)
1819
+
1820
+
1821
+class _ArgumentGroup(_ActionsContainer):
1822
+
1823
+ def __init__(self, container, title=None, description=None, **kwargs):
1824
+ # add any missing keyword arguments by checking the container
1825
+ update = kwargs.setdefault
1826
+ update('conflict_handler', container.conflict_handler)
1827
+ update('prefix_chars', container.prefix_chars)
1828
+ update('argument_default', container.argument_default)
1829
+ super_init = super(_ArgumentGroup, self).__init__
1830
+ super_init(description=description, **kwargs)
1831
+
1832
+ # group attributes
1833
+ self.title = title
1834
+ self._group_actions = []
1835
+
1836
+ # share most attributes with the container
1837
+ self._registries = container._registries
1838
+ self._actions = container._actions
1839
+ self._option_string_actions = container._option_string_actions
1840
+ self._defaults = container._defaults
1841
+ self._has_negative_number_optionals = \
1842
+ container._has_negative_number_optionals
1843
+
1844
+ def _add_action(self, action):
1845
+ action = super(_ArgumentGroup, self)._add_action(action)
1846
+ self._group_actions.append(action)
1847
+ return action
1848
+
1849
+ def _remove_action(self, action):
1850
+ super(_ArgumentGroup, self)._remove_action(action)
1851
+ self._group_actions.remove(action)
1852
+
1853
+
1854
+class _MutuallyExclusiveGroup(_ArgumentGroup):
1855
+
1856
+ def __init__(self, container, required=False):
1857
+ super(_MutuallyExclusiveGroup, self).__init__(container)
1858
+ self.required = required
1859
+ self._container = container
1860
+
1861
+ def _add_action(self, action):
1862
+ if action.required:
1863
+ msg = _('mutually exclusive arguments must be optional')
1864
+ raise ValueError(msg)
1865
+ action = self._container._add_action(action)
1866
+ self._group_actions.append(action)
1867
+ return action
1868
+
1869
+ def _remove_action(self, action):
1870
+ self._container._remove_action(action)
1871
+ self._group_actions.remove(action)
1872
+
1873
+
1874
+class ArgumentParser(_AttributeHolder, _ActionsContainer):
1875
+ """Object for parsing command line strings into Python objects.
1876
+
1877
+ Keyword Arguments:
1878
+ - prog -- The name of the program (default: sys.argv[0])
1879
+ - usage -- A usage message (default: auto-generated from arguments)
1880
+ - description -- A description of what the program does
1881
+ - epilog -- Text following the argument descriptions
1882
+ - parents -- Parsers whose arguments should be copied into this one
1883
+ - formatter_class -- HelpFormatter class for printing help messages
1884
+ - prefix_chars -- Characters that prefix optional arguments
1885
+ - fromfile_prefix_chars -- Characters that prefix files containing
1886
+ additional arguments
1887
+ - argument_default -- The default value for all arguments
1888
+ - conflict_handler -- String indicating how to handle conflicts
1889
+ - add_help -- Add a -h/-help option
1890
+ """
1891
+
1892
+ def __init__(self,
1893
+ prog=None,
1894
+ usage=None,
1895
+ description=None,
1896
+ epilog=None,
1897
+ version=None,
1898
+ parents=[],
1899
+ formatter_class=HelpFormatter,
1900
+ prefix_chars='-',
1901
+ fromfile_prefix_chars=None,
1902
+ argument_default=None,
1903
+ conflict_handler='error',
1904
+ add_help=True):
1905
+
1906
+ if version is not None:
1907
+ import warnings
1908
+ warnings.warn(
1909
+ """The "version" argument to ArgumentParser is deprecated. """
1910
+ """Please use """
1911
+ """"add_argument(..., action='version', version="N", ...)" """
1912
+ """instead""", DeprecationWarning)
1913
+
1914
+ superinit = super(ArgumentParser, self).__init__
1915
+ superinit(description=description,
1916
+ prefix_chars=prefix_chars,
1917
+ argument_default=argument_default,
1918
+ conflict_handler=conflict_handler)
1919
+
1920
+ # default setting for prog
1921
+ if prog is None:
1922
+ prog = _os.path.basename(_sys.argv[0])
1923
+
1924
+ self.prog = prog
1925
+ self.usage = usage
1926
+ self.epilog = epilog
1927
+ self.version = version
1928
+ self.formatter_class = formatter_class
1929
+ self.fromfile_prefix_chars = fromfile_prefix_chars
1930
+ self.add_help = add_help
1931
+
1932
+ add_group = self.add_argument_group
1933
+ self._positionals = add_group(_('positional arguments'))
1934
+ self._optionals = add_group(_('optional arguments'))
1935
+ self._subparsers = None
1936
+
1937
+ # register types
1938
+ def identity(string):
1939
+ return string
1940
+ self.register('type', None, identity)
1941
+
1942
+ # add help and version arguments if necessary
1943
+ # (using explicit default to override global argument_default)
1944
+ if '-' in prefix_chars:
1945
+ default_prefix = '-'
1946
+ else:
1947
+ default_prefix = prefix_chars[0]
1948
+ if self.add_help:
1949
+ self.add_argument(
1950
+ default_prefix+'h', default_prefix*2+'help',
1951
+ action='help', default=SUPPRESS,
1952
+ help=_('show this help message and exit'))
1953
+ if self.version:
1954
+ self.add_argument(
1955
+ default_prefix+'v', default_prefix*2+'version',
1956
+ action='version', default=SUPPRESS,
1957
+ version=self.version,
1958
+ help=_("show program's version number and exit"))
1959
+
1960
+ # add parent arguments and defaults
1961
+ for parent in parents:
1962
+ self._add_container_actions(parent)
1963
+ try:
1964
+ defaults = parent._defaults
1965
+ except AttributeError:
1966
+ pass
1967
+ else:
1968
+ self._defaults.update(defaults)
1969
+
1970
+ # =======================
1971
+ # Pretty __repr__ methods
1972
+ # =======================
1973
+ def _get_kwargs(self):
1974
+ names = [
1975
+ 'prog',
1976
+ 'usage',
1977
+ 'description',
1978
+ 'version',
1979
+ 'formatter_class',
1980
+ 'conflict_handler',
1981
+ 'add_help',
1982
+ ]
1983
+ return [(name, getattr(self, name)) for name in names]
1984
+
1985
+ # ==================================
1986
+ # Optional/Positional adding methods
1987
+ # ==================================
1988
+ def add_subparsers(self, **kwargs):
1989
+ if self._subparsers is not None:
1990
+ self.error(_('cannot have multiple subparser arguments'))
1991
+
1992
+ # add the parser class to the arguments if it's not present
1993
+ kwargs.setdefault('parser_class', type(self))
1994
+
1995
+ if 'title' in kwargs or 'description' in kwargs:
1996
+ title = _(kwargs.pop('title', 'subcommands'))
1997
+ description = _(kwargs.pop('description', None))
1998
+ self._subparsers = self.add_argument_group(title, description)
1999
+ else:
2000
+ self._subparsers = self._positionals
2001
+
2002
+ # prog defaults to the usage message of this parser, skipping
2003
+ # optional arguments and with no "usage:" prefix
2004
+ if kwargs.get('prog') is None:
2005
+ formatter = self._get_formatter()
2006
+ positionals = self._get_positional_actions()
2007
+ groups = self._mutually_exclusive_groups
2008
+ formatter.add_usage(self.usage, positionals, groups, '')
2009
+ kwargs['prog'] = formatter.format_help().strip()
2010
+
2011
+ # create the parsers action and add it to the positionals list
2012
+ parsers_class = self._pop_action_class(kwargs, 'parsers')
2013
+ action = parsers_class(option_strings=[], **kwargs)
2014
+ self._subparsers._add_action(action)
2015
+
2016
+ # return the created parsers action
2017
+ return action
2018
+
2019
+ def _add_action(self, action):
2020
+ if action.option_strings:
2021
+ self._optionals._add_action(action)
2022
+ else:
2023
+ self._positionals._add_action(action)
2024
+ return action
2025
+
2026
+ def _get_optional_actions(self):
2027
+ return [action
2028
+ for action in self._actions
2029
+ if action.option_strings]
2030
+
2031
+ def _get_positional_actions(self):
2032
+ return [action
2033
+ for action in self._actions
2034
+ if not action.option_strings]
2035
+
2036
+ # =====================================
2037
+ # Command line argument parsing methods
2038
+ # =====================================
2039
+ def parse_args(self, args=None, namespace=None):
2040
+ args, argv = self.parse_known_args(args, namespace)
2041
+ if argv:
2042
+ msg = _('unrecognized arguments: %s')
2043
+ self.error(msg % ' '.join(argv))
2044
+ return args
2045
+
2046
+ def parse_known_args(self, args=None, namespace=None):
2047
+ # args default to the system args
2048
+ if args is None:
2049
+ args = _sys.argv[1:]
2050
+
2051
+ # default Namespace built from parser defaults
2052
+ if namespace is None:
2053
+ namespace = Namespace()
2054
+
2055
+ # add any action defaults that aren't present
2056
+ for action in self._actions:
2057
+ if action.dest is not SUPPRESS:
2058
+ if not hasattr(namespace, action.dest):
2059
+ if action.default is not SUPPRESS:
2060
+ setattr(namespace, action.dest, action.default)
2061
+
2062
+ # add any parser defaults that aren't present
2063
+ for dest in self._defaults:
2064
+ if not hasattr(namespace, dest):
2065
+ setattr(namespace, dest, self._defaults[dest])
2066
+
2067
+ # parse the arguments and exit if there are any errors
2068
+ try:
2069
+ namespace, args = self._parse_known_args(args, namespace)
2070
+ if hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR):
2071
+ args.extend(getattr(namespace, _UNRECOGNIZED_ARGS_ATTR))
2072
+ delattr(namespace, _UNRECOGNIZED_ARGS_ATTR)
2073
+ return namespace, args
2074
+ except ArgumentError:
2075
+ err = _sys.exc_info()[1]
2076
+ self.error(str(err))
2077
+
2078
+ def _parse_known_args(self, arg_strings, namespace):
2079
+ # replace arg strings that are file references
2080
+ if self.fromfile_prefix_chars is not None:
2081
+ arg_strings = self._read_args_from_files(arg_strings)
2082
+
2083
+ # map all mutually exclusive arguments to the other arguments
2084
+ # they can't occur with
2085
+ action_conflicts = {}
2086
+ for mutex_group in self._mutually_exclusive_groups:
2087
+ group_actions = mutex_group._group_actions
2088
+ for i, mutex_action in enumerate(mutex_group._group_actions):
2089
+ conflicts = action_conflicts.setdefault(mutex_action, [])
2090
+ conflicts.extend(group_actions[:i])
2091
+ conflicts.extend(group_actions[i + 1:])
2092
+
2093
+ # find all option indices, and determine the arg_string_pattern
2094
+ # which has an 'O' if there is an option at an index,
2095
+ # an 'A' if there is an argument, or a '-' if there is a '--'
2096
+ option_string_indices = {}
2097
+ arg_string_pattern_parts = []
2098
+ arg_strings_iter = iter(arg_strings)
2099
+ for i, arg_string in enumerate(arg_strings_iter):
2100
+
2101
+ # all args after -- are non-options
2102
+ if arg_string == '--':
2103
+ arg_string_pattern_parts.append('-')
2104
+ for arg_string in arg_strings_iter:
2105
+ arg_string_pattern_parts.append('A')
2106
+
2107
+ # otherwise, add the arg to the arg strings
2108
+ # and note the index if it was an option
2109
+ else:
2110
+ option_tuple = self._parse_optional(arg_string)
2111
+ if option_tuple is None:
2112
+ pattern = 'A'
2113
+ else:
2114
+ option_string_indices[i] = option_tuple
2115
+ pattern = 'O'
2116
+ arg_string_pattern_parts.append(pattern)
2117
+
2118
+ # join the pieces together to form the pattern
2119
+ arg_strings_pattern = ''.join(arg_string_pattern_parts)
2120
+
2121
+ # converts arg strings to the appropriate and then takes the action
2122
+ seen_actions = set()
2123
+ seen_non_default_actions = set()
2124
+
2125
+ def take_action(action, argument_strings, option_string=None):
2126
+ seen_actions.add(action)
2127
+ argument_values = self._get_values(action, argument_strings)
2128
+
2129
+ # error if this argument is not allowed with other previously
2130
+ # seen arguments, assuming that actions that use the default
2131
+ # value don't really count as "present"
2132
+ if argument_values is not action.default:
2133
+ seen_non_default_actions.add(action)
2134
+ for conflict_action in action_conflicts.get(action, []):
2135
+ if conflict_action in seen_non_default_actions:
2136
+ msg = _('not allowed with argument %s')
2137
+ action_name = _get_action_name(conflict_action)
2138
+ raise ArgumentError(action, msg % action_name)
2139
+
2140
+ # take the action if we didn't receive a SUPPRESS value
2141
+ # (e.g. from a default)
2142
+ if argument_values is not SUPPRESS:
2143
+ action(self, namespace, argument_values, option_string)
2144
+
2145
+ # function to convert arg_strings into an optional action
2146
+ def consume_optional(start_index):
2147
+
2148
+ # get the optional identified at this index
2149
+ option_tuple = option_string_indices[start_index]
2150
+ action, option_string, explicit_arg = option_tuple
2151
+
2152
+ # identify additional optionals in the same arg string
2153
+ # (e.g. -xyz is the same as -x -y -z if no args are required)
2154
+ match_argument = self._match_argument
2155
+ action_tuples = []
2156
+ while True:
2157
+
2158
+ # if we found no optional action, skip it
2159
+ if action is None:
2160
+ extras.append(arg_strings[start_index])
2161
+ return start_index + 1
2162
+
2163
+ # if there is an explicit argument, try to match the
2164
+ # optional's string arguments to only this
2165
+ if explicit_arg is not None:
2166
+ arg_count = match_argument(action, 'A')
2167
+
2168
+ # if the action is a single-dash option and takes no
2169
+ # arguments, try to parse more single-dash options out
2170
+ # of the tail of the option string
2171
+ chars = self.prefix_chars
2172
+ if arg_count == 0 and option_string[1] not in chars:
2173
+ action_tuples.append((action, [], option_string))
2174
+ char = option_string[0]
2175
+ option_string = char + explicit_arg[0]
2176
+ new_explicit_arg = explicit_arg[1:] or None
2177
+ optionals_map = self._option_string_actions
2178
+ if option_string in optionals_map:
2179
+ action = optionals_map[option_string]
2180
+ explicit_arg = new_explicit_arg
2181
+ else:
2182
+ msg = _('ignored explicit argument %r')
2183
+ raise ArgumentError(action, msg % explicit_arg)
2184
+
2185
+ # if the action expect exactly one argument, we've
2186
+ # successfully matched the option; exit the loop
2187
+ elif arg_count == 1:
2188
+ stop = start_index + 1
2189
+ args = [explicit_arg]
2190
+ action_tuples.append((action, args, option_string))
2191
+ break
2192
+
2193
+ # error if a double-dash option did not use the
2194
+ # explicit argument
2195
+ else:
2196
+ msg = _('ignored explicit argument %r')
2197
+ raise ArgumentError(action, msg % explicit_arg)
2198
+
2199
+ # if there is no explicit argument, try to match the
2200
+ # optional's string arguments with the following strings
2201
+ # if successful, exit the loop
2202
+ else:
2203
+ start = start_index + 1
2204
+ selected_patterns = arg_strings_pattern[start:]
2205
+ arg_count = match_argument(action, selected_patterns)
2206
+ stop = start + arg_count
2207
+ args = arg_strings[start:stop]
2208
+ action_tuples.append((action, args, option_string))
2209
+ break
2210
+
2211
+ # add the Optional to the list and return the index at which
2212
+ # the Optional's string args stopped
2213
+ assert action_tuples
2214
+ for action, args, option_string in action_tuples:
2215
+ take_action(action, args, option_string)
2216
+ return stop
2217
+
2218
+ # the list of Positionals left to be parsed; this is modified
2219
+ # by consume_positionals()
2220
+ positionals = self._get_positional_actions()
2221
+
2222
+ # function to convert arg_strings into positional actions
2223
+ def consume_positionals(start_index):
2224
+ # match as many Positionals as possible
2225
+ match_partial = self._match_arguments_partial
2226
+ selected_pattern = arg_strings_pattern[start_index:]
2227
+ arg_counts = match_partial(positionals, selected_pattern)
2228
+
2229
+ # slice off the appropriate arg strings for each Positional
2230
+ # and add the Positional and its args to the list
2231
+ for action, arg_count in zip(positionals, arg_counts):
2232
+ args = arg_strings[start_index: start_index + arg_count]
2233
+ start_index += arg_count
2234
+ take_action(action, args)
2235
+
2236
+ # slice off the Positionals that we just parsed and return the
2237
+ # index at which the Positionals' string args stopped
2238
+ positionals[:] = positionals[len(arg_counts):]
2239
+ return start_index
2240
+
2241
+ # consume Positionals and Optionals alternately, until we have
2242
+ # passed the last option string
2243
+ extras = []
2244
+ start_index = 0
2245
+ if option_string_indices:
2246
+ max_option_string_index = max(option_string_indices)
2247
+ else:
2248
+ max_option_string_index = -1
2249
+ while start_index <= max_option_string_index:
2250
+
2251
+ # consume any Positionals preceding the next option
2252
+ next_option_string_index = min([
2253
+ index
2254
+ for index in option_string_indices
2255
+ if index >= start_index])
2256
+ if start_index != next_option_string_index:
2257
+ positionals_end_index = consume_positionals(start_index)
2258
+
2259
+ # only try to parse the next optional if we didn't consume
2260
+ # the option string during the positionals parsing
2261
+ if positionals_end_index > start_index:
2262
+ start_index = positionals_end_index
2263
+ continue
2264
+ else:
2265
+ start_index = positionals_end_index
2266
+
2267
+ # if we consumed all the positionals we could and we're not
2268
+ # at the index of an option string, there were extra arguments
2269
+ if start_index not in option_string_indices:
2270
+ strings = arg_strings[start_index:next_option_string_index]
2271
+ extras.extend(strings)
2272
+ start_index = next_option_string_index
2273
+
2274
+ # consume the next optional and any arguments for it
2275
+ start_index = consume_optional(start_index)
2276
+
2277
+ # consume any positionals following the last Optional
2278
+ stop_index = consume_positionals(start_index)
2279
+
2280
+ # if we didn't consume all the argument strings, there were extras
2281
+ extras.extend(arg_strings[stop_index:])
2282
+
2283
+ # if we didn't use all the Positional objects, there were too few
2284
+ # arg strings supplied.
2285
+ if positionals:
2286
+ self.error(_('too few arguments'))
2287
+
2288
+ # make sure all required actions were present, and convert defaults.
2289
+ for action in self._actions:
2290
+ if action not in seen_actions:
2291
+ if action.required:
2292
+ name = _get_action_name(action)
2293
+ self.error(_('argument %s is required') % name)
2294
+ else:
2295
+ # Convert action default now instead of doing it before
2296
+ # parsing arguments to avoid calling convert functions
2297
+ # twice (which may fail) if the argument was given, but
2298
+ # only if it was defined already in the namespace
2299
+ if (action.default is not None and
2300
+ isinstance(action.default, basestring) and
2301
+ hasattr(namespace, action.dest) and
2302
+ action.default is getattr(namespace, action.dest)):
2303
+ setattr(namespace, action.dest,
2304
+ self._get_value(action, action.default))
2305
+
2306
+ # make sure all required groups had one option present
2307
+ for group in self._mutually_exclusive_groups:
2308
+ if group.required:
2309
+ for action in group._group_actions:
2310
+ if action in seen_non_default_actions:
2311
+ break
2312
+
2313
+ # if no actions were used, report the error
2314
+ else:
2315
+ names = [_get_action_name(action)
2316
+ for action in group._group_actions
2317
+ if action.help is not SUPPRESS]
2318
+ msg = _('one of the arguments %s is required')
2319
+ self.error(msg % ' '.join(names))
2320
+
2321
+ # return the updated namespace and the extra arguments
2322
+ return namespace, extras
2323
+
2324
+ def _read_args_from_files(self, arg_strings):
2325
+ # expand arguments referencing files
2326
+ new_arg_strings = []
2327
+ for arg_string in arg_strings:
2328
+
2329
+ # for regular arguments, just add them back into the list
2330
+ if arg_string[0] not in self.fromfile_prefix_chars:
2331
+ new_arg_strings.append(arg_string)
2332
+
2333
+ # replace arguments referencing files with the file content
2334
+ else:
2335
+ try:
2336
+ args_file = open(arg_string[1:])
2337
+ try:
2338
+ arg_strings = []
2339
+ for arg_line in args_file.read().splitlines():
2340
+ for arg in self.convert_arg_line_to_args(arg_line):
2341
+ arg_strings.append(arg)
2342
+ arg_strings = self._read_args_from_files(arg_strings)
2343
+ new_arg_strings.extend(arg_strings)
2344
+ finally:
2345
+ args_file.close()
2346
+ except IOError:
2347
+ err = _sys.exc_info()[1]
2348
+ self.error(str(err))
2349
+
2350
+ # return the modified argument list
2351
+ return new_arg_strings
2352
+
2353
+ def convert_arg_line_to_args(self, arg_line):
2354
+ return [arg_line]
2355
+
2356
+ def _match_argument(self, action, arg_strings_pattern):
2357
+ # match the pattern for this action to the arg strings
2358
+ nargs_pattern = self._get_nargs_pattern(action)
2359
+ match = _re.match(nargs_pattern, arg_strings_pattern)
2360
+
2361
+ # raise an exception if we weren't able to find a match
2362
+ if match is None:
2363
+ nargs_errors = {
2364
+ None: _('expected one argument'),
2365
+ OPTIONAL: _('expected at most one argument'),
2366
+ ONE_OR_MORE: _('expected at least one argument'),
2367
+ }
2368
+ default = _('expected %s argument(s)') % action.nargs
2369
+ msg = nargs_errors.get(action.nargs, default)
2370
+ raise ArgumentError(action, msg)
2371
+
2372
+ # return the number of arguments matched
2373
+ return len(match.group(1))
2374
+
2375
+ def _match_arguments_partial(self, actions, arg_strings_pattern):
2376
+ # progressively shorten the actions list by slicing off the
2377
+ # final actions until we find a match
2378
+ result = []
2379
+ for i in range(len(actions), 0, -1):
2380
+ actions_slice = actions[:i]
2381
+ pattern = ''.join([self._get_nargs_pattern(action)
2382
+ for action in actions_slice])
2383
+ match = _re.match(pattern, arg_strings_pattern)
2384
+ if match is not None:
2385
+ result.extend([len(string) for string in match.groups()])
2386
+ break
2387
+
2388
+ # return the list of arg string counts
2389
+ return result
2390
+
2391
+ def _parse_optional(self, arg_string):
2392
+ # if it's an empty string, it was meant to be a positional
2393
+ if not arg_string:
2394
+ return None
2395
+
2396
+ # if it doesn't start with a prefix, it was meant to be positional
2397
+ if not arg_string[0] in self.prefix_chars:
2398
+ return None
2399
+
2400
+ # if the option string is present in the parser, return the action
2401
+ if arg_string in self._option_string_actions:
2402
+ action = self._option_string_actions[arg_string]
2403
+ return action, arg_string, None
2404
+
2405
+ # if it's just a single character, it was meant to be positional
2406
+ if len(arg_string) == 1:
2407
+ return None
2408
+
2409
+ # if the option string before the "=" is present, return the action
2410
+ if '=' in arg_string:
2411
+ option_string, explicit_arg = arg_string.split('=', 1)
2412
+ if option_string in self._option_string_actions:
2413
+ action = self._option_string_actions[option_string]
2414
+ return action, option_string, explicit_arg
2415
+
2416
+ # search through all possible prefixes of the option string
2417
+ # and all actions in the parser for possible interpretations
2418
+ option_tuples = self._get_option_tuples(arg_string)
2419
+
2420
+ # if multiple actions match, the option string was ambiguous
2421
+ if len(option_tuples) > 1:
2422
+ options = ', '.join([option_string
2423
+ for action, option_string, explicit_arg in option_tuples])
2424
+ tup = arg_string, options
2425
+ self.error(_('ambiguous option: %s could match %s') % tup)
2426
+
2427
+ # if exactly one action matched, this segmentation is good,
2428
+ # so return the parsed action
2429
+ elif len(option_tuples) == 1:
2430
+ option_tuple, = option_tuples
2431
+ return option_tuple
2432
+
2433
+ # if it was not found as an option, but it looks like a negative
2434
+ # number, it was meant to be positional
2435
+ # unless there are negative-number-like options
2436
+ if self._negative_number_matcher.match(arg_string):
2437
+ if not self._has_negative_number_optionals:
2438
+ return None
2439
+
2440
+ # if it contains a space, it was meant to be a positional
2441
+ if ' ' in arg_string:
2442
+ return None
2443
+
2444
+ # it was meant to be an optional but there is no such option
2445
+ # in this parser (though it might be a valid option in a subparser)
2446
+ return None, arg_string, None
2447
+
2448
+ def _get_option_tuples(self, option_string):
2449
+ result = []
2450
+
2451
+ # option strings starting with two prefix characters are only
2452
+ # split at the '='
2453
+ chars = self.prefix_chars
2454
+ if option_string[0] in chars and option_string[1] in chars:
2455
+ if '=' in option_string:
2456
+ option_prefix, explicit_arg = option_string.split('=', 1)
2457
+ else:
2458
+ option_prefix = option_string
2459
+ explicit_arg = None
2460
+ for option_string in self._option_string_actions:
2461
+ if option_string.startswith(option_prefix):
2462
+ action = self._option_string_actions[option_string]
2463
+ tup = action, option_string, explicit_arg
2464
+ result.append(tup)
2465
+
2466
+ # single character options can be concatenated with their arguments
2467
+ # but multiple character options always have to have their argument
2468
+ # separate
2469
+ elif option_string[0] in chars and option_string[1] not in chars:
2470
+ option_prefix = option_string
2471
+ explicit_arg = None
2472
+ short_option_prefix = option_string[:2]
2473
+ short_explicit_arg = option_string[2:]
2474
+
2475
+ for option_string in self._option_string_actions:
2476
+ if option_string == short_option_prefix:
2477
+ action = self._option_string_actions[option_string]
2478
+ tup = action, option_string, short_explicit_arg
2479
+ result.append(tup)
2480
+ elif option_string.startswith(option_prefix):
2481
+ action = self._option_string_actions[option_string]
2482
+ tup = action, option_string, explicit_arg
2483
+ result.append(tup)
2484
+
2485
+ # shouldn't ever get here
2486
+ else:
2487
+ self.error(_('unexpected option string: %s') % option_string)
2488
+
2489
+ # return the collected option tuples
2490
+ return result
2491
+
2492
+ def _get_nargs_pattern(self, action):
2493
+ # in all examples below, we have to allow for '--' args
2494
+ # which are represented as '-' in the pattern
2495
+ nargs = action.nargs
2496
+
2497
+ # the default (None) is assumed to be a single argument
2498
+ if nargs is None:
2499
+ nargs_pattern = '(-*A-*)'
2500
+
2501
+ # allow zero or one arguments
2502
+ elif nargs == OPTIONAL:
2503
+ nargs_pattern = '(-*A?-*)'
2504
+
2505
+ # allow zero or more arguments
2506
+ elif nargs == ZERO_OR_MORE:
2507
+ nargs_pattern = '(-*[A-]*)'
2508
+
2509
+ # allow one or more arguments
2510
+ elif nargs == ONE_OR_MORE:
2511
+ nargs_pattern = '(-*A[A-]*)'
2512
+
2513
+ # allow any number of options or arguments
2514
+ elif nargs == REMAINDER:
2515
+ nargs_pattern = '([-AO]*)'
2516
+
2517
+ # allow one argument followed by any number of options or arguments
2518
+ elif nargs == PARSER:
2519
+ nargs_pattern = '(-*A[-AO]*)'
2520
+
2521
+ # all others should be integers
2522
+ else:
2523
+ nargs_pattern = '(-*%s-*)' % '-*'.join('A' * nargs)
2524
+
2525
+ # if this is an optional action, -- is not allowed
2526
+ if action.option_strings:
2527
+ nargs_pattern = nargs_pattern.replace('-*', '')
2528
+ nargs_pattern = nargs_pattern.replace('-', '')
2529
+
2530
+ # return the pattern
2531
+ return nargs_pattern
2532
+
2533
+ # ========================
2534
+ # Value conversion methods
2535
+ # ========================
2536
+ def _get_values(self, action, arg_strings):
2537
+ # for everything but PARSER args, strip out '--'
2538
+ if action.nargs not in [PARSER, REMAINDER]:
2539
+ arg_strings = [s for s in arg_strings if s != '--']
2540
+
2541
+ # optional argument produces a default when not present
2542
+ if not arg_strings and action.nargs == OPTIONAL:
2543
+ if action.option_strings:
2544
+ value = action.const
2545
+ else:
2546
+ value = action.default
2547
+ if isinstance(value, basestring):
2548
+ value = self._get_value(action, value)
2549
+ self._check_value(action, value)
2550
+
2551
+ # when nargs='*' on a positional, if there were no command-line
2552
+ # args, use the default if it is anything other than None
2553
+ elif (not arg_strings and action.nargs == ZERO_OR_MORE and
2554
+ not action.option_strings):
2555
+ if action.default is not None:
2556
+ value = action.default
2557
+ else:
2558
+ value = arg_strings
2559
+ self._check_value(action, value)
2560
+
2561
+ # single argument or optional argument produces a single value
2562
+ elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]:
2563
+ arg_string, = arg_strings
2564
+ value = self._get_value(action, arg_string)
2565
+ self._check_value(action, value)
2566
+
2567
+ # REMAINDER arguments convert all values, checking none
2568
+ elif action.nargs == REMAINDER:
2569
+ value = [self._get_value(action, v) for v in arg_strings]
2570
+
2571
+ # PARSER arguments convert all values, but check only the first
2572
+ elif action.nargs == PARSER:
2573
+ value = [self._get_value(action, v) for v in arg_strings]
2574
+ self._check_value(action, value[0])
2575
+
2576
+ # all other types of nargs produce a list
2577
+ else:
2578
+ value = [self._get_value(action, v) for v in arg_strings]
2579
+ for v in value:
2580
+ self._check_value(action, v)
2581
+
2582
+ # return the converted value
2583
+ return value
2584
+
2585
+ def _get_value(self, action, arg_string):
2586
+ type_func = self._registry_get('type', action.type, action.type)
2587
+ if not _callable(type_func):
2588
+ msg = _('%r is not callable')
2589
+ raise ArgumentError(action, msg % type_func)
2590
+
2591
+ # convert the value to the appropriate type
2592
+ try:
2593
+ result = type_func(arg_string)
2594
+
2595
+ # ArgumentTypeErrors indicate errors
2596
+ except ArgumentTypeError:
2597
+ name = getattr(action.type, '__name__', repr(action.type))
2598
+ msg = str(_sys.exc_info()[1])
2599
+ raise ArgumentError(action, msg)
2600
+
2601
+ # TypeErrors or ValueErrors also indicate errors
2602
+ except (TypeError, ValueError):
2603
+ name = getattr(action.type, '__name__', repr(action.type))
2604
+ msg = _('invalid %s value: %r')
2605
+ raise ArgumentError(action, msg % (name, arg_string))
2606
+
2607
+ # return the converted value
2608
+ return result
2609
+
2610
+ def _check_value(self, action, value):
2611
+ # converted value must be one of the choices (if specified)
2612
+ if action.choices is not None and value not in action.choices:
2613
+ tup = value, ', '.join(map(repr, action.choices))
2614
+ msg = _('invalid choice: %r (choose from %s)') % tup
2615
+ raise ArgumentError(action, msg)
2616
+
2617
+ # =======================
2618
+ # Help-formatting methods
2619
+ # =======================
2620
+ def format_usage(self):
2621
+ formatter = self._get_formatter()
2622
+ formatter.add_usage(self.usage, self._actions,
2623
+ self._mutually_exclusive_groups)
2624
+ return formatter.format_help()
2625
+
2626
+ def format_help(self):
2627
+ formatter = self._get_formatter()
2628
+
2629
+ # usage
2630
+ formatter.add_usage(self.usage, self._actions,
2631
+ self._mutually_exclusive_groups)
2632
+
2633
+ # description
2634
+ formatter.add_text(self.description)
2635
+
2636
+ # positionals, optionals and user-defined groups
2637
+ for action_group in self._action_groups:
2638
+ formatter.start_section(action_group.title)
2639
+ formatter.add_text(action_group.description)
2640
+ formatter.add_arguments(action_group._group_actions)
2641
+ formatter.end_section()
2642
+
2643
+ # epilog
2644
+ formatter.add_text(self.epilog)
2645
+
2646
+ # determine help from format above
2647
+ return formatter.format_help()
2648
+
2649
+ def format_version(self):
2650
+ import warnings
2651
+ warnings.warn(
2652
+ 'The format_version method is deprecated -- the "version" '
2653
+ 'argument to ArgumentParser is no longer supported.',
2654
+ DeprecationWarning)
2655
+ formatter = self._get_formatter()
2656
+ formatter.add_text(self.version)
2657
+ return formatter.format_help()
2658
+
2659
+ def _get_formatter(self):
2660
+ return self.formatter_class(prog=self.prog)
2661
+
2662
+ # =====================
2663
+ # Help-printing methods
2664
+ # =====================
2665
+ def print_usage(self, file=None):
2666
+ if file is None:
2667
+ file = _sys.stdout
2668
+ self._print_message(self.format_usage(), file)
2669
+
2670
+ def print_help(self, file=None):
2671
+ if file is None:
2672
+ file = _sys.stdout
2673
+ self._print_message(self.format_help(), file)
2674
+
2675
+ def print_version(self, file=None):
2676
+ import warnings
2677
+ warnings.warn(
2678
+ 'The print_version method is deprecated -- the "version" '
2679
+ 'argument to ArgumentParser is no longer supported.',
2680
+ DeprecationWarning)
2681
+ self._print_message(self.format_version(), file)
2682
+
2683
+ def _print_message(self, message, file=None):
2684
+ if message:
2685
+ if file is None:
2686
+ file = _sys.stderr
2687
+ file.write(message)
2688
+
2689
+ # ===============
2690
+ # Exiting methods
2691
+ # ===============
2692
+ def exit(self, status=0, message=None):
2693
+ if message:
2694
+ self._print_message(message, _sys.stderr)
2695
+ _sys.exit(status)
2696
+
2697
+ def error(self, message):
2698
+ """error(message: string)
2699
+
2700
+ Prints a usage message incorporating the message to stderr and
2701
+ exits.
2702
+
2703
+ If you override this in a subclass, it should not return -- it
2704
+ should either exit or raise an exception.
2705
+ """
2706
+ self.print_usage(_sys.stderr)
2707
+ self.exit(2, _('%s: error: %s\n') % (self.prog, message))
2708
--
187
--
2709
2.13.5
188
2.29.2
2710
189
2711
190
diff view generated by jsdifflib
1
From: Fred Rolland <rollandf@gmail.com>
1
From: David Edmondson <david.edmondson@oracle.com>
2
2
3
Update doc with the usage of UUID for initiator name.
3
When a call to fcntl(2) for the purpose of adding file locks fails
4
with an error other than EAGAIN or EACCES, report the error returned
5
by fcntl.
4
6
5
Related-To: https://bugzilla.redhat.com/1006468
7
EAGAIN or EACCES are elided as they are considered to be common
6
Signed-off-by: Fred Rolland <frolland@redhat.com>
8
failures, indicating that a conflicting lock is held by another
7
Message-id: 20170823084830.30500-1-frolland@redhat.com
9
process.
8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
11
No errors are elided when removing file locks.
12
13
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
14
Message-Id: <20210113164447.2545785-1-david.edmondson@oracle.com>
15
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
16
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
17
---
10
qemu-doc.texi | 5 +++--
18
block/file-posix.c | 38 ++++++++++++++++++++++++++++----------
11
1 file changed, 3 insertions(+), 2 deletions(-)
19
1 file changed, 28 insertions(+), 10 deletions(-)
12
20
13
diff --git a/qemu-doc.texi b/qemu-doc.texi
21
diff --git a/block/file-posix.c b/block/file-posix.c
14
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
15
--- a/qemu-doc.texi
23
--- a/block/file-posix.c
16
+++ b/qemu-doc.texi
24
+++ b/block/file-posix.c
17
@@ -XXX,XX +XXX,XX @@ in a configuration file provided via '-readconfig' or directly on the
25
@@ -XXX,XX +XXX,XX @@ typedef struct RawPosixAIOData {
18
command line.
26
static int cdrom_reopen(BlockDriverState *bs);
19
27
#endif
20
If the initiator-name is not specified qemu will use a default name
28
21
-of 'iqn.2008-11.org.linux-kvm[:<name>'] where <name> is the name of the
29
+/*
22
+of 'iqn.2008-11.org.linux-kvm[:<uuid>'] where <uuid> is the UUID of the
30
+ * Elide EAGAIN and EACCES details when failing to lock, as this
23
+virtual machine. If the UUID is not specified qemu will use
31
+ * indicates that the specified file region is already locked by
24
+'iqn.2008-11.org.linux-kvm[:<name>'] where <name> is the name of the
32
+ * another process, which is considered a common scenario.
25
virtual machine.
33
+ */
26
34
+#define raw_lock_error_setg_errno(errp, err, fmt, ...) \
27
-
35
+ do { \
28
@example
36
+ if ((err) == EAGAIN || (err) == EACCES) { \
29
Setting a specific initiator name to use when logging in to the target
37
+ error_setg((errp), (fmt), ## __VA_ARGS__); \
30
-iscsi initiator-name=iqn.qemu.test:my-initiator
38
+ } else { \
39
+ error_setg_errno((errp), (err), (fmt), ## __VA_ARGS__); \
40
+ } \
41
+ } while (0)
42
+
43
#if defined(__NetBSD__)
44
static int raw_normalize_devicepath(const char **filename, Error **errp)
45
{
46
@@ -XXX,XX +XXX,XX @@ static int raw_apply_lock_bytes(BDRVRawState *s, int fd,
47
if ((perm_lock_bits & bit) && !(locked_perm & bit)) {
48
ret = qemu_lock_fd(fd, off, 1, false);
49
if (ret) {
50
- error_setg(errp, "Failed to lock byte %d", off);
51
+ raw_lock_error_setg_errno(errp, -ret, "Failed to lock byte %d",
52
+ off);
53
return ret;
54
} else if (s) {
55
s->locked_perm |= bit;
56
@@ -XXX,XX +XXX,XX @@ static int raw_apply_lock_bytes(BDRVRawState *s, int fd,
57
} else if (unlock && (locked_perm & bit) && !(perm_lock_bits & bit)) {
58
ret = qemu_unlock_fd(fd, off, 1);
59
if (ret) {
60
- error_setg(errp, "Failed to unlock byte %d", off);
61
+ error_setg_errno(errp, -ret, "Failed to unlock byte %d", off);
62
return ret;
63
} else if (s) {
64
s->locked_perm &= ~bit;
65
@@ -XXX,XX +XXX,XX @@ static int raw_apply_lock_bytes(BDRVRawState *s, int fd,
66
if ((shared_perm_lock_bits & bit) && !(locked_shared_perm & bit)) {
67
ret = qemu_lock_fd(fd, off, 1, false);
68
if (ret) {
69
- error_setg(errp, "Failed to lock byte %d", off);
70
+ raw_lock_error_setg_errno(errp, -ret, "Failed to lock byte %d",
71
+ off);
72
return ret;
73
} else if (s) {
74
s->locked_shared_perm |= bit;
75
@@ -XXX,XX +XXX,XX @@ static int raw_apply_lock_bytes(BDRVRawState *s, int fd,
76
!(shared_perm_lock_bits & bit)) {
77
ret = qemu_unlock_fd(fd, off, 1);
78
if (ret) {
79
- error_setg(errp, "Failed to unlock byte %d", off);
80
+ error_setg_errno(errp, -ret, "Failed to unlock byte %d", off);
81
return ret;
82
} else if (s) {
83
s->locked_shared_perm &= ~bit;
84
@@ -XXX,XX +XXX,XX @@ static int raw_check_lock_bytes(int fd, uint64_t perm, uint64_t shared_perm,
85
ret = qemu_lock_fd_test(fd, off, 1, true);
86
if (ret) {
87
char *perm_name = bdrv_perm_names(p);
88
- error_setg(errp,
89
- "Failed to get \"%s\" lock",
90
- perm_name);
91
+
92
+ raw_lock_error_setg_errno(errp, -ret,
93
+ "Failed to get \"%s\" lock",
94
+ perm_name);
95
g_free(perm_name);
96
return ret;
97
}
98
@@ -XXX,XX +XXX,XX @@ static int raw_check_lock_bytes(int fd, uint64_t perm, uint64_t shared_perm,
99
ret = qemu_lock_fd_test(fd, off, 1, true);
100
if (ret) {
101
char *perm_name = bdrv_perm_names(p);
102
- error_setg(errp,
103
- "Failed to get shared \"%s\" lock",
104
- perm_name);
105
+
106
+ raw_lock_error_setg_errno(errp, -ret,
107
+ "Failed to get shared \"%s\" lock",
108
+ perm_name);
109
g_free(perm_name);
110
return ret;
111
}
31
--
112
--
32
2.13.5
113
2.29.2
33
114
34
115
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Alberto Garcia <berto@igalia.com>
2
2
3
The way the throttling algorithm works is that requests start being
3
Signed-off-by: Alberto Garcia <berto@igalia.com>
4
throttled once the bucket level exceeds the burst limit. When we get
4
Suggested-by: Maxim Levitsky <mlevitsk@redhat.com>
5
there the bucket leaks at the level set by the user (bkt->avg), and
5
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
6
that leak rate is what prevents guest I/O from exceeding the desired
6
Message-Id: <20210112170540.2912-1-berto@igalia.com>
7
limit.
7
[mreitz: Add "# group:" line]
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
tests/qemu-iotests/313 | 104 +++++++++++++++++++++++++++++++++++++
11
tests/qemu-iotests/313.out | 29 +++++++++++
12
tests/qemu-iotests/group | 1 +
13
3 files changed, 134 insertions(+)
14
create mode 100755 tests/qemu-iotests/313
15
create mode 100644 tests/qemu-iotests/313.out
8
16
9
If we don't allow bursts (i.e. bkt->max == 0) then we can start
17
diff --git a/tests/qemu-iotests/313 b/tests/qemu-iotests/313
10
throttling requests immediately. The problem with keeping the
18
new file mode 100755
11
threshold at 0 is that it only allows one request at a time, and as
19
index XXXXXXX..XXXXXXX
12
soon as there's a bit of I/O from the guest every other request will
20
--- /dev/null
13
be throttled and performance will suffer considerably. That can even
21
+++ b/tests/qemu-iotests/313
14
make the guest unable to reach the throttle limit if that limit is
22
@@ -XXX,XX +XXX,XX @@
15
high enough, and that happens regardless of the block scheduler used
23
+#!/usr/bin/env bash
16
by the guest.
24
+# group: rw auto quick
17
25
+#
18
Increasing that threshold gives flexibility to the guest, allowing it
26
+# Test for the regression fixed in commit c8bf9a9169
19
to perform short bursts of I/O before being throttled. Increasing the
27
+#
20
threshold too much does not make a difference in the long run (because
28
+# Copyright (C) 2020 Igalia, S.L.
21
it's the leak rate what defines the actual throughput) but it does
29
+# Author: Alberto Garcia <berto@igalia.com>
22
allow the guest to perform longer initial bursts and exceed the
30
+# Based on a test case by Maxim Levitsky <mlevitsk@redhat.com>
23
throttle limit for a short while.
31
+#
24
32
+# This program is free software; you can redistribute it and/or modify
25
A burst value of bkt->avg / 10 allows the guest to perform 100ms'
33
+# it under the terms of the GNU General Public License as published by
26
worth of I/O at the target rate without being throttled.
34
+# the Free Software Foundation; either version 2 of the License, or
27
35
+# (at your option) any later version.
28
Signed-off-by: Alberto Garcia <berto@igalia.com>
36
+#
29
Message-id: 31aae6645f0d1fbf3860fb2b528b757236f0c0a7.1503580370.git.berto@igalia.com
37
+# This program is distributed in the hope that it will be useful,
30
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
38
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
31
---
39
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32
util/throttle.c | 11 +++--------
40
+# GNU General Public License for more details.
33
1 file changed, 3 insertions(+), 8 deletions(-)
41
+#
34
42
+# You should have received a copy of the GNU General Public License
35
diff --git a/util/throttle.c b/util/throttle.c
43
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
44
+#
45
+
46
+# creator
47
+owner=berto@igalia.com
48
+
49
+seq=`basename $0`
50
+echo "QA output created by $seq"
51
+
52
+status=1 # failure is the default!
53
+
54
+_cleanup()
55
+{
56
+ _cleanup_test_img
57
+}
58
+trap "_cleanup; exit \$status" 0 1 2 3 15
59
+
60
+# get standard environment, filters and checks
61
+. ./common.rc
62
+. ./common.filter
63
+
64
+_supported_fmt qcow2
65
+_supported_proto file
66
+_supported_os Linux
67
+_unsupported_imgopts cluster_size refcount_bits extended_l2 compat=0.10 data_file
68
+
69
+# The cluster size must be at least the granularity of the mirror job (4KB)
70
+# Note that larger cluster sizes will produce very large images (several GBs)
71
+cluster_size=4096
72
+refcount_bits=64 # Make it equal to the L2 entry size for convenience
73
+options="cluster_size=${cluster_size},refcount_bits=${refcount_bits}"
74
+
75
+# Number of refcount entries per refcount blocks
76
+ref_entries=$(( ${cluster_size} * 8 / ${refcount_bits} ))
77
+
78
+# Number of data clusters needed to fill a refcount block
79
+# Equals ${ref_entries} minus two (one L2 table and one refcount block)
80
+data_clusters_per_refblock=$(( ${ref_entries} - 2 ))
81
+
82
+# Number of entries in the refcount cache
83
+ref_blocks=4
84
+
85
+# Write enough data clusters to fill the refcount cache and allocate
86
+# one more refcount block.
87
+# Subtract 3 clusters from the total: qcow2 header, refcount table, L1 table
88
+total_data_clusters=$(( ${data_clusters_per_refblock} * ${ref_blocks} + 1 - 3 ))
89
+
90
+# Total size to write in bytes
91
+total_size=$(( ${total_data_clusters} * ${cluster_size} ))
92
+
93
+echo
94
+echo '### Create the image'
95
+echo
96
+TEST_IMG_FILE=$TEST_IMG.base _make_test_img -o $options $total_size | _filter_img_create_size
97
+
98
+echo
99
+echo '### Write data to allocate more refcount blocks than the cache can hold'
100
+echo
101
+$QEMU_IO -c "write -P 1 0 $total_size" $TEST_IMG.base | _filter_qemu_io
102
+
103
+echo
104
+echo '### Create an overlay'
105
+echo
106
+_make_test_img -F $IMGFMT -b $TEST_IMG.base -o $options | _filter_img_create_size
107
+
108
+echo
109
+echo '### Fill the overlay with zeroes'
110
+echo
111
+$QEMU_IO -c "write -z 0 $total_size" $TEST_IMG | _filter_qemu_io
112
+
113
+echo
114
+echo '### Commit changes to the base image'
115
+echo
116
+$QEMU_IMG commit $TEST_IMG
117
+
118
+echo
119
+echo '### Check the base image'
120
+echo
121
+$QEMU_IMG check $TEST_IMG.base
122
+
123
+# success, all done
124
+echo "*** done"
125
+rm -f $seq.full
126
+status=0
127
diff --git a/tests/qemu-iotests/313.out b/tests/qemu-iotests/313.out
128
new file mode 100644
129
index XXXXXXX..XXXXXXX
130
--- /dev/null
131
+++ b/tests/qemu-iotests/313.out
132
@@ -XXX,XX +XXX,XX @@
133
+QA output created by 313
134
+
135
+### Create the image
136
+
137
+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=SIZE
138
+
139
+### Write data to allocate more refcount blocks than the cache can hold
140
+
141
+wrote 8347648/8347648 bytes at offset 0
142
+7.961 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
143
+
144
+### Create an overlay
145
+
146
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=IMGFMT
147
+
148
+### Fill the overlay with zeroes
149
+
150
+wrote 8347648/8347648 bytes at offset 0
151
+7.961 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
152
+
153
+### Commit changes to the base image
154
+
155
+Image committed.
156
+
157
+### Check the base image
158
+
159
+No errors were found on the image.
160
+Image end offset: 8396800
161
+*** done
162
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
36
index XXXXXXX..XXXXXXX 100644
163
index XXXXXXX..XXXXXXX 100644
37
--- a/util/throttle.c
164
--- a/tests/qemu-iotests/group
38
+++ b/util/throttle.c
165
+++ b/tests/qemu-iotests/group
39
@@ -XXX,XX +XXX,XX @@ static void throttle_fix_bucket(LeakyBucket *bkt)
166
@@ -XXX,XX +XXX,XX @@
40
/* zero bucket level */
167
309 rw auto quick
41
bkt->level = bkt->burst_level = 0;
168
310 rw quick
42
169
312 rw quick
43
- /* The following is done to cope with the Linux CFQ block scheduler
170
+313 rw auto quick
44
- * which regroup reads and writes by block of 100ms in the guest.
45
- * When they are two process one making reads and one making writes cfq
46
- * make a pattern looking like the following:
47
- * WWWWWWWWWWWRRRRRRRRRRRRRRWWWWWWWWWWWWWwRRRRRRRRRRRRRRRRR
48
- * Having a max burst value of 100ms of the average will help smooth the
49
- * throttling
50
- */
51
+ /* If bkt->max is 0 we still want to allow short bursts of I/O
52
+ * from the guest, otherwise every other request will be throttled
53
+ * and performance will suffer considerably. */
54
min = bkt->avg / 10;
55
if (bkt->avg && !bkt->max) {
56
bkt->max = min;
57
--
171
--
58
2.13.5
172
2.29.2
59
173
60
174
diff view generated by jsdifflib
1
Add the scripts/ directory to sys.path so Python 2.6 will be able to
1
Commit 0afec75734331 removed the 'change' QMP command, so we can no
2
import argparse.
2
longer test it in 118.
3
3
4
Cc: Daniel P. Berrange <berrange@redhat.com>
4
Fixes: 0afec75734331a0b52fa3aa4235220eda8c7846f
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5
('qmp: remove deprecated "change" command')
6
Acked-by: John Snow <jsnow@redhat.com>
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Acked-by: Fam Zheng <famz@redhat.com>
7
Message-Id: <20210126104833.57026-1-mreitz@redhat.com>
8
Message-id: 20170825155732.15665-4-stefanha@redhat.com
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
---
9
---
11
tests/migration/guestperf/shell.py | 8 +++++---
10
tests/qemu-iotests/118 | 20 +-------------------
12
1 file changed, 5 insertions(+), 3 deletions(-)
11
tests/qemu-iotests/118.out | 4 ++--
12
2 files changed, 3 insertions(+), 21 deletions(-)
13
13
14
diff --git a/tests/migration/guestperf/shell.py b/tests/migration/guestperf/shell.py
14
diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118
15
index XXXXXXX..XXXXXXX 100755
16
--- a/tests/qemu-iotests/118
17
+++ b/tests/qemu-iotests/118
18
@@ -XXX,XX +XXX,XX @@
19
#!/usr/bin/env python3
20
# group: rw
21
#
22
-# Test case for the QMP 'change' command and all other associated
23
-# commands
24
+# Test case for media change monitor commands
25
#
26
# Copyright (C) 2015 Red Hat, Inc.
27
#
28
@@ -XXX,XX +XXX,XX @@ class ChangeBaseClass(iotests.QMPTestCase):
29
30
class GeneralChangeTestsBaseClass(ChangeBaseClass):
31
32
- def test_change(self):
33
- # 'change' requires a drive name, so skip the test for blockdev
34
- if not self.use_drive:
35
- return
36
-
37
- result = self.vm.qmp('change', device='drive0', target=new_img,
38
- arg=iotests.imgfmt)
39
- self.assert_qmp(result, 'return', {})
40
-
41
- self.wait_for_open()
42
- self.wait_for_close()
43
-
44
- result = self.vm.qmp('query-block')
45
- if self.has_real_tray:
46
- self.assert_qmp(result, 'return[0]/tray_open', False)
47
- self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
48
-
49
def test_blockdev_change_medium(self):
50
result = self.vm.qmp('blockdev-change-medium',
51
id=self.device_name, filename=new_img,
52
diff --git a/tests/qemu-iotests/118.out b/tests/qemu-iotests/118.out
15
index XXXXXXX..XXXXXXX 100644
53
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/migration/guestperf/shell.py
54
--- a/tests/qemu-iotests/118.out
17
+++ b/tests/migration/guestperf/shell.py
55
+++ b/tests/qemu-iotests/118.out
18
@@ -XXX,XX +XXX,XX @@
56
@@ -XXX,XX +XXX,XX @@
19
#
57
-.......................................................................................................................................................................
20
58
+...........................................................................................................................................................
21
59
----------------------------------------------------------------------
22
-import argparse
60
-Ran 167 tests
23
-import fnmatch
61
+Ran 155 tests
24
import os
62
25
import os.path
63
OK
26
-import platform
27
import sys
28
+sys.path.append(os.path.join(os.path.dirname(__file__),
29
+ '..', '..', '..', 'scripts'))
30
+import argparse
31
+import fnmatch
32
+import platform
33
34
from guestperf.hardware import Hardware
35
from guestperf.engine import Engine
36
--
64
--
37
2.13.5
65
2.29.2
38
66
39
67
diff view generated by jsdifflib
1
From: Dan Aloni <dan@kernelim.com>
1
ccd3b3b8112 has deprecated short-hand boolean options (i.e., options
2
with values). All options without values are interpreted as boolean
3
options, so this includes the invalid option "snapshot.foo" used in
4
iotest 178.
2
5
3
The number of queues that should be return by the admin command should:
6
So after ccd3b3b8112, 178 fails with:
4
7
5
1) Only mention the number of non-admin queues.
8
+qemu-img: warning: short-form boolean option 'snapshot.foo' deprecated
6
2) It is zero-based, meaning that '0 == one non-admin queue',
9
+Please use snapshot.foo=on instead
7
'1 == two non-admin queues', and so forth.
8
10
9
Because our `num_queues` means the number of queues _plus_ the admin
11
Suppress that deprecation warning by passing some value to it (it does
10
queue, then the right calculation for the number returned from the admin
12
not matter which, because the option is invalid anyway).
11
command is `num_queues - 2`, combining the two requirements mentioned.
12
13
13
The issue was discovered by reducing num_queues from 64 to 8 and running
14
Fixes: ccd3b3b8112b670fdccf8a392b8419b173ffccb4
14
a Linux VM with an SMP parameter larger than that (e.g. 22). It tries to
15
("qemu-option: warn for short-form boolean options")
15
utilize all queues, and therefore fails with an invalid queue number
16
Signed-off-by: Max Reitz <mreitz@redhat.com>
16
when trying to queue I/Os on the last queue.
17
Message-Id: <20210126123834.115915-1-mreitz@redhat.com>
18
---
19
tests/qemu-iotests/178 | 2 +-
20
tests/qemu-iotests/178.out.qcow2 | 2 +-
21
tests/qemu-iotests/178.out.raw | 2 +-
22
3 files changed, 3 insertions(+), 3 deletions(-)
17
23
18
Signed-off-by: Dan Aloni <dan@kernelim.com>
24
diff --git a/tests/qemu-iotests/178 b/tests/qemu-iotests/178
19
CC: Alex Friedman <alex@e8storage.com>
25
index XXXXXXX..XXXXXXX 100755
20
CC: Keith Busch <keith.busch@intel.com>
26
--- a/tests/qemu-iotests/178
21
CC: Stefan Hajnoczi <stefanha@redhat.com>
27
+++ b/tests/qemu-iotests/178
22
Reviewed-by: Keith Busch <keith.busch@intel.com>
28
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG measure --image-opts # missing filename
23
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
29
$QEMU_IMG measure -f qcow2 # missing filename
24
---
30
$QEMU_IMG measure -l snap1 # missing filename
25
hw/block/nvme.c | 4 ++--
31
$QEMU_IMG measure -o , # invalid option list
26
1 file changed, 2 insertions(+), 2 deletions(-)
32
-$QEMU_IMG measure -l snapshot.foo # invalid snapshot option
27
33
+$QEMU_IMG measure -l snapshot.foo=bar # invalid snapshot option
28
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
34
$QEMU_IMG measure --output foo # invalid output format
35
$QEMU_IMG measure --size -1 # invalid image size
36
$QEMU_IMG measure -O foo "$TEST_IMG" # unknown image file format
37
diff --git a/tests/qemu-iotests/178.out.qcow2 b/tests/qemu-iotests/178.out.qcow2
29
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/block/nvme.c
39
--- a/tests/qemu-iotests/178.out.qcow2
31
+++ b/hw/block/nvme.c
40
+++ b/tests/qemu-iotests/178.out.qcow2
32
@@ -XXX,XX +XXX,XX @@ static uint16_t nvme_get_feature(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
41
@@ -XXX,XX +XXX,XX @@ qemu-img: --image-opts, -f, and -l require a filename argument.
33
result = blk_enable_write_cache(n->conf.blk);
42
qemu-img: --image-opts, -f, and -l require a filename argument.
34
break;
43
qemu-img: Invalid option list: ,
35
case NVME_NUMBER_OF_QUEUES:
44
qemu-img: Invalid parameter 'snapshot.foo'
36
- result = cpu_to_le32((n->num_queues - 1) | ((n->num_queues - 1) << 16));
45
-qemu-img: Failed in parsing snapshot param 'snapshot.foo'
37
+ result = cpu_to_le32((n->num_queues - 2) | ((n->num_queues - 2) << 16));
46
+qemu-img: Failed in parsing snapshot param 'snapshot.foo=bar'
38
break;
47
qemu-img: --output must be used with human or json as argument.
39
default:
48
qemu-img: Invalid image size specified. Must be between 0 and 9223372036854775807.
40
return NVME_INVALID_FIELD | NVME_DNR;
49
qemu-img: Unknown file format 'foo'
41
@@ -XXX,XX +XXX,XX @@ static uint16_t nvme_set_feature(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
50
diff --git a/tests/qemu-iotests/178.out.raw b/tests/qemu-iotests/178.out.raw
42
break;
51
index XXXXXXX..XXXXXXX 100644
43
case NVME_NUMBER_OF_QUEUES:
52
--- a/tests/qemu-iotests/178.out.raw
44
req->cqe.result =
53
+++ b/tests/qemu-iotests/178.out.raw
45
- cpu_to_le32((n->num_queues - 1) | ((n->num_queues - 1) << 16));
54
@@ -XXX,XX +XXX,XX @@ qemu-img: --image-opts, -f, and -l require a filename argument.
46
+ cpu_to_le32((n->num_queues - 2) | ((n->num_queues - 2) << 16));
55
qemu-img: --image-opts, -f, and -l require a filename argument.
47
break;
56
qemu-img: Invalid option list: ,
48
default:
57
qemu-img: Invalid parameter 'snapshot.foo'
49
return NVME_INVALID_FIELD | NVME_DNR;
58
-qemu-img: Failed in parsing snapshot param 'snapshot.foo'
59
+qemu-img: Failed in parsing snapshot param 'snapshot.foo=bar'
60
qemu-img: --output must be used with human or json as argument.
61
qemu-img: Invalid image size specified. Must be between 0 and 9223372036854775807.
62
qemu-img: Unknown file format 'foo'
50
--
63
--
51
2.13.5
64
2.29.2
52
65
53
66
diff view generated by jsdifflib