1
The following changes since commit 23919ddfd56135cad3cb468a8f54d5a595f024f4:
1
The following changes since commit 96662996eda78c48aadddd4e76d8615c7eb72d80:
2
2
3
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190827' into staging (2019-08-27 15:52:36 +0100)
3
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20210513a' into staging (2021-05-14 12:03:47 +0100)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://github.com/XanClic/qemu.git tags/pull-block-2019-08-27
7
https://github.com/XanClic/qemu.git tags/pull-block-2021-05-14
8
8
9
for you to fetch changes up to bb043c056cffcc2f3ce88bfdaf2e76e455c09e2c:
9
for you to fetch changes up to c61ebf362d0abf288ce266845519d5a550a1d89f:
10
10
11
iotests: Unify cache mode quoting (2019-08-27 19:48:44 +0200)
11
write-threshold: deal with includes (2021-05-14 16:14:10 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches:
14
Block patches:
15
- qemu-io now accepts a file to read a write pattern from
15
- drop block/io write notifiers
16
- Ensure that raw files have their first block allocated so we can probe
16
- qemu-iotests enhancements to make debugging easier
17
the O_DIRECT alignment if necessary
17
- rbd parsing fix
18
- Various fixes
18
- HMP qemu-io fix (for iothreads)
19
- mirror job cancel relaxation (do not cancel in-flight requests when a
20
READY mirror job is canceled with force=false)
21
- document qcow2's data_file and data_file_raw features
22
- fix iotest 297 for pylint 2.8
23
- block/copy-on-read refactoring
19
24
20
----------------------------------------------------------------
25
----------------------------------------------------------------
21
Denis Plotnikov (1):
26
Connor Kuehl (3):
22
qemu-io: add pattern file for write command
27
iotests/231: Update expected deprecation message
28
block/rbd: Add an escape-aware strchr helper
29
Document qemu-img options data_file and data_file_raw
23
30
24
Max Reitz (7):
31
Emanuele Giuseppe Esposito (1):
25
iotests: Fix _filter_img_create()
32
qemu-iotests: fix pylint 2.8 consider-using-with error
26
vmdk: Use bdrv_dirname() for relative extent paths
27
iotests: Keep testing broken relative extent paths
28
vmdk: Reject invalid compressed writes
29
iotests: Disable broken streamOptimized tests
30
iotests: Disable 110 for vmdk.twoGbMaxExtentSparse
31
iotests: Disable 126 for flat vmdk subformats
32
33
33
Nir Soffer (3):
34
Paolo Bonzini (5):
34
block: posix: Always allocate the first block
35
qemu-iotests: do not buffer the test output
35
iotests: Test allocate_first_block() with O_DIRECT
36
qemu-iotests: allow passing unittest.main arguments to the test
36
iotests: Unify cache mode quoting
37
scripts
38
qemu-iotests: move command line and environment handling from
39
TestRunner to TestEnv
40
qemu-iotests: let "check" spawn an arbitrary test command
41
qemu-iotests: fix case of SOCK_DIR already in the environment
37
42
38
Stefan Hajnoczi (1):
43
Vladimir Sementsov-Ogievskiy (10):
39
file-posix: fix request_alignment typo
44
monitor: hmp_qemu_io: acquire aio contex, fix crash
45
mirror: stop cancelling in-flight requests on non-force cancel in
46
READY
47
block/copy-on-read: use bdrv_drop_filter() and drop s->active
48
block/write-threshold: don't use write notifiers
49
block: drop write notifiers
50
test-write-threshold: rewrite test_threshold_(not_)trigger tests
51
block/write-threshold: drop extra APIs
52
test-write-threshold: drop extra tests
53
test-write-threshold: drop extra TestStruct structure
54
write-threshold: deal with includes
40
55
41
Thomas Huth (2):
56
docs/tools/qemu-img.rst | 31 +++++++
42
iotests: Check for enabled drivers before testing them
57
include/block/block_int.h | 15 +---
43
tests/check-block: Skip iotests when sanitizers are enabled
58
include/block/write-threshold.h | 27 ++----
44
59
include/qemu/job.h | 2 +-
45
Vladimir Sementsov-Ogievskiy (1):
60
block.c | 1 -
46
block: fix permission update in bdrv_replace_node
61
block/backup.c | 2 +-
47
62
block/copy-on-read.c | 33 +------
48
block.c | 5 +-
63
block/io.c | 11 +--
49
block/file-posix.c | 53 +++++++++-
64
block/mirror.c | 6 +-
50
block/vmdk.c | 64 ++++++++----
65
block/monitor/block-hmp-cmds.c | 31 ++++---
51
qemu-io-cmds.c | 99 +++++++++++++++++--
66
block/rbd.c | 32 ++++---
52
tests/check-block.sh | 5 +
67
block/write-threshold.c | 91 ++++---------------
53
tests/qemu-iotests/002 | 1 +
68
job.c | 2 +-
54
tests/qemu-iotests/003 | 1 +
69
qemu-io-cmds.c | 8 +-
55
tests/qemu-iotests/005 | 3 +-
70
qemu-io.c | 17 +++-
56
tests/qemu-iotests/009 | 1 +
71
tests/unit/test-write-threshold.c | 90 ++-----------------
57
tests/qemu-iotests/010 | 1 +
72
tests/qemu-iotests/231 | 4 +
58
tests/qemu-iotests/011 | 1 +
73
tests/qemu-iotests/231.out | 7 +-
59
tests/qemu-iotests/017 | 3 +-
74
tests/qemu-iotests/240.out | 8 +-
60
tests/qemu-iotests/018 | 3 +-
75
tests/qemu-iotests/245.out | 8 +-
61
tests/qemu-iotests/019 | 3 +-
76
tests/qemu-iotests/264 | 2 +-
62
tests/qemu-iotests/020 | 3 +-
77
tests/qemu-iotests/295.out | 6 +-
63
tests/qemu-iotests/026 | 4 +-
78
tests/qemu-iotests/296.out | 8 +-
64
tests/qemu-iotests/027 | 1 +
79
tests/qemu-iotests/check | 19 +++-
65
tests/qemu-iotests/032 | 1 +
80
tests/qemu-iotests/iotests.py | 145 +++++++++++++++++-------------
66
tests/qemu-iotests/033 | 1 +
81
tests/qemu-iotests/pylintrc | 3 +
67
tests/qemu-iotests/034 | 3 +-
82
tests/qemu-iotests/testenv.py | 22 ++++-
68
tests/qemu-iotests/037 | 3 +-
83
tests/qemu-iotests/testrunner.py | 37 +++-----
69
tests/qemu-iotests/039 | 4 +-
84
28 files changed, 289 insertions(+), 379 deletions(-)
70
tests/qemu-iotests/052 | 2 +-
71
tests/qemu-iotests/059 | 34 ++++++-
72
tests/qemu-iotests/059.out | 26 +++--
73
tests/qemu-iotests/063 | 3 +-
74
tests/qemu-iotests/071 | 1 +
75
tests/qemu-iotests/072 | 1 +
76
tests/qemu-iotests/081 | 4 +-
77
tests/qemu-iotests/091 | 4 +-
78
tests/qemu-iotests/099 | 1 +
79
tests/qemu-iotests/105 | 3 +-
80
tests/qemu-iotests/110 | 3 +-
81
tests/qemu-iotests/120 | 1 +
82
tests/qemu-iotests/126 | 2 +
83
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
84
tests/qemu-iotests/150.out.raw | 12 +++
85
tests/qemu-iotests/162 | 4 +-
86
tests/qemu-iotests/175 | 47 +++++++--
87
tests/qemu-iotests/175.out | 16 ++-
88
tests/qemu-iotests/178.out.qcow2 | 4 +-
89
tests/qemu-iotests/184 | 1 +
90
tests/qemu-iotests/186 | 1 +
91
tests/qemu-iotests/197 | 1 +
92
tests/qemu-iotests/215 | 1 +
93
tests/qemu-iotests/221.out | 12 ++-
94
tests/qemu-iotests/251 | 1 +
95
tests/qemu-iotests/253.out | 12 ++-
96
tests/qemu-iotests/common.filter | 4 +-
97
tests/qemu-iotests/common.rc | 14 +++
98
50 files changed, 391 insertions(+), 87 deletions(-)
99
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
100
create mode 100644 tests/qemu-iotests/150.out.raw
101
85
102
--
86
--
103
2.21.0
87
2.31.1
104
88
105
89
diff view generated by jsdifflib
New patch
1
From: Connor Kuehl <ckuehl@redhat.com>
1
2
3
The deprecation message in the expected output has technically been
4
wrong since the wrong version of a patch was applied to it. Because of
5
this, the test fails. Correct the expected output so that it passes.
6
7
Signed-off-by: Connor Kuehl <ckuehl@redhat.com>
8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
10
Message-Id: <20210421212343.85524-2-ckuehl@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
13
tests/qemu-iotests/231.out | 4 +---
14
1 file changed, 1 insertion(+), 3 deletions(-)
15
16
diff --git a/tests/qemu-iotests/231.out b/tests/qemu-iotests/231.out
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qemu-iotests/231.out
19
+++ b/tests/qemu-iotests/231.out
20
@@ -XXX,XX +XXX,XX @@
21
QA output created by 231
22
-qemu-img: RBD options encoded in the filename as keyvalue pairs is deprecated. Future versions may cease to parse these options in the future.
23
+qemu-img: warning: RBD options encoded in the filename as keyvalue pairs is deprecated
24
unable to get monitor info from DNS SRV with service name: ceph-mon
25
-no monitors specified to connect to.
26
qemu-img: Could not open 'json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=BOGUS_CONF'}': error connecting: No such file or directory
27
unable to get monitor info from DNS SRV with service name: ceph-mon
28
-no monitors specified to connect to.
29
qemu-img: Could not open 'json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'BOGUS_CONF'}': error connecting: No such file or directory
30
*** done
31
--
32
2.31.1
33
34
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: Connor Kuehl <ckuehl@redhat.com>
2
2
3
Using block_resize we can test allocate_first_block() with file
3
Sometimes the parser needs to further split a token it has collected
4
descriptor opened with O_DIRECT, ensuring that it works for any size
4
from the token input stream. Right now, it does a cursory check to see
5
larger than 4096 bytes.
5
if the relevant characters appear in the token to determine if it should
6
break it down further.
6
7
7
Testing smaller sizes is tricky as the result depends on the filesystem
8
However, qemu_rbd_next_tok() will escape characters as it removes tokens
8
used for testing. For example on NFS any size will work since O_DIRECT
9
from the token stream and plain strchr() won't. This can make the
9
does not require any alignment.
10
initial strchr() check slightly misleading since it implies
11
qemu_rbd_next_tok() will find the token and split on it, except the
12
reality is that qemu_rbd_next_tok() will pass over it if it is escaped.
10
13
11
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
14
Use a custom strchr to avoid mixing escaped and unescaped string
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
15
operations. Furthermore, this code is identical to how
13
Message-id: 20190827010528.8818-3-nsoffer@redhat.com
16
qemu_rbd_next_tok() seeks its next token, so incorporate this custom
17
strchr into the body of that function to reduce duplication.
18
19
Reported-by: Han Han <hhan@redhat.com>
20
Fixes: https://bugzilla.redhat.com/1873913
21
Signed-off-by: Connor Kuehl <ckuehl@redhat.com>
22
Message-Id: <20210421212343.85524-3-ckuehl@redhat.com>
23
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
24
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
25
---
16
tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++
26
block/rbd.c | 32 +++++++++++++++++++++-----------
17
tests/qemu-iotests/175.out | 8 ++++++++
27
tests/qemu-iotests/231 | 4 ++++
18
2 files changed, 36 insertions(+)
28
tests/qemu-iotests/231.out | 3 +++
29
3 files changed, 28 insertions(+), 11 deletions(-)
19
30
20
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
31
diff --git a/block/rbd.c b/block/rbd.c
21
index XXXXXXX..XXXXXXX 100755
32
index XXXXXXX..XXXXXXX 100644
22
--- a/tests/qemu-iotests/175
33
--- a/block/rbd.c
23
+++ b/tests/qemu-iotests/175
34
+++ b/block/rbd.c
24
@@ -XXX,XX +XXX,XX @@ _filter_blocks()
35
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
25
-e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
36
const char *keypairs, const char *secretid,
26
}
37
Error **errp);
27
38
28
+# Resize image using block_resize.
39
+static char *qemu_rbd_strchr(char *src, char delim)
29
+# Parameter 1: image path
30
+# Parameter 2: new size
31
+_block_resize()
32
+{
40
+{
33
+ local path=$1
41
+ char *p;
34
+ local size=$2
35
+
42
+
36
+ $QEMU -qmp stdio -nographic -nodefaults \
43
+ for (p = src; *p; ++p) {
37
+ -blockdev file,node-name=file,filename=$path,cache.direct=on \
44
+ if (*p == delim) {
38
+ <<EOF
45
+ return p;
39
+{'execute': 'qmp_capabilities'}
46
+ }
40
+{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}}
47
+ if (*p == '\\' && p[1] != '\0') {
41
+{'execute': 'quit'}
48
+ ++p;
42
+EOF
49
+ }
50
+ }
51
+
52
+ return NULL;
43
+}
53
+}
44
+
54
+
45
# get standard environment, filters and checks
46
. ./common.rc
47
. ./common.filter
48
@@ -XXX,XX +XXX,XX @@ _supported_fmt raw
49
_supported_proto file
50
_supported_os Linux
51
52
+_default_cache_mode none
53
+_supported_cache_modes none directsync
54
+
55
+
55
size=$((1 * 1024 * 1024))
56
static char *qemu_rbd_next_tok(char *src, char delim, char **p)
56
57
{
57
touch "$TEST_DIR/empty"
58
char *end;
58
@@ -XXX,XX +XXX,XX @@ for mode in off full falloc; do
59
59
stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
60
*p = NULL;
60
done
61
61
62
- for (end = src; *end; ++end) {
62
+for new_size in 4096 1048576; do
63
- if (*end == delim) {
63
+ echo
64
- break;
64
+ echo "== resize empty image with block_resize =="
65
- }
65
+ _make_test_img 0 | _filter_imgfmt
66
- if (*end == '\\' && end[1] != '\0') {
66
+ _block_resize $TEST_IMG $new_size >/dev/null
67
- end++;
67
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $new_size
68
- }
68
+done
69
- }
70
- if (*end == delim) {
71
+ end = qemu_rbd_strchr(src, delim);
72
+ if (end) {
73
*p = end + 1;
74
*end = '\0';
75
}
76
@@ -XXX,XX +XXX,XX @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options,
77
qemu_rbd_unescape(found_str);
78
qdict_put_str(options, "pool", found_str);
79
80
- if (strchr(p, '@')) {
81
+ if (qemu_rbd_strchr(p, '@')) {
82
image_name = qemu_rbd_next_tok(p, '@', &p);
83
84
found_str = qemu_rbd_next_tok(p, ':', &p);
85
@@ -XXX,XX +XXX,XX @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options,
86
image_name = qemu_rbd_next_tok(p, ':', &p);
87
}
88
/* Check for namespace in the image_name */
89
- if (strchr(image_name, '/')) {
90
+ if (qemu_rbd_strchr(image_name, '/')) {
91
found_str = qemu_rbd_next_tok(image_name, '/', &image_name);
92
qemu_rbd_unescape(found_str);
93
qdict_put_str(options, "namespace", found_str);
94
diff --git a/tests/qemu-iotests/231 b/tests/qemu-iotests/231
95
index XXXXXXX..XXXXXXX 100755
96
--- a/tests/qemu-iotests/231
97
+++ b/tests/qemu-iotests/231
98
@@ -XXX,XX +XXX,XX @@ _filter_conf()
99
$QEMU_IMG info "json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=${BOGUS_CONF}'}" 2>&1 | _filter_conf
100
$QEMU_IMG info "json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'${BOGUS_CONF}'}" 2>&1 | _filter_conf
101
102
+# Regression test: the qemu-img invocation is expected to fail, but it should
103
+# not seg fault the parser.
104
+$QEMU_IMG create "rbd:rbd/aa\/bb:conf=${BOGUS_CONF}" 1M 2>&1 | _filter_conf
69
+
105
+
70
# success, all done
106
# success, all done
71
echo "*** done"
107
echo "*** done"
72
rm -f $seq.full
108
rm -f $seq.full
73
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
109
diff --git a/tests/qemu-iotests/231.out b/tests/qemu-iotests/231.out
74
index XXXXXXX..XXXXXXX 100644
110
index XXXXXXX..XXXXXXX 100644
75
--- a/tests/qemu-iotests/175.out
111
--- a/tests/qemu-iotests/231.out
76
+++ b/tests/qemu-iotests/175.out
112
+++ b/tests/qemu-iotests/231.out
77
@@ -XXX,XX +XXX,XX @@ size=1048576, max allocation
113
@@ -XXX,XX +XXX,XX @@ unable to get monitor info from DNS SRV with service name: ceph-mon
78
== creating image with preallocation falloc ==
114
qemu-img: Could not open 'json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=BOGUS_CONF'}': error connecting: No such file or directory
79
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
115
unable to get monitor info from DNS SRV with service name: ceph-mon
80
size=1048576, max allocation
116
qemu-img: Could not open 'json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'BOGUS_CONF'}': error connecting: No such file or directory
81
+
117
+Formatting 'rbd:rbd/aa\/bb:conf=BOGUS_CONF', fmt=raw size=1048576
82
+== resize empty image with block_resize ==
118
+unable to get monitor info from DNS SRV with service name: ceph-mon
83
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
119
+qemu-img: rbd:rbd/aa\/bb:conf=BOGUS_CONF: error connecting: No such file or directory
84
+size=4096, min allocation
120
*** done
85
+
86
+== resize empty image with block_resize ==
87
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
88
+size=1048576, min allocation
89
*** done
90
--
121
--
91
2.21.0
122
2.31.1
92
123
93
124
diff view generated by jsdifflib
1
From: Denis Plotnikov <dplotnikov@virtuozzo.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
The patch allows to provide a pattern file for write
3
Max reported the following bug:
4
command. There was no similar ability before.
4
5
5
$ ./qemu-img create -f raw src.img 1G
6
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
6
$ ./qemu-img create -f raw dst.img 1G
7
Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com
7
8
Reviewed-by: Eric Blake <eblake@redhat.com>
8
$ (echo '
9
[mreitz: Keep optstring in alphabetical order]
9
{"execute":"qmp_capabilities"}
10
{"execute":"blockdev-mirror",
11
"arguments":{"job-id":"mirror",
12
"device":"source",
13
"target":"target",
14
"sync":"full",
15
"filter-node-name":"mirror-top"}}
16
'; sleep 3; echo '
17
{"execute":"human-monitor-command",
18
"arguments":{"command-line":
19
"qemu-io mirror-top \"write 0 1G\""}}') \
20
| x86_64-softmmu/qemu-system-x86_64 \
21
-qmp stdio \
22
-blockdev file,node-name=source,filename=src.img \
23
-blockdev file,node-name=target,filename=dst.img \
24
-object iothread,id=iothr0 \
25
-device virtio-blk,drive=source,iothread=iothr0
26
27
crashes:
28
29
0 raise () at /usr/lib/libc.so.6
30
1 abort () at /usr/lib/libc.so.6
31
2 error_exit
32
(err=<optimized out>,
33
msg=msg@entry=0x55fbb1634790 <__func__.27> "qemu_mutex_unlock_impl")
34
at ../util/qemu-thread-posix.c:37
35
3 qemu_mutex_unlock_impl
36
(mutex=mutex@entry=0x55fbb25ab6e0,
37
file=file@entry=0x55fbb1636957 "../util/async.c",
38
line=line@entry=650)
39
at ../util/qemu-thread-posix.c:109
40
4 aio_context_release (ctx=ctx@entry=0x55fbb25ab680) at ../util/async.c:650
41
5 bdrv_do_drained_begin
42
(bs=bs@entry=0x55fbb3a87000, recursive=recursive@entry=false,
43
parent=parent@entry=0x0,
44
ignore_bds_parents=ignore_bds_parents@entry=false,
45
poll=poll@entry=true) at ../block/io.c:441
46
6 bdrv_do_drained_begin
47
(poll=true, ignore_bds_parents=false, parent=0x0, recursive=false,
48
bs=0x55fbb3a87000) at ../block/io.c:448
49
7 blk_drain (blk=0x55fbb26c5a00) at ../block/block-backend.c:1718
50
8 blk_unref (blk=0x55fbb26c5a00) at ../block/block-backend.c:498
51
9 blk_unref (blk=0x55fbb26c5a00) at ../block/block-backend.c:491
52
10 hmp_qemu_io (mon=0x7fffaf3fc7d0, qdict=<optimized out>)
53
at ../block/monitor/block-hmp-cmds.c:628
54
55
man pthread_mutex_unlock
56
...
57
EPERM The mutex type is PTHREAD_MUTEX_ERRORCHECK or
58
PTHREAD_MUTEX_RECURSIVE, or the mutex is a robust mutex, and the
59
current thread does not own the mutex.
60
61
So, thread doesn't own the mutex. And we have iothread here.
62
63
Next, note that AIO_WAIT_WHILE() documents that ctx must be acquired
64
exactly once by caller. But where is it acquired in the call stack?
65
Seems nowhere.
66
67
qemuio_command do acquire aio context.. But we need context acquired
68
around blk_unref() as well and actually around blk_insert_bs() too.
69
70
Let's refactor qemuio_command so that it doesn't acquire aio context
71
but callers do that instead. This way we can cleanly acquire aio
72
context in hmp_qemu_io() around all three calls.
73
74
Reported-by: Max Reitz <mreitz@redhat.com>
75
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
76
Message-Id: <20210423134233.51495-1-vsementsov@virtuozzo.com>
77
[mreitz: Fixed comment]
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
78
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
79
---
12
qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++---
80
block/monitor/block-hmp-cmds.c | 31 +++++++++++++++++++++----------
13
1 file changed, 93 insertions(+), 6 deletions(-)
81
qemu-io-cmds.c | 8 ++++----
14
82
qemu-io.c | 17 +++++++++++++++--
83
3 files changed, 40 insertions(+), 16 deletions(-)
84
85
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/block/monitor/block-hmp-cmds.c
88
+++ b/block/monitor/block-hmp-cmds.c
89
@@ -XXX,XX +XXX,XX @@ void hmp_eject(Monitor *mon, const QDict *qdict)
90
91
void hmp_qemu_io(Monitor *mon, const QDict *qdict)
92
{
93
- BlockBackend *blk;
94
+ BlockBackend *blk = NULL;
95
+ BlockDriverState *bs = NULL;
96
BlockBackend *local_blk = NULL;
97
+ AioContext *ctx = NULL;
98
bool qdev = qdict_get_try_bool(qdict, "qdev", false);
99
const char *device = qdict_get_str(qdict, "device");
100
const char *command = qdict_get_str(qdict, "command");
101
@@ -XXX,XX +XXX,XX @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
102
} else {
103
blk = blk_by_name(device);
104
if (!blk) {
105
- BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
106
- if (bs) {
107
- blk = local_blk = blk_new(bdrv_get_aio_context(bs),
108
- 0, BLK_PERM_ALL);
109
- ret = blk_insert_bs(blk, bs, &err);
110
- if (ret < 0) {
111
- goto fail;
112
- }
113
- } else {
114
+ bs = bdrv_lookup_bs(NULL, device, &err);
115
+ if (!bs) {
116
goto fail;
117
}
118
}
119
}
120
121
+ ctx = blk ? blk_get_aio_context(blk) : bdrv_get_aio_context(bs);
122
+ aio_context_acquire(ctx);
123
+
124
+ if (bs) {
125
+ blk = local_blk = blk_new(bdrv_get_aio_context(bs), 0, BLK_PERM_ALL);
126
+ ret = blk_insert_bs(blk, bs, &err);
127
+ if (ret < 0) {
128
+ goto fail;
129
+ }
130
+ }
131
+
132
/*
133
* Notably absent: Proper permission management. This is sad, but it seems
134
* almost impossible to achieve without changing the semantics and thereby
135
@@ -XXX,XX +XXX,XX @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
136
137
fail:
138
blk_unref(local_blk);
139
+
140
+ if (ctx) {
141
+ aio_context_release(ctx);
142
+ }
143
+
144
hmp_handle_error(mon, err);
145
}
146
15
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
147
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
16
index XXXXXXX..XXXXXXX 100644
148
index XXXXXXX..XXXXXXX 100644
17
--- a/qemu-io-cmds.c
149
--- a/qemu-io-cmds.c
18
+++ b/qemu-io-cmds.c
150
+++ b/qemu-io-cmds.c
19
@@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p)
151
@@ -XXX,XX +XXX,XX @@ static const cmdinfo_t help_cmd = {
20
qemu_vfree(p);
152
.oneline = "help for one or all commands",
153
};
154
155
+/*
156
+ * Called with aio context of blk acquired. Or with qemu_get_aio_context()
157
+ * context acquired if blk is NULL.
158
+ */
159
int qemuio_command(BlockBackend *blk, const char *cmd)
160
{
161
- AioContext *ctx;
162
char *input;
163
const cmdinfo_t *ct;
164
char **v;
165
@@ -XXX,XX +XXX,XX @@ int qemuio_command(BlockBackend *blk, const char *cmd)
166
if (c) {
167
ct = find_command(v[0]);
168
if (ct) {
169
- ctx = blk ? blk_get_aio_context(blk) : qemu_get_aio_context();
170
- aio_context_acquire(ctx);
171
ret = command(blk, ct, c, v);
172
- aio_context_release(ctx);
173
} else {
174
fprintf(stderr, "command \"%s\" not found\n", v[0]);
175
ret = -EINVAL;
176
diff --git a/qemu-io.c b/qemu-io.c
177
index XXXXXXX..XXXXXXX 100644
178
--- a/qemu-io.c
179
+++ b/qemu-io.c
180
@@ -XXX,XX +XXX,XX @@ static void prep_fetchline(void *opaque)
181
*fetchable= 1;
21
}
182
}
22
183
23
+/*
184
+static int do_qemuio_command(const char *cmd)
24
+ * qemu_io_alloc_from_file()
25
+ *
26
+ * Allocates the buffer and populates it with the content of the given file
27
+ * up to @len bytes. If the file length is less than @len, then the buffer
28
+ * is populated with the file content cyclically.
29
+ *
30
+ * @blk - the block backend where the buffer content is going to be written to
31
+ * @len - the buffer length
32
+ * @file_name - the file to read the content from
33
+ *
34
+ * Returns: the buffer pointer on success
35
+ * NULL on error
36
+ */
37
+static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len,
38
+ const char *file_name)
39
+{
185
+{
40
+ char *buf, *buf_origin;
186
+ int ret;
41
+ FILE *f = fopen(file_name, "r");
187
+ AioContext *ctx =
42
+ int pattern_len;
188
+ qemuio_blk ? blk_get_aio_context(qemuio_blk) : qemu_get_aio_context();
43
+
189
+
44
+ if (!f) {
190
+ aio_context_acquire(ctx);
45
+ perror(file_name);
191
+ ret = qemuio_command(qemuio_blk, cmd);
46
+ return NULL;
192
+ aio_context_release(ctx);
47
+ }
193
+
48
+
194
+ return ret;
49
+ if (qemuio_misalign) {
50
+ len += MISALIGN_OFFSET;
51
+ }
52
+
53
+ buf_origin = buf = blk_blockalign(blk, len);
54
+
55
+ if (qemuio_misalign) {
56
+ buf_origin += MISALIGN_OFFSET;
57
+ buf += MISALIGN_OFFSET;
58
+ len -= MISALIGN_OFFSET;
59
+ }
60
+
61
+ pattern_len = fread(buf_origin, 1, len, f);
62
+
63
+ if (ferror(f)) {
64
+ perror(file_name);
65
+ goto error;
66
+ }
67
+
68
+ if (pattern_len == 0) {
69
+ fprintf(stderr, "%s: file is empty\n", file_name);
70
+ goto error;
71
+ }
72
+
73
+ fclose(f);
74
+
75
+ if (len > pattern_len) {
76
+ len -= pattern_len;
77
+ buf += pattern_len;
78
+
79
+ while (len > 0) {
80
+ size_t len_to_copy = MIN(pattern_len, len);
81
+
82
+ memcpy(buf, buf_origin, len_to_copy);
83
+
84
+ len -= len_to_copy;
85
+ buf += len_to_copy;
86
+ }
87
+ }
88
+
89
+ return buf_origin;
90
+
91
+error:
92
+ qemu_io_free(buf_origin);
93
+ return NULL;
94
+}
195
+}
95
+
196
+
96
static void dump_buffer(const void *buffer, int64_t offset, int64_t len)
197
static int command_loop(void)
97
{
198
{
98
uint64_t i;
199
int i, fetchable = 0, prompted = 0;
99
@@ -XXX,XX +XXX,XX @@ static void write_help(void)
200
@@ -XXX,XX +XXX,XX @@ static int command_loop(void)
100
" -n, -- with -z, don't allow slow fallback\n"
201
char *input;
101
" -p, -- ignored for backwards compatibility\n"
202
102
" -P, -- use different pattern to fill file\n"
203
for (i = 0; !quit_qemu_io && i < ncmdline; i++) {
103
+" -s, -- use a pattern file to fill the write buffer\n"
204
- ret = qemuio_command(qemuio_blk, cmdline[i]);
104
" -C, -- report statistics in a machine parsable format\n"
205
+ ret = do_qemuio_command(cmdline[i]);
105
" -q, -- quiet mode, do not show I/O statistics\n"
206
if (ret < 0) {
106
" -u, -- with -z, allow unmapping\n"
207
last_error = ret;
107
@@ -XXX,XX +XXX,XX @@ static const cmdinfo_t write_cmd = {
208
}
108
.perm = BLK_PERM_WRITE,
209
@@ -XXX,XX +XXX,XX @@ static int command_loop(void)
109
.argmin = 2,
210
if (input == NULL) {
110
.argmax = -1,
111
- .args = "[-bcCfnquz] [-P pattern] off len",
112
+ .args = "[-bcCfnquz] [-P pattern | -s source_file] off len",
113
.oneline = "writes a number of bytes at a specified offset",
114
.help = write_help,
115
};
116
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
117
{
118
struct timespec t1, t2;
119
bool Cflag = false, qflag = false, bflag = false;
120
- bool Pflag = false, zflag = false, cflag = false;
121
+ bool Pflag = false, zflag = false, cflag = false, sflag = false;
122
int flags = 0;
123
int c, cnt, ret;
124
char *buf = NULL;
125
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
126
/* Some compilers get confused and warn if this is not initialized. */
127
int64_t total = 0;
128
int pattern = 0xcd;
129
+ const char *file_name = NULL;
130
131
- while ((c = getopt(argc, argv, "bcCfnpP:quz")) != -1) {
132
+ while ((c = getopt(argc, argv, "bcCfnpP:qs:uz")) != -1) {
133
switch (c) {
134
case 'b':
135
bflag = true;
136
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
137
case 'q':
138
qflag = true;
139
break;
211
break;
140
+ case 's':
212
}
141
+ sflag = true;
213
- ret = qemuio_command(qemuio_blk, input);
142
+ file_name = optarg;
214
+ ret = do_qemuio_command(input);
143
+ break;
215
g_free(input);
144
case 'u':
216
145
flags |= BDRV_REQ_MAY_UNMAP;
217
if (ret < 0) {
146
break;
147
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
148
return -EINVAL;
149
}
150
151
- if (zflag && Pflag) {
152
- printf("-z and -P cannot be specified at the same time\n");
153
+ if (zflag + Pflag + sflag > 1) {
154
+ printf("Only one of -z, -P, and -s "
155
+ "can be specified at the same time\n");
156
return -EINVAL;
157
}
158
159
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
160
}
161
162
if (!zflag) {
163
- buf = qemu_io_alloc(blk, count, pattern);
164
+ if (sflag) {
165
+ buf = qemu_io_alloc_from_file(blk, count, file_name);
166
+ if (!buf) {
167
+ return -EINVAL;
168
+ }
169
+ } else {
170
+ buf = qemu_io_alloc(blk, count, pattern);
171
+ }
172
}
173
174
clock_gettime(CLOCK_MONOTONIC, &t1);
175
--
218
--
176
2.21.0
219
2.31.1
177
220
178
221
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
If mirror is READY than cancel operation is not discarding the whole
4
result of the operation, but instead it's a documented way get a
5
point-in-time snapshot of source disk.
6
7
So, we should not cancel any requests if mirror is READ and
8
force=false. Let's fix that case.
9
10
Note, that bug that we have before this commit is not critical, as the
11
only .bdrv_cancel_in_flight implementation is nbd_cancel_in_flight()
12
and it cancels only requests waiting for reconnection, so it should be
13
rare case.
14
15
Fixes: 521ff8b779b11c394dbdc43f02e158dd99df308a
16
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
17
Message-Id: <20210421075858.40197-1-vsementsov@virtuozzo.com>
18
Signed-off-by: Max Reitz <mreitz@redhat.com>
19
---
20
include/block/block_int.h | 2 +-
21
include/qemu/job.h | 2 +-
22
block/backup.c | 2 +-
23
block/mirror.c | 6 ++++--
24
job.c | 2 +-
25
tests/qemu-iotests/264 | 2 +-
26
6 files changed, 9 insertions(+), 7 deletions(-)
27
28
diff --git a/include/block/block_int.h b/include/block/block_int.h
29
index XXXXXXX..XXXXXXX 100644
30
--- a/include/block/block_int.h
31
+++ b/include/block/block_int.h
32
@@ -XXX,XX +XXX,XX @@ struct BlockDriver {
33
* of in-flight requests, so don't waste the time if possible.
34
*
35
* One example usage is to avoid waiting for an nbd target node reconnect
36
- * timeout during job-cancel.
37
+ * timeout during job-cancel with force=true.
38
*/
39
void (*bdrv_cancel_in_flight)(BlockDriverState *bs);
40
41
diff --git a/include/qemu/job.h b/include/qemu/job.h
42
index XXXXXXX..XXXXXXX 100644
43
--- a/include/qemu/job.h
44
+++ b/include/qemu/job.h
45
@@ -XXX,XX +XXX,XX @@ struct JobDriver {
46
/**
47
* If the callback is not NULL, it will be invoked in job_cancel_async
48
*/
49
- void (*cancel)(Job *job);
50
+ void (*cancel)(Job *job, bool force);
51
52
53
/** Called when the job is freed */
54
diff --git a/block/backup.c b/block/backup.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/block/backup.c
57
+++ b/block/backup.c
58
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn backup_set_speed(BlockJob *job, int64_t speed)
59
}
60
}
61
62
-static void backup_cancel(Job *job)
63
+static void backup_cancel(Job *job, bool force)
64
{
65
BackupBlockJob *s = container_of(job, BackupBlockJob, common.job);
66
67
diff --git a/block/mirror.c b/block/mirror.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/block/mirror.c
70
+++ b/block/mirror.c
71
@@ -XXX,XX +XXX,XX @@ static bool mirror_drained_poll(BlockJob *job)
72
return !!s->in_flight;
73
}
74
75
-static void mirror_cancel(Job *job)
76
+static void mirror_cancel(Job *job, bool force)
77
{
78
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job);
79
BlockDriverState *target = blk_bs(s->target);
80
81
- bdrv_cancel_in_flight(target);
82
+ if (force || !job_is_ready(job)) {
83
+ bdrv_cancel_in_flight(target);
84
+ }
85
}
86
87
static const BlockJobDriver mirror_job_driver = {
88
diff --git a/job.c b/job.c
89
index XXXXXXX..XXXXXXX 100644
90
--- a/job.c
91
+++ b/job.c
92
@@ -XXX,XX +XXX,XX @@ static int job_finalize_single(Job *job)
93
static void job_cancel_async(Job *job, bool force)
94
{
95
if (job->driver->cancel) {
96
- job->driver->cancel(job);
97
+ job->driver->cancel(job, force);
98
}
99
if (job->user_paused) {
100
/* Do not call job_enter here, the caller will handle it. */
101
diff --git a/tests/qemu-iotests/264 b/tests/qemu-iotests/264
102
index XXXXXXX..XXXXXXX 100755
103
--- a/tests/qemu-iotests/264
104
+++ b/tests/qemu-iotests/264
105
@@ -XXX,XX +XXX,XX @@ class TestNbdReconnect(iotests.QMPTestCase):
106
self.assert_qmp(result, 'return', {})
107
108
def cancel_job(self):
109
- result = self.vm.qmp('block-job-cancel', device='drive0')
110
+ result = self.vm.qmp('block-job-cancel', device='drive0', force=True)
111
self.assert_qmp(result, 'return', {})
112
113
start_t = time.time()
114
--
115
2.31.1
116
117
diff view generated by jsdifflib
New patch
1
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
3
Instead of buffering the test output into a StringIO, patch it on
4
the fly by wrapping sys.stdout's write method. This can be
5
done unconditionally, even if using -d, which makes execute_unittest
6
a bit simpler.
7
8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
11
Message-Id: <20210323181928.311862-2-pbonzini@redhat.com>
12
Message-Id: <20210503110110.476887-2-pbonzini@redhat.com>
13
Signed-off-by: Max Reitz <mreitz@redhat.com>
14
---
15
tests/qemu-iotests/240.out | 8 ++--
16
tests/qemu-iotests/245.out | 8 ++--
17
tests/qemu-iotests/295.out | 6 +--
18
tests/qemu-iotests/296.out | 8 ++--
19
tests/qemu-iotests/iotests.py | 70 ++++++++++++++++++++---------------
20
5 files changed, 56 insertions(+), 44 deletions(-)
21
22
diff --git a/tests/qemu-iotests/240.out b/tests/qemu-iotests/240.out
23
index XXXXXXX..XXXXXXX 100644
24
--- a/tests/qemu-iotests/240.out
25
+++ b/tests/qemu-iotests/240.out
26
@@ -XXX,XX +XXX,XX @@
27
{"return": {}}
28
{"execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
29
{"return": {}}
30
-==Attach two SCSI disks using the same block device and the same iothread==
31
+.==Attach two SCSI disks using the same block device and the same iothread==
32
{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}}
33
{"return": {}}
34
{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
35
@@ -XXX,XX +XXX,XX @@
36
{"return": {}}
37
{"execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
38
{"return": {}}
39
-==Attach two SCSI disks using the same block device but different iothreads==
40
+.==Attach two SCSI disks using the same block device but different iothreads==
41
{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}}
42
{"return": {}}
43
{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
44
@@ -XXX,XX +XXX,XX @@
45
{"return": {}}
46
{"execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
47
{"return": {}}
48
-==Attach a SCSI disks using the same block device as a NBD server==
49
+.==Attach a SCSI disks using the same block device as a NBD server==
50
{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}}
51
{"return": {}}
52
{"execute": "nbd-server-start", "arguments": {"addr": {"data": {"path": "SOCK_DIR/PID-nbd.sock"}, "type": "unix"}}}
53
@@ -XXX,XX +XXX,XX @@
54
{"return": {}}
55
{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
56
{"return": {}}
57
-....
58
+.
59
----------------------------------------------------------------------
60
Ran 4 tests
61
62
diff --git a/tests/qemu-iotests/245.out b/tests/qemu-iotests/245.out
63
index XXXXXXX..XXXXXXX 100644
64
--- a/tests/qemu-iotests/245.out
65
+++ b/tests/qemu-iotests/245.out
66
@@ -XXX,XX +XXX,XX @@
67
-{"execute": "job-finalize", "arguments": {"id": "commit0"}}
68
+..{"execute": "job-finalize", "arguments": {"id": "commit0"}}
69
{"return": {}}
70
{"data": {"id": "commit0", "type": "commit"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
71
{"data": {"device": "commit0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
72
-{"execute": "job-finalize", "arguments": {"id": "stream0"}}
73
+...{"execute": "job-finalize", "arguments": {"id": "stream0"}}
74
{"return": {}}
75
{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
76
{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
77
-{"execute": "job-finalize", "arguments": {"id": "stream0"}}
78
+.{"execute": "job-finalize", "arguments": {"id": "stream0"}}
79
{"return": {}}
80
{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
81
{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
82
-.....................
83
+...............
84
----------------------------------------------------------------------
85
Ran 21 tests
86
87
diff --git a/tests/qemu-iotests/295.out b/tests/qemu-iotests/295.out
88
index XXXXXXX..XXXXXXX 100644
89
--- a/tests/qemu-iotests/295.out
90
+++ b/tests/qemu-iotests/295.out
91
@@ -XXX,XX +XXX,XX @@
92
{"return": {}}
93
{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}}
94
{"return": {}}
95
-{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}}
96
+.{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}}
97
{"return": {}}
98
{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}}
99
{"return": {}}
100
@@ -XXX,XX +XXX,XX @@ Job failed: Invalid password, cannot unlock any keyslot
101
{"return": {}}
102
{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}}
103
{"return": {}}
104
-{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}}
105
+.{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}}
106
{"return": {}}
107
{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}}
108
{"return": {}}
109
@@ -XXX,XX +XXX,XX @@ Job failed: All the active keyslots match the (old) password that was given and
110
{"return": {}}
111
{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}}
112
{"return": {}}
113
-...
114
+.
115
----------------------------------------------------------------------
116
Ran 3 tests
117
118
diff --git a/tests/qemu-iotests/296.out b/tests/qemu-iotests/296.out
119
index XXXXXXX..XXXXXXX 100644
120
--- a/tests/qemu-iotests/296.out
121
+++ b/tests/qemu-iotests/296.out
122
@@ -XXX,XX +XXX,XX @@ Job failed: Failed to get shared "consistent read" lock
123
qemu-img: Failed to get shared "consistent read" lock
124
Is another process using the image [TEST_DIR/test.img]?
125
126
-Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10
127
+.Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10
128
129
Job failed: Block node is read-only
130
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
131
@@ -XXX,XX +XXX,XX @@ Job failed: Failed to get shared "consistent read" lock
132
{"return": {}}
133
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
134
{"return": {}}
135
-Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10
136
+.Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10
137
138
{"return": {}}
139
{"error": {"class": "GenericError", "desc": "Failed to get \"write\" lock"}}
140
-Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10
141
+.Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10
142
143
{"return": {}}
144
{"return": {}}
145
-....
146
+.
147
----------------------------------------------------------------------
148
Ran 4 tests
149
150
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
151
index XXXXXXX..XXXXXXX 100644
152
--- a/tests/qemu-iotests/iotests.py
153
+++ b/tests/qemu-iotests/iotests.py
154
@@ -XXX,XX +XXX,XX @@
155
import bz2
156
from collections import OrderedDict
157
import faulthandler
158
-import io
159
import json
160
import logging
161
import os
162
@@ -XXX,XX +XXX,XX @@
163
import sys
164
import time
165
from typing import (Any, Callable, Dict, Iterable,
166
- List, Optional, Sequence, Tuple, TypeVar)
167
+ List, Optional, Sequence, TextIO, Tuple, Type, TypeVar)
168
import unittest
169
170
from contextlib import contextmanager
171
@@ -XXX,XX +XXX,XX @@ def func_wrapper(*args, **kwargs):
172
return func(*args, **kwargs)
173
return func_wrapper
174
175
+# We need to filter out the time taken from the output so that
176
+# qemu-iotest can reliably diff the results against master output,
177
+# and hide skipped tests from the reference output.
178
+
179
+class ReproducibleTestResult(unittest.TextTestResult):
180
+ def addSkip(self, test, reason):
181
+ # Same as TextTestResult, but print dot instead of "s"
182
+ unittest.TestResult.addSkip(self, test, reason)
183
+ if self.showAll:
184
+ self.stream.writeln("skipped {0!r}".format(reason))
185
+ elif self.dots:
186
+ self.stream.write(".")
187
+ self.stream.flush()
188
+
189
+class ReproducibleStreamWrapper:
190
+ def __init__(self, stream: TextIO):
191
+ self.stream = stream
192
+
193
+ def __getattr__(self, attr):
194
+ if attr in ('stream', '__getstate__'):
195
+ raise AttributeError(attr)
196
+ return getattr(self.stream, attr)
197
+
198
+ def write(self, arg=None):
199
+ arg = re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', arg)
200
+ arg = re.sub(r' \(skipped=\d+\)', r'', arg)
201
+ self.stream.write(arg)
202
+
203
+class ReproducibleTestRunner(unittest.TextTestRunner):
204
+ def __init__(self, stream: Optional[TextIO] = None,
205
+ resultclass: Type[unittest.TestResult] = ReproducibleTestResult,
206
+ **kwargs: Any) -> None:
207
+ rstream = ReproducibleStreamWrapper(stream or sys.stdout)
208
+ super().__init__(stream=rstream, # type: ignore
209
+ descriptions=True,
210
+ resultclass=resultclass,
211
+ **kwargs)
212
+
213
def execute_unittest(debug=False):
214
"""Executes unittests within the calling module."""
215
216
verbosity = 2 if debug else 1
217
-
218
- if debug:
219
- output = sys.stdout
220
- else:
221
- # We need to filter out the time taken from the output so that
222
- # qemu-iotest can reliably diff the results against master output.
223
- output = io.StringIO()
224
-
225
- runner = unittest.TextTestRunner(stream=output, descriptions=True,
226
- verbosity=verbosity)
227
- try:
228
- # unittest.main() will use sys.exit(); so expect a SystemExit
229
- # exception
230
- unittest.main(testRunner=runner)
231
- finally:
232
- # We need to filter out the time taken from the output so that
233
- # qemu-iotest can reliably diff the results against master output.
234
- if not debug:
235
- out = output.getvalue()
236
- out = re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', out)
237
-
238
- # Hide skipped tests from the reference output
239
- out = re.sub(r'OK \(skipped=\d+\)', 'OK', out)
240
- out_first_line, out_rest = out.split('\n', 1)
241
- out = out_first_line.replace('s', '.') + '\n' + out_rest
242
-
243
- sys.stderr.write(out)
244
+ runner = ReproducibleTestRunner(verbosity=verbosity)
245
+ unittest.main(testRunner=runner)
246
247
def execute_setup_common(supported_fmts: Sequence[str] = (),
248
supported_platforms: Sequence[str] = (),
249
--
250
2.31.1
251
252
diff view generated by jsdifflib
New patch
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
2
3
Python test scripts that use unittest consist of multiple tests.
4
unittest.main allows selecting which tests to run, but currently this
5
is not possible because the iotests wrapper ignores sys.argv.
6
7
unittest.main command line options also allow the user to pick the
8
desired options for verbosity, failfast mode, etc. While "-d" is
9
currently translated to "-v", it also enables extra debug output,
10
and other options are not available at all.
11
12
These command line options only work if the unittest.main testRunner
13
argument is a type, rather than a TestRunner instance. Therefore, pass
14
the class name and "verbosity" argument to unittest.main, and adjust for
15
the different default warnings between TextTestRunner and unittest.main.
16
17
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
18
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
19
Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
20
Message-Id: <20210323181928.311862-3-pbonzini@redhat.com>
21
Message-Id: <20210503110110.476887-3-pbonzini@redhat.com>
22
Signed-off-by: Max Reitz <mreitz@redhat.com>
23
---
24
tests/qemu-iotests/iotests.py | 14 +++++++++-----
25
1 file changed, 9 insertions(+), 5 deletions(-)
26
27
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
28
index XXXXXXX..XXXXXXX 100644
29
--- a/tests/qemu-iotests/iotests.py
30
+++ b/tests/qemu-iotests/iotests.py
31
@@ -XXX,XX +XXX,XX @@ def __init__(self, stream: Optional[TextIO] = None,
32
resultclass=resultclass,
33
**kwargs)
34
35
-def execute_unittest(debug=False):
36
+def execute_unittest(argv: List[str], debug: bool = False) -> None:
37
"""Executes unittests within the calling module."""
38
39
- verbosity = 2 if debug else 1
40
- runner = ReproducibleTestRunner(verbosity=verbosity)
41
- unittest.main(testRunner=runner)
42
+ # Some tests have warnings, especially ResourceWarnings for unclosed
43
+ # files and sockets. Ignore them for now to ensure reproducibility of
44
+ # the test output.
45
+ unittest.main(argv=argv,
46
+ testRunner=ReproducibleTestRunner,
47
+ verbosity=2 if debug else 1,
48
+ warnings=None if sys.warnoptions else 'ignore')
49
50
def execute_setup_common(supported_fmts: Sequence[str] = (),
51
supported_platforms: Sequence[str] = (),
52
@@ -XXX,XX +XXX,XX @@ def execute_test(*args, test_function=None, **kwargs):
53
54
debug = execute_setup_common(*args, **kwargs)
55
if not test_function:
56
- execute_unittest(debug)
57
+ execute_unittest(sys.argv, debug)
58
else:
59
test_function()
60
61
--
62
2.31.1
63
64
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
2
3
The sanitizers (especially the address sanitizer from Clang) are
3
In the next patch, "check" will learn how to execute a test script without
4
sometimes printing out warnings or false positives - this spoils
4
going through TestRunner. To enable this, keep only the text output
5
the output of the iotests, causing some of the tests to fail.
5
and subprocess handling in the TestRunner; move into TestEnv the logic
6
Thus let's skip the automatic iotests during "make check" when the
6
to prepare for running a subprocess.
7
user configured QEMU with --enable-sanitizers.
8
7
9
Signed-off-by: Thomas Huth <thuth@redhat.com>
8
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
Message-id: 20190823084203.29734-1-thuth@redhat.com
9
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10
Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
11
Message-Id: <20210323181928.311862-4-pbonzini@redhat.com>
12
Message-Id: <20210503110110.476887-4-pbonzini@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
Signed-off-by: Max Reitz <mreitz@redhat.com>
12
---
14
---
13
tests/check-block.sh | 5 +++++
15
tests/qemu-iotests/testenv.py | 17 ++++++++++++++++-
14
1 file changed, 5 insertions(+)
16
tests/qemu-iotests/testrunner.py | 14 +-------------
17
2 files changed, 17 insertions(+), 14 deletions(-)
15
18
16
diff --git a/tests/check-block.sh b/tests/check-block.sh
19
diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
17
index XXXXXXX..XXXXXXX 100755
20
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/check-block.sh
21
--- a/tests/qemu-iotests/testenv.py
19
+++ b/tests/check-block.sh
22
+++ b/tests/qemu-iotests/testenv.py
20
@@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then
23
@@ -XXX,XX +XXX,XX @@
21
exit 0
24
import random
22
fi
25
import subprocess
23
26
import glob
24
+if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then
27
-from typing import Dict, Any, Optional, ContextManager
25
+ echo "Sanitizers are enabled ==> Not running the qemu-iotests."
28
+from typing import List, Dict, Any, Optional, ContextManager
26
+ exit 0
29
27
+fi
30
31
def isxfile(path: str) -> bool:
32
@@ -XXX,XX +XXX,XX @@ class TestEnv(ContextManager['TestEnv']):
33
'CACHEMODE_IS_DEFAULT', 'IMGFMT_GENERIC', 'IMGOPTSSYNTAX',
34
'IMGKEYSECRET', 'QEMU_DEFAULT_MACHINE', 'MALLOC_PERTURB_']
35
36
+ def prepare_subprocess(self, args: List[str]) -> Dict[str, str]:
37
+ if self.debug:
38
+ args.append('-d')
28
+
39
+
29
if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then
40
+ with open(args[0], encoding="utf-8") as f:
30
echo "No qemu-system binary available ==> Not running the qemu-iotests."
41
+ try:
31
exit 0
42
+ if f.readline().rstrip() == '#!/usr/bin/env python3':
43
+ args.insert(0, self.python)
44
+ except UnicodeDecodeError: # binary test? for future.
45
+ pass
46
+
47
+ os_env = os.environ.copy()
48
+ os_env.update(self.get_env())
49
+ return os_env
50
+
51
def get_env(self) -> Dict[str, str]:
52
env = {}
53
for v in self.env_variables:
54
diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
55
index XXXXXXX..XXXXXXX 100644
56
--- a/tests/qemu-iotests/testrunner.py
57
+++ b/tests/qemu-iotests/testrunner.py
58
@@ -XXX,XX +XXX,XX @@ class TestRunner(ContextManager['TestRunner']):
59
def __init__(self, env: TestEnv, makecheck: bool = False,
60
color: str = 'auto') -> None:
61
self.env = env
62
- self.test_run_env = self.env.get_env()
63
self.makecheck = makecheck
64
self.last_elapsed = LastElapsedTime('.last-elapsed-cache', env)
65
66
@@ -XXX,XX +XXX,XX @@ def do_run_test(self, test: str) -> TestResult:
67
silent_unlink(p)
68
69
args = [str(f_test.resolve())]
70
- if self.env.debug:
71
- args.append('-d')
72
-
73
- with f_test.open(encoding="utf-8") as f:
74
- try:
75
- if f.readline().rstrip() == '#!/usr/bin/env python3':
76
- args.insert(0, self.env.python)
77
- except UnicodeDecodeError: # binary test? for future.
78
- pass
79
-
80
- env = os.environ.copy()
81
- env.update(self.test_run_env)
82
+ env = self.env.prepare_subprocess(args)
83
84
t0 = time.time()
85
with f_bad.open('w', encoding="utf-8") as f:
32
--
86
--
33
2.21.0
87
2.31.1
34
88
35
89
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
2
3
Quoting cache mode is not needed, and most tests use unquoted values.
3
Right now there is no easy way for "check" to print a reproducer command.
4
Unify all test to use the same style.
4
Because such a reproducer command line would be huge, we can instead teach
5
check to start a command of our choice. This can be for example a Python
6
unit test with arguments to only run a specific subtest.
5
7
6
Message-id: 20190827173432.7656-1-nsoffer@redhat.com
8
Move the trailing empty line to print_env(), since it always looks better
7
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
9
and one caller was not adding it.
10
11
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
13
Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
14
Message-Id: <20210323181928.311862-5-pbonzini@redhat.com>
15
Message-Id: <20210503110110.476887-5-pbonzini@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
16
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
17
---
10
tests/qemu-iotests/026 | 4 ++--
18
tests/qemu-iotests/check | 19 ++++++++++++++++++-
11
tests/qemu-iotests/039 | 4 ++--
19
tests/qemu-iotests/testenv.py | 3 ++-
12
tests/qemu-iotests/052 | 2 +-
20
tests/qemu-iotests/testrunner.py | 1 -
13
tests/qemu-iotests/091 | 4 ++--
21
3 files changed, 20 insertions(+), 3 deletions(-)
14
4 files changed, 7 insertions(+), 7 deletions(-)
15
22
16
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
23
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
17
index XXXXXXX..XXXXXXX 100755
24
index XXXXXXX..XXXXXXX 100755
18
--- a/tests/qemu-iotests/026
25
--- a/tests/qemu-iotests/check
19
+++ b/tests/qemu-iotests/026
26
+++ b/tests/qemu-iotests/check
20
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
27
@@ -XXX,XX +XXX,XX @@
21
# Currently only qcow2 supports rebasing
28
import os
22
_supported_fmt qcow2
29
import sys
23
_supported_proto file
30
import argparse
24
-_default_cache_mode "writethrough"
31
+import shutil
25
-_supported_cache_modes "writethrough" "none"
32
+from pathlib import Path
26
+_default_cache_mode writethrough
33
+
27
+_supported_cache_modes writethrough none
34
from findtests import TestFinder
28
# The refcount table tests expect a certain minimum width for refcount entries
35
from testenv import TestEnv
29
# (so that the refcount table actually needs to grow); that minimum is 16 bits,
36
from testrunner import TestRunner
30
# being the default refcount entry width.
37
@@ -XXX,XX +XXX,XX @@ def make_argparser() -> argparse.ArgumentParser:
31
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
38
'rerun failed ./check command, starting from the '
32
index XXXXXXX..XXXXXXX 100755
39
'middle of the process.')
33
--- a/tests/qemu-iotests/039
40
g_sel.add_argument('tests', metavar='TEST_FILES', nargs='*',
34
+++ b/tests/qemu-iotests/039
41
- help='tests to run')
35
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
42
+ help='tests to run, or "--" followed by a command')
36
_supported_fmt qcow2
43
37
_supported_proto file
44
return p
38
_supported_os Linux
45
39
-_default_cache_mode "writethrough"
46
@@ -XXX,XX +XXX,XX @@ if __name__ == '__main__':
40
-_supported_cache_modes "writethrough"
47
imgopts=args.imgopts, misalign=args.misalign,
41
+_default_cache_mode writethrough
48
debug=args.debug, valgrind=args.valgrind)
42
+_supported_cache_modes writethrough
49
43
50
+ if len(sys.argv) > 1 and sys.argv[-len(args.tests)-1] == '--':
44
size=128M
51
+ if not args.tests:
45
52
+ sys.exit("missing command after '--'")
46
diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052
53
+ cmd = args.tests
47
index XXXXXXX..XXXXXXX 100755
54
+ env.print_env()
48
--- a/tests/qemu-iotests/052
55
+ exec_pathstr = shutil.which(cmd[0])
49
+++ b/tests/qemu-iotests/052
56
+ if exec_pathstr is None:
50
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
57
+ sys.exit('command not found: ' + cmd[0])
51
_supported_proto file
58
+ exec_path = Path(exec_pathstr).resolve()
52
59
+ cmd[0] = str(exec_path)
53
# Don't do O_DIRECT on tmpfs
60
+ full_env = env.prepare_subprocess(cmd)
54
-_supported_cache_modes "writeback" "writethrough" "unsafe"
61
+ os.chdir(exec_path.parent)
55
+_supported_cache_modes writeback writethrough unsafe
62
+ os.execve(cmd[0], cmd, full_env)
56
63
+
57
size=128M
64
testfinder = TestFinder(test_dir=env.source_iotests)
58
_make_test_img $size
65
59
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
66
groups = args.groups.split(',') if args.groups else None
60
index XXXXXXX..XXXXXXX 100755
67
diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
61
--- a/tests/qemu-iotests/091
68
index XXXXXXX..XXXXXXX 100644
62
+++ b/tests/qemu-iotests/091
69
--- a/tests/qemu-iotests/testenv.py
63
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
70
+++ b/tests/qemu-iotests/testenv.py
64
_supported_fmt qcow2
71
@@ -XXX,XX +XXX,XX @@ def print_env(self) -> None:
65
_supported_proto file
72
PLATFORM -- {platform}
66
_supported_os Linux
73
TEST_DIR -- {TEST_DIR}
67
-_default_cache_mode "none"
74
SOCK_DIR -- {SOCK_DIR}
68
-_supported_cache_modes "writethrough" "none" "writeback"
75
-SOCKET_SCM_HELPER -- {SOCKET_SCM_HELPER}"""
69
+_default_cache_mode none
76
+SOCKET_SCM_HELPER -- {SOCKET_SCM_HELPER}
70
+_supported_cache_modes writethrough none writeback
77
+"""
71
78
72
size=1G
79
args = collections.defaultdict(str, self.get_env())
80
81
diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
82
index XXXXXXX..XXXXXXX 100644
83
--- a/tests/qemu-iotests/testrunner.py
84
+++ b/tests/qemu-iotests/testrunner.py
85
@@ -XXX,XX +XXX,XX @@ def run_tests(self, tests: List[str]) -> bool:
86
87
if not self.makecheck:
88
self.env.print_env()
89
- print()
90
91
test_field_width = max(len(os.path.basename(t)) for t in tests) + 2
73
92
74
--
93
--
75
2.21.0
94
2.31.1
76
95
77
96
diff view generated by jsdifflib
1
From: Stefan Hajnoczi <stefanha@redhat.com>
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
2
3
Fixes: a6b257a08e3d72219f03e461a52152672fec0612
3
Due to a typo, in this case the SOCK_DIR was not being created.
4
("file-posix: Handle undetectable alignment")
4
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
6
Message-id: 20190827101328.4062-1-stefanha@redhat.com
6
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7
Reviewed-by: Thomas Huth <thuth@redhat.com>
7
Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
8
Message-Id: <20210323181928.311862-6-pbonzini@redhat.com>
9
Message-Id: <20210503110110.476887-6-pbonzini@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
11
---
10
block/file-posix.c | 2 +-
12
tests/qemu-iotests/testenv.py | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
13
1 file changed, 1 insertion(+), 1 deletion(-)
12
14
13
diff --git a/block/file-posix.c b/block/file-posix.c
15
diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/block/file-posix.c
17
--- a/tests/qemu-iotests/testenv.py
16
+++ b/block/file-posix.c
18
+++ b/tests/qemu-iotests/testenv.py
17
@@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
19
@@ -XXX,XX +XXX,XX @@ def init_directories(self) -> None:
18
for (i = 0; i < ARRAY_SIZE(alignments); i++) {
20
try:
19
align = alignments[i];
21
self.sock_dir = os.environ['SOCK_DIR']
20
if (raw_is_io_aligned(fd, buf + align, max_align)) {
22
self.tmp_sock_dir = False
21
- /* Fallback to request_aligment. */
23
- Path(self.test_dir).mkdir(parents=True, exist_ok=True)
22
+ /* Fallback to request_alignment. */
24
+ Path(self.sock_dir).mkdir(parents=True, exist_ok=True)
23
s->buf_align = (align != 1) ? align : bs->bl.request_alignment;
25
except KeyError:
24
break;
26
self.sock_dir = tempfile.mkdtemp()
25
}
27
self.tmp_sock_dir = True
26
--
28
--
27
2.21.0
29
2.31.1
28
30
29
31
diff view generated by jsdifflib
1
iotest 126 requires backing file support, which flat vmdks cannot offer.
1
From: Connor Kuehl <ckuehl@redhat.com>
2
Skip this test for such subformats.
3
2
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
The contents of this patch were initially developed and posted by Han
5
Message-id: 20190815153638.4600-8-mreitz@redhat.com
4
Han[1], however, it appears the original patch was not applied. Since
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
then, the relevant documentation has been moved and adapted to a new
6
format.
7
8
I've taken most of the original wording and tweaked it according to
9
some of the feedback from the original patch submission. I've also
10
adapted it to restructured text, which is the format the documentation
11
currently uses.
12
13
[1] https://lists.nongnu.org/archive/html/qemu-block/2019-10/msg01253.html
14
15
Fixes: https://bugzilla.redhat.com/1763105
16
Signed-off-by: Han Han <hhan@redhat.com>
17
Suggested-by: Max Reitz <mreitz@redhat.com>
18
[ Max: provided description of data_file_raw behavior ]
19
Signed-off-by: Connor Kuehl <ckuehl@redhat.com>
20
Message-Id: <20210505195512.391128-1-ckuehl@redhat.com>
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
---
22
---
9
tests/qemu-iotests/126 | 2 ++
23
docs/tools/qemu-img.rst | 31 +++++++++++++++++++++++++++++++
10
1 file changed, 2 insertions(+)
24
1 file changed, 31 insertions(+)
11
25
12
diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
26
diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
13
index XXXXXXX..XXXXXXX 100755
27
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/qemu-iotests/126
28
--- a/docs/tools/qemu-img.rst
15
+++ b/tests/qemu-iotests/126
29
+++ b/docs/tools/qemu-img.rst
16
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
30
@@ -XXX,XX +XXX,XX @@ Supported image file formats:
17
31
issue ``lsattr filename`` to check if the NOCOW flag is set or not
18
# Needs backing file support
32
(Capital 'C' is NOCOW flag).
19
_supported_fmt qcow qcow2 qed vmdk
33
20
+_unsupported_imgopts "subformat=monolithicFlat" \
34
+ ``data_file``
21
+ "subformat=twoGbMaxExtentFlat"
35
+ Filename where all guest data will be stored. If this option is used,
22
# This is the default protocol (and we want to test the difference between
36
+ the qcow2 file will only contain the image's metadata.
23
# colons which separate a protocol prefix from the rest and colons which are
37
+
24
# just part of the filename, so we cannot test protocols which require a prefix)
38
+ Note: Data loss will occur if the given filename already exists when
39
+ using this option with ``qemu-img create`` since ``qemu-img`` will create
40
+ the data file anew, overwriting the file's original contents. To simply
41
+ update the reference to point to the given pre-existing file, use
42
+ ``qemu-img amend``.
43
+
44
+ ``data_file_raw``
45
+ If this option is set to ``on``, QEMU will always keep the external data
46
+ file consistent as a standalone read-only raw image.
47
+
48
+ It does this by forwarding all write accesses to the qcow2 file through to
49
+ the raw data file, including their offsets. Therefore, data that is visible
50
+ on the qcow2 node (i.e., to the guest) at some offset is visible at the same
51
+ offset in the raw data file. This results in a read-only raw image. Writes
52
+ that bypass the qcow2 metadata may corrupt the qcow2 metadata because the
53
+ out-of-band writes may result in the metadata falling out of sync with the
54
+ raw image.
55
+
56
+ If this option is ``off``, QEMU will use the data file to store data in an
57
+ arbitrary manner. The file’s content will not make sense without the
58
+ accompanying qcow2 metadata. Where data is written will have no relation to
59
+ its offset as seen by the guest, and some writes (specifically zero writes)
60
+ may not be forwarded to the data file at all, but will only be handled by
61
+ modifying qcow2 metadata.
62
+
63
+ This option can only be enabled if ``data_file`` is set.
64
+
65
``Other``
66
67
QEMU also supports various other image file formats for
25
--
68
--
26
2.21.0
69
2.31.1
27
70
28
71
diff view generated by jsdifflib
1
streamOptimized does not support writes that do not span exactly one
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
cluster. Furthermore, it cannot rewrite already allocated clusters.
3
As such, many iotests do not work with it. Disable them.
4
2
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
Now, after huge update of block graph permission update algorithm, we
6
Message-id: 20190815153638.4600-6-mreitz@redhat.com
4
don't need this workaround with active state of the filter. Drop it and
7
Reviewed-by: John Snow <jsnow@redhat.com>
5
use new smart bdrv_drop_filter() function.
6
7
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Message-Id: <20210506194143.394141-1-vsementsov@virtuozzo.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
---
10
tests/qemu-iotests/002 | 1 +
11
block/copy-on-read.c | 33 +--------------------------------
11
tests/qemu-iotests/003 | 1 +
12
1 file changed, 1 insertion(+), 32 deletions(-)
12
tests/qemu-iotests/005 | 3 ++-
13
tests/qemu-iotests/009 | 1 +
14
tests/qemu-iotests/010 | 1 +
15
tests/qemu-iotests/011 | 1 +
16
tests/qemu-iotests/017 | 3 ++-
17
tests/qemu-iotests/018 | 3 ++-
18
tests/qemu-iotests/019 | 3 ++-
19
tests/qemu-iotests/020 | 3 ++-
20
tests/qemu-iotests/027 | 1 +
21
tests/qemu-iotests/032 | 1 +
22
tests/qemu-iotests/033 | 1 +
23
tests/qemu-iotests/034 | 3 ++-
24
tests/qemu-iotests/037 | 3 ++-
25
tests/qemu-iotests/063 | 3 ++-
26
tests/qemu-iotests/072 | 1 +
27
tests/qemu-iotests/105 | 3 ++-
28
tests/qemu-iotests/197 | 1 +
29
tests/qemu-iotests/215 | 1 +
30
tests/qemu-iotests/251 | 1 +
31
21 files changed, 30 insertions(+), 9 deletions(-)
32
13
33
diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002
14
diff --git a/block/copy-on-read.c b/block/copy-on-read.c
34
index XXXXXXX..XXXXXXX 100755
15
index XXXXXXX..XXXXXXX 100644
35
--- a/tests/qemu-iotests/002
16
--- a/block/copy-on-read.c
36
+++ b/tests/qemu-iotests/002
17
+++ b/block/copy-on-read.c
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
18
@@ -XXX,XX +XXX,XX @@
38
19
39
_supported_fmt generic
20
40
_supported_proto generic
21
typedef struct BDRVStateCOR {
41
+_unsupported_imgopts "subformat=streamOptimized"
22
- bool active;
42
23
BlockDriverState *bottom_bs;
43
24
bool chain_frozen;
44
size=128M
25
} BDRVStateCOR;
45
diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003
26
@@ -XXX,XX +XXX,XX @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags,
46
index XXXXXXX..XXXXXXX 100755
27
*/
47
--- a/tests/qemu-iotests/003
28
bdrv_ref(bottom_bs);
48
+++ b/tests/qemu-iotests/003
29
}
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
30
- state->active = true;
50
31
state->bottom_bs = bottom_bs;
51
_supported_fmt generic
32
52
_supported_proto generic
33
/*
53
+_unsupported_imgopts "subformat=streamOptimized"
34
@@ -XXX,XX +XXX,XX @@ static void cor_child_perm(BlockDriverState *bs, BdrvChild *c,
54
35
uint64_t perm, uint64_t shared,
55
size=128M
36
uint64_t *nperm, uint64_t *nshared)
56
offset=67M
37
{
57
diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005
38
- BDRVStateCOR *s = bs->opaque;
58
index XXXXXXX..XXXXXXX 100755
39
-
59
--- a/tests/qemu-iotests/005
40
- if (!s->active) {
60
+++ b/tests/qemu-iotests/005
41
- /*
61
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
42
- * While the filter is being removed
62
_supported_proto generic
43
- */
63
_supported_os Linux
44
- *nperm = 0;
64
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
45
- *nshared = BLK_PERM_ALL;
65
- "subformat=twoGbMaxExtentSparse"
46
- return;
66
+ "subformat=twoGbMaxExtentSparse" \
47
- }
67
+ "subformat=streamOptimized"
48
-
68
49
*nperm = perm & PERM_PASSTHROUGH;
69
# vpc is limited to 127GB, so we can't test it here
50
*nshared = (shared & PERM_PASSTHROUGH) | PERM_UNCHANGED;
70
if [ "$IMGFMT" = "vpc" ]; then
51
71
diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009
52
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_copy_on_read = {
72
index XXXXXXX..XXXXXXX 100755
53
73
--- a/tests/qemu-iotests/009
54
void bdrv_cor_filter_drop(BlockDriverState *cor_filter_bs)
74
+++ b/tests/qemu-iotests/009
55
{
75
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
56
- BdrvChild *child;
76
57
- BlockDriverState *bs;
77
_supported_fmt generic
58
BDRVStateCOR *s = cor_filter_bs->opaque;
78
_supported_proto generic
59
79
+_unsupported_imgopts "subformat=streamOptimized"
60
- child = bdrv_filter_child(cor_filter_bs);
80
61
- if (!child) {
81
62
- return;
82
size=6G
63
- }
83
diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010
64
- bs = child->bs;
84
index XXXXXXX..XXXXXXX 100755
65
-
85
--- a/tests/qemu-iotests/010
66
- /* Retain the BDS until we complete the graph change. */
86
+++ b/tests/qemu-iotests/010
67
- bdrv_ref(bs);
87
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
68
- /* Hold a guest back from writing while permissions are being reset. */
88
69
- bdrv_drained_begin(bs);
89
_supported_fmt generic
70
- /* Drop permissions before the graph change. */
90
_supported_proto generic
71
- s->active = false;
91
+_unsupported_imgopts "subformat=streamOptimized"
72
/* unfreeze, as otherwise bdrv_replace_node() will fail */
92
73
if (s->chain_frozen) {
93
74
s->chain_frozen = false;
94
size=6G
75
bdrv_unfreeze_backing_chain(cor_filter_bs, s->bottom_bs);
95
diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011
76
}
96
index XXXXXXX..XXXXXXX 100755
77
- bdrv_child_refresh_perms(cor_filter_bs, child, &error_abort);
97
--- a/tests/qemu-iotests/011
78
- bdrv_replace_node(cor_filter_bs, bs, &error_abort);
98
+++ b/tests/qemu-iotests/011
79
-
99
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
80
- bdrv_drained_end(bs);
100
81
- bdrv_unref(bs);
101
_supported_fmt generic
82
+ bdrv_drop_filter(cor_filter_bs, &error_abort);
102
_supported_proto generic
83
bdrv_unref(cor_filter_bs);
103
+_unsupported_imgopts "subformat=streamOptimized"
84
}
104
85
105
106
size=6G
107
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
108
index XXXXXXX..XXXXXXX 100755
109
--- a/tests/qemu-iotests/017
110
+++ b/tests/qemu-iotests/017
111
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
112
_supported_fmt qcow qcow2 vmdk qed
113
_supported_proto generic
114
_unsupported_proto vxhs
115
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
116
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
117
+ "subformat=streamOptimized"
118
119
TEST_OFFSETS="0 4294967296"
120
121
diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018
122
index XXXXXXX..XXXXXXX 100755
123
--- a/tests/qemu-iotests/018
124
+++ b/tests/qemu-iotests/018
125
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
126
_supported_fmt qcow qcow2 vmdk qed
127
_supported_proto file
128
_supported_os Linux
129
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
130
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
131
+ "streamOptimized"
132
133
TEST_OFFSETS="0 4294967296"
134
135
diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
136
index XXXXXXX..XXXXXXX 100755
137
--- a/tests/qemu-iotests/019
138
+++ b/tests/qemu-iotests/019
139
@@ -XXX,XX +XXX,XX @@ _supported_proto file
140
_supported_os Linux
141
_unsupported_imgopts "subformat=monolithicFlat" \
142
"subformat=twoGbMaxExtentFlat" \
143
- "subformat=twoGbMaxExtentSparse"
144
+ "subformat=twoGbMaxExtentSparse" \
145
+ "subformat=streamOptimized"
146
147
TEST_OFFSETS="0 4294967296"
148
CLUSTER_SIZE=65536
149
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
150
index XXXXXXX..XXXXXXX 100755
151
--- a/tests/qemu-iotests/020
152
+++ b/tests/qemu-iotests/020
153
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
154
_supported_proto file
155
_unsupported_imgopts "subformat=monolithicFlat" \
156
"subformat=twoGbMaxExtentFlat" \
157
- "subformat=twoGbMaxExtentSparse"
158
+ "subformat=twoGbMaxExtentSparse" \
159
+ "subformat=streamOptimized"
160
161
TEST_OFFSETS="0 4294967296"
162
163
diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027
164
index XXXXXXX..XXXXXXX 100755
165
--- a/tests/qemu-iotests/027
166
+++ b/tests/qemu-iotests/027
167
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
168
169
_supported_fmt vmdk qcow qcow2 qed
170
_supported_proto generic
171
+_unsupported_imgopts "subformat=streamOptimized"
172
173
174
size=128M
175
diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032
176
index XXXXXXX..XXXXXXX 100755
177
--- a/tests/qemu-iotests/032
178
+++ b/tests/qemu-iotests/032
179
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
180
# This works for any image format (though unlikely to segfault for raw)
181
_supported_fmt generic
182
_supported_proto generic
183
+_unsupported_imgopts "subformat=streamOptimized"
184
185
echo
186
echo === Prepare image ===
187
diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033
188
index XXXXXXX..XXXXXXX 100755
189
--- a/tests/qemu-iotests/033
190
+++ b/tests/qemu-iotests/033
191
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
192
193
_supported_fmt generic
194
_supported_proto generic
195
+_unsupported_imgopts "subformat=streamOptimized"
196
197
198
size=128M
199
diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034
200
index XXXXXXX..XXXXXXX 100755
201
--- a/tests/qemu-iotests/034
202
+++ b/tests/qemu-iotests/034
203
@@ -XXX,XX +XXX,XX @@ _supported_proto file
204
_supported_os Linux
205
_unsupported_imgopts "subformat=monolithicFlat" \
206
"subformat=twoGbMaxExtentFlat" \
207
- "subformat=twoGbMaxExtentSparse"
208
+ "subformat=twoGbMaxExtentSparse" \
209
+ "subformat=streamOptimized"
210
211
CLUSTER_SIZE=4k
212
size=128M
213
diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037
214
index XXXXXXX..XXXXXXX 100755
215
--- a/tests/qemu-iotests/037
216
+++ b/tests/qemu-iotests/037
217
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
218
_supported_proto file
219
_unsupported_imgopts "subformat=monolithicFlat" \
220
"subformat=twoGbMaxExtentFlat" \
221
- "subformat=twoGbMaxExtentSparse"
222
+ "subformat=twoGbMaxExtentSparse" \
223
+ "subformat=streamOptimized"
224
225
CLUSTER_SIZE=4k
226
size=128M
227
diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
228
index XXXXXXX..XXXXXXX 100755
229
--- a/tests/qemu-iotests/063
230
+++ b/tests/qemu-iotests/063
231
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed raw
232
_supported_proto file
233
_unsupported_imgopts "subformat=monolithicFlat" \
234
"subformat=twoGbMaxExtentFlat" \
235
- "subformat=twoGbMaxExtentSparse"
236
+ "subformat=twoGbMaxExtentSparse" \
237
+ "subformat=streamOptimized"
238
239
_make_test_img 4M
240
241
diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072
242
index XXXXXXX..XXXXXXX 100755
243
--- a/tests/qemu-iotests/072
244
+++ b/tests/qemu-iotests/072
245
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
246
247
_supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow
248
_supported_proto file
249
+_unsupported_imgopts "subformat=streamOptimized"
250
251
IMG_SIZE=64M
252
253
diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105
254
index XXXXXXX..XXXXXXX 100755
255
--- a/tests/qemu-iotests/105
256
+++ b/tests/qemu-iotests/105
257
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
258
_supported_fmt qcow2 vmdk vhdx qed
259
_supported_proto generic
260
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
261
- "subformat=twoGbMaxExtentSparse"
262
+ "subformat=twoGbMaxExtentSparse" \
263
+ "subformat=streamOptimized"
264
265
echo
266
echo "creating large image"
267
diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197
268
index XXXXXXX..XXXXXXX 100755
269
--- a/tests/qemu-iotests/197
270
+++ b/tests/qemu-iotests/197
271
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
272
_supported_proto generic
273
# LUKS support may be possible, but it complicates things.
274
_unsupported_fmt luks
275
+_unsupported_imgopts "subformat=streamOptimized"
276
277
echo
278
echo '=== Copy-on-read ==='
279
diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215
280
index XXXXXXX..XXXXXXX 100755
281
--- a/tests/qemu-iotests/215
282
+++ b/tests/qemu-iotests/215
283
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
284
_supported_proto generic
285
# LUKS support may be possible, but it complicates things.
286
_unsupported_fmt luks
287
+_unsupported_imgopts "subformat=streamOptimized"
288
289
echo
290
echo '=== Copy-on-read ==='
291
diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251
292
index XXXXXXX..XXXXXXX 100755
293
--- a/tests/qemu-iotests/251
294
+++ b/tests/qemu-iotests/251
295
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
296
_supported_fmt generic
297
_supported_proto file
298
_supported_os Linux
299
+_unsupported_imgopts "subformat=streamOptimized"
300
301
if [ "$IMGOPTSSYNTAX" = "true" ]; then
302
# We use json:{} filenames here, so we cannot work with additional options.
303
--
86
--
304
2.21.0
87
2.31.1
305
88
306
89
diff view generated by jsdifflib
1
Compressed writes generally have to write full clusters, not just in
1
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
2
theory but also in practice when it comes to vmdk's streamOptimized
3
subformat. It currently is just silently broken for writes with
4
non-zero in-cluster offsets:
5
2
6
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
3
pylint 2.8 introduces consider-using-with error, suggesting
7
$ qemu-io -c 'write 4k 4k' -c 'read 4k 4k' foo.vmdk
4
to use the 'with' block statement when possible.
8
wrote 4096/4096 bytes at offset 4096
9
4 KiB, 1 ops; 00.01 sec (443.724 KiB/sec and 110.9309 ops/sec)
10
read failed: Invalid argument
11
5
12
(The technical reason is that vmdk_write_extent() just writes the
6
Modify all subprocess.Popen call to use the 'with' statement,
13
incomplete compressed data actually to offset 4k. When reading the
7
except the one in __init__ of QemuIoInteractive class, since
14
data, vmdk_read_extent() looks at offset 0 and finds the compressed data
8
it is assigned to a class field and used in other methods.
15
size to be 0, because that is what it reads from there. This yields an
16
error.)
17
9
18
For incomplete writes with zero in-cluster offsets, the error path when
10
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
19
reading the rest of the cluster is a bit different, but the result is
11
Message-Id: <20210510190449.65948-1-eesposit@redhat.com>
20
the same:
12
[mreitz: Disable bad-option-value warning in the iotests' pylintrc, so
21
13
that disabling consider-using-with in QemuIoInteractive will
22
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
14
not produce a warning in pre-2.8 pylint versions]
23
$ qemu-io -c 'write 0k 4k' -c 'read 4k 4k' foo.vmdk
24
wrote 4096/4096 bytes at offset 0
25
4 KiB, 1 ops; 00.01 sec (362.641 KiB/sec and 90.6603 ops/sec)
26
read failed: Invalid argument
27
28
(Here, vmdk_read_extent() finds the data and then sees that the
29
uncompressed data is short.)
30
31
It is better to reject invalid writes than to make the user believe they
32
might have succeeded and then fail when trying to read it back.
33
34
Signed-off-by: Max Reitz <mreitz@redhat.com>
35
Reviewed-by: John Snow <jsnow@redhat.com>
36
Message-id: 20190815153638.4600-5-mreitz@redhat.com
37
Reviewed-by: John Snow <jsnow@redhat.com>
38
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
39
---
16
---
40
block/vmdk.c | 10 ++++++++++
17
tests/qemu-iotests/iotests.py | 65 ++++++++++++++++----------------
41
1 file changed, 10 insertions(+)
18
tests/qemu-iotests/pylintrc | 3 ++
19
tests/qemu-iotests/testrunner.py | 22 +++++------
20
3 files changed, 47 insertions(+), 43 deletions(-)
42
21
43
diff --git a/block/vmdk.c b/block/vmdk.c
22
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
44
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
45
--- a/block/vmdk.c
24
--- a/tests/qemu-iotests/iotests.py
46
+++ b/block/vmdk.c
25
+++ b/tests/qemu-iotests/iotests.py
47
@@ -XXX,XX +XXX,XX @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset,
26
@@ -XXX,XX +XXX,XX @@ def qemu_tool_pipe_and_status(tool: str, args: Sequence[str],
48
if (extent->compressed) {
27
Run a tool and return both its output and its exit code
49
void *compressed_data;
28
"""
50
29
stderr = subprocess.STDOUT if connect_stderr else None
51
+ /* Only whole clusters */
30
- subp = subprocess.Popen(args,
52
+ if (offset_in_cluster ||
31
- stdout=subprocess.PIPE,
53
+ n_bytes > (extent->cluster_sectors * SECTOR_SIZE) ||
32
- stderr=stderr,
54
+ (n_bytes < (extent->cluster_sectors * SECTOR_SIZE) &&
33
- universal_newlines=True)
55
+ offset + n_bytes != extent->end_sector * SECTOR_SIZE))
34
- output = subp.communicate()[0]
56
+ {
35
- if subp.returncode < 0:
57
+ ret = -EINVAL;
36
- cmd = ' '.join(args)
58
+ goto out;
37
- sys.stderr.write(f'{tool} received signal {-subp.returncode}: {cmd}\n')
59
+ }
38
- return (output, subp.returncode)
39
+ with subprocess.Popen(args, stdout=subprocess.PIPE,
40
+ stderr=stderr, universal_newlines=True) as subp:
41
+ output = subp.communicate()[0]
42
+ if subp.returncode < 0:
43
+ cmd = ' '.join(args)
44
+ sys.stderr.write(f'{tool} received signal \
45
+ {-subp.returncode}: {cmd}\n')
46
+ return (output, subp.returncode)
47
48
def qemu_img_pipe_and_status(*args: str) -> Tuple[str, int]:
49
"""
50
@@ -XXX,XX +XXX,XX @@ def qemu_io_silent_check(*args):
51
class QemuIoInteractive:
52
def __init__(self, *args):
53
self.args = qemu_io_args_no_fmt + list(args)
54
+ # We need to keep the Popen objext around, and not
55
+ # close it immediately. Therefore, disable the pylint check:
56
+ # pylint: disable=consider-using-with
57
self._p = subprocess.Popen(self.args, stdin=subprocess.PIPE,
58
stdout=subprocess.PIPE,
59
stderr=subprocess.STDOUT,
60
@@ -XXX,XX +XXX,XX @@ def qemu_nbd_popen(*args):
61
cmd.extend(args)
62
63
log('Start NBD server')
64
- p = subprocess.Popen(cmd)
65
- try:
66
- while not os.path.exists(pid_file):
67
- if p.poll() is not None:
68
- raise RuntimeError(
69
- "qemu-nbd terminated with exit code {}: {}"
70
- .format(p.returncode, ' '.join(cmd)))
71
-
72
- time.sleep(0.01)
73
- yield
74
- finally:
75
- if os.path.exists(pid_file):
76
- os.remove(pid_file)
77
- log('Kill NBD server')
78
- p.kill()
79
- p.wait()
80
+ with subprocess.Popen(cmd) as p:
81
+ try:
82
+ while not os.path.exists(pid_file):
83
+ if p.poll() is not None:
84
+ raise RuntimeError(
85
+ "qemu-nbd terminated with exit code {}: {}"
86
+ .format(p.returncode, ' '.join(cmd)))
60
+
87
+
61
if (!extent->has_marker) {
88
+ time.sleep(0.01)
62
ret = -EINVAL;
89
+ yield
63
goto out;
90
+ finally:
91
+ if os.path.exists(pid_file):
92
+ os.remove(pid_file)
93
+ log('Kill NBD server')
94
+ p.kill()
95
+ p.wait()
96
97
def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt):
98
'''Return True if two image files are identical'''
99
@@ -XXX,XX +XXX,XX @@ def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt):
100
101
def create_image(name, size):
102
'''Create a fully-allocated raw image with sector markers'''
103
- file = open(name, 'wb')
104
- i = 0
105
- while i < size:
106
- sector = struct.pack('>l504xl', i // 512, i // 512)
107
- file.write(sector)
108
- i = i + 512
109
- file.close()
110
+ with open(name, 'wb') as file:
111
+ i = 0
112
+ while i < size:
113
+ sector = struct.pack('>l504xl', i // 512, i // 512)
114
+ file.write(sector)
115
+ i = i + 512
116
117
def image_size(img):
118
'''Return image's virtual size'''
119
diff --git a/tests/qemu-iotests/pylintrc b/tests/qemu-iotests/pylintrc
120
index XXXXXXX..XXXXXXX 100644
121
--- a/tests/qemu-iotests/pylintrc
122
+++ b/tests/qemu-iotests/pylintrc
123
@@ -XXX,XX +XXX,XX @@ disable=invalid-name,
124
too-many-public-methods,
125
# pylint warns about Optional[] etc. as unsubscriptable in 3.9
126
unsubscriptable-object,
127
+ # Sometimes we need to disable a newly introduced pylint warning.
128
+ # Doing so should not produce a warning in older versions of pylint.
129
+ bad-option-value,
130
# These are temporary, and should be removed:
131
missing-docstring,
132
too-many-return-statements,
133
diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
134
index XXXXXXX..XXXXXXX 100644
135
--- a/tests/qemu-iotests/testrunner.py
136
+++ b/tests/qemu-iotests/testrunner.py
137
@@ -XXX,XX +XXX,XX @@ def do_run_test(self, test: str) -> TestResult:
138
139
t0 = time.time()
140
with f_bad.open('w', encoding="utf-8") as f:
141
- proc = subprocess.Popen(args, cwd=str(f_test.parent), env=env,
142
- stdout=f, stderr=subprocess.STDOUT)
143
- try:
144
- proc.wait()
145
- except KeyboardInterrupt:
146
- proc.terminate()
147
- proc.wait()
148
- return TestResult(status='not run',
149
- description='Interrupted by user',
150
- interrupted=True)
151
- ret = proc.returncode
152
+ with subprocess.Popen(args, cwd=str(f_test.parent), env=env,
153
+ stdout=f, stderr=subprocess.STDOUT) as proc:
154
+ try:
155
+ proc.wait()
156
+ except KeyboardInterrupt:
157
+ proc.terminate()
158
+ proc.wait()
159
+ return TestResult(status='not run',
160
+ description='Interrupted by user',
161
+ interrupted=True)
162
+ ret = proc.returncode
163
164
elapsed = round(time.time() - t0, 1)
165
64
--
166
--
65
2.21.0
167
2.31.1
66
168
67
169
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
It is possible to enable only a subset of the block drivers with the
3
write-notifiers are used only for write-threshold. New code for such
4
"--block-drv-rw-whitelist" option of the "configure" script. All other
4
purpose should create filters.
5
drivers are marked as unusable (or only included as read-only with the
6
"--block-drv-ro-whitelist" option). If an iotest is now using such a
7
disabled block driver, it is failing - which is bad, since at least the
8
tests in the "auto" group should be able to deal with this situation.
9
Thus let's introduce a "_require_drivers" function that can be used by
10
the shell tests to check for the availability of certain drivers first,
11
and marks the test as "not run" if one of the drivers is missing.
12
5
13
This patch mainly targets the test in the "auto" group which should
6
Let's better special-case write-threshold and drop write notifiers at
14
never fail in such a case, but also improves some of the other tests
7
all. (Actually, write-threshold is special-cased anyway, as the only
15
along the way. Note that we also assume that the "qcow2" and "file"
8
user of write-notifiers)
16
drivers are always available - otherwise it does not make sense to
17
run "make check-block" at all (which only tests with qcow2 by default).
18
9
19
Signed-off-by: Thomas Huth <thuth@redhat.com>
10
So, create a new direct interface for bdrv_co_write_req_prepare() and
20
Message-id: 20190823133552.11680-1-thuth@redhat.com
11
drop all write-notifier related logic from write-threshold.c.
12
13
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
14
Reviewed-by: Max Reitz <mreitz@redhat.com>
15
Message-Id: <20210506090621.11848-2-vsementsov@virtuozzo.com>
16
Reviewed-by: Eric Blake <eblake@redhat.com>
17
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
18
[mreitz: Adjusted comment as per Eric's suggestion]
21
Signed-off-by: Max Reitz <mreitz@redhat.com>
19
Signed-off-by: Max Reitz <mreitz@redhat.com>
22
---
20
---
23
tests/qemu-iotests/071 | 1 +
21
include/block/block_int.h | 1 -
24
tests/qemu-iotests/081 | 4 +---
22
include/block/write-threshold.h | 9 +++++
25
tests/qemu-iotests/099 | 1 +
23
block/io.c | 5 ++-
26
tests/qemu-iotests/120 | 1 +
24
block/write-threshold.c | 70 +++++++--------------------------
27
tests/qemu-iotests/162 | 4 +---
25
4 files changed, 27 insertions(+), 58 deletions(-)
28
tests/qemu-iotests/184 | 1 +
29
tests/qemu-iotests/186 | 1 +
30
tests/qemu-iotests/common.rc | 14 ++++++++++++++
31
8 files changed, 21 insertions(+), 6 deletions(-)
32
26
33
diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071
27
diff --git a/include/block/block_int.h b/include/block/block_int.h
34
index XXXXXXX..XXXXXXX 100755
28
index XXXXXXX..XXXXXXX 100644
35
--- a/tests/qemu-iotests/071
29
--- a/include/block/block_int.h
36
+++ b/tests/qemu-iotests/071
30
+++ b/include/block/block_int.h
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
31
@@ -XXX,XX +XXX,XX @@ struct BlockDriverState {
38
32
39
_supported_fmt qcow2
33
/* threshold limit for writes, in bytes. "High water mark". */
40
_supported_proto file
34
uint64_t write_threshold_offset;
41
+_require_drivers blkdebug blkverify
35
- NotifierWithReturn write_threshold_notifier;
42
36
43
do_run_qemu()
37
/* Writing to the list requires the BQL _and_ the dirty_bitmap_mutex.
38
* Reading from the list can be done with either the BQL or the
39
diff --git a/include/block/write-threshold.h b/include/block/write-threshold.h
40
index XXXXXXX..XXXXXXX 100644
41
--- a/include/block/write-threshold.h
42
+++ b/include/block/write-threshold.h
43
@@ -XXX,XX +XXX,XX @@ bool bdrv_write_threshold_is_set(const BlockDriverState *bs);
44
uint64_t bdrv_write_threshold_exceeded(const BlockDriverState *bs,
45
const BdrvTrackedRequest *req);
46
47
+/*
48
+ * bdrv_write_threshold_check_write
49
+ *
50
+ * Check whether the specified request exceeds the write threshold.
51
+ * If so, send a corresponding event and disable write threshold checking.
52
+ */
53
+void bdrv_write_threshold_check_write(BlockDriverState *bs, int64_t offset,
54
+ int64_t bytes);
55
+
56
#endif
57
diff --git a/block/io.c b/block/io.c
58
index XXXXXXX..XXXXXXX 100644
59
--- a/block/io.c
60
+++ b/block/io.c
61
@@ -XXX,XX +XXX,XX @@
62
#include "block/blockjob_int.h"
63
#include "block/block_int.h"
64
#include "block/coroutines.h"
65
+#include "block/write-threshold.h"
66
#include "qemu/cutils.h"
67
#include "qapi/error.h"
68
#include "qemu/error-report.h"
69
@@ -XXX,XX +XXX,XX @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, int64_t bytes,
70
} else {
71
assert(child->perm & BLK_PERM_WRITE);
72
}
73
- return notifier_with_return_list_notify(&bs->before_write_notifiers,
74
- req);
75
+ bdrv_write_threshold_check_write(bs, offset, bytes);
76
+ return 0;
77
case BDRV_TRACKED_TRUNCATE:
78
assert(child->perm & BLK_PERM_RESIZE);
79
return 0;
80
diff --git a/block/write-threshold.c b/block/write-threshold.c
81
index XXXXXXX..XXXXXXX 100644
82
--- a/block/write-threshold.c
83
+++ b/block/write-threshold.c
84
@@ -XXX,XX +XXX,XX @@ bool bdrv_write_threshold_is_set(const BlockDriverState *bs)
85
return bs->write_threshold_offset > 0;
86
}
87
88
-static void write_threshold_disable(BlockDriverState *bs)
89
-{
90
- if (bdrv_write_threshold_is_set(bs)) {
91
- notifier_with_return_remove(&bs->write_threshold_notifier);
92
- bs->write_threshold_offset = 0;
93
- }
94
-}
95
-
96
uint64_t bdrv_write_threshold_exceeded(const BlockDriverState *bs,
97
const BdrvTrackedRequest *req)
44
{
98
{
45
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
99
@@ -XXX,XX +XXX,XX @@ uint64_t bdrv_write_threshold_exceeded(const BlockDriverState *bs,
46
index XXXXXXX..XXXXXXX 100755
100
return 0;
47
--- a/tests/qemu-iotests/081
101
}
48
+++ b/tests/qemu-iotests/081
102
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
103
-static int coroutine_fn before_write_notify(NotifierWithReturn *notifier,
50
_supported_fmt raw
104
- void *opaque)
51
_supported_proto file
105
-{
52
_supported_os Linux
106
- BdrvTrackedRequest *req = opaque;
53
+_require_drivers quorum
107
- BlockDriverState *bs = req->bs;
54
108
- uint64_t amount = 0;
55
do_run_qemu()
109
-
110
- amount = bdrv_write_threshold_exceeded(bs, req);
111
- if (amount > 0) {
112
- qapi_event_send_block_write_threshold(
113
- bs->node_name,
114
- amount,
115
- bs->write_threshold_offset);
116
-
117
- /* autodisable to avoid flooding the monitor */
118
- write_threshold_disable(bs);
119
- }
120
-
121
- return 0; /* should always let other notifiers run */
122
-}
123
-
124
-static void write_threshold_register_notifier(BlockDriverState *bs)
125
-{
126
- bs->write_threshold_notifier.notify = before_write_notify;
127
- bdrv_add_before_write_notifier(bs, &bs->write_threshold_notifier);
128
-}
129
-
130
-static void write_threshold_update(BlockDriverState *bs,
131
- int64_t threshold_bytes)
132
-{
133
- bs->write_threshold_offset = threshold_bytes;
134
-}
135
-
136
void bdrv_write_threshold_set(BlockDriverState *bs, uint64_t threshold_bytes)
56
{
137
{
57
@@ -XXX,XX +XXX,XX @@ run_qemu()
138
- if (bdrv_write_threshold_is_set(bs)) {
58
| _filter_qemu_io | _filter_generated_node_ids
139
- if (threshold_bytes > 0) {
140
- write_threshold_update(bs, threshold_bytes);
141
- } else {
142
- write_threshold_disable(bs);
143
- }
144
- } else {
145
- if (threshold_bytes > 0) {
146
- /* avoid multiple registration */
147
- write_threshold_register_notifier(bs);
148
- write_threshold_update(bs, threshold_bytes);
149
- }
150
- /* discard bogus disable request */
151
- }
152
+ bs->write_threshold_offset = threshold_bytes;
59
}
153
}
60
154
61
-test_quorum=$($QEMU_IMG --help|grep quorum)
155
void qmp_block_set_write_threshold(const char *node_name,
62
-[ "$test_quorum" = "" ] && _supported_fmt quorum
156
@@ -XXX,XX +XXX,XX @@ void qmp_block_set_write_threshold(const char *node_name,
63
-
157
64
quorum="driver=raw,file.driver=quorum,file.vote-threshold=2"
158
aio_context_release(aio_context);
65
quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw"
66
quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw"
67
diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099
68
index XXXXXXX..XXXXXXX 100755
69
--- a/tests/qemu-iotests/099
70
+++ b/tests/qemu-iotests/099
71
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
72
_supported_fmt qcow qcow2 qed vdi vhdx vmdk vpc
73
_supported_proto file
74
_supported_os Linux
75
+_require_drivers blkdebug blkverify
76
_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
77
"subformat=twoGbMaxExtentSparse"
78
79
diff --git a/tests/qemu-iotests/120 b/tests/qemu-iotests/120
80
index XXXXXXX..XXXXXXX 100755
81
--- a/tests/qemu-iotests/120
82
+++ b/tests/qemu-iotests/120
83
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
84
_supported_fmt generic
85
_supported_proto file
86
_unsupported_fmt luks
87
+_require_drivers raw
88
89
_make_test_img 64M
90
91
diff --git a/tests/qemu-iotests/162 b/tests/qemu-iotests/162
92
index XXXXXXX..XXXXXXX 100755
93
--- a/tests/qemu-iotests/162
94
+++ b/tests/qemu-iotests/162
95
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
96
. ./common.filter
97
98
_supported_fmt generic
99
-
100
-test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)')
101
-[ "$test_ssh" = "" ] && _notrun "ssh support required"
102
+_require_drivers ssh
103
104
echo
105
echo '=== NBD ==='
106
diff --git a/tests/qemu-iotests/184 b/tests/qemu-iotests/184
107
index XXXXXXX..XXXXXXX 100755
108
--- a/tests/qemu-iotests/184
109
+++ b/tests/qemu-iotests/184
110
@@ -XXX,XX +XXX,XX @@ trap "exit \$status" 0 1 2 3 15
111
. ./common.filter
112
113
_supported_os Linux
114
+_require_drivers throttle
115
116
do_run_qemu()
117
{
118
diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186
119
index XXXXXXX..XXXXXXX 100755
120
--- a/tests/qemu-iotests/186
121
+++ b/tests/qemu-iotests/186
122
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
123
124
_supported_fmt qcow2
125
_supported_proto file
126
+_require_drivers null-co
127
128
if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
129
_notrun "Requires a PC machine"
130
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
131
index XXXXXXX..XXXXXXX 100644
132
--- a/tests/qemu-iotests/common.rc
133
+++ b/tests/qemu-iotests/common.rc
134
@@ -XXX,XX +XXX,XX @@ _require_command()
135
[ -x "$c" ] || _notrun "$1 utility required, skipped this test"
136
}
159
}
137
160
+
138
+# Check that a set of drivers has been whitelisted in the QEMU binary
161
+void bdrv_write_threshold_check_write(BlockDriverState *bs, int64_t offset,
139
+#
162
+ int64_t bytes)
140
+_require_drivers()
141
+{
163
+{
142
+ available=$($QEMU -drive format=help | \
164
+ int64_t end = offset + bytes;
143
+ sed -e '/Supported formats:/!d' -e 's/Supported formats://')
165
+ uint64_t wtr = bs->write_threshold_offset;
144
+ for driver
166
+
145
+ do
167
+ if (wtr > 0 && end > wtr) {
146
+ if ! echo "$available" | grep -q " $driver\( \|$\)"; then
168
+ qapi_event_send_block_write_threshold(bs->node_name, end - wtr, wtr);
147
+ _notrun "$driver not available"
169
+
148
+ fi
170
+ /* autodisable to avoid flooding the monitor */
149
+ done
171
+ bdrv_write_threshold_set(bs, 0);
172
+ }
150
+}
173
+}
151
+
152
# make sure this script returns success
153
true
154
--
174
--
155
2.21.0
175
2.31.1
156
176
157
177
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
It's wrong to OR shared permissions. It may lead to crash on further
3
They are unused now.
4
permission updates.
5
Also, no needs to consider previously calculated permissions, as at
6
this point we already bind all new parents and bdrv_get_cumulative_perm
7
result is enough. So fix the bug by just set permissions by
8
bdrv_get_cumulative_perm result.
9
10
Bug was introduced in long ago 234ac1a9025, in 2.9.
11
4
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
13
Message-id: 20190824100740.61635-1-vsementsov@virtuozzo.com
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
7
Message-Id: <20210506090621.11848-3-vsementsov@virtuozzo.com>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
10
---
16
block.c | 5 ++---
11
include/block/block_int.h | 12 ------------
17
1 file changed, 2 insertions(+), 3 deletions(-)
12
block.c | 1 -
13
block/io.c | 6 ------
14
3 files changed, 19 deletions(-)
18
15
16
diff --git a/include/block/block_int.h b/include/block/block_int.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/block/block_int.h
19
+++ b/include/block/block_int.h
20
@@ -XXX,XX +XXX,XX @@ struct BlockDriverState {
21
*/
22
int64_t total_sectors;
23
24
- /* Callback before write request is processed */
25
- NotifierWithReturnList before_write_notifiers;
26
-
27
/* threshold limit for writes, in bytes. "High water mark". */
28
uint64_t write_threshold_offset;
29
30
@@ -XXX,XX +XXX,XX @@ void bdrv_parse_filename_strip_prefix(const char *filename, const char *prefix,
31
bool bdrv_backing_overridden(BlockDriverState *bs);
32
33
34
-/**
35
- * bdrv_add_before_write_notifier:
36
- *
37
- * Register a callback that is invoked before write requests are processed but
38
- * after any throttling or waiting for overlapping requests.
39
- */
40
-void bdrv_add_before_write_notifier(BlockDriverState *bs,
41
- NotifierWithReturn *notifier);
42
-
43
/**
44
* bdrv_add_aio_context_notifier:
45
*
19
diff --git a/block.c b/block.c
46
diff --git a/block.c b/block.c
20
index XXXXXXX..XXXXXXX 100644
47
index XXXXXXX..XXXXXXX 100644
21
--- a/block.c
48
--- a/block.c
22
+++ b/block.c
49
+++ b/block.c
23
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
50
@@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_new(void)
51
for (i = 0; i < BLOCK_OP_TYPE_MAX; i++) {
52
QLIST_INIT(&bs->op_blockers[i]);
53
}
54
- notifier_with_return_list_init(&bs->before_write_notifiers);
55
qemu_co_mutex_init(&bs->reqs_lock);
56
qemu_mutex_init(&bs->dirty_bitmap_mutex);
57
bs->refcnt = 1;
58
diff --git a/block/io.c b/block/io.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/block/io.c
61
+++ b/block/io.c
62
@@ -XXX,XX +XXX,XX @@ bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov)
63
return true;
64
}
65
66
-void bdrv_add_before_write_notifier(BlockDriverState *bs,
67
- NotifierWithReturn *notifier)
68
-{
69
- notifier_with_return_list_add(&bs->before_write_notifiers, notifier);
70
-}
71
-
72
void bdrv_io_plug(BlockDriverState *bs)
24
{
73
{
25
BdrvChild *c, *next;
74
BdrvChild *child;
26
GSList *list = NULL, *p;
27
- uint64_t old_perm, old_shared;
28
uint64_t perm = 0, shared = BLK_PERM_ALL;
29
int ret;
30
31
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
32
bdrv_unref(from);
33
}
34
35
- bdrv_get_cumulative_perm(to, &old_perm, &old_shared);
36
- bdrv_set_perm(to, old_perm | perm, old_shared | shared);
37
+ bdrv_get_cumulative_perm(to, &perm, &shared);
38
+ bdrv_set_perm(to, perm, shared);
39
40
out:
41
g_slist_free(list);
42
--
75
--
43
2.21.0
76
2.31.1
44
77
45
78
diff view generated by jsdifflib
1
This makes iotest 033 pass with e.g. subformat=monolithicFlat. It also
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
turns a former error in 059 into success.
3
2
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
These tests use bdrv_write_threshold_exceeded() API, which is used only
5
Message-id: 20190815153638.4600-3-mreitz@redhat.com
4
for test (since pre-previous commit). Better is testing real API, which
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
is used in block.c as well.
6
7
So, let's call bdrv_write_threshold_check_write(), and check is
8
bs->write_threshold_offset cleared or not (it's cleared iff threshold
9
triggered).
10
11
Also we get rid of BdrvTrackedRequest use here. Note, that paranoiac
12
bdrv_check_request() calls were added in 8b1170012b1 to protect
13
BdrvTrackedRequest. Drop them now.
14
15
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
16
Reviewed-by: Max Reitz <mreitz@redhat.com>
17
Message-Id: <20210506090621.11848-4-vsementsov@virtuozzo.com>
18
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
19
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
---
20
---
9
block/vmdk.c | 54 ++++++++++++++++++++++++--------------
21
tests/unit/test-write-threshold.c | 22 ++++------------------
10
tests/qemu-iotests/059 | 7 +++--
22
1 file changed, 4 insertions(+), 18 deletions(-)
11
tests/qemu-iotests/059.out | 4 ++-
12
3 files changed, 42 insertions(+), 23 deletions(-)
13
23
14
diff --git a/block/vmdk.c b/block/vmdk.c
24
diff --git a/tests/unit/test-write-threshold.c b/tests/unit/test-write-threshold.c
15
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
16
--- a/block/vmdk.c
26
--- a/tests/unit/test-write-threshold.c
17
+++ b/block/vmdk.c
27
+++ b/tests/unit/test-write-threshold.c
18
@@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s)
28
@@ -XXX,XX +XXX,XX @@ static void test_threshold_multi_set_get(void)
29
30
static void test_threshold_not_trigger(void)
31
{
32
- uint64_t amount = 0;
33
uint64_t threshold = 4 * 1024 * 1024;
34
BlockDriverState bs;
35
- BdrvTrackedRequest req;
36
37
memset(&bs, 0, sizeof(bs));
38
- memset(&req, 0, sizeof(req));
39
- req.offset = 1024;
40
- req.bytes = 1024;
41
-
42
- bdrv_check_request(req.offset, req.bytes, &error_abort);
43
44
bdrv_write_threshold_set(&bs, threshold);
45
- amount = bdrv_write_threshold_exceeded(&bs, &req);
46
- g_assert_cmpuint(amount, ==, 0);
47
+ bdrv_write_threshold_check_write(&bs, 1024, 1024);
48
+ g_assert_cmpuint(bdrv_write_threshold_get(&bs), ==, threshold);
19
}
49
}
20
50
21
static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
51
22
- const char *desc_file_path, QDict *options,
52
static void test_threshold_trigger(void)
23
- Error **errp)
24
+ QDict *options, Error **errp)
25
{
53
{
26
int ret;
54
- uint64_t amount = 0;
27
int matches;
55
uint64_t threshold = 4 * 1024 * 1024;
28
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
56
BlockDriverState bs;
29
const char *p, *np;
57
- BdrvTrackedRequest req;
30
int64_t sectors = 0;
58
31
int64_t flat_offset;
59
memset(&bs, 0, sizeof(bs));
32
+ char *desc_file_dir = NULL;
60
- memset(&req, 0, sizeof(req));
33
char *extent_path;
61
- req.offset = (4 * 1024 * 1024) - 1024;
34
BdrvChild *extent_file;
62
- req.bytes = 2 * 1024;
35
BDRVVmdkState *s = bs->opaque;
63
-
36
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
64
- bdrv_check_request(req.offset, req.bytes, &error_abort);
37
continue;
65
38
}
66
bdrv_write_threshold_set(&bs, threshold);
39
67
- amount = bdrv_write_threshold_exceeded(&bs, &req);
40
- if (!path_is_absolute(fname) && !path_has_protocol(fname) &&
68
- g_assert_cmpuint(amount, >=, 1024);
41
- !desc_file_path[0])
69
+ bdrv_write_threshold_check_write(&bs, threshold - 1024, 2 * 1024);
42
- {
70
+ g_assert_cmpuint(bdrv_write_threshold_get(&bs), ==, 0);
43
- bdrv_refresh_filename(bs->file->bs);
44
- error_setg(errp, "Cannot use relative extent paths with VMDK "
45
- "descriptor file '%s'", bs->file->bs->filename);
46
- return -EINVAL;
47
- }
48
+ if (path_is_absolute(fname)) {
49
+ extent_path = g_strdup(fname);
50
+ } else {
51
+ if (!desc_file_dir) {
52
+ desc_file_dir = bdrv_dirname(bs->file->bs, errp);
53
+ if (!desc_file_dir) {
54
+ bdrv_refresh_filename(bs->file->bs);
55
+ error_prepend(errp, "Cannot use relative paths with VMDK "
56
+ "descriptor file '%s': ",
57
+ bs->file->bs->filename);
58
+ ret = -EINVAL;
59
+ goto out;
60
+ }
61
+ }
62
63
- extent_path = path_combine(desc_file_path, fname);
64
+ extent_path = g_strconcat(desc_file_dir, fname, NULL);
65
+ }
66
67
ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents);
68
assert(ret < 32);
69
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
70
g_free(extent_path);
71
if (local_err) {
72
error_propagate(errp, local_err);
73
- return -EINVAL;
74
+ ret = -EINVAL;
75
+ goto out;
76
}
77
78
/* save to extents array */
79
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
80
0, 0, 0, 0, 0, &extent, errp);
81
if (ret < 0) {
82
bdrv_unref_child(bs, extent_file);
83
- return ret;
84
+ goto out;
85
}
86
extent->flat_start_offset = flat_offset << 9;
87
} else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) {
88
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
89
g_free(buf);
90
if (ret) {
91
bdrv_unref_child(bs, extent_file);
92
- return ret;
93
+ goto out;
94
}
95
extent = &s->extents[s->num_extents - 1];
96
} else if (!strcmp(type, "SESPARSE")) {
97
ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp);
98
if (ret) {
99
bdrv_unref_child(bs, extent_file);
100
- return ret;
101
+ goto out;
102
}
103
extent = &s->extents[s->num_extents - 1];
104
} else {
105
error_setg(errp, "Unsupported extent type '%s'", type);
106
bdrv_unref_child(bs, extent_file);
107
- return -ENOTSUP;
108
+ ret = -ENOTSUP;
109
+ goto out;
110
}
111
extent->type = g_strdup(type);
112
}
113
- return 0;
114
+
115
+ ret = 0;
116
+ goto out;
117
118
invalid:
119
np = next_line(p);
120
@@ -XXX,XX +XXX,XX @@ invalid:
121
np--;
122
}
123
error_setg(errp, "Invalid extent line: %.*s", (int)(np - p), p);
124
- return -EINVAL;
125
+ ret = -EINVAL;
126
+
127
+out:
128
+ g_free(desc_file_dir);
129
+ return ret;
130
}
71
}
131
72
132
static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
73
typedef struct TestStruct {
133
@@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
134
}
135
s->create_type = g_strdup(ct);
136
s->desc_offset = 0;
137
- ret = vmdk_parse_extents(buf, bs, bs->file->bs->exact_filename, options,
138
- errp);
139
+ ret = vmdk_parse_extents(buf, bs, options, errp);
140
exit:
141
return ret;
142
}
143
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
144
index XXXXXXX..XXXXXXX 100755
145
--- a/tests/qemu-iotests/059
146
+++ b/tests/qemu-iotests/059
147
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
148
149
echo
150
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
151
+# Should work, because bdrv_dirname() works fine with blkdebug
152
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
153
-$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" 2>&1 \
154
- | _filter_testdir | _filter_imgfmt
155
+$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
156
+ -c info \
157
+ 2>&1 \
158
+ | _filter_testdir | _filter_imgfmt | _filter_img_info
159
_cleanup_test_img
160
161
echo
162
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
163
index XXXXXXX..XXXXXXX 100644
164
--- a/tests/qemu-iotests/059.out
165
+++ b/tests/qemu-iotests/059.out
166
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
167
168
=== Testing monolithicFlat with internally generated JSON file name ===
169
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
170
-qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}'
171
+format name: IMGFMT
172
+cluster size: 0 bytes
173
+vm state offset: 0 bytes
174
175
=== Testing version 3 ===
176
image: TEST_DIR/iotest-version3.IMGFMT
177
--
74
--
178
2.21.0
75
2.31.1
179
76
180
77
diff view generated by jsdifflib
1
We had a test for a case where relative extent paths did not work, but
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
unfortunately we just fixed the underlying problem, so it works now.
3
This patch adds a new test case that still fails.
4
2
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
bdrv_write_threshold_exceeded() is unused.
6
Reviewed-by: John Snow <jsnow@redhat.com>
4
7
Message-id: 20190815153638.4600-4-mreitz@redhat.com
5
bdrv_write_threshold_is_set() is used only to double check the value of
8
Reviewed-by: John Snow <jsnow@redhat.com>
6
bs->write_threshold_offset in tests. No real sense in it (both tests do
7
check real value with help of bdrv_write_threshold_get())
8
9
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
10
Reviewed-by: Max Reitz <mreitz@redhat.com>
11
Message-Id: <20210506090621.11848-5-vsementsov@virtuozzo.com>
12
Reviewed-by: Eric Blake <eblake@redhat.com>
13
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
14
[mreitz: Adjusted commit message as per Eric's suggestion]
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
16
---
11
tests/qemu-iotests/059 | 27 +++++++++++++++++++++++++++
17
include/block/write-threshold.h | 24 ------------------------
12
tests/qemu-iotests/059.out | 4 ++++
18
block/write-threshold.c | 19 -------------------
13
2 files changed, 31 insertions(+)
19
tests/unit/test-write-threshold.c | 4 ----
20
3 files changed, 47 deletions(-)
14
21
15
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
22
diff --git a/include/block/write-threshold.h b/include/block/write-threshold.h
16
index XXXXXXX..XXXXXXX 100755
17
--- a/tests/qemu-iotests/059
18
+++ b/tests/qemu-iotests/059
19
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
20
21
echo
22
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
23
+
24
+echo '--- blkdebug ---'
25
# Should work, because bdrv_dirname() works fine with blkdebug
26
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
27
$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
28
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TE
29
| _filter_testdir | _filter_imgfmt | _filter_img_info
30
_cleanup_test_img
31
32
+echo '--- quorum ---'
33
+# Should not work, because bdrv_dirname() does not work with quorum
34
+IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
35
+cp "$TEST_IMG" "$TEST_IMG.orig"
36
+
37
+filename="json:{
38
+ \"driver\": \"$IMGFMT\",
39
+ \"file\": {
40
+ \"driver\": \"quorum\",
41
+ \"children\": [ {
42
+ \"driver\": \"file\",
43
+ \"filename\": \"$TEST_IMG\"
44
+ }, {
45
+ \"driver\": \"file\",
46
+ \"filename\": \"$TEST_IMG.orig\"
47
+ } ],
48
+ \"vote-threshold\": 1
49
+ } }"
50
+
51
+filename=$(echo "$filename" | tr '\n' ' ' | sed -e 's/\s\+/ /g')
52
+$QEMU_IMG info "$filename" 2>&1 \
53
+ | sed -e "s/'json:[^']*'/\$QUORUM_FILE/g" \
54
+ | _filter_testdir | _filter_imgfmt | _filter_img_info
55
+
56
+
57
echo
58
echo "=== Testing version 3 ==="
59
_use_sample_img iotest-version3.vmdk.bz2
60
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
61
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
62
--- a/tests/qemu-iotests/059.out
24
--- a/include/block/write-threshold.h
63
+++ b/tests/qemu-iotests/059.out
25
+++ b/include/block/write-threshold.h
64
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
26
@@ -XXX,XX +XXX,XX @@ void bdrv_write_threshold_set(BlockDriverState *bs, uint64_t threshold_bytes);
65
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
27
*/
66
28
uint64_t bdrv_write_threshold_get(const BlockDriverState *bs);
67
=== Testing monolithicFlat with internally generated JSON file name ===
29
68
+--- blkdebug ---
30
-/*
69
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
31
- * bdrv_write_threshold_is_set
70
format name: IMGFMT
32
- *
71
cluster size: 0 bytes
33
- * Tell if a write threshold is set for a given BDS.
72
vm state offset: 0 bytes
34
- */
73
+--- quorum ---
35
-bool bdrv_write_threshold_is_set(const BlockDriverState *bs);
74
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
36
-
75
+qemu-img: Could not open $QUORUM_FILE: Cannot use relative paths with VMDK descriptor file $QUORUM_FILE: Cannot generate a base directory for quorum nodes
37
-/*
76
38
- * bdrv_write_threshold_exceeded
77
=== Testing version 3 ===
39
- *
78
image: TEST_DIR/iotest-version3.IMGFMT
40
- * Return the extent of a write request that exceeded the threshold,
41
- * or zero if the request is below the threshold.
42
- * Return zero also if the threshold was not set.
43
- *
44
- * NOTE: here we assume the following holds for each request this code
45
- * deals with:
46
- *
47
- * assert((req->offset + req->bytes) <= UINT64_MAX)
48
- *
49
- * Please not there is *not* an actual C assert().
50
- */
51
-uint64_t bdrv_write_threshold_exceeded(const BlockDriverState *bs,
52
- const BdrvTrackedRequest *req);
53
-
54
/*
55
* bdrv_write_threshold_check_write
56
*
57
diff --git a/block/write-threshold.c b/block/write-threshold.c
58
index XXXXXXX..XXXXXXX 100644
59
--- a/block/write-threshold.c
60
+++ b/block/write-threshold.c
61
@@ -XXX,XX +XXX,XX @@ uint64_t bdrv_write_threshold_get(const BlockDriverState *bs)
62
return bs->write_threshold_offset;
63
}
64
65
-bool bdrv_write_threshold_is_set(const BlockDriverState *bs)
66
-{
67
- return bs->write_threshold_offset > 0;
68
-}
69
-
70
-uint64_t bdrv_write_threshold_exceeded(const BlockDriverState *bs,
71
- const BdrvTrackedRequest *req)
72
-{
73
- if (bdrv_write_threshold_is_set(bs)) {
74
- if (req->offset > bs->write_threshold_offset) {
75
- return (req->offset - bs->write_threshold_offset) + req->bytes;
76
- }
77
- if ((req->offset + req->bytes) > bs->write_threshold_offset) {
78
- return (req->offset + req->bytes) - bs->write_threshold_offset;
79
- }
80
- }
81
- return 0;
82
-}
83
-
84
void bdrv_write_threshold_set(BlockDriverState *bs, uint64_t threshold_bytes)
85
{
86
bs->write_threshold_offset = threshold_bytes;
87
diff --git a/tests/unit/test-write-threshold.c b/tests/unit/test-write-threshold.c
88
index XXXXXXX..XXXXXXX 100644
89
--- a/tests/unit/test-write-threshold.c
90
+++ b/tests/unit/test-write-threshold.c
91
@@ -XXX,XX +XXX,XX @@ static void test_threshold_not_set_on_init(void)
92
BlockDriverState bs;
93
memset(&bs, 0, sizeof(bs));
94
95
- g_assert(!bdrv_write_threshold_is_set(&bs));
96
-
97
res = bdrv_write_threshold_get(&bs);
98
g_assert_cmpint(res, ==, 0);
99
}
100
@@ -XXX,XX +XXX,XX @@ static void test_threshold_set_get(void)
101
102
bdrv_write_threshold_set(&bs, threshold);
103
104
- g_assert(bdrv_write_threshold_is_set(&bs));
105
-
106
res = bdrv_write_threshold_get(&bs);
107
g_assert_cmpint(res, ==, threshold);
108
}
79
--
109
--
80
2.21.0
110
2.31.1
81
111
82
112
diff view generated by jsdifflib
1
fe646693acc changed qemu-img create's output so that it no longer prints
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
single quotes around parameter values. The subformat and adapter_type
3
filters in _filter_img_create() have never been adapted to that change.
4
2
5
Fixes: fe646693acc13ac48b98435d14149ab04dc597bc
3
Testing set/get of one 64bit variable doesn't seem necessary. We have a
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
4
lot of such variables. Also remaining tests do test set/get anyway.
7
Reviewed-by: John Snow <jsnow@redhat.com>
5
8
Message-id: 20190815153638.4600-2-mreitz@redhat.com
6
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
Reviewed-by: John Snow <jsnow@redhat.com>
7
Reviewed-by: Max Reitz <mreitz@redhat.com>
8
Message-Id: <20210506090621.11848-7-vsementsov@virtuozzo.com>
9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
11
---
12
tests/qemu-iotests/059.out | 16 ++++++++--------
12
tests/unit/test-write-threshold.c | 43 -------------------------------
13
tests/qemu-iotests/common.filter | 4 ++--
13
1 file changed, 43 deletions(-)
14
2 files changed, 10 insertions(+), 10 deletions(-)
15
14
16
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
15
diff --git a/tests/unit/test-write-threshold.c b/tests/unit/test-write-threshold.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qemu-iotests/059.out
17
--- a/tests/unit/test-write-threshold.c
19
+++ b/tests/qemu-iotests/059.out
18
+++ b/tests/unit/test-write-threshold.c
20
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
19
@@ -XXX,XX +XXX,XX @@
21
qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big
20
#include "block/write-threshold.h"
22
21
23
=== Testing monolithicFlat creation and opening ===
22
24
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
23
-static void test_threshold_not_set_on_init(void)
25
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
24
-{
26
image: TEST_DIR/t.IMGFMT
25
- uint64_t res;
27
file format: IMGFMT
26
- BlockDriverState bs;
28
virtual size: 2 GiB (2147483648 bytes)
27
- memset(&bs, 0, sizeof(bs));
29
28
-
30
=== Testing monolithicFlat with zeroed_grain ===
29
- res = bdrv_write_threshold_get(&bs);
31
qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain
30
- g_assert_cmpint(res, ==, 0);
32
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
31
-}
33
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
32
-
34
33
-static void test_threshold_set_get(void)
35
=== Testing big twoGbMaxExtentFlat ===
34
-{
36
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMaxExtentFlat
35
- uint64_t threshold = 4 * 1024 * 1024;
37
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000
36
- uint64_t res;
38
image: TEST_DIR/t.vmdk
37
- BlockDriverState bs;
39
file format: vmdk
38
- memset(&bs, 0, sizeof(bs));
40
virtual size: 0.977 TiB (1073741824000 bytes)
39
-
41
@@ -XXX,XX +XXX,XX @@ Format specific information:
40
- bdrv_write_threshold_set(&bs, threshold);
42
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 12582912 VMFS "dummy.IMGFMT" 1
41
-
43
42
- res = bdrv_write_threshold_get(&bs);
44
=== Testing truncated sparse ===
43
- g_assert_cmpint(res, ==, threshold);
45
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 subformat=monolithicSparse
44
-}
46
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400
45
-
47
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes
46
-static void test_threshold_multi_set_get(void)
48
47
-{
49
=== Converting to streamOptimized from image with small cluster size===
48
- uint64_t threshold1 = 4 * 1024 * 1024;
50
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
49
- uint64_t threshold2 = 15 * 1024 * 1024;
51
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
50
- uint64_t res;
52
51
- BlockDriverState bs;
53
=== Testing monolithicFlat with internally generated JSON file name ===
52
- memset(&bs, 0, sizeof(bs));
54
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 subformat=monolithicFlat
53
-
55
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
54
- bdrv_write_threshold_set(&bs, threshold1);
56
qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}'
55
- bdrv_write_threshold_set(&bs, threshold2);
57
56
- res = bdrv_write_threshold_get(&bs);
58
=== Testing version 3 ===
57
- g_assert_cmpint(res, ==, threshold2);
59
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 64931328
58
-}
60
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
59
-
61
60
static void test_threshold_not_trigger(void)
62
=== Testing 4TB monolithicFlat creation and IO ===
61
{
63
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 subformat=monolithicFlat
62
uint64_t threshold = 4 * 1024 * 1024;
64
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104
63
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
65
image: TEST_DIR/t.IMGFMT
64
{
66
file format: IMGFMT
65
size_t i;
67
virtual size: 4 TiB (4398046511104 bytes)
66
TestStruct tests[] = {
68
@@ -XXX,XX +XXX,XX @@ read 1024/1024 bytes at offset 966367641600
67
- { "/write-threshold/not-set-on-init",
69
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
68
- test_threshold_not_set_on_init },
70
69
- { "/write-threshold/set-get",
71
=== Testing qemu-img map on extents ===
70
- test_threshold_set_get },
72
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=monolithicSparse
71
- { "/write-threshold/multi-set-get",
73
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
72
- test_threshold_multi_set_get },
74
wrote 1024/1024 bytes at offset 65024
73
{ "/write-threshold/not-trigger",
75
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
74
test_threshold_not_trigger },
76
wrote 1024/1024 bytes at offset 2147483136
75
{ "/write-threshold/trigger",
77
@@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File
78
0 0x20000 0x3f0000 TEST_DIR/t.vmdk
79
0x7fff0000 0x20000 0x410000 TEST_DIR/t.vmdk
80
0x140000000 0x10000 0x430000 TEST_DIR/t.vmdk
81
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=twoGbMaxExtentSparse
82
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
83
wrote 1024/1024 bytes at offset 65024
84
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
85
wrote 1024/1024 bytes at offset 2147483136
86
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
87
index XXXXXXX..XXXXXXX 100644
88
--- a/tests/qemu-iotests/common.filter
89
+++ b/tests/qemu-iotests/common.filter
90
@@ -XXX,XX +XXX,XX @@ _filter_img_create()
91
-e "s# compat6=\\(on\\|off\\)##g" \
92
-e "s# static=\\(on\\|off\\)##g" \
93
-e "s# zeroed_grain=\\(on\\|off\\)##g" \
94
- -e "s# subformat='[^']*'##g" \
95
- -e "s# adapter_type='[^']*'##g" \
96
+ -e "s# subformat=[^ ]*##g" \
97
+ -e "s# adapter_type=[^ ]*##g" \
98
-e "s# hwversion=[^ ]*##g" \
99
-e "s# lazy_refcounts=\\(on\\|off\\)##g" \
100
-e "s# block_size=[0-9]\\+##g" \
101
--
76
--
102
2.21.0
77
2.31.1
103
78
104
79
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
2
3
When creating an image with preallocation "off" or "falloc", the first
3
We don't need this extra logic: it doesn't make code simpler.
4
block of the image is typically not allocated. When using Gluster
5
storage backed by XFS filesystem, reading this block using direct I/O
6
succeeds regardless of request length, fooling alignment detection.
7
4
8
In this case we fallback to a safe value (4096) instead of the optimal
5
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
9
value (512), which may lead to unneeded data copying when aligning
10
requests. Allocating the first block avoids the fallback.
11
12
Since we allocate the first block even with preallocation=off, we no
13
longer create images with zero disk size:
14
15
$ ./qemu-img create -f raw test.raw 1g
16
Formatting 'test.raw', fmt=raw size=1073741824
17
18
$ ls -lhs test.raw
19
4.0K -rw-r--r--. 1 nsoffer nsoffer 1.0G Aug 16 23:48 test.raw
20
21
And converting the image requires additional cluster:
22
23
$ ./qemu-img measure -f raw -O qcow2 test.raw
24
required size: 458752
25
fully allocated size: 1074135040
26
27
When using format like vmdk with multiple files per image, we allocate
28
one block per file:
29
30
$ ./qemu-img create -f vmdk -o subformat=twoGbMaxExtentFlat test.vmdk 4g
31
Formatting 'test.vmdk', fmt=vmdk size=4294967296 compat6=off hwversion=undefined subformat=twoGbMaxExtentFlat
32
33
$ ls -lhs test*.vmdk
34
4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f001.vmdk
35
4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f002.vmdk
36
4.0K -rw-r--r--. 1 nsoffer nsoffer 353 Aug 27 03:23 test.vmdk
37
38
I did quick performance test for copying disks with qemu-img convert to
39
new raw target image to Gluster storage with sector size of 512 bytes:
40
41
for i in $(seq 10); do
42
rm -f dst.raw
43
sleep 10
44
time ./qemu-img convert -f raw -O raw -t none -T none src.raw dst.raw
45
done
46
47
Here is a table comparing the total time spent:
48
49
Type Before(s) After(s) Diff(%)
50
---------------------------------------
51
real 530.028 469.123 -11.4
52
user 17.204 10.768 -37.4
53
sys 17.881 7.011 -60.7
54
55
We can see very clear improvement in CPU usage.
56
57
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
58
Message-id: 20190827010528.8818-2-nsoffer@redhat.com
59
Reviewed-by: Max Reitz <mreitz@redhat.com>
6
Reviewed-by: Max Reitz <mreitz@redhat.com>
7
Message-Id: <20210506090621.11848-8-vsementsov@virtuozzo.com>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
60
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
61
---
10
---
62
block/file-posix.c | 51 +++++++++++++++++++
11
tests/unit/test-write-threshold.c | 20 +++-----------------
63
tests/qemu-iotests/059.out | 2 +-
12
1 file changed, 3 insertions(+), 17 deletions(-)
64
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
65
tests/qemu-iotests/150.out.raw | 12 +++++
66
tests/qemu-iotests/175 | 19 ++++---
67
tests/qemu-iotests/175.out | 8 +--
68
tests/qemu-iotests/178.out.qcow2 | 4 +-
69
tests/qemu-iotests/221.out | 12 +++--
70
tests/qemu-iotests/253.out | 12 +++--
71
9 files changed, 99 insertions(+), 21 deletions(-)
72
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
73
create mode 100644 tests/qemu-iotests/150.out.raw
74
13
75
diff --git a/block/file-posix.c b/block/file-posix.c
14
diff --git a/tests/unit/test-write-threshold.c b/tests/unit/test-write-threshold.c
76
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
77
--- a/block/file-posix.c
16
--- a/tests/unit/test-write-threshold.c
78
+++ b/block/file-posix.c
17
+++ b/tests/unit/test-write-threshold.c
79
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque)
18
@@ -XXX,XX +XXX,XX @@ static void test_threshold_trigger(void)
80
return ret;
19
g_assert_cmpuint(bdrv_write_threshold_get(&bs), ==, 0);
81
}
20
}
82
21
83
+/*
22
-typedef struct TestStruct {
84
+ * Help alignment probing by allocating the first block.
23
- const char *name;
85
+ *
24
- void (*func)(void);
86
+ * When reading with direct I/O from unallocated area on Gluster backed by XFS,
25
-} TestStruct;
87
+ * reading succeeds regardless of request length. In this case we fallback to
26
-
88
+ * safe alignment which is not optimal. Allocating the first block avoids this
27
89
+ * fallback.
28
int main(int argc, char **argv)
90
+ *
29
{
91
+ * fd may be opened with O_DIRECT, but we don't know the buffer alignment or
30
- size_t i;
92
+ * request alignment, so we use safe values.
31
- TestStruct tests[] = {
93
+ *
32
- { "/write-threshold/not-trigger",
94
+ * Returns: 0 on success, -errno on failure. Since this is an optimization,
33
- test_threshold_not_trigger },
95
+ * caller may ignore failures.
34
- { "/write-threshold/trigger",
96
+ */
35
- test_threshold_trigger },
97
+static int allocate_first_block(int fd, size_t max_size)
36
- { NULL, NULL }
98
+{
37
- };
99
+ size_t write_size = (max_size < MAX_BLOCKSIZE)
38
-
100
+ ? BDRV_SECTOR_SIZE
39
g_test_init(&argc, &argv, NULL);
101
+ : MAX_BLOCKSIZE;
40
- for (i = 0; tests[i].name != NULL; i++) {
102
+ size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize());
41
- g_test_add_func(tests[i].name, tests[i].func);
103
+ void *buf;
42
- }
104
+ ssize_t n;
43
+ g_test_add_func("/write-threshold/not-trigger", test_threshold_not_trigger);
105
+ int ret;
44
+ g_test_add_func("/write-threshold/trigger", test_threshold_trigger);
106
+
45
+
107
+ buf = qemu_memalign(max_align, write_size);
46
return g_test_run();
108
+ memset(buf, 0, write_size);
109
+
110
+ do {
111
+ n = pwrite(fd, buf, write_size, 0);
112
+ } while (n == -1 && errno == EINTR);
113
+
114
+ ret = (n == -1) ? -errno : 0;
115
+
116
+ qemu_vfree(buf);
117
+ return ret;
118
+}
119
+
120
static int handle_aiocb_truncate(void *opaque)
121
{
122
RawPosixAIOData *aiocb = opaque;
123
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
124
/* posix_fallocate() doesn't set errno. */
125
error_setg_errno(errp, -result,
126
"Could not preallocate new data");
127
+ } else if (current_length == 0) {
128
+ /*
129
+ * posix_fallocate() uses fallocate() if the filesystem
130
+ * supports it, or fallback to manually writing zeroes. If
131
+ * fallocate() was used, unaligned reads from the fallocated
132
+ * area in raw_probe_alignment() will succeed, hence we need to
133
+ * allocate the first block.
134
+ *
135
+ * Optimize future alignment probing; ignore failures.
136
+ */
137
+ allocate_first_block(fd, offset);
138
}
139
} else {
140
result = 0;
141
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
142
if (ftruncate(fd, offset) != 0) {
143
result = -errno;
144
error_setg_errno(errp, -result, "Could not resize file");
145
+ } else if (current_length == 0 && offset > current_length) {
146
+ /* Optimize future alignment probing; ignore failures. */
147
+ allocate_first_block(fd, offset);
148
}
149
return result;
150
default:
151
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
152
index XXXXXXX..XXXXXXX 100644
153
--- a/tests/qemu-iotests/059.out
154
+++ b/tests/qemu-iotests/059.out
155
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMax
156
image: TEST_DIR/t.vmdk
157
file format: vmdk
158
virtual size: 0.977 TiB (1073741824000 bytes)
159
-disk size: 16 KiB
160
+disk size: 1.97 MiB
161
Format specific information:
162
cid: XXXXXXXX
163
parent cid: XXXXXXXX
164
diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out.qcow2
165
similarity index 100%
166
rename from tests/qemu-iotests/150.out
167
rename to tests/qemu-iotests/150.out.qcow2
168
diff --git a/tests/qemu-iotests/150.out.raw b/tests/qemu-iotests/150.out.raw
169
new file mode 100644
170
index XXXXXXX..XXXXXXX
171
--- /dev/null
172
+++ b/tests/qemu-iotests/150.out.raw
173
@@ -XXX,XX +XXX,XX @@
174
+QA output created by 150
175
+
176
+=== Mapping sparse conversion ===
177
+
178
+Offset Length File
179
+0 0x1000 TEST_DIR/t.IMGFMT
180
+
181
+=== Mapping non-sparse conversion ===
182
+
183
+Offset Length File
184
+0 0x100000 TEST_DIR/t.IMGFMT
185
+*** done
186
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
187
index XXXXXXX..XXXXXXX 100755
188
--- a/tests/qemu-iotests/175
189
+++ b/tests/qemu-iotests/175
190
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
191
# the file size. This function hides the resulting difference in the
192
# stat -c '%b' output.
193
# Parameter 1: Number of blocks an empty file occupies
194
-# Parameter 2: Image size in bytes
195
+# Parameter 2: Minimal number of blocks in an image
196
+# Parameter 3: Image size in bytes
197
_filter_blocks()
198
{
199
extra_blocks=$1
200
- img_size=$2
201
+ min_blocks=$2
202
+ img_size=$3
203
204
- sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \
205
- -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/everything allocated/"
206
+ sed -e "s/blocks=$min_blocks\\(\$\\|[^0-9]\\)/min allocation/" \
207
+ -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
208
}
47
}
209
210
# get standard environment, filters and checks
211
@@ -XXX,XX +XXX,XX @@ size=$((1 * 1024 * 1024))
212
touch "$TEST_DIR/empty"
213
extra_blocks=$(stat -c '%b' "$TEST_DIR/empty")
214
215
+# We always write the first byte; check how many blocks this filesystem
216
+# allocates to match empty image alloation.
217
+printf "\0" > "$TEST_DIR/empty"
218
+min_blocks=$(stat -c '%b' "$TEST_DIR/empty")
219
+
220
echo
221
echo "== creating image with default preallocation =="
222
_make_test_img $size | _filter_imgfmt
223
-stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size
224
+stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
225
226
for mode in off full falloc; do
227
echo
228
echo "== creating image with preallocation $mode =="
229
IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt
230
- stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size
231
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
232
done
233
234
# success, all done
235
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
236
index XXXXXXX..XXXXXXX 100644
237
--- a/tests/qemu-iotests/175.out
238
+++ b/tests/qemu-iotests/175.out
239
@@ -XXX,XX +XXX,XX @@ QA output created by 175
240
241
== creating image with default preallocation ==
242
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
243
-size=1048576, nothing allocated
244
+size=1048576, min allocation
245
246
== creating image with preallocation off ==
247
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=off
248
-size=1048576, nothing allocated
249
+size=1048576, min allocation
250
251
== creating image with preallocation full ==
252
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=full
253
-size=1048576, everything allocated
254
+size=1048576, max allocation
255
256
== creating image with preallocation falloc ==
257
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
258
-size=1048576, everything allocated
259
+size=1048576, max allocation
260
*** done
261
diff --git a/tests/qemu-iotests/178.out.qcow2 b/tests/qemu-iotests/178.out.qcow2
262
index XXXXXXX..XXXXXXX 100644
263
--- a/tests/qemu-iotests/178.out.qcow2
264
+++ b/tests/qemu-iotests/178.out.qcow2
265
@@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608
266
== raw input image with data (human) ==
267
268
Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824
269
-required size: 393216
270
+required size: 458752
271
fully allocated size: 1074135040
272
wrote 512/512 bytes at offset 512
273
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
274
@@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608
275
276
Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824
277
{
278
- "required": 393216,
279
+ "required": 458752,
280
"fully-allocated": 1074135040
281
}
282
wrote 512/512 bytes at offset 512
283
diff --git a/tests/qemu-iotests/221.out b/tests/qemu-iotests/221.out
284
index XXXXXXX..XXXXXXX 100644
285
--- a/tests/qemu-iotests/221.out
286
+++ b/tests/qemu-iotests/221.out
287
@@ -XXX,XX +XXX,XX @@ QA output created by 221
288
=== Check mapping of unaligned raw image ===
289
290
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65537
291
-[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
292
-[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
293
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
294
+{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
295
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
296
+{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
297
wrote 1/1 bytes at offset 65536
298
1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
299
-[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
300
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
301
+{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
302
{ "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
303
{ "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
304
-[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
305
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
306
+{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
307
{ "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
308
{ "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
309
*** done
310
diff --git a/tests/qemu-iotests/253.out b/tests/qemu-iotests/253.out
311
index XXXXXXX..XXXXXXX 100644
312
--- a/tests/qemu-iotests/253.out
313
+++ b/tests/qemu-iotests/253.out
314
@@ -XXX,XX +XXX,XX @@ QA output created by 253
315
=== Check mapping of unaligned raw image ===
316
317
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048575
318
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
319
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
320
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
321
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
322
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
323
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
324
wrote 65535/65535 bytes at offset 983040
325
63.999 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
326
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
327
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
328
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
329
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
330
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
331
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
332
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
333
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
334
*** done
335
--
48
--
336
2.21.0
49
2.31.1
337
50
338
51
diff view generated by jsdifflib
1
The error message for the test case where we have a quorum node for
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
which no directory name can be generated is different: For
3
twoGbMaxExtentSparse, it complains that it cannot open the extent file.
4
For other (sub)formats, it just notes that it cannot determine the
5
backing file path. Both are fine, but just disable twoGbMaxExtentSparse
6
for simplicity's sake.
7
2
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
"qemu/typedefs.h" is enough for include/block/write-threshold.h header
9
Reviewed-by: John Snow <jsnow@redhat.com>
4
with forward declaration of BlockDriverState. Also drop extra includes
10
Message-id: 20190815153638.4600-7-mreitz@redhat.com
5
from block/write-threshold.c and tests/unit/test-write-threshold.c
11
Reviewed-by: John Snow <jsnow@redhat.com>
6
7
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
Message-Id: <20210506090621.11848-9-vsementsov@virtuozzo.com>
9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
11
---
14
tests/qemu-iotests/110 | 3 ++-
12
include/block/write-threshold.h | 2 +-
15
1 file changed, 2 insertions(+), 1 deletion(-)
13
block/write-threshold.c | 2 --
14
tests/unit/test-write-threshold.c | 1 -
15
3 files changed, 1 insertion(+), 4 deletions(-)
16
16
17
diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110
17
diff --git a/include/block/write-threshold.h b/include/block/write-threshold.h
18
index XXXXXXX..XXXXXXX 100755
18
index XXXXXXX..XXXXXXX 100644
19
--- a/tests/qemu-iotests/110
19
--- a/include/block/write-threshold.h
20
+++ b/tests/qemu-iotests/110
20
+++ b/include/block/write-threshold.h
21
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
21
@@ -XXX,XX +XXX,XX @@
22
# Any format supporting backing files
22
#ifndef BLOCK_WRITE_THRESHOLD_H
23
_supported_fmt qed qcow qcow2 vmdk
23
#define BLOCK_WRITE_THRESHOLD_H
24
_supported_proto file
24
25
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
25
-#include "block/block_int.h"
26
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
26
+#include "qemu/typedefs.h"
27
+ "subformat=twoGbMaxExtentSparse"
27
28
28
/*
29
TEST_IMG_REL=$(basename "$TEST_IMG")
29
* bdrv_write_threshold_set:
30
diff --git a/block/write-threshold.c b/block/write-threshold.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/block/write-threshold.c
33
+++ b/block/write-threshold.c
34
@@ -XXX,XX +XXX,XX @@
35
36
#include "qemu/osdep.h"
37
#include "block/block_int.h"
38
-#include "qemu/coroutine.h"
39
#include "block/write-threshold.h"
40
-#include "qemu/notify.h"
41
#include "qapi/error.h"
42
#include "qapi/qapi-commands-block-core.h"
43
#include "qapi/qapi-events-block-core.h"
44
diff --git a/tests/unit/test-write-threshold.c b/tests/unit/test-write-threshold.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/tests/unit/test-write-threshold.c
47
+++ b/tests/unit/test-write-threshold.c
48
@@ -XXX,XX +XXX,XX @@
49
*/
50
51
#include "qemu/osdep.h"
52
-#include "qapi/error.h"
53
#include "block/block_int.h"
54
#include "block/write-threshold.h"
30
55
31
--
56
--
32
2.21.0
57
2.31.1
33
58
34
59
diff view generated by jsdifflib