1
The following changes since commit 23919ddfd56135cad3cb468a8f54d5a595f024f4:
1
The following changes since commit 1be5a765c08cee3a9587c8a8d3fc2ea247b13f9c:
2
2
3
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190827' into staging (2019-08-27 15:52:36 +0100)
3
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2022-04-19 18:22:16 -0700)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://github.com/XanClic/qemu.git tags/pull-block-2019-08-27
7
https://gitlab.com/hreitz/qemu.git tags/pull-block-2022-04-20
8
8
9
for you to fetch changes up to bb043c056cffcc2f3ce88bfdaf2e76e455c09e2c:
9
for you to fetch changes up to 0423f75351ab83b844a31349218b0eadd830e07a:
10
10
11
iotests: Unify cache mode quoting (2019-08-27 19:48:44 +0200)
11
qcow2: Add errp to rebuild_refcount_structure() (2022-04-20 12:09:17 +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
- Some changes for qcow2's refcount repair algorithm to make it work for
16
- Ensure that raw files have their first block allocated so we can probe
16
qcow2 images stored on block devices
17
the O_DIRECT alignment if necessary
17
- Skip test cases that require zstd when support for it is missing
18
- Various fixes
18
- Some refactoring in the iotests' meson.build
19
19
20
----------------------------------------------------------------
20
----------------------------------------------------------------
21
Denis Plotnikov (1):
21
Hanna Reitz (6):
22
qemu-io: add pattern file for write command
22
iotests.py: Add supports_qcow2_zstd_compression()
23
23
iotests/065: Check for zstd support
24
Max Reitz (7):
24
iotests/303: Check for zstd support
25
iotests: Fix _filter_img_create()
25
qcow2: Improve refcount structure rebuilding
26
vmdk: Use bdrv_dirname() for relative extent paths
26
iotests/108: Test new refcount rebuild algorithm
27
iotests: Keep testing broken relative extent paths
27
qcow2: Add errp to rebuild_refcount_structure()
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
Nir Soffer (3):
34
block: posix: Always allocate the first block
35
iotests: Test allocate_first_block() with O_DIRECT
36
iotests: Unify cache mode quoting
37
38
Stefan Hajnoczi (1):
39
file-posix: fix request_alignment typo
40
28
41
Thomas Huth (2):
29
Thomas Huth (2):
42
iotests: Check for enabled drivers before testing them
30
tests/qemu-iotests/meson.build: Improve the indentation
43
tests/check-block: Skip iotests when sanitizers are enabled
31
tests/qemu-iotests: Move the bash and sanitizer checks to meson.build
44
32
45
Vladimir Sementsov-Ogievskiy (1):
33
block/qcow2-refcount.c | 353 +++++++++++++++++++++++----------
46
block: fix permission update in bdrv_replace_node
34
tests/check-block.sh | 26 ---
47
35
tests/qemu-iotests/065 | 24 ++-
48
block.c | 5 +-
36
tests/qemu-iotests/108 | 259 +++++++++++++++++++++++-
49
block/file-posix.c | 53 +++++++++-
37
tests/qemu-iotests/108.out | 81 ++++++++
50
block/vmdk.c | 64 ++++++++----
38
tests/qemu-iotests/303 | 4 +-
51
qemu-io-cmds.c | 99 +++++++++++++++++--
39
tests/qemu-iotests/iotests.py | 20 ++
52
tests/check-block.sh | 5 +
40
tests/qemu-iotests/meson.build | 73 ++++---
53
tests/qemu-iotests/002 | 1 +
41
8 files changed, 673 insertions(+), 167 deletions(-)
54
tests/qemu-iotests/003 | 1 +
55
tests/qemu-iotests/005 | 3 +-
56
tests/qemu-iotests/009 | 1 +
57
tests/qemu-iotests/010 | 1 +
58
tests/qemu-iotests/011 | 1 +
59
tests/qemu-iotests/017 | 3 +-
60
tests/qemu-iotests/018 | 3 +-
61
tests/qemu-iotests/019 | 3 +-
62
tests/qemu-iotests/020 | 3 +-
63
tests/qemu-iotests/026 | 4 +-
64
tests/qemu-iotests/027 | 1 +
65
tests/qemu-iotests/032 | 1 +
66
tests/qemu-iotests/033 | 1 +
67
tests/qemu-iotests/034 | 3 +-
68
tests/qemu-iotests/037 | 3 +-
69
tests/qemu-iotests/039 | 4 +-
70
tests/qemu-iotests/052 | 2 +-
71
tests/qemu-iotests/059 | 34 ++++++-
72
tests/qemu-iotests/059.out | 26 +++--
73
tests/qemu-iotests/063 | 3 +-
74
tests/qemu-iotests/071 | 1 +
75
tests/qemu-iotests/072 | 1 +
76
tests/qemu-iotests/081 | 4 +-
77
tests/qemu-iotests/091 | 4 +-
78
tests/qemu-iotests/099 | 1 +
79
tests/qemu-iotests/105 | 3 +-
80
tests/qemu-iotests/110 | 3 +-
81
tests/qemu-iotests/120 | 1 +
82
tests/qemu-iotests/126 | 2 +
83
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
84
tests/qemu-iotests/150.out.raw | 12 +++
85
tests/qemu-iotests/162 | 4 +-
86
tests/qemu-iotests/175 | 47 +++++++--
87
tests/qemu-iotests/175.out | 16 ++-
88
tests/qemu-iotests/178.out.qcow2 | 4 +-
89
tests/qemu-iotests/184 | 1 +
90
tests/qemu-iotests/186 | 1 +
91
tests/qemu-iotests/197 | 1 +
92
tests/qemu-iotests/215 | 1 +
93
tests/qemu-iotests/221.out | 12 ++-
94
tests/qemu-iotests/251 | 1 +
95
tests/qemu-iotests/253.out | 12 ++-
96
tests/qemu-iotests/common.filter | 4 +-
97
tests/qemu-iotests/common.rc | 14 +++
98
50 files changed, 391 insertions(+), 87 deletions(-)
99
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
100
create mode 100644 tests/qemu-iotests/150.out.raw
101
42
102
--
43
--
103
2.21.0
44
2.35.1
104
105
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
It is possible to enable only a subset of the block drivers with the
3
By using subdir_done(), we can get rid of one level of indentation
4
"--block-drv-rw-whitelist" option of the "configure" script. All other
4
in this file. This will make it easier to add more conditions to
5
drivers are marked as unusable (or only included as read-only with the
5
skip the iotests in future patches.
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
6
13
This patch mainly targets the test in the "auto" group which should
7
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
14
never fail in such a case, but also improves some of the other tests
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
along the way. Note that we also assume that the "qcow2" and "file"
9
Signed-off-by: Thomas Huth <thuth@redhat.com>
16
drivers are always available - otherwise it does not make sense to
10
Message-Id: <20220223093840.2515281-3-thuth@redhat.com>
17
run "make check-block" at all (which only tests with qcow2 by default).
11
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
13
tests/qemu-iotests/meson.build | 61 ++++++++++++++++++----------------
14
1 file changed, 32 insertions(+), 29 deletions(-)
18
15
19
Signed-off-by: Thomas Huth <thuth@redhat.com>
16
diff --git a/tests/qemu-iotests/meson.build b/tests/qemu-iotests/meson.build
20
Message-id: 20190823133552.11680-1-thuth@redhat.com
17
index XXXXXXX..XXXXXXX 100644
21
Signed-off-by: Max Reitz <mreitz@redhat.com>
18
--- a/tests/qemu-iotests/meson.build
22
---
19
+++ b/tests/qemu-iotests/meson.build
23
tests/qemu-iotests/071 | 1 +
20
@@ -XXX,XX +XXX,XX @@
24
tests/qemu-iotests/081 | 4 +---
21
-if have_tools and targetos != 'windows' and not get_option('gprof')
25
tests/qemu-iotests/099 | 1 +
22
- qemu_iotests_binaries = [qemu_img, qemu_io, qemu_nbd, qsd]
26
tests/qemu-iotests/120 | 1 +
23
- qemu_iotests_env = {'PYTHON': python.full_path()}
27
tests/qemu-iotests/162 | 4 +---
24
- qemu_iotests_formats = {
28
tests/qemu-iotests/184 | 1 +
25
- 'qcow2': 'quick',
29
tests/qemu-iotests/186 | 1 +
26
- 'raw': 'slow',
30
tests/qemu-iotests/common.rc | 14 ++++++++++++++
27
- 'qed': 'thorough',
31
8 files changed, 21 insertions(+), 6 deletions(-)
28
- 'vmdk': 'thorough',
32
29
- 'vpc': 'thorough'
33
diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071
30
- }
34
index XXXXXXX..XXXXXXX 100755
35
--- a/tests/qemu-iotests/071
36
+++ b/tests/qemu-iotests/071
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
38
39
_supported_fmt qcow2
40
_supported_proto file
41
+_require_drivers blkdebug blkverify
42
43
do_run_qemu()
44
{
45
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
46
index XXXXXXX..XXXXXXX 100755
47
--- a/tests/qemu-iotests/081
48
+++ b/tests/qemu-iotests/081
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
50
_supported_fmt raw
51
_supported_proto file
52
_supported_os Linux
53
+_require_drivers quorum
54
55
do_run_qemu()
56
{
57
@@ -XXX,XX +XXX,XX @@ run_qemu()
58
| _filter_qemu_io | _filter_generated_node_ids
59
}
60
61
-test_quorum=$($QEMU_IMG --help|grep quorum)
62
-[ "$test_quorum" = "" ] && _supported_fmt quorum
63
-
31
-
64
quorum="driver=raw,file.driver=quorum,file.vote-threshold=2"
32
- foreach k, v : emulators
65
quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw"
33
- if k.startswith('qemu-system-')
66
quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw"
34
- qemu_iotests_binaries += v
67
diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099
35
- endif
68
index XXXXXXX..XXXXXXX 100755
36
- endforeach
69
--- a/tests/qemu-iotests/099
37
- foreach format, speed: qemu_iotests_formats
70
+++ b/tests/qemu-iotests/099
38
- if speed == 'quick'
71
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
39
- suites = 'block'
72
_supported_fmt qcow qcow2 qed vdi vhdx vmdk vpc
40
- else
73
_supported_proto file
41
- suites = ['block-' + speed, speed]
74
_supported_os Linux
42
- endif
75
+_require_drivers blkdebug blkverify
43
- test('qemu-iotests ' + format, sh, args: [files('../check-block.sh'), format],
76
_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
44
- depends: qemu_iotests_binaries, env: qemu_iotests_env,
77
"subformat=twoGbMaxExtentSparse"
45
- protocol: 'tap',
78
46
- suite: suites,
79
diff --git a/tests/qemu-iotests/120 b/tests/qemu-iotests/120
47
- timeout: 0,
80
index XXXXXXX..XXXXXXX 100755
48
- is_parallel: false)
81
--- a/tests/qemu-iotests/120
49
- endforeach
82
+++ b/tests/qemu-iotests/120
50
+if not have_tools or targetos == 'windows' or get_option('gprof')
83
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
51
+ subdir_done()
84
_supported_fmt generic
52
endif
85
_supported_proto file
53
+
86
_unsupported_fmt luks
54
+qemu_iotests_binaries = [qemu_img, qemu_io, qemu_nbd, qsd]
87
+_require_drivers raw
55
+qemu_iotests_env = {'PYTHON': python.full_path()}
88
56
+qemu_iotests_formats = {
89
_make_test_img 64M
57
+ 'qcow2': 'quick',
90
58
+ 'raw': 'slow',
91
diff --git a/tests/qemu-iotests/162 b/tests/qemu-iotests/162
59
+ 'qed': 'thorough',
92
index XXXXXXX..XXXXXXX 100755
60
+ 'vmdk': 'thorough',
93
--- a/tests/qemu-iotests/162
61
+ 'vpc': 'thorough'
94
+++ b/tests/qemu-iotests/162
95
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
96
. ./common.filter
97
98
_supported_fmt generic
99
-
100
-test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)')
101
-[ "$test_ssh" = "" ] && _notrun "ssh support required"
102
+_require_drivers ssh
103
104
echo
105
echo '=== NBD ==='
106
diff --git a/tests/qemu-iotests/184 b/tests/qemu-iotests/184
107
index XXXXXXX..XXXXXXX 100755
108
--- a/tests/qemu-iotests/184
109
+++ b/tests/qemu-iotests/184
110
@@ -XXX,XX +XXX,XX @@ trap "exit \$status" 0 1 2 3 15
111
. ./common.filter
112
113
_supported_os Linux
114
+_require_drivers throttle
115
116
do_run_qemu()
117
{
118
diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186
119
index XXXXXXX..XXXXXXX 100755
120
--- a/tests/qemu-iotests/186
121
+++ b/tests/qemu-iotests/186
122
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
123
124
_supported_fmt qcow2
125
_supported_proto file
126
+_require_drivers null-co
127
128
if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
129
_notrun "Requires a PC machine"
130
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
131
index XXXXXXX..XXXXXXX 100644
132
--- a/tests/qemu-iotests/common.rc
133
+++ b/tests/qemu-iotests/common.rc
134
@@ -XXX,XX +XXX,XX @@ _require_command()
135
[ -x "$c" ] || _notrun "$1 utility required, skipped this test"
136
}
137
138
+# Check that a set of drivers has been whitelisted in the QEMU binary
139
+#
140
+_require_drivers()
141
+{
142
+ available=$($QEMU -drive format=help | \
143
+ sed -e '/Supported formats:/!d' -e 's/Supported formats://')
144
+ for driver
145
+ do
146
+ if ! echo "$available" | grep -q " $driver\( \|$\)"; then
147
+ _notrun "$driver not available"
148
+ fi
149
+ done
150
+}
62
+}
151
+
63
+
152
# make sure this script returns success
64
+foreach k, v : emulators
153
true
65
+ if k.startswith('qemu-system-')
66
+ qemu_iotests_binaries += v
67
+ endif
68
+endforeach
69
+
70
+foreach format, speed: qemu_iotests_formats
71
+ if speed == 'quick'
72
+ suites = 'block'
73
+ else
74
+ suites = ['block-' + speed, speed]
75
+ endif
76
+ test('qemu-iotests ' + format, sh, args: [files('../check-block.sh'), format],
77
+ depends: qemu_iotests_binaries, env: qemu_iotests_env,
78
+ protocol: 'tap',
79
+ suite: suites,
80
+ timeout: 0,
81
+ is_parallel: false)
82
+endforeach
154
--
83
--
155
2.21.0
84
2.35.1
156
85
157
86
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
The sanitizers (especially the address sanitizer from Clang) are
3
We want to get rid of check-block.sh in the long run, so let's move
4
sometimes printing out warnings or false positives - this spoils
4
the checks for the bash version and sanitizers from check-block.sh
5
the output of the iotests, causing some of the tests to fail.
5
into the meson.build file instead.
6
Thus let's skip the automatic iotests during "make check" when the
7
user configured QEMU with --enable-sanitizers.
8
6
9
Signed-off-by: Thomas Huth <thuth@redhat.com>
7
Signed-off-by: Thomas Huth <thuth@redhat.com>
10
Message-id: 20190823084203.29734-1-thuth@redhat.com
8
Message-Id: <20220223093840.2515281-4-thuth@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12
---
10
---
13
tests/check-block.sh | 5 +++++
11
tests/check-block.sh | 26 --------------------------
14
1 file changed, 5 insertions(+)
12
tests/qemu-iotests/meson.build | 14 ++++++++++++++
13
2 files changed, 14 insertions(+), 26 deletions(-)
15
14
16
diff --git a/tests/check-block.sh b/tests/check-block.sh
15
diff --git a/tests/check-block.sh b/tests/check-block.sh
17
index XXXXXXX..XXXXXXX 100755
16
index XXXXXXX..XXXXXXX 100755
18
--- a/tests/check-block.sh
17
--- a/tests/check-block.sh
19
+++ b/tests/check-block.sh
18
+++ b/tests/check-block.sh
20
@@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then
19
@@ -XXX,XX +XXX,XX @@ skip() {
21
exit 0
20
exit 0
21
}
22
23
-# Disable tests with any sanitizer except for specific ones
24
-SANITIZE_FLAGS=$( grep "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null )
25
-ALLOWED_SANITIZE_FLAGS="safe-stack cfi-icall"
26
-#Remove all occurrencies of allowed Sanitize flags
27
-for j in ${ALLOWED_SANITIZE_FLAGS}; do
28
- TMP_FLAGS=${SANITIZE_FLAGS}
29
- SANITIZE_FLAGS=""
30
- for i in ${TMP_FLAGS}; do
31
- if ! echo ${i} | grep -q "${j}" 2>/dev/null; then
32
- SANITIZE_FLAGS="${SANITIZE_FLAGS} ${i}"
33
- fi
34
- done
35
-done
36
-if echo ${SANITIZE_FLAGS} | grep -q "\-fsanitize" 2>/dev/null; then
37
- # Have a sanitize flag that is not allowed, stop
38
- skip "Sanitizers are enabled ==> Not running the qemu-iotests."
39
-fi
40
-
41
if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then
42
skip "No qemu-system binary available ==> Not running the qemu-iotests."
22
fi
43
fi
23
44
24
+if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then
45
-if ! command -v bash >/dev/null 2>&1 ; then
25
+ echo "Sanitizers are enabled ==> Not running the qemu-iotests."
46
- skip "bash not available ==> Not running the qemu-iotests."
26
+ exit 0
47
-fi
27
+fi
48
-
49
-if LANG=C bash --version | grep -q 'GNU bash, version [123]' ; then
50
- skip "bash version too old ==> Not running the qemu-iotests."
51
-fi
52
-
53
cd tests/qemu-iotests
54
55
# QEMU_CHECK_BLOCK_AUTO is used to disable some unstable sub-tests
56
diff --git a/tests/qemu-iotests/meson.build b/tests/qemu-iotests/meson.build
57
index XXXXXXX..XXXXXXX 100644
58
--- a/tests/qemu-iotests/meson.build
59
+++ b/tests/qemu-iotests/meson.build
60
@@ -XXX,XX +XXX,XX @@ if not have_tools or targetos == 'windows' or get_option('gprof')
61
subdir_done()
62
endif
63
64
+foreach cflag: config_host['QEMU_CFLAGS'].split()
65
+ if cflag.startswith('-fsanitize') and \
66
+ not cflag.contains('safe-stack') and not cflag.contains('cfi-icall')
67
+ message('Sanitizers are enabled ==> Disabled the qemu-iotests.')
68
+ subdir_done()
69
+ endif
70
+endforeach
28
+
71
+
29
if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then
72
+bash = find_program('bash', required: false, version: '>= 4.0')
30
echo "No qemu-system binary available ==> Not running the qemu-iotests."
73
+if not bash.found()
31
exit 0
74
+ message('bash >= v4.0 not available ==> Disabled the qemu-iotests.')
75
+ subdir_done()
76
+endif
77
+
78
qemu_iotests_binaries = [qemu_img, qemu_io, qemu_nbd, qsd]
79
qemu_iotests_env = {'PYTHON': python.full_path()}
80
qemu_iotests_formats = {
32
--
81
--
33
2.21.0
82
2.35.1
34
35
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
3
Message-Id: <20220323105522.53660-2-hreitz@redhat.com>
4
Reviewed-by: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>
5
---
6
tests/qemu-iotests/iotests.py | 20 ++++++++++++++++++++
7
1 file changed, 20 insertions(+)
2
8
3
Quoting cache mode is not needed, and most tests use unquoted values.
9
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
4
Unify all test to use the same style.
10
index XXXXXXX..XXXXXXX 100644
5
11
--- a/tests/qemu-iotests/iotests.py
6
Message-id: 20190827173432.7656-1-nsoffer@redhat.com
12
+++ b/tests/qemu-iotests/iotests.py
7
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
13
@@ -XXX,XX +XXX,XX @@ def verify_working_luks():
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
14
if not working:
9
---
15
notrun(reason)
10
tests/qemu-iotests/026 | 4 ++--
16
11
tests/qemu-iotests/039 | 4 ++--
17
+def supports_qcow2_zstd_compression() -> bool:
12
tests/qemu-iotests/052 | 2 +-
18
+ img_file = f'{test_dir}/qcow2-zstd-test.qcow2'
13
tests/qemu-iotests/091 | 4 ++--
19
+ res = qemu_img('create', '-f', 'qcow2', '-o', 'compression_type=zstd',
14
4 files changed, 7 insertions(+), 7 deletions(-)
20
+ img_file, '0',
15
21
+ check=False)
16
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
22
+ try:
17
index XXXXXXX..XXXXXXX 100755
23
+ os.remove(img_file)
18
--- a/tests/qemu-iotests/026
24
+ except OSError:
19
+++ b/tests/qemu-iotests/026
25
+ pass
20
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
26
+
21
# Currently only qcow2 supports rebasing
27
+ if res.returncode == 1 and \
22
_supported_fmt qcow2
28
+ "'compression-type' does not accept value 'zstd'" in res.stdout:
23
_supported_proto file
29
+ return False
24
-_default_cache_mode "writethrough"
30
+ else:
25
-_supported_cache_modes "writethrough" "none"
31
+ return True
26
+_default_cache_mode writethrough
32
+
27
+_supported_cache_modes writethrough none
33
+def verify_qcow2_zstd_compression():
28
# The refcount table tests expect a certain minimum width for refcount entries
34
+ if not supports_qcow2_zstd_compression():
29
# (so that the refcount table actually needs to grow); that minimum is 16 bits,
35
+ notrun('zstd compression not supported')
30
# being the default refcount entry width.
36
+
31
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
37
def qemu_pipe(*args: str) -> str:
32
index XXXXXXX..XXXXXXX 100755
38
"""
33
--- a/tests/qemu-iotests/039
39
Run qemu with an option to print something and exit (e.g. a help option).
34
+++ b/tests/qemu-iotests/039
35
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
36
_supported_fmt qcow2
37
_supported_proto file
38
_supported_os Linux
39
-_default_cache_mode "writethrough"
40
-_supported_cache_modes "writethrough"
41
+_default_cache_mode writethrough
42
+_supported_cache_modes writethrough
43
44
size=128M
45
46
diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052
47
index XXXXXXX..XXXXXXX 100755
48
--- a/tests/qemu-iotests/052
49
+++ b/tests/qemu-iotests/052
50
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
51
_supported_proto file
52
53
# Don't do O_DIRECT on tmpfs
54
-_supported_cache_modes "writeback" "writethrough" "unsafe"
55
+_supported_cache_modes writeback writethrough unsafe
56
57
size=128M
58
_make_test_img $size
59
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
60
index XXXXXXX..XXXXXXX 100755
61
--- a/tests/qemu-iotests/091
62
+++ b/tests/qemu-iotests/091
63
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
64
_supported_fmt qcow2
65
_supported_proto file
66
_supported_os Linux
67
-_default_cache_mode "none"
68
-_supported_cache_modes "writethrough" "none" "writeback"
69
+_default_cache_mode none
70
+_supported_cache_modes writethrough none writeback
71
72
size=1G
73
74
--
40
--
75
2.21.0
41
2.35.1
76
77
diff view generated by jsdifflib
1
From: Stefan Hajnoczi <stefanha@redhat.com>
1
Some test cases run in iotest 065 want to run with zstd compression just
2
for added coverage. Run them with zlib if there is no zstd support
3
compiled in.
2
4
3
Fixes: a6b257a08e3d72219f03e461a52152672fec0612
5
Reported-by: Thomas Huth <thuth@redhat.com>
4
("file-posix: Handle undetectable alignment")
6
Fixes: 12a936171d71f839dc907ff ("iotest 065: explicit compression type")
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
6
Message-id: 20190827101328.4062-1-stefanha@redhat.com
8
Message-Id: <20220323105522.53660-3-hreitz@redhat.com>
7
Reviewed-by: Thomas Huth <thuth@redhat.com>
9
Reviewed-by: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
---
10
block/file-posix.c | 2 +-
11
tests/qemu-iotests/065 | 24 ++++++++++++++++++------
11
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 18 insertions(+), 6 deletions(-)
12
13
13
diff --git a/block/file-posix.c b/block/file-posix.c
14
diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100755
15
--- a/block/file-posix.c
16
--- a/tests/qemu-iotests/065
16
+++ b/block/file-posix.c
17
+++ b/tests/qemu-iotests/065
17
@@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
18
@@ -XXX,XX +XXX,XX @@ import os
18
for (i = 0; i < ARRAY_SIZE(alignments); i++) {
19
import re
19
align = alignments[i];
20
import json
20
if (raw_is_io_aligned(fd, buf + align, max_align)) {
21
import iotests
21
- /* Fallback to request_aligment. */
22
-from iotests import qemu_img, qemu_img_info
22
+ /* Fallback to request_alignment. */
23
+from iotests import qemu_img, qemu_img_info, supports_qcow2_zstd_compression
23
s->buf_align = (align != 1) ? align : bs->bl.request_alignment;
24
import unittest
24
break;
25
25
}
26
test_img = os.path.join(iotests.test_dir, 'test.img')
27
@@ -XXX,XX +XXX,XX @@ class TestQCow2(TestQemuImgInfo):
28
29
class TestQCow3NotLazy(TestQemuImgInfo):
30
'''Testing a qcow2 version 3 image with lazy refcounts disabled'''
31
- img_options = 'compat=1.1,lazy_refcounts=off,compression_type=zstd'
32
+ if supports_qcow2_zstd_compression():
33
+ compression_type = 'zstd'
34
+ else:
35
+ compression_type = 'zlib'
36
+
37
+ img_options = 'compat=1.1,lazy_refcounts=off'
38
+ img_options += f',compression_type={compression_type}'
39
json_compare = { 'compat': '1.1', 'lazy-refcounts': False,
40
'refcount-bits': 16, 'corrupt': False,
41
- 'compression-type': 'zstd', 'extended-l2': False }
42
- human_compare = [ 'compat: 1.1', 'compression type: zstd',
43
+ 'compression-type': compression_type, 'extended-l2': False }
44
+ human_compare = [ 'compat: 1.1', f'compression type: {compression_type}',
45
'lazy refcounts: false', 'refcount bits: 16',
46
'corrupt: false', 'extended l2: false' ]
47
48
@@ -XXX,XX +XXX,XX @@ class TestQCow3NotLazyQMP(TestQMP):
49
class TestQCow3LazyQMP(TestQMP):
50
'''Testing a qcow2 version 3 image with lazy refcounts enabled, opening
51
with lazy refcounts disabled'''
52
- img_options = 'compat=1.1,lazy_refcounts=on,compression_type=zstd'
53
+ if supports_qcow2_zstd_compression():
54
+ compression_type = 'zstd'
55
+ else:
56
+ compression_type = 'zlib'
57
+
58
+ img_options = 'compat=1.1,lazy_refcounts=on'
59
+ img_options += f',compression_type={compression_type}'
60
qemu_options = 'lazy-refcounts=off'
61
compare = { 'compat': '1.1', 'lazy-refcounts': True,
62
'refcount-bits': 16, 'corrupt': False,
63
- 'compression-type': 'zstd', 'extended-l2': False }
64
+ 'compression-type': compression_type, 'extended-l2': False }
65
66
TestImageInfoSpecific = None
67
TestQemuImgInfo = None
26
--
68
--
27
2.21.0
69
2.35.1
28
29
diff view generated by jsdifflib
1
iotest 126 requires backing file support, which flat vmdks cannot offer.
1
303 runs two test cases, one of which requires zstd support.
2
Skip this test for such subformats.
2
Unfortunately, given that this is not a unittest-style test, we cannot
3
easily skip that single case, and instead can only skip the whole test.
3
4
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
(Alternatively, we could split this test into a zlib and a zstd part,
5
Message-id: 20190815153638.4600-8-mreitz@redhat.com
6
but that seems excessive, given that this test is not in auto and thus
6
Reviewed-by: John Snow <jsnow@redhat.com>
7
likely only run by developers who have zstd support compiled in.)
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
9
Fixes: 677e0bae686e7c670a71d1f ("iotest 303: explicit compression type")
10
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
11
Reviewed-by: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>
12
Message-Id: <20220323105522.53660-4-hreitz@redhat.com>
8
---
13
---
9
tests/qemu-iotests/126 | 2 ++
14
tests/qemu-iotests/303 | 4 +++-
10
1 file changed, 2 insertions(+)
15
1 file changed, 3 insertions(+), 1 deletion(-)
11
16
12
diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
17
diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303
13
index XXXXXXX..XXXXXXX 100755
18
index XXXXXXX..XXXXXXX 100755
14
--- a/tests/qemu-iotests/126
19
--- a/tests/qemu-iotests/303
15
+++ b/tests/qemu-iotests/126
20
+++ b/tests/qemu-iotests/303
16
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
21
@@ -XXX,XX +XXX,XX @@
17
22
18
# Needs backing file support
23
import iotests
19
_supported_fmt qcow qcow2 qed vmdk
24
import subprocess
20
+_unsupported_imgopts "subformat=monolithicFlat" \
25
-from iotests import qemu_img_create, qemu_io, file_path, log, filter_qemu_io
21
+ "subformat=twoGbMaxExtentFlat"
26
+from iotests import qemu_img_create, qemu_io, file_path, log, filter_qemu_io, \
22
# This is the default protocol (and we want to test the difference between
27
+ verify_qcow2_zstd_compression
23
# colons which separate a protocol prefix from the rest and colons which are
28
24
# just part of the filename, so we cannot test protocols which require a prefix)
29
iotests.script_initialize(supported_fmts=['qcow2'],
30
unsupported_imgopts=['refcount_bits', 'compat'])
31
+verify_qcow2_zstd_compression()
32
33
disk = file_path('disk')
34
chunk = 1024 * 1024
25
--
35
--
26
2.21.0
36
2.35.1
27
28
diff view generated by jsdifflib
1
From: Denis Plotnikov <dplotnikov@virtuozzo.com>
1
When rebuilding the refcount structures (when qemu-img check -r found
2
errors with refcount = 0, but reference count > 0), the new refcount
3
table defaults to being put at the image file end[1]. There is no good
4
reason for that except that it means we will not have to rewrite any
5
refblocks we already wrote to disk.
2
6
3
The patch allows to provide a pattern file for write
7
Changing the code to rewrite those refblocks is not too difficult,
4
command. There was no similar ability before.
8
though, so let us do that. That is beneficial for images on block
9
devices, where we cannot really write beyond the end of the image file.
5
10
6
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
11
Use this opportunity to add extensive comments to the code, and refactor
7
Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com
12
it a bit, getting rid of the backwards-jumping goto.
13
14
[1] Unless there is something allocated in the area pointed to by the
15
last refblock, so we have to write that refblock. In that case, we
16
try to put the reftable in there.
17
18
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1519071
19
Closes: https://gitlab.com/qemu-project/qemu/-/issues/941
8
Reviewed-by: Eric Blake <eblake@redhat.com>
20
Reviewed-by: Eric Blake <eblake@redhat.com>
9
[mreitz: Keep optstring in alphabetical order]
21
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
22
Message-Id: <20220405134652.19278-2-hreitz@redhat.com>
11
---
23
---
12
qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++---
24
block/qcow2-refcount.c | 332 +++++++++++++++++++++++++++++------------
13
1 file changed, 93 insertions(+), 6 deletions(-)
25
1 file changed, 235 insertions(+), 97 deletions(-)
14
26
15
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
27
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
16
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
17
--- a/qemu-io-cmds.c
29
--- a/block/qcow2-refcount.c
18
+++ b/qemu-io-cmds.c
30
+++ b/block/qcow2-refcount.c
19
@@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p)
31
@@ -XXX,XX +XXX,XX @@ static int64_t alloc_clusters_imrt(BlockDriverState *bs,
20
qemu_vfree(p);
21
}
32
}
22
33
34
/*
35
- * Creates a new refcount structure based solely on the in-memory information
36
- * given through *refcount_table. All necessary allocations will be reflected
37
- * in that array.
38
+ * Helper function for rebuild_refcount_structure().
39
*
40
- * On success, the old refcount structure is leaked (it will be covered by the
41
- * new refcount structure).
42
+ * Scan the range of clusters [first_cluster, end_cluster) for allocated
43
+ * clusters and write all corresponding refblocks to disk. The refblock
44
+ * and allocation data is taken from the in-memory refcount table
45
+ * *refcount_table[] (of size *nb_clusters), which is basically one big
46
+ * (unlimited size) refblock for the whole image.
47
+ *
48
+ * For these refblocks, clusters are allocated using said in-memory
49
+ * refcount table. Care is taken that these allocations are reflected
50
+ * in the refblocks written to disk.
51
+ *
52
+ * The refblocks' offsets are written into a reftable, which is
53
+ * *on_disk_reftable_ptr[] (of size *on_disk_reftable_entries_ptr). If
54
+ * that reftable is of insufficient size, it will be resized to fit.
55
+ * This reftable is not written to disk.
56
+ *
57
+ * (If *on_disk_reftable_ptr is not NULL, the entries within are assumed
58
+ * to point to existing valid refblocks that do not need to be allocated
59
+ * again.)
60
+ *
61
+ * Return whether the on-disk reftable array was resized (true/false),
62
+ * or -errno on error.
63
*/
64
-static int rebuild_refcount_structure(BlockDriverState *bs,
65
- BdrvCheckResult *res,
66
- void **refcount_table,
67
- int64_t *nb_clusters)
68
+static int rebuild_refcounts_write_refblocks(
69
+ BlockDriverState *bs, void **refcount_table, int64_t *nb_clusters,
70
+ int64_t first_cluster, int64_t end_cluster,
71
+ uint64_t **on_disk_reftable_ptr, uint32_t *on_disk_reftable_entries_ptr
72
+ )
73
{
74
BDRVQcow2State *s = bs->opaque;
75
- int64_t first_free_cluster = 0, reftable_offset = -1, cluster = 0;
76
+ int64_t cluster;
77
int64_t refblock_offset, refblock_start, refblock_index;
78
- uint32_t reftable_size = 0;
79
- uint64_t *on_disk_reftable = NULL;
80
+ int64_t first_free_cluster = 0;
81
+ uint64_t *on_disk_reftable = *on_disk_reftable_ptr;
82
+ uint32_t on_disk_reftable_entries = *on_disk_reftable_entries_ptr;
83
void *on_disk_refblock;
84
- int ret = 0;
85
- struct {
86
- uint64_t reftable_offset;
87
- uint32_t reftable_clusters;
88
- } QEMU_PACKED reftable_offset_and_clusters;
89
-
90
- qcow2_cache_empty(bs, s->refcount_block_cache);
91
+ bool reftable_grown = false;
92
+ int ret;
93
94
-write_refblocks:
95
- for (; cluster < *nb_clusters; cluster++) {
96
+ for (cluster = first_cluster; cluster < end_cluster; cluster++) {
97
+ /* Check all clusters to find refblocks that contain non-zero entries */
98
if (!s->get_refcount(*refcount_table, cluster)) {
99
continue;
100
}
101
102
+ /*
103
+ * This cluster is allocated, so we need to create a refblock
104
+ * for it. The data we will write to disk is just the
105
+ * respective slice from *refcount_table, so it will contain
106
+ * accurate refcounts for all clusters belonging to this
107
+ * refblock. After we have written it, we will therefore skip
108
+ * all remaining clusters in this refblock.
109
+ */
110
+
111
refblock_index = cluster >> s->refcount_block_bits;
112
refblock_start = refblock_index << s->refcount_block_bits;
113
114
- /* Don't allocate a cluster in a refblock already written to disk */
115
- if (first_free_cluster < refblock_start) {
116
- first_free_cluster = refblock_start;
117
- }
118
- refblock_offset = alloc_clusters_imrt(bs, 1, refcount_table,
119
- nb_clusters, &first_free_cluster);
120
- if (refblock_offset < 0) {
121
- fprintf(stderr, "ERROR allocating refblock: %s\n",
122
- strerror(-refblock_offset));
123
- res->check_errors++;
124
- ret = refblock_offset;
125
- goto fail;
126
- }
127
+ if (on_disk_reftable_entries > refblock_index &&
128
+ on_disk_reftable[refblock_index])
129
+ {
130
+ /*
131
+ * We can get here after a `goto write_refblocks`: We have a
132
+ * reftable from a previous run, and the refblock is already
133
+ * allocated. No need to allocate it again.
134
+ */
135
+ refblock_offset = on_disk_reftable[refblock_index];
136
+ } else {
137
+ int64_t refblock_cluster_index;
138
139
- if (reftable_size <= refblock_index) {
140
- uint32_t old_reftable_size = reftable_size;
141
- uint64_t *new_on_disk_reftable;
142
+ /* Don't allocate a cluster in a refblock already written to disk */
143
+ if (first_free_cluster < refblock_start) {
144
+ first_free_cluster = refblock_start;
145
+ }
146
+ refblock_offset = alloc_clusters_imrt(bs, 1, refcount_table,
147
+ nb_clusters,
148
+ &first_free_cluster);
149
+ if (refblock_offset < 0) {
150
+ fprintf(stderr, "ERROR allocating refblock: %s\n",
151
+ strerror(-refblock_offset));
152
+ return refblock_offset;
153
+ }
154
155
- reftable_size = ROUND_UP((refblock_index + 1) * REFTABLE_ENTRY_SIZE,
156
- s->cluster_size) / REFTABLE_ENTRY_SIZE;
157
- new_on_disk_reftable = g_try_realloc(on_disk_reftable,
158
- reftable_size *
159
- REFTABLE_ENTRY_SIZE);
160
- if (!new_on_disk_reftable) {
161
- res->check_errors++;
162
- ret = -ENOMEM;
163
- goto fail;
164
+ refblock_cluster_index = refblock_offset / s->cluster_size;
165
+ if (refblock_cluster_index >= end_cluster) {
166
+ /*
167
+ * We must write the refblock that holds this refblock's
168
+ * refcount
169
+ */
170
+ end_cluster = refblock_cluster_index + 1;
171
}
172
- on_disk_reftable = new_on_disk_reftable;
173
174
- memset(on_disk_reftable + old_reftable_size, 0,
175
- (reftable_size - old_reftable_size) * REFTABLE_ENTRY_SIZE);
176
+ if (on_disk_reftable_entries <= refblock_index) {
177
+ on_disk_reftable_entries =
178
+ ROUND_UP((refblock_index + 1) * REFTABLE_ENTRY_SIZE,
179
+ s->cluster_size) / REFTABLE_ENTRY_SIZE;
180
+ on_disk_reftable =
181
+ g_try_realloc(on_disk_reftable,
182
+ on_disk_reftable_entries *
183
+ REFTABLE_ENTRY_SIZE);
184
+ if (!on_disk_reftable) {
185
+ return -ENOMEM;
186
+ }
187
188
- /* The offset we have for the reftable is now no longer valid;
189
- * this will leak that range, but we can easily fix that by running
190
- * a leak-fixing check after this rebuild operation */
191
- reftable_offset = -1;
192
- } else {
193
- assert(on_disk_reftable);
194
- }
195
- on_disk_reftable[refblock_index] = refblock_offset;
196
+ memset(on_disk_reftable + *on_disk_reftable_entries_ptr, 0,
197
+ (on_disk_reftable_entries -
198
+ *on_disk_reftable_entries_ptr) *
199
+ REFTABLE_ENTRY_SIZE);
200
201
- /* If this is apparently the last refblock (for now), try to squeeze the
202
- * reftable in */
203
- if (refblock_index == (*nb_clusters - 1) >> s->refcount_block_bits &&
204
- reftable_offset < 0)
205
- {
206
- uint64_t reftable_clusters = size_to_clusters(s, reftable_size *
207
- REFTABLE_ENTRY_SIZE);
208
- reftable_offset = alloc_clusters_imrt(bs, reftable_clusters,
209
- refcount_table, nb_clusters,
210
- &first_free_cluster);
211
- if (reftable_offset < 0) {
212
- fprintf(stderr, "ERROR allocating reftable: %s\n",
213
- strerror(-reftable_offset));
214
- res->check_errors++;
215
- ret = reftable_offset;
216
- goto fail;
217
+ *on_disk_reftable_ptr = on_disk_reftable;
218
+ *on_disk_reftable_entries_ptr = on_disk_reftable_entries;
219
+
220
+ reftable_grown = true;
221
+ } else {
222
+ assert(on_disk_reftable);
223
}
224
+ on_disk_reftable[refblock_index] = refblock_offset;
225
}
226
227
+ /* Refblock is allocated, write it to disk */
228
+
229
ret = qcow2_pre_write_overlap_check(bs, 0, refblock_offset,
230
s->cluster_size, false);
231
if (ret < 0) {
232
fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
233
- goto fail;
234
+ return ret;
235
}
236
237
- /* The size of *refcount_table is always cluster-aligned, therefore the
238
- * write operation will not overflow */
239
+ /*
240
+ * The refblock is simply a slice of *refcount_table.
241
+ * Note that the size of *refcount_table is always aligned to
242
+ * whole clusters, so the write operation will not result in
243
+ * out-of-bounds accesses.
244
+ */
245
on_disk_refblock = (void *)((char *) *refcount_table +
246
refblock_index * s->cluster_size);
247
248
@@ -XXX,XX +XXX,XX @@ write_refblocks:
249
s->cluster_size);
250
if (ret < 0) {
251
fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
252
- goto fail;
253
+ return ret;
254
}
255
256
- /* Go to the end of this refblock */
257
+ /* This refblock is done, skip to its end */
258
cluster = refblock_start + s->refcount_block_size - 1;
259
}
260
261
- if (reftable_offset < 0) {
262
- uint64_t post_refblock_start, reftable_clusters;
263
+ return reftable_grown;
264
+}
265
+
23
+/*
266
+/*
24
+ * qemu_io_alloc_from_file()
267
+ * Creates a new refcount structure based solely on the in-memory information
268
+ * given through *refcount_table (this in-memory information is basically just
269
+ * the concatenation of all refblocks). All necessary allocations will be
270
+ * reflected in that array.
25
+ *
271
+ *
26
+ * Allocates the buffer and populates it with the content of the given file
272
+ * On success, the old refcount structure is leaked (it will be covered by the
27
+ * up to @len bytes. If the file length is less than @len, then the buffer
273
+ * new refcount structure).
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
+ */
274
+ */
37
+static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len,
275
+static int rebuild_refcount_structure(BlockDriverState *bs,
38
+ const char *file_name)
276
+ BdrvCheckResult *res,
277
+ void **refcount_table,
278
+ int64_t *nb_clusters)
39
+{
279
+{
40
+ char *buf, *buf_origin;
280
+ BDRVQcow2State *s = bs->opaque;
41
+ FILE *f = fopen(file_name, "r");
281
+ int64_t reftable_offset = -1;
42
+ int pattern_len;
282
+ int64_t reftable_length = 0;
43
+
283
+ int64_t reftable_clusters;
44
+ if (!f) {
284
+ int64_t refblock_index;
45
+ perror(file_name);
285
+ uint32_t on_disk_reftable_entries = 0;
46
+ return NULL;
286
+ uint64_t *on_disk_reftable = NULL;
287
+ int ret = 0;
288
+ int reftable_size_changed = 0;
289
+ struct {
290
+ uint64_t reftable_offset;
291
+ uint32_t reftable_clusters;
292
+ } QEMU_PACKED reftable_offset_and_clusters;
293
+
294
+ qcow2_cache_empty(bs, s->refcount_block_cache);
295
+
296
+ /*
297
+ * For each refblock containing entries, we try to allocate a
298
+ * cluster (in the in-memory refcount table) and write its offset
299
+ * into on_disk_reftable[]. We then write the whole refblock to
300
+ * disk (as a slice of the in-memory refcount table).
301
+ * This is done by rebuild_refcounts_write_refblocks().
302
+ *
303
+ * Once we have scanned all clusters, we try to find space for the
304
+ * reftable. This will dirty the in-memory refcount table (i.e.
305
+ * make it differ from the refblocks we have already written), so we
306
+ * need to run rebuild_refcounts_write_refblocks() again for the
307
+ * range of clusters where the reftable has been allocated.
308
+ *
309
+ * This second run might make the reftable grow again, in which case
310
+ * we will need to allocate another space for it, which is why we
311
+ * repeat all this until the reftable stops growing.
312
+ *
313
+ * (This loop will terminate, because with every cluster the
314
+ * reftable grows, it can accomodate a multitude of more refcounts,
315
+ * so that at some point this must be able to cover the reftable
316
+ * and all refblocks describing it.)
317
+ *
318
+ * We then convert the reftable to big-endian and write it to disk.
319
+ *
320
+ * Note that we never free any reftable allocations. Doing so would
321
+ * needlessly complicate the algorithm: The eventual second check
322
+ * run we do will clean up all leaks we have caused.
323
+ */
324
+
325
+ reftable_size_changed =
326
+ rebuild_refcounts_write_refblocks(bs, refcount_table, nb_clusters,
327
+ 0, *nb_clusters,
328
+ &on_disk_reftable,
329
+ &on_disk_reftable_entries);
330
+ if (reftable_size_changed < 0) {
331
+ res->check_errors++;
332
+ ret = reftable_size_changed;
333
+ goto fail;
47
+ }
334
+ }
48
+
335
+
49
+ if (qemuio_misalign) {
336
+ /*
50
+ len += MISALIGN_OFFSET;
337
+ * There was no reftable before, so rebuild_refcounts_write_refblocks()
51
+ }
338
+ * must have increased its size (from 0 to something).
52
+
339
+ */
53
+ buf_origin = buf = blk_blockalign(blk, len);
340
+ assert(reftable_size_changed);
54
+
341
+
55
+ if (qemuio_misalign) {
342
+ do {
56
+ buf_origin += MISALIGN_OFFSET;
343
+ int64_t reftable_start_cluster, reftable_end_cluster;
57
+ buf += MISALIGN_OFFSET;
344
+ int64_t first_free_cluster = 0;
58
+ len -= MISALIGN_OFFSET;
345
+
59
+ }
346
+ reftable_length = on_disk_reftable_entries * REFTABLE_ENTRY_SIZE;
60
+
347
+ reftable_clusters = size_to_clusters(s, reftable_length);
61
+ pattern_len = fread(buf_origin, 1, len, f);
348
62
+
349
- post_refblock_start = ROUND_UP(*nb_clusters, s->refcount_block_size);
63
+ if (ferror(f)) {
350
- reftable_clusters =
64
+ perror(file_name);
351
- size_to_clusters(s, reftable_size * REFTABLE_ENTRY_SIZE);
65
+ goto error;
352
- /* Not pretty but simple */
66
+ }
353
- if (first_free_cluster < post_refblock_start) {
67
+
354
- first_free_cluster = post_refblock_start;
68
+ if (pattern_len == 0) {
355
- }
69
+ fprintf(stderr, "%s: file is empty\n", file_name);
356
reftable_offset = alloc_clusters_imrt(bs, reftable_clusters,
70
+ goto error;
357
refcount_table, nb_clusters,
71
+ }
358
&first_free_cluster);
72
+
359
@@ -XXX,XX +XXX,XX @@ write_refblocks:
73
+ fclose(f);
360
goto fail;
74
+
361
}
75
+ if (len > pattern_len) {
362
76
+ len -= pattern_len;
363
- goto write_refblocks;
77
+ buf += pattern_len;
364
- }
78
+
365
+ /*
79
+ while (len > 0) {
366
+ * We need to update the affected refblocks, so re-run the
80
+ size_t len_to_copy = MIN(pattern_len, len);
367
+ * write_refblocks loop for the reftable's range of clusters.
81
+
368
+ */
82
+ memcpy(buf, buf_origin, len_to_copy);
369
+ assert(offset_into_cluster(s, reftable_offset) == 0);
83
+
370
+ reftable_start_cluster = reftable_offset / s->cluster_size;
84
+ len -= len_to_copy;
371
+ reftable_end_cluster = reftable_start_cluster + reftable_clusters;
85
+ buf += len_to_copy;
372
+ reftable_size_changed =
373
+ rebuild_refcounts_write_refblocks(bs, refcount_table, nb_clusters,
374
+ reftable_start_cluster,
375
+ reftable_end_cluster,
376
+ &on_disk_reftable,
377
+ &on_disk_reftable_entries);
378
+ if (reftable_size_changed < 0) {
379
+ res->check_errors++;
380
+ ret = reftable_size_changed;
381
+ goto fail;
86
+ }
382
+ }
87
+ }
383
+
88
+
384
+ /*
89
+ return buf_origin;
385
+ * If the reftable size has changed, we will need to find a new
90
+
386
+ * allocation, repeating the loop.
91
+error:
387
+ */
92
+ qemu_io_free(buf_origin);
388
+ } while (reftable_size_changed);
93
+ return NULL;
389
94
+}
390
- for (refblock_index = 0; refblock_index < reftable_size; refblock_index++) {
95
+
391
+ /* The above loop must have run at least once */
96
static void dump_buffer(const void *buffer, int64_t offset, int64_t len)
392
+ assert(reftable_offset >= 0);
97
{
393
+
98
uint64_t i;
394
+ /*
99
@@ -XXX,XX +XXX,XX @@ static void write_help(void)
395
+ * All allocations are done, all refblocks are written, convert the
100
" -n, -- with -z, don't allow slow fallback\n"
396
+ * reftable to big-endian and write it to disk.
101
" -p, -- ignored for backwards compatibility\n"
397
+ */
102
" -P, -- use different pattern to fill file\n"
398
+
103
+" -s, -- use a pattern file to fill the write buffer\n"
399
+ for (refblock_index = 0; refblock_index < on_disk_reftable_entries;
104
" -C, -- report statistics in a machine parsable format\n"
400
+ refblock_index++)
105
" -q, -- quiet mode, do not show I/O statistics\n"
401
+ {
106
" -u, -- with -z, allow unmapping\n"
402
cpu_to_be64s(&on_disk_reftable[refblock_index]);
107
@@ -XXX,XX +XXX,XX @@ static const cmdinfo_t write_cmd = {
108
.perm = BLK_PERM_WRITE,
109
.argmin = 2,
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;
140
+ case 's':
141
+ sflag = true;
142
+ file_name = optarg;
143
+ break;
144
case 'u':
145
flags |= BDRV_REQ_MAY_UNMAP;
146
break;
147
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
148
return -EINVAL;
149
}
403
}
150
404
151
- if (zflag && Pflag) {
405
- ret = qcow2_pre_write_overlap_check(bs, 0, reftable_offset,
152
- printf("-z and -P cannot be specified at the same time\n");
406
- reftable_size * REFTABLE_ENTRY_SIZE,
153
+ if (zflag + Pflag + sflag > 1) {
407
+ ret = qcow2_pre_write_overlap_check(bs, 0, reftable_offset, reftable_length,
154
+ printf("Only one of -z, -P, and -s "
408
false);
155
+ "can be specified at the same time\n");
409
if (ret < 0) {
156
return -EINVAL;
410
fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
411
goto fail;
157
}
412
}
158
413
159
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
414
- assert(reftable_size < INT_MAX / REFTABLE_ENTRY_SIZE);
415
+ assert(reftable_length < INT_MAX);
416
ret = bdrv_pwrite(bs->file, reftable_offset, on_disk_reftable,
417
- reftable_size * REFTABLE_ENTRY_SIZE);
418
+ reftable_length);
419
if (ret < 0) {
420
fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
421
goto fail;
422
@@ -XXX,XX +XXX,XX @@ write_refblocks:
423
/* Enter new reftable into the image header */
424
reftable_offset_and_clusters.reftable_offset = cpu_to_be64(reftable_offset);
425
reftable_offset_and_clusters.reftable_clusters =
426
- cpu_to_be32(size_to_clusters(s, reftable_size * REFTABLE_ENTRY_SIZE));
427
+ cpu_to_be32(reftable_clusters);
428
ret = bdrv_pwrite_sync(bs->file,
429
offsetof(QCowHeader, refcount_table_offset),
430
&reftable_offset_and_clusters,
431
@@ -XXX,XX +XXX,XX @@ write_refblocks:
432
goto fail;
160
}
433
}
161
434
162
if (!zflag) {
435
- for (refblock_index = 0; refblock_index < reftable_size; refblock_index++) {
163
- buf = qemu_io_alloc(blk, count, pattern);
436
+ for (refblock_index = 0; refblock_index < on_disk_reftable_entries;
164
+ if (sflag) {
437
+ refblock_index++)
165
+ buf = qemu_io_alloc_from_file(blk, count, file_name);
438
+ {
166
+ if (!buf) {
439
be64_to_cpus(&on_disk_reftable[refblock_index]);
167
+ return -EINVAL;
168
+ }
169
+ } else {
170
+ buf = qemu_io_alloc(blk, count, pattern);
171
+ }
172
}
440
}
173
441
s->refcount_table = on_disk_reftable;
174
clock_gettime(CLOCK_MONOTONIC, &t1);
442
s->refcount_table_offset = reftable_offset;
443
- s->refcount_table_size = reftable_size;
444
+ s->refcount_table_size = on_disk_reftable_entries;
445
update_max_refcount_table_index(s);
446
447
return 0;
175
--
448
--
176
2.21.0
449
2.35.1
177
178
diff view generated by jsdifflib
Deleted patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
1
3
It's wrong to OR shared permissions. It may lead to crash on further
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
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
13
Message-id: 20190824100740.61635-1-vsementsov@virtuozzo.com
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
block.c | 5 ++---
17
1 file changed, 2 insertions(+), 3 deletions(-)
18
19
diff --git a/block.c b/block.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block.c
22
+++ b/block.c
23
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
24
{
25
BdrvChild *c, *next;
26
GSList *list = NULL, *p;
27
- uint64_t old_perm, old_shared;
28
uint64_t perm = 0, shared = BLK_PERM_ALL;
29
int ret;
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
--
43
2.21.0
44
45
diff view generated by jsdifflib
Deleted patch
1
From: Nir Soffer <nirsof@gmail.com>
2
1
3
When creating an image with preallocation "off" or "falloc", the first
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
8
In this case we fallback to a safe value (4096) instead of the optimal
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>
60
Signed-off-by: Max Reitz <mreitz@redhat.com>
61
---
62
block/file-posix.c | 51 +++++++++++++++++++
63
tests/qemu-iotests/059.out | 2 +-
64
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
65
tests/qemu-iotests/150.out.raw | 12 +++++
66
tests/qemu-iotests/175 | 19 ++++---
67
tests/qemu-iotests/175.out | 8 +--
68
tests/qemu-iotests/178.out.qcow2 | 4 +-
69
tests/qemu-iotests/221.out | 12 +++--
70
tests/qemu-iotests/253.out | 12 +++--
71
9 files changed, 99 insertions(+), 21 deletions(-)
72
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
73
create mode 100644 tests/qemu-iotests/150.out.raw
74
75
diff --git a/block/file-posix.c b/block/file-posix.c
76
index XXXXXXX..XXXXXXX 100644
77
--- a/block/file-posix.c
78
+++ b/block/file-posix.c
79
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque)
80
return ret;
81
}
82
83
+/*
84
+ * Help alignment probing by allocating the first block.
85
+ *
86
+ * When reading with direct I/O from unallocated area on Gluster backed by XFS,
87
+ * reading succeeds regardless of request length. In this case we fallback to
88
+ * safe alignment which is not optimal. Allocating the first block avoids this
89
+ * fallback.
90
+ *
91
+ * fd may be opened with O_DIRECT, but we don't know the buffer alignment or
92
+ * request alignment, so we use safe values.
93
+ *
94
+ * Returns: 0 on success, -errno on failure. Since this is an optimization,
95
+ * caller may ignore failures.
96
+ */
97
+static int allocate_first_block(int fd, size_t max_size)
98
+{
99
+ size_t write_size = (max_size < MAX_BLOCKSIZE)
100
+ ? BDRV_SECTOR_SIZE
101
+ : MAX_BLOCKSIZE;
102
+ size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize());
103
+ void *buf;
104
+ ssize_t n;
105
+ int ret;
106
+
107
+ buf = qemu_memalign(max_align, write_size);
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
}
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
--
336
2.21.0
337
338
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
One clear problem with how qcow2's refcount structure rebuild algorithm
2
used to be before "qcow2: Improve refcount structure rebuilding" was
3
that it is prone to failure for qcow2 images on block devices: There is
4
generally unused space after the actual image, and if that exceeds what
5
one refblock covers, the old algorithm would invariably write the
6
reftable past the block device's end, which cannot work. The new
7
algorithm does not have this problem.
2
8
3
Using block_resize we can test allocate_first_block() with file
9
Test it with three tests:
4
descriptor opened with O_DIRECT, ensuring that it works for any size
10
(1) Create an image with more empty space at the end than what one
5
larger than 4096 bytes.
11
refblock covers, see whether rebuilding the refcount structures
12
results in a change in the image file length. (It should not.)
6
13
7
Testing smaller sizes is tricky as the result depends on the filesystem
14
(2) Leave precisely enough space somewhere at the beginning of the image
8
used for testing. For example on NFS any size will work since O_DIRECT
15
for the new reftable (and the refblock for that place), see whether
9
does not require any alignment.
16
the new algorithm puts the reftable there. (It should.)
10
17
11
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
18
(3) Test the original problem: Create (something like) a block device
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
19
with a fixed size, then create a qcow2 image in there, write some
13
Message-id: 20190827010528.8818-3-nsoffer@redhat.com
20
data, and then have qemu-img check rebuild the refcount structures.
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
21
Before HEAD^, the reftable would have been written past the image
22
file end, i.e. outside of what the block device provides, which
23
cannot work. HEAD^ should have fixed that.
24
("Something like a block device" means a loop device if we can use
25
one ("sudo -n losetup" works), or a FUSE block export with
26
growable=false otherwise.)
27
28
Reviewed-by: Eric Blake <eblake@redhat.com>
29
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
30
Message-Id: <20220405134652.19278-3-hreitz@redhat.com>
15
---
31
---
16
tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++
32
tests/qemu-iotests/108 | 259 ++++++++++++++++++++++++++++++++++++-
17
tests/qemu-iotests/175.out | 8 ++++++++
33
tests/qemu-iotests/108.out | 81 ++++++++++++
18
2 files changed, 36 insertions(+)
34
2 files changed, 339 insertions(+), 1 deletion(-)
19
35
20
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
36
diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108
21
index XXXXXXX..XXXXXXX 100755
37
index XXXXXXX..XXXXXXX 100755
22
--- a/tests/qemu-iotests/175
38
--- a/tests/qemu-iotests/108
23
+++ b/tests/qemu-iotests/175
39
+++ b/tests/qemu-iotests/108
24
@@ -XXX,XX +XXX,XX @@ _filter_blocks()
40
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
25
-e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
41
42
_cleanup()
43
{
44
-    _cleanup_test_img
45
+ _cleanup_test_img
46
+ if [ -f "$TEST_DIR/qsd.pid" ]; then
47
+ qsd_pid=$(cat "$TEST_DIR/qsd.pid")
48
+ kill -KILL "$qsd_pid"
49
+ fusermount -u "$TEST_DIR/fuse-export" &>/dev/null
50
+ fi
51
+ rm -f "$TEST_DIR/fuse-export"
26
}
52
}
27
53
trap "_cleanup; exit \$status" 0 1 2 3 15
28
+# Resize image using block_resize.
54
29
+# Parameter 1: image path
30
+# Parameter 2: new size
31
+_block_resize()
32
+{
33
+ local path=$1
34
+ local size=$2
35
+
36
+ $QEMU -qmp stdio -nographic -nodefaults \
37
+ -blockdev file,node-name=file,filename=$path,cache.direct=on \
38
+ <<EOF
39
+{'execute': 'qmp_capabilities'}
40
+{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}}
41
+{'execute': 'quit'}
42
+EOF
43
+}
44
+
45
# get standard environment, filters and checks
55
# get standard environment, filters and checks
46
. ./common.rc
56
. ./common.rc
47
. ./common.filter
57
. ./common.filter
48
@@ -XXX,XX +XXX,XX @@ _supported_fmt raw
58
+. ./common.qemu
49
_supported_proto file
59
50
_supported_os Linux
60
# This tests qcow2-specific low-level functionality
51
61
_supported_fmt qcow2
52
+_default_cache_mode none
62
@@ -XXX,XX +XXX,XX @@ _supported_os Linux
53
+_supported_cache_modes none directsync
63
# files
54
+
64
_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file
55
size=$((1 * 1024 * 1024))
65
56
66
+# This test either needs sudo -n losetup or FUSE exports to work
57
touch "$TEST_DIR/empty"
67
+if sudo -n losetup &>/dev/null; then
58
@@ -XXX,XX +XXX,XX @@ for mode in off full falloc; do
68
+ loopdev=true
59
stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
69
+else
60
done
70
+ loopdev=false
61
71
+
62
+for new_size in 4096 1048576; do
72
+ # QSD --export fuse will either yield "Parameter 'id' is missing"
63
+ echo
73
+ # or "Invalid parameter 'fuse'", depending on whether there is
64
+ echo "== resize empty image with block_resize =="
74
+ # FUSE support or not.
65
+ _make_test_img 0 | _filter_imgfmt
75
+ error=$($QSD --export fuse 2>&1)
66
+ _block_resize $TEST_IMG $new_size >/dev/null
76
+ if [[ $error = *"'fuse'"* ]]; then
67
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $new_size
77
+ _notrun 'Passwordless sudo for losetup or FUSE support required, but' \
78
+ 'neither is available'
79
+ fi
80
+fi
81
+
82
echo
83
echo '=== Repairing an image without any refcount table ==='
84
echo
85
@@ -XXX,XX +XXX,XX @@ _make_test_img 64M
86
poke_file "$TEST_IMG" $((0x10008)) "\xff\xff\xff\xff\xff\xff\x00\x00"
87
_check_test_img -r all
88
89
+echo
90
+echo '=== Check rebuilt reftable location ==='
91
+
92
+# In an earlier version of the refcount rebuild algorithm, the
93
+# reftable was generally placed at the image end (unless something was
94
+# allocated in the area covered by the refblock right before the image
95
+# file end, then we would try to place the reftable in that refblock).
96
+# This was later changed so the reftable would be placed in the
97
+# earliest possible location. Test this.
98
+
99
+echo
100
+echo '--- Does the image size increase? ---'
101
+echo
102
+
103
+# First test: Just create some image, write some data to it, and
104
+# resize it so there is free space at the end of the image (enough
105
+# that it spans at least one full refblock, which for cluster_size=512
106
+# images, spans 128k). With the old algorithm, the reftable would
107
+# have then been placed at the end of the image file, but with the new
108
+# one, it will be put in that free space.
109
+# We want to check whether the size of the image file increases due to
110
+# rebuilding the refcount structures (it should not).
111
+
112
+_make_test_img -o 'cluster_size=512' 1M
113
+# Write something
114
+$QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io
115
+
116
+# Add free space
117
+file_len=$(stat -c '%s' "$TEST_IMG")
118
+truncate -s $((file_len + 256 * 1024)) "$TEST_IMG"
119
+
120
+# Corrupt the image by saying the image header was not allocated
121
+rt_offset=$(peek_file_be "$TEST_IMG" 48 8)
122
+rb_offset=$(peek_file_be "$TEST_IMG" $rt_offset 8)
123
+poke_file "$TEST_IMG" $rb_offset "\x00\x00"
124
+
125
+# Check whether rebuilding the refcount structures increases the image
126
+# file size
127
+file_len=$(stat -c '%s' "$TEST_IMG")
128
+echo
129
+# The only leaks there can be are the old refcount structures that are
130
+# leaked during rebuilding, no need to clutter the output with them
131
+_check_test_img -r all | grep -v '^Repairing cluster.*refcount=1 reference=0'
132
+echo
133
+post_repair_file_len=$(stat -c '%s' "$TEST_IMG")
134
+
135
+if [[ $file_len -eq $post_repair_file_len ]]; then
136
+ echo 'OK: Image size did not change'
137
+else
138
+ echo 'ERROR: Image size differs' \
139
+ "($file_len before, $post_repair_file_len after)"
140
+fi
141
+
142
+echo
143
+echo '--- Will the reftable occupy a hole specifically left for it? ---'
144
+echo
145
+
146
+# Note: With cluster_size=512, every refblock covers 128k.
147
+# The reftable covers 8M per reftable cluster.
148
+
149
+# Create an image that requires two reftable clusters (just because
150
+# this is more interesting than a single-clustered reftable).
151
+_make_test_img -o 'cluster_size=512' 9M
152
+$QEMU_IO -c 'write 0 8M' "$TEST_IMG" | _filter_qemu_io
153
+
154
+# Writing 8M will have resized the reftable. Unfortunately, doing so
155
+# will leave holes in the file, so we need to fill them up so we can
156
+# be sure the whole file is allocated. Do that by writing
157
+# consecutively smaller chunks starting from 8 MB, until the file
158
+# length increases even with a chunk size of 512. Then we must have
159
+# filled all holes.
160
+ofs=$((8 * 1024 * 1024))
161
+block_len=$((16 * 1024))
162
+while [[ $block_len -ge 512 ]]; do
163
+ file_len=$(stat -c '%s' "$TEST_IMG")
164
+ while [[ $(stat -c '%s' "$TEST_IMG") -eq $file_len ]]; do
165
+ # Do not include this in the reference output, it does not
166
+ # really matter which qemu-io calls we do here exactly
167
+ $QEMU_IO -c "write $ofs $block_len" "$TEST_IMG" >/dev/null
168
+ ofs=$((ofs + block_len))
169
+ done
170
+ block_len=$((block_len / 2))
68
+done
171
+done
69
+
172
+
173
+# Fill up to 9M (do not include this in the reference output either,
174
+# $ofs is random for all we know)
175
+$QEMU_IO -c "write $ofs $((9 * 1024 * 1024 - ofs))" "$TEST_IMG" >/dev/null
176
+
177
+# Make space as follows:
178
+# - For the first refblock: Right at the beginning of the image (this
179
+# refblock is placed in the first place possible),
180
+# - For the reftable somewhere soon afterwards, still near the
181
+# beginning of the image (i.e. covered by the first refblock); the
182
+# reftable too is placed in the first place possible, but only after
183
+# all refblocks have been placed)
184
+# No space is needed for the other refblocks, because no refblock is
185
+# put before the space it covers. In this test case, we do not mind
186
+# if they are placed at the image file's end.
187
+
188
+# Before we make that space, we have to find out the host offset of
189
+# the area that belonged to the two data clusters at guest offset 4k,
190
+# because we expect the reftable to be placed there, and we will have
191
+# to verify that it is.
192
+
193
+l1_offset=$(peek_file_be "$TEST_IMG" 40 8)
194
+l2_offset=$(peek_file_be "$TEST_IMG" $l1_offset 8)
195
+l2_offset=$((l2_offset & 0x00fffffffffffe00))
196
+data_4k_offset=$(peek_file_be "$TEST_IMG" \
197
+ $((l2_offset + 4096 / 512 * 8)) 8)
198
+data_4k_offset=$((data_4k_offset & 0x00fffffffffffe00))
199
+
200
+$QEMU_IO -c "discard 0 512" -c "discard 4k 1k" "$TEST_IMG" | _filter_qemu_io
201
+
202
+# Corrupt the image by saying the image header was not allocated
203
+rt_offset=$(peek_file_be "$TEST_IMG" 48 8)
204
+rb_offset=$(peek_file_be "$TEST_IMG" $rt_offset 8)
205
+poke_file "$TEST_IMG" $rb_offset "\x00\x00"
206
+
207
+echo
208
+# The only leaks there can be are the old refcount structures that are
209
+# leaked during rebuilding, no need to clutter the output with them
210
+_check_test_img -r all | grep -v '^Repairing cluster.*refcount=1 reference=0'
211
+echo
212
+
213
+# Check whether the reftable was put where we expected
214
+rt_offset=$(peek_file_be "$TEST_IMG" 48 8)
215
+if [[ $rt_offset -eq $data_4k_offset ]]; then
216
+ echo 'OK: Reftable is where we expect it'
217
+else
218
+ echo "ERROR: Reftable is at $rt_offset, but was expected at $data_4k_offset"
219
+fi
220
+
221
+echo
222
+echo '--- Rebuilding refcount structures on block devices ---'
223
+echo
224
+
225
+# A block device cannot really grow, at least not during qemu-img
226
+# check. As mentioned in the above cases, rebuilding the refcount
227
+# structure may lead to new refcount structures being written after
228
+# the end of the image, and in the past that happened even if there
229
+# was more than sufficient space in the image. Such post-EOF writes
230
+# will not work on block devices, so test that the new algorithm
231
+# avoids it.
232
+
233
+# If we have passwordless sudo and losetup, we can use those to create
234
+# a block device. Otherwise, we can resort to qemu's FUSE export to
235
+# create a file that isn't growable, which effectively tests the same
236
+# thing.
237
+
238
+_cleanup_test_img
239
+truncate -s $((64 * 1024 * 1024)) "$TEST_IMG"
240
+
241
+if $loopdev; then
242
+ export_mp=$(sudo -n losetup --show -f "$TEST_IMG")
243
+ export_mp_driver=host_device
244
+ sudo -n chmod go+rw "$export_mp"
245
+else
246
+ # Create non-growable FUSE export that is a bit like an empty
247
+ # block device
248
+ export_mp="$TEST_DIR/fuse-export"
249
+ export_mp_driver=file
250
+ touch "$export_mp"
251
+
252
+ $QSD \
253
+ --blockdev file,node-name=export-node,filename="$TEST_IMG" \
254
+ --export fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=off \
255
+ --pidfile "$TEST_DIR/qsd.pid" \
256
+ --daemonize
257
+fi
258
+
259
+# Now create a qcow2 image on the device -- unfortunately, qemu-img
260
+# create force-creates the file, so we have to resort to the
261
+# blockdev-create job.
262
+_launch_qemu \
263
+ --blockdev $export_mp_driver,node-name=file,filename="$export_mp"
264
+
265
+_send_qemu_cmd \
266
+ $QEMU_HANDLE \
267
+ '{ "execute": "qmp_capabilities" }' \
268
+ 'return'
269
+
270
+# Small cluster size again, so the image needs multiple refblocks
271
+_send_qemu_cmd \
272
+ $QEMU_HANDLE \
273
+ '{ "execute": "blockdev-create",
274
+ "arguments": {
275
+ "job-id": "create",
276
+ "options": {
277
+ "driver": "qcow2",
278
+ "file": "file",
279
+ "size": '$((64 * 1024 * 1024))',
280
+ "cluster-size": 512
281
+ } } }' \
282
+ '"concluded"'
283
+
284
+_send_qemu_cmd \
285
+ $QEMU_HANDLE \
286
+ '{ "execute": "job-dismiss", "arguments": { "id": "create" } }' \
287
+ 'return'
288
+
289
+_send_qemu_cmd \
290
+ $QEMU_HANDLE \
291
+ '{ "execute": "quit" }' \
292
+ 'return'
293
+
294
+wait=y _cleanup_qemu
295
+echo
296
+
297
+# Write some data
298
+$QEMU_IO -c 'write 0 64k' "$export_mp" | _filter_qemu_io
299
+
300
+# Corrupt the image by saying the image header was not allocated
301
+rt_offset=$(peek_file_be "$export_mp" 48 8)
302
+rb_offset=$(peek_file_be "$export_mp" $rt_offset 8)
303
+poke_file "$export_mp" $rb_offset "\x00\x00"
304
+
305
+# Repairing such a simple case should just work
306
+# (We used to put the reftable at the end of the image file, which can
307
+# never work for non-growable devices.)
308
+echo
309
+TEST_IMG="$export_mp" _check_test_img -r all \
310
+ | grep -v '^Repairing cluster.*refcount=1 reference=0'
311
+
312
+if $loopdev; then
313
+ sudo -n losetup -d "$export_mp"
314
+else
315
+ qsd_pid=$(cat "$TEST_DIR/qsd.pid")
316
+ kill -TERM "$qsd_pid"
317
+ # Wait for process to exit (cannot `wait` because the QSD is daemonized)
318
+ while [ -f "$TEST_DIR/qsd.pid" ]; do
319
+ true
320
+ done
321
+fi
322
+
70
# success, all done
323
# success, all done
71
echo "*** done"
324
echo '*** done'
72
rm -f $seq.full
325
rm -f $seq.full
73
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
326
diff --git a/tests/qemu-iotests/108.out b/tests/qemu-iotests/108.out
74
index XXXXXXX..XXXXXXX 100644
327
index XXXXXXX..XXXXXXX 100644
75
--- a/tests/qemu-iotests/175.out
328
--- a/tests/qemu-iotests/108.out
76
+++ b/tests/qemu-iotests/175.out
329
+++ b/tests/qemu-iotests/108.out
77
@@ -XXX,XX +XXX,XX @@ size=1048576, max allocation
330
@@ -XXX,XX +XXX,XX @@ The following inconsistencies were found and repaired:
78
== creating image with preallocation falloc ==
331
0 leaked clusters
79
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
332
1 corruptions
80
size=1048576, max allocation
333
81
+
334
+Double checking the fixed image now...
82
+== resize empty image with block_resize ==
335
+No errors were found on the image.
83
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
336
+
84
+size=4096, min allocation
337
+=== Check rebuilt reftable location ===
85
+
338
+
86
+== resize empty image with block_resize ==
339
+--- Does the image size increase? ---
87
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
340
+
88
+size=1048576, min allocation
341
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
89
*** done
342
+wrote 65536/65536 bytes at offset 0
343
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
344
+
345
+ERROR cluster 0 refcount=0 reference=1
346
+Rebuilding refcount structure
347
+The following inconsistencies were found and repaired:
348
+
349
+ 0 leaked clusters
350
+ 1 corruptions
351
+
352
+Double checking the fixed image now...
353
+No errors were found on the image.
354
+
355
+OK: Image size did not change
356
+
357
+--- Will the reftable occupy a hole specifically left for it? ---
358
+
359
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=9437184
360
+wrote 8388608/8388608 bytes at offset 0
361
+8 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
362
+discard 512/512 bytes at offset 0
363
+512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
364
+discard 1024/1024 bytes at offset 4096
365
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
366
+
367
+ERROR cluster 0 refcount=0 reference=1
368
+Rebuilding refcount structure
369
+The following inconsistencies were found and repaired:
370
+
371
+ 0 leaked clusters
372
+ 1 corruptions
373
+
374
+Double checking the fixed image now...
375
+No errors were found on the image.
376
+
377
+OK: Reftable is where we expect it
378
+
379
+--- Rebuilding refcount structures on block devices ---
380
+
381
+{ "execute": "qmp_capabilities" }
382
+{"return": {}}
383
+{ "execute": "blockdev-create",
384
+ "arguments": {
385
+ "job-id": "create",
386
+ "options": {
387
+ "driver": "IMGFMT",
388
+ "file": "file",
389
+ "size": 67108864,
390
+ "cluster-size": 512
391
+ } } }
392
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "create"}}
393
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "create"}}
394
+{"return": {}}
395
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "create"}}
396
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "create"}}
397
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "create"}}
398
+{ "execute": "job-dismiss", "arguments": { "id": "create" } }
399
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "create"}}
400
+{"return": {}}
401
+{ "execute": "quit" }
402
+{"return": {}}
403
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
404
+
405
+wrote 65536/65536 bytes at offset 0
406
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
407
+
408
+ERROR cluster 0 refcount=0 reference=1
409
+Rebuilding refcount structure
410
+The following inconsistencies were found and repaired:
411
+
412
+ 0 leaked clusters
413
+ 1 corruptions
414
+
415
Double checking the fixed image now...
416
No errors were found on the image.
417
*** done
90
--
418
--
91
2.21.0
419
2.35.1
92
93
diff view generated by jsdifflib
Deleted patch
1
fe646693acc changed qemu-img create's output so that it no longer prints
2
single quotes around parameter values. The subformat and adapter_type
3
filters in _filter_img_create() have never been adapted to that change.
4
1
5
Fixes: fe646693acc13ac48b98435d14149ab04dc597bc
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: John Snow <jsnow@redhat.com>
8
Message-id: 20190815153638.4600-2-mreitz@redhat.com
9
Reviewed-by: John Snow <jsnow@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
tests/qemu-iotests/059.out | 16 ++++++++--------
13
tests/qemu-iotests/common.filter | 4 ++--
14
2 files changed, 10 insertions(+), 10 deletions(-)
15
16
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qemu-iotests/059.out
19
+++ b/tests/qemu-iotests/059.out
20
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
21
qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big
22
23
=== Testing monolithicFlat creation and opening ===
24
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
25
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
26
image: TEST_DIR/t.IMGFMT
27
file format: IMGFMT
28
virtual size: 2 GiB (2147483648 bytes)
29
30
=== Testing monolithicFlat with zeroed_grain ===
31
qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain
32
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
33
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
34
35
=== Testing big twoGbMaxExtentFlat ===
36
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMaxExtentFlat
37
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000
38
image: TEST_DIR/t.vmdk
39
file format: vmdk
40
virtual size: 0.977 TiB (1073741824000 bytes)
41
@@ -XXX,XX +XXX,XX @@ Format specific information:
42
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 12582912 VMFS "dummy.IMGFMT" 1
43
44
=== Testing truncated sparse ===
45
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 subformat=monolithicSparse
46
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400
47
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes
48
49
=== Converting to streamOptimized from image with small cluster size===
50
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
51
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
52
53
=== Testing monolithicFlat with internally generated JSON file name ===
54
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 subformat=monolithicFlat
55
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
56
qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}'
57
58
=== Testing version 3 ===
59
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 64931328
60
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
61
62
=== Testing 4TB monolithicFlat creation and IO ===
63
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 subformat=monolithicFlat
64
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104
65
image: TEST_DIR/t.IMGFMT
66
file format: IMGFMT
67
virtual size: 4 TiB (4398046511104 bytes)
68
@@ -XXX,XX +XXX,XX @@ read 1024/1024 bytes at offset 966367641600
69
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
70
71
=== Testing qemu-img map on extents ===
72
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=monolithicSparse
73
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
74
wrote 1024/1024 bytes at offset 65024
75
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
76
wrote 1024/1024 bytes at offset 2147483136
77
@@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File
78
0 0x20000 0x3f0000 TEST_DIR/t.vmdk
79
0x7fff0000 0x20000 0x410000 TEST_DIR/t.vmdk
80
0x140000000 0x10000 0x430000 TEST_DIR/t.vmdk
81
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=twoGbMaxExtentSparse
82
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
83
wrote 1024/1024 bytes at offset 65024
84
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
85
wrote 1024/1024 bytes at offset 2147483136
86
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
87
index XXXXXXX..XXXXXXX 100644
88
--- a/tests/qemu-iotests/common.filter
89
+++ b/tests/qemu-iotests/common.filter
90
@@ -XXX,XX +XXX,XX @@ _filter_img_create()
91
-e "s# compat6=\\(on\\|off\\)##g" \
92
-e "s# static=\\(on\\|off\\)##g" \
93
-e "s# zeroed_grain=\\(on\\|off\\)##g" \
94
- -e "s# subformat='[^']*'##g" \
95
- -e "s# adapter_type='[^']*'##g" \
96
+ -e "s# subformat=[^ ]*##g" \
97
+ -e "s# adapter_type=[^ ]*##g" \
98
-e "s# hwversion=[^ ]*##g" \
99
-e "s# lazy_refcounts=\\(on\\|off\\)##g" \
100
-e "s# block_size=[0-9]\\+##g" \
101
--
102
2.21.0
103
104
diff view generated by jsdifflib
1
This makes iotest 033 pass with e.g. subformat=monolithicFlat. It also
1
Instead of fprint()-ing error messages in rebuild_refcount_structure()
2
turns a former error in 059 into success.
2
and its rebuild_refcounts_write_refblocks() helper, pass them through an
3
Error object to qcow2_check_refcounts() (which will then print it).
3
4
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
Suggested-by: Eric Blake <eblake@redhat.com>
5
Message-id: 20190815153638.4600-3-mreitz@redhat.com
6
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
6
Reviewed-by: John Snow <jsnow@redhat.com>
7
Message-Id: <20220405134652.19278-4-hreitz@redhat.com>
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
8
---
9
---
9
block/vmdk.c | 54 ++++++++++++++++++++++++--------------
10
block/qcow2-refcount.c | 33 +++++++++++++++++++--------------
10
tests/qemu-iotests/059 | 7 +++--
11
1 file changed, 19 insertions(+), 14 deletions(-)
11
tests/qemu-iotests/059.out | 4 ++-
12
3 files changed, 42 insertions(+), 23 deletions(-)
13
12
14
diff --git a/block/vmdk.c b/block/vmdk.c
13
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/block/vmdk.c
15
--- a/block/qcow2-refcount.c
17
+++ b/block/vmdk.c
16
+++ b/block/qcow2-refcount.c
18
@@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s)
17
@@ -XXX,XX +XXX,XX @@ static int64_t alloc_clusters_imrt(BlockDriverState *bs,
19
}
18
static int rebuild_refcounts_write_refblocks(
20
19
BlockDriverState *bs, void **refcount_table, int64_t *nb_clusters,
21
static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
20
int64_t first_cluster, int64_t end_cluster,
22
- const char *desc_file_path, QDict *options,
21
- uint64_t **on_disk_reftable_ptr, uint32_t *on_disk_reftable_entries_ptr
23
- Error **errp)
22
+ uint64_t **on_disk_reftable_ptr, uint32_t *on_disk_reftable_entries_ptr,
24
+ QDict *options, Error **errp)
23
+ Error **errp
24
)
25
{
25
{
26
int ret;
26
BDRVQcow2State *s = bs->opaque;
27
int matches;
27
@@ -XXX,XX +XXX,XX @@ static int rebuild_refcounts_write_refblocks(
28
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
28
nb_clusters,
29
const char *p, *np;
29
&first_free_cluster);
30
int64_t sectors = 0;
30
if (refblock_offset < 0) {
31
int64_t flat_offset;
31
- fprintf(stderr, "ERROR allocating refblock: %s\n",
32
+ char *desc_file_dir = NULL;
32
- strerror(-refblock_offset));
33
char *extent_path;
33
+ error_setg_errno(errp, -refblock_offset,
34
BdrvChild *extent_file;
34
+ "ERROR allocating refblock");
35
BDRVVmdkState *s = bs->opaque;
35
return refblock_offset;
36
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
36
}
37
continue;
37
38
@@ -XXX,XX +XXX,XX @@ static int rebuild_refcounts_write_refblocks(
39
on_disk_reftable_entries *
40
REFTABLE_ENTRY_SIZE);
41
if (!on_disk_reftable) {
42
+ error_setg(errp, "ERROR allocating reftable memory");
43
return -ENOMEM;
44
}
45
46
@@ -XXX,XX +XXX,XX @@ static int rebuild_refcounts_write_refblocks(
47
ret = qcow2_pre_write_overlap_check(bs, 0, refblock_offset,
48
s->cluster_size, false);
49
if (ret < 0) {
50
- fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
51
+ error_setg_errno(errp, -ret, "ERROR writing refblock");
52
return ret;
38
}
53
}
39
54
40
- if (!path_is_absolute(fname) && !path_has_protocol(fname) &&
55
@@ -XXX,XX +XXX,XX @@ static int rebuild_refcounts_write_refblocks(
41
- !desc_file_path[0])
56
ret = bdrv_pwrite(bs->file, refblock_offset, on_disk_refblock,
42
- {
57
s->cluster_size);
43
- bdrv_refresh_filename(bs->file->bs);
58
if (ret < 0) {
44
- error_setg(errp, "Cannot use relative extent paths with VMDK "
59
- fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
45
- "descriptor file '%s'", bs->file->bs->filename);
60
+ error_setg_errno(errp, -ret, "ERROR writing refblock");
46
- return -EINVAL;
61
return ret;
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
}
62
}
77
63
78
/* save to extents array */
64
@@ -XXX,XX +XXX,XX @@ static int rebuild_refcounts_write_refblocks(
79
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
65
static int rebuild_refcount_structure(BlockDriverState *bs,
80
0, 0, 0, 0, 0, &extent, errp);
66
BdrvCheckResult *res,
81
if (ret < 0) {
67
void **refcount_table,
82
bdrv_unref_child(bs, extent_file);
68
- int64_t *nb_clusters)
83
- return ret;
69
+ int64_t *nb_clusters,
84
+ goto out;
70
+ Error **errp)
85
}
71
{
86
extent->flat_start_offset = flat_offset << 9;
72
BDRVQcow2State *s = bs->opaque;
87
} else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) {
73
int64_t reftable_offset = -1;
88
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
74
@@ -XXX,XX +XXX,XX @@ static int rebuild_refcount_structure(BlockDriverState *bs,
89
g_free(buf);
75
rebuild_refcounts_write_refblocks(bs, refcount_table, nb_clusters,
90
if (ret) {
76
0, *nb_clusters,
91
bdrv_unref_child(bs, extent_file);
77
&on_disk_reftable,
92
- return ret;
78
- &on_disk_reftable_entries);
93
+ goto out;
79
+ &on_disk_reftable_entries, errp);
94
}
80
if (reftable_size_changed < 0) {
95
extent = &s->extents[s->num_extents - 1];
81
res->check_errors++;
96
} else if (!strcmp(type, "SESPARSE")) {
82
ret = reftable_size_changed;
97
ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp);
83
@@ -XXX,XX +XXX,XX @@ static int rebuild_refcount_structure(BlockDriverState *bs,
98
if (ret) {
84
refcount_table, nb_clusters,
99
bdrv_unref_child(bs, extent_file);
85
&first_free_cluster);
100
- return ret;
86
if (reftable_offset < 0) {
101
+ goto out;
87
- fprintf(stderr, "ERROR allocating reftable: %s\n",
102
}
88
- strerror(-reftable_offset));
103
extent = &s->extents[s->num_extents - 1];
89
+ error_setg_errno(errp, -reftable_offset,
104
} else {
90
+ "ERROR allocating reftable");
105
error_setg(errp, "Unsupported extent type '%s'", type);
91
res->check_errors++;
106
bdrv_unref_child(bs, extent_file);
92
ret = reftable_offset;
107
- return -ENOTSUP;
93
goto fail;
108
+ ret = -ENOTSUP;
94
@@ -XXX,XX +XXX,XX @@ static int rebuild_refcount_structure(BlockDriverState *bs,
109
+ goto out;
95
reftable_start_cluster,
96
reftable_end_cluster,
97
&on_disk_reftable,
98
- &on_disk_reftable_entries);
99
+ &on_disk_reftable_entries, errp);
100
if (reftable_size_changed < 0) {
101
res->check_errors++;
102
ret = reftable_size_changed;
103
@@ -XXX,XX +XXX,XX @@ static int rebuild_refcount_structure(BlockDriverState *bs,
104
ret = qcow2_pre_write_overlap_check(bs, 0, reftable_offset, reftable_length,
105
false);
106
if (ret < 0) {
107
- fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
108
+ error_setg_errno(errp, -ret, "ERROR writing reftable");
109
goto fail;
110
}
111
112
@@ -XXX,XX +XXX,XX @@ static int rebuild_refcount_structure(BlockDriverState *bs,
113
ret = bdrv_pwrite(bs->file, reftable_offset, on_disk_reftable,
114
reftable_length);
115
if (ret < 0) {
116
- fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
117
+ error_setg_errno(errp, -ret, "ERROR writing reftable");
118
goto fail;
119
}
120
121
@@ -XXX,XX +XXX,XX @@ static int rebuild_refcount_structure(BlockDriverState *bs,
122
&reftable_offset_and_clusters,
123
sizeof(reftable_offset_and_clusters));
124
if (ret < 0) {
125
- fprintf(stderr, "ERROR setting reftable: %s\n", strerror(-ret));
126
+ error_setg_errno(errp, -ret, "ERROR setting reftable");
127
goto fail;
128
}
129
130
@@ -XXX,XX +XXX,XX @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
131
if (rebuild && (fix & BDRV_FIX_ERRORS)) {
132
BdrvCheckResult old_res = *res;
133
int fresh_leaks = 0;
134
+ Error *local_err = NULL;
135
136
fprintf(stderr, "Rebuilding refcount structure\n");
137
ret = rebuild_refcount_structure(bs, res, &refcount_table,
138
- &nb_clusters);
139
+ &nb_clusters, &local_err);
140
if (ret < 0) {
141
+ error_report_err(local_err);
142
goto fail;
110
}
143
}
111
extent->type = g_strdup(type);
144
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
}
131
132
static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
133
@@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
134
}
135
s->create_type = g_strdup(ct);
136
s->desc_offset = 0;
137
- ret = vmdk_parse_extents(buf, bs, bs->file->bs->exact_filename, options,
138
- errp);
139
+ ret = vmdk_parse_extents(buf, bs, options, errp);
140
exit:
141
return ret;
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
--
145
--
178
2.21.0
146
2.35.1
179
180
diff view generated by jsdifflib
Deleted patch
1
We had a test for a case where relative extent paths did not work, but
2
unfortunately we just fixed the underlying problem, so it works now.
3
This patch adds a new test case that still fails.
4
1
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
Reviewed-by: John Snow <jsnow@redhat.com>
7
Message-id: 20190815153638.4600-4-mreitz@redhat.com
8
Reviewed-by: John Snow <jsnow@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
11
tests/qemu-iotests/059 | 27 +++++++++++++++++++++++++++
12
tests/qemu-iotests/059.out | 4 ++++
13
2 files changed, 31 insertions(+)
14
15
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
16
index XXXXXXX..XXXXXXX 100755
17
--- a/tests/qemu-iotests/059
18
+++ b/tests/qemu-iotests/059
19
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
20
21
echo
22
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
23
+
24
+echo '--- blkdebug ---'
25
# Should work, because bdrv_dirname() works fine with blkdebug
26
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
27
$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
28
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TE
29
| _filter_testdir | _filter_imgfmt | _filter_img_info
30
_cleanup_test_img
31
32
+echo '--- quorum ---'
33
+# Should not work, because bdrv_dirname() does not work with quorum
34
+IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
35
+cp "$TEST_IMG" "$TEST_IMG.orig"
36
+
37
+filename="json:{
38
+ \"driver\": \"$IMGFMT\",
39
+ \"file\": {
40
+ \"driver\": \"quorum\",
41
+ \"children\": [ {
42
+ \"driver\": \"file\",
43
+ \"filename\": \"$TEST_IMG\"
44
+ }, {
45
+ \"driver\": \"file\",
46
+ \"filename\": \"$TEST_IMG.orig\"
47
+ } ],
48
+ \"vote-threshold\": 1
49
+ } }"
50
+
51
+filename=$(echo "$filename" | tr '\n' ' ' | sed -e 's/\s\+/ /g')
52
+$QEMU_IMG info "$filename" 2>&1 \
53
+ | sed -e "s/'json:[^']*'/\$QUORUM_FILE/g" \
54
+ | _filter_testdir | _filter_imgfmt | _filter_img_info
55
+
56
+
57
echo
58
echo "=== Testing version 3 ==="
59
_use_sample_img iotest-version3.vmdk.bz2
60
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
61
index XXXXXXX..XXXXXXX 100644
62
--- a/tests/qemu-iotests/059.out
63
+++ b/tests/qemu-iotests/059.out
64
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
65
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
66
67
=== Testing monolithicFlat with internally generated JSON file name ===
68
+--- blkdebug ---
69
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
70
format name: IMGFMT
71
cluster size: 0 bytes
72
vm state offset: 0 bytes
73
+--- quorum ---
74
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
75
+qemu-img: Could not open $QUORUM_FILE: Cannot use relative paths with VMDK descriptor file $QUORUM_FILE: Cannot generate a base directory for quorum nodes
76
77
=== Testing version 3 ===
78
image: TEST_DIR/iotest-version3.IMGFMT
79
--
80
2.21.0
81
82
diff view generated by jsdifflib
Deleted patch
1
Compressed writes generally have to write full clusters, not just in
2
theory but also in practice when it comes to vmdk's streamOptimized
3
subformat. It currently is just silently broken for writes with
4
non-zero in-cluster offsets:
5
1
6
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
7
$ qemu-io -c 'write 4k 4k' -c 'read 4k 4k' foo.vmdk
8
wrote 4096/4096 bytes at offset 4096
9
4 KiB, 1 ops; 00.01 sec (443.724 KiB/sec and 110.9309 ops/sec)
10
read failed: Invalid argument
11
12
(The technical reason is that vmdk_write_extent() just writes the
13
incomplete compressed data actually to offset 4k. When reading the
14
data, vmdk_read_extent() looks at offset 0 and finds the compressed data
15
size to be 0, because that is what it reads from there. This yields an
16
error.)
17
18
For incomplete writes with zero in-cluster offsets, the error path when
19
reading the rest of the cluster is a bit different, but the result is
20
the same:
21
22
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
23
$ qemu-io -c 'write 0k 4k' -c 'read 4k 4k' foo.vmdk
24
wrote 4096/4096 bytes at offset 0
25
4 KiB, 1 ops; 00.01 sec (362.641 KiB/sec and 90.6603 ops/sec)
26
read failed: Invalid argument
27
28
(Here, vmdk_read_extent() finds the data and then sees that the
29
uncompressed data is short.)
30
31
It is better to reject invalid writes than to make the user believe they
32
might have succeeded and then fail when trying to read it back.
33
34
Signed-off-by: Max Reitz <mreitz@redhat.com>
35
Reviewed-by: John Snow <jsnow@redhat.com>
36
Message-id: 20190815153638.4600-5-mreitz@redhat.com
37
Reviewed-by: John Snow <jsnow@redhat.com>
38
Signed-off-by: Max Reitz <mreitz@redhat.com>
39
---
40
block/vmdk.c | 10 ++++++++++
41
1 file changed, 10 insertions(+)
42
43
diff --git a/block/vmdk.c b/block/vmdk.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/block/vmdk.c
46
+++ b/block/vmdk.c
47
@@ -XXX,XX +XXX,XX @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset,
48
if (extent->compressed) {
49
void *compressed_data;
50
51
+ /* Only whole clusters */
52
+ if (offset_in_cluster ||
53
+ n_bytes > (extent->cluster_sectors * SECTOR_SIZE) ||
54
+ (n_bytes < (extent->cluster_sectors * SECTOR_SIZE) &&
55
+ offset + n_bytes != extent->end_sector * SECTOR_SIZE))
56
+ {
57
+ ret = -EINVAL;
58
+ goto out;
59
+ }
60
+
61
if (!extent->has_marker) {
62
ret = -EINVAL;
63
goto out;
64
--
65
2.21.0
66
67
diff view generated by jsdifflib
Deleted patch
1
streamOptimized does not support writes that do not span exactly one
2
cluster. Furthermore, it cannot rewrite already allocated clusters.
3
As such, many iotests do not work with it. Disable them.
4
1
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
Message-id: 20190815153638.4600-6-mreitz@redhat.com
7
Reviewed-by: John Snow <jsnow@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
tests/qemu-iotests/002 | 1 +
11
tests/qemu-iotests/003 | 1 +
12
tests/qemu-iotests/005 | 3 ++-
13
tests/qemu-iotests/009 | 1 +
14
tests/qemu-iotests/010 | 1 +
15
tests/qemu-iotests/011 | 1 +
16
tests/qemu-iotests/017 | 3 ++-
17
tests/qemu-iotests/018 | 3 ++-
18
tests/qemu-iotests/019 | 3 ++-
19
tests/qemu-iotests/020 | 3 ++-
20
tests/qemu-iotests/027 | 1 +
21
tests/qemu-iotests/032 | 1 +
22
tests/qemu-iotests/033 | 1 +
23
tests/qemu-iotests/034 | 3 ++-
24
tests/qemu-iotests/037 | 3 ++-
25
tests/qemu-iotests/063 | 3 ++-
26
tests/qemu-iotests/072 | 1 +
27
tests/qemu-iotests/105 | 3 ++-
28
tests/qemu-iotests/197 | 1 +
29
tests/qemu-iotests/215 | 1 +
30
tests/qemu-iotests/251 | 1 +
31
21 files changed, 30 insertions(+), 9 deletions(-)
32
33
diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002
34
index XXXXXXX..XXXXXXX 100755
35
--- a/tests/qemu-iotests/002
36
+++ b/tests/qemu-iotests/002
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
38
39
_supported_fmt generic
40
_supported_proto generic
41
+_unsupported_imgopts "subformat=streamOptimized"
42
43
44
size=128M
45
diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003
46
index XXXXXXX..XXXXXXX 100755
47
--- a/tests/qemu-iotests/003
48
+++ b/tests/qemu-iotests/003
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
50
51
_supported_fmt generic
52
_supported_proto generic
53
+_unsupported_imgopts "subformat=streamOptimized"
54
55
size=128M
56
offset=67M
57
diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005
58
index XXXXXXX..XXXXXXX 100755
59
--- a/tests/qemu-iotests/005
60
+++ b/tests/qemu-iotests/005
61
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
62
_supported_proto generic
63
_supported_os Linux
64
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
65
- "subformat=twoGbMaxExtentSparse"
66
+ "subformat=twoGbMaxExtentSparse" \
67
+ "subformat=streamOptimized"
68
69
# vpc is limited to 127GB, so we can't test it here
70
if [ "$IMGFMT" = "vpc" ]; then
71
diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009
72
index XXXXXXX..XXXXXXX 100755
73
--- a/tests/qemu-iotests/009
74
+++ b/tests/qemu-iotests/009
75
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
76
77
_supported_fmt generic
78
_supported_proto generic
79
+_unsupported_imgopts "subformat=streamOptimized"
80
81
82
size=6G
83
diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010
84
index XXXXXXX..XXXXXXX 100755
85
--- a/tests/qemu-iotests/010
86
+++ b/tests/qemu-iotests/010
87
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
88
89
_supported_fmt generic
90
_supported_proto generic
91
+_unsupported_imgopts "subformat=streamOptimized"
92
93
94
size=6G
95
diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011
96
index XXXXXXX..XXXXXXX 100755
97
--- a/tests/qemu-iotests/011
98
+++ b/tests/qemu-iotests/011
99
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
100
101
_supported_fmt generic
102
_supported_proto generic
103
+_unsupported_imgopts "subformat=streamOptimized"
104
105
106
size=6G
107
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
108
index XXXXXXX..XXXXXXX 100755
109
--- a/tests/qemu-iotests/017
110
+++ b/tests/qemu-iotests/017
111
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
112
_supported_fmt qcow qcow2 vmdk qed
113
_supported_proto generic
114
_unsupported_proto vxhs
115
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
116
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
117
+ "subformat=streamOptimized"
118
119
TEST_OFFSETS="0 4294967296"
120
121
diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018
122
index XXXXXXX..XXXXXXX 100755
123
--- a/tests/qemu-iotests/018
124
+++ b/tests/qemu-iotests/018
125
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
126
_supported_fmt qcow qcow2 vmdk qed
127
_supported_proto file
128
_supported_os Linux
129
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
130
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
131
+ "streamOptimized"
132
133
TEST_OFFSETS="0 4294967296"
134
135
diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
136
index XXXXXXX..XXXXXXX 100755
137
--- a/tests/qemu-iotests/019
138
+++ b/tests/qemu-iotests/019
139
@@ -XXX,XX +XXX,XX @@ _supported_proto file
140
_supported_os Linux
141
_unsupported_imgopts "subformat=monolithicFlat" \
142
"subformat=twoGbMaxExtentFlat" \
143
- "subformat=twoGbMaxExtentSparse"
144
+ "subformat=twoGbMaxExtentSparse" \
145
+ "subformat=streamOptimized"
146
147
TEST_OFFSETS="0 4294967296"
148
CLUSTER_SIZE=65536
149
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
150
index XXXXXXX..XXXXXXX 100755
151
--- a/tests/qemu-iotests/020
152
+++ b/tests/qemu-iotests/020
153
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
154
_supported_proto file
155
_unsupported_imgopts "subformat=monolithicFlat" \
156
"subformat=twoGbMaxExtentFlat" \
157
- "subformat=twoGbMaxExtentSparse"
158
+ "subformat=twoGbMaxExtentSparse" \
159
+ "subformat=streamOptimized"
160
161
TEST_OFFSETS="0 4294967296"
162
163
diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027
164
index XXXXXXX..XXXXXXX 100755
165
--- a/tests/qemu-iotests/027
166
+++ b/tests/qemu-iotests/027
167
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
168
169
_supported_fmt vmdk qcow qcow2 qed
170
_supported_proto generic
171
+_unsupported_imgopts "subformat=streamOptimized"
172
173
174
size=128M
175
diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032
176
index XXXXXXX..XXXXXXX 100755
177
--- a/tests/qemu-iotests/032
178
+++ b/tests/qemu-iotests/032
179
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
180
# This works for any image format (though unlikely to segfault for raw)
181
_supported_fmt generic
182
_supported_proto generic
183
+_unsupported_imgopts "subformat=streamOptimized"
184
185
echo
186
echo === Prepare image ===
187
diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033
188
index XXXXXXX..XXXXXXX 100755
189
--- a/tests/qemu-iotests/033
190
+++ b/tests/qemu-iotests/033
191
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
192
193
_supported_fmt generic
194
_supported_proto generic
195
+_unsupported_imgopts "subformat=streamOptimized"
196
197
198
size=128M
199
diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034
200
index XXXXXXX..XXXXXXX 100755
201
--- a/tests/qemu-iotests/034
202
+++ b/tests/qemu-iotests/034
203
@@ -XXX,XX +XXX,XX @@ _supported_proto file
204
_supported_os Linux
205
_unsupported_imgopts "subformat=monolithicFlat" \
206
"subformat=twoGbMaxExtentFlat" \
207
- "subformat=twoGbMaxExtentSparse"
208
+ "subformat=twoGbMaxExtentSparse" \
209
+ "subformat=streamOptimized"
210
211
CLUSTER_SIZE=4k
212
size=128M
213
diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037
214
index XXXXXXX..XXXXXXX 100755
215
--- a/tests/qemu-iotests/037
216
+++ b/tests/qemu-iotests/037
217
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
218
_supported_proto file
219
_unsupported_imgopts "subformat=monolithicFlat" \
220
"subformat=twoGbMaxExtentFlat" \
221
- "subformat=twoGbMaxExtentSparse"
222
+ "subformat=twoGbMaxExtentSparse" \
223
+ "subformat=streamOptimized"
224
225
CLUSTER_SIZE=4k
226
size=128M
227
diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
228
index XXXXXXX..XXXXXXX 100755
229
--- a/tests/qemu-iotests/063
230
+++ b/tests/qemu-iotests/063
231
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed raw
232
_supported_proto file
233
_unsupported_imgopts "subformat=monolithicFlat" \
234
"subformat=twoGbMaxExtentFlat" \
235
- "subformat=twoGbMaxExtentSparse"
236
+ "subformat=twoGbMaxExtentSparse" \
237
+ "subformat=streamOptimized"
238
239
_make_test_img 4M
240
241
diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072
242
index XXXXXXX..XXXXXXX 100755
243
--- a/tests/qemu-iotests/072
244
+++ b/tests/qemu-iotests/072
245
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
246
247
_supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow
248
_supported_proto file
249
+_unsupported_imgopts "subformat=streamOptimized"
250
251
IMG_SIZE=64M
252
253
diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105
254
index XXXXXXX..XXXXXXX 100755
255
--- a/tests/qemu-iotests/105
256
+++ b/tests/qemu-iotests/105
257
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
258
_supported_fmt qcow2 vmdk vhdx qed
259
_supported_proto generic
260
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
261
- "subformat=twoGbMaxExtentSparse"
262
+ "subformat=twoGbMaxExtentSparse" \
263
+ "subformat=streamOptimized"
264
265
echo
266
echo "creating large image"
267
diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197
268
index XXXXXXX..XXXXXXX 100755
269
--- a/tests/qemu-iotests/197
270
+++ b/tests/qemu-iotests/197
271
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
272
_supported_proto generic
273
# LUKS support may be possible, but it complicates things.
274
_unsupported_fmt luks
275
+_unsupported_imgopts "subformat=streamOptimized"
276
277
echo
278
echo '=== Copy-on-read ==='
279
diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215
280
index XXXXXXX..XXXXXXX 100755
281
--- a/tests/qemu-iotests/215
282
+++ b/tests/qemu-iotests/215
283
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
284
_supported_proto generic
285
# LUKS support may be possible, but it complicates things.
286
_unsupported_fmt luks
287
+_unsupported_imgopts "subformat=streamOptimized"
288
289
echo
290
echo '=== Copy-on-read ==='
291
diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251
292
index XXXXXXX..XXXXXXX 100755
293
--- a/tests/qemu-iotests/251
294
+++ b/tests/qemu-iotests/251
295
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
296
_supported_fmt generic
297
_supported_proto file
298
_supported_os Linux
299
+_unsupported_imgopts "subformat=streamOptimized"
300
301
if [ "$IMGOPTSSYNTAX" = "true" ]; then
302
# We use json:{} filenames here, so we cannot work with additional options.
303
--
304
2.21.0
305
306
diff view generated by jsdifflib
Deleted patch
1
The error message for the test case where we have a quorum node for
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
1
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
Reviewed-by: John Snow <jsnow@redhat.com>
10
Message-id: 20190815153638.4600-7-mreitz@redhat.com
11
Reviewed-by: John Snow <jsnow@redhat.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
14
tests/qemu-iotests/110 | 3 ++-
15
1 file changed, 2 insertions(+), 1 deletion(-)
16
17
diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110
18
index XXXXXXX..XXXXXXX 100755
19
--- a/tests/qemu-iotests/110
20
+++ b/tests/qemu-iotests/110
21
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
22
# Any format supporting backing files
23
_supported_fmt qed qcow qcow2 vmdk
24
_supported_proto file
25
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
26
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
27
+ "subformat=twoGbMaxExtentSparse"
28
29
TEST_IMG_REL=$(basename "$TEST_IMG")
30
31
--
32
2.21.0
33
34
diff view generated by jsdifflib