iotests: Allow ./check -o data_file
cover iotests: Allow ./check -o data_file
Hi,
It’s my understanding that we want better test coverage for qcow2’s external data files. I think the natural thing to do is to let all tests create images with external data files.
We already have the -o option for ./check for additional image options (and I regularly use it for recount_bits=1 and compat=0.10). Unfortunately, we cannot use it directly for data_file, because of course every test image needs its own data file. What I think we want is a pattern: Something like -o 'data_file=$TEST_IMG.data_file', and then “$TEST_IMG” is replaced by the qcow2 image name.
This is done by the final patch in this series. There is a lot of preparatory work to be done, though.
(1) Some tests overwrite IMGOPTS. This will make them ignore user-specified options. That was always a problem (that means those tests ignored my pleas for refcount_bits=1 and compat=0.10) but someone needs to fix this at some point, and I guess that’s me right now.
So we need to stop tests from overwriting IMGOPTS. This is done by patches 1 through 9.
In addition, patch 10 fixes other cases where user-specified options are ignored (because some tests use qemu-img create directly instead of _make_test_img).
(2) Some tests access image files directly. This can only work for images without external data files. There are two subcases:
(A) rm: Fixed by patch 11
(B) cp/mv: Fixed by patch 12
(3) Some tests are broken with data_file, but we can fix it. Done by patches 13 through 16.
(4) Some tests are broken with data_file, and I don’t think we can fix it. So patch 17 adds _unsupported_imgopts data_file for them.
(5) And then there’s patch 18, which does what we really want.
Future work:
- Python tests currently completely ignore IMGOPTS. Preexisting problem, needs to be addressed in another series, but for the moment it at least means they won’t break if you run the tests with data_file.
- data_file_raw=on needs to be addressed in another series. I suspect this will mainly consist of making it unsupported in all tests that use backing files.
Max Reitz (18):
iotests: Filter refcount_order in 036
iotests: Replace IMGOPTS by _unsupported_imgopts
iotests: Drop compat=1.1 in 050
iotests: Let _make_test_img parse its parameters
iotests: Add -o and --no-opts to _make_test_img
iotests: Inject space into -ocompat=0.10 in 051
iotests: Replace IMGOPTS= by -o
iotests: Replace IMGOPTS='' by --no-opts
iotests: Drop IMGOPTS use in 267
iotests: Avoid qemu-img create
iotests: Use _rm_test_img for deleting test images
iotests: Avoid cp/mv of test images
iotests: Make 091 work with data_file
iotests: Make 110 work with data_file
iotests: Make 137 work with data_file
iotests: Make 198 work with data_file
iotests: Disable data_file where it cannot be used
iotests: Allow check -o data_file
tests/qemu-iotests/005 | 2 +- tests/qemu-iotests/007 | 5 +-- tests/qemu-iotests/014 | 2 ++ tests/qemu-iotests/015 | 5 +-- tests/qemu-iotests/019 | 6 ++-- tests/qemu-iotests/020 | 6 ++-- tests/qemu-iotests/024 | 10 +++--- tests/qemu-iotests/026 | 5 ++- tests/qemu-iotests/028 | 2 +- tests/qemu-iotests/029 | 7 ++-- tests/qemu-iotests/031 | 9 +++-- tests/qemu-iotests/036 | 15 ++++---- tests/qemu-iotests/036.out | 6 ++-- tests/qemu-iotests/039 | 27 ++++++-------- tests/qemu-iotests/043 | 4 ++- tests/qemu-iotests/046 | 2 ++ tests/qemu-iotests/048 | 4 ++- tests/qemu-iotests/050 | 8 ++--- tests/qemu-iotests/051 | 7 ++-- tests/qemu-iotests/053 | 4 +-- tests/qemu-iotests/058 | 7 ++-- tests/qemu-iotests/059 | 20 +++++------ tests/qemu-iotests/060 | 12 ++++--- tests/qemu-iotests/061 | 61 +++++++++++++++++--------------- tests/qemu-iotests/062 | 3 +- tests/qemu-iotests/063 | 18 +++++----- tests/qemu-iotests/063.out | 3 +- tests/qemu-iotests/066 | 3 +- tests/qemu-iotests/067 | 6 ++-- tests/qemu-iotests/068 | 4 ++- tests/qemu-iotests/069 | 2 +- tests/qemu-iotests/071 | 7 ++-- tests/qemu-iotests/073 | 2 ++ tests/qemu-iotests/074 | 4 ++- tests/qemu-iotests/079 | 3 +- tests/qemu-iotests/080 | 7 ++-- tests/qemu-iotests/081 | 6 ++-- tests/qemu-iotests/085 | 18 +++++----- tests/qemu-iotests/085.out | 8 ++--- tests/qemu-iotests/088 | 2 +- tests/qemu-iotests/090 | 2 ++ tests/qemu-iotests/091 | 3 +- tests/qemu-iotests/091.out | 1 - tests/qemu-iotests/092 | 2 +- tests/qemu-iotests/094 | 4 +-- tests/qemu-iotests/095 | 5 +-- tests/qemu-iotests/098 | 5 +-- tests/qemu-iotests/099 | 10 +++--- tests/qemu-iotests/103 | 5 +-- tests/qemu-iotests/106 | 2 +- tests/qemu-iotests/108 | 8 +++-- tests/qemu-iotests/109 | 4 +-- tests/qemu-iotests/110 | 11 +++--- tests/qemu-iotests/110.out | 4 +-- tests/qemu-iotests/111 | 3 +- tests/qemu-iotests/112 | 37 +++++++++---------- tests/qemu-iotests/114 | 2 ++ tests/qemu-iotests/115 | 3 +- tests/qemu-iotests/121 | 9 +++-- tests/qemu-iotests/122 | 6 ++-- tests/qemu-iotests/123 | 4 +-- tests/qemu-iotests/125 | 2 +- tests/qemu-iotests/137 | 12 ++++--- tests/qemu-iotests/137.out | 4 +-- tests/qemu-iotests/138 | 5 +-- tests/qemu-iotests/141 | 4 ++- tests/qemu-iotests/142 | 2 +- tests/qemu-iotests/144 | 4 ++- tests/qemu-iotests/153 | 12 +++---- tests/qemu-iotests/156 | 10 ++++-- tests/qemu-iotests/159 | 2 +- tests/qemu-iotests/160 | 3 +- tests/qemu-iotests/161 | 4 +-- tests/qemu-iotests/170 | 2 +- tests/qemu-iotests/172 | 6 ++-- tests/qemu-iotests/173 | 3 +- tests/qemu-iotests/174 | 2 +- tests/qemu-iotests/175 | 2 +- tests/qemu-iotests/176 | 7 ++-- tests/qemu-iotests/178 | 6 ++-- tests/qemu-iotests/182 | 2 +- tests/qemu-iotests/183 | 2 +- tests/qemu-iotests/185 | 4 +-- tests/qemu-iotests/187 | 6 ++-- tests/qemu-iotests/190 | 4 +-- tests/qemu-iotests/191 | 11 +++--- tests/qemu-iotests/195 | 2 +- tests/qemu-iotests/197 | 6 ++-- tests/qemu-iotests/198 | 6 ++-- tests/qemu-iotests/198.out | 4 +-- tests/qemu-iotests/200 | 7 ++-- tests/qemu-iotests/201 | 6 ++-- tests/qemu-iotests/214 | 3 +- tests/qemu-iotests/215 | 6 ++-- tests/qemu-iotests/217 | 3 +- tests/qemu-iotests/220 | 5 ++- tests/qemu-iotests/225 | 2 +- tests/qemu-iotests/229 | 3 +- tests/qemu-iotests/232 | 4 ++- tests/qemu-iotests/243 | 10 ++++-- tests/qemu-iotests/244 | 15 ++++---- tests/qemu-iotests/247 | 4 ++- tests/qemu-iotests/249 | 4 +-- tests/qemu-iotests/250 | 5 +-- tests/qemu-iotests/252 | 2 +- tests/qemu-iotests/265 | 2 +- tests/qemu-iotests/267 | 17 +++++---- tests/qemu-iotests/common.filter | 21 +++++++++-- tests/qemu-iotests/common.rc | 51 +++++++++++++++++++++----- 109 files changed, 455 insertions(+), 316 deletions(-)
Signature · 1 line
2.21.0
PATCH 1/18 iotests: Filter refcount_order in 036
This test can run just fine with other values for refcount_bits, so we should filter the value from qcow2.py's dump-header.
(036 currently ignores user-specified image options, but that will be fixed in the next patch.)
--- tests/qemu-iotests/036 | 9 ++++++--- tests/qemu-iotests/036.out | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-)
tests/qemu-iotests/036 +6 -3
@@ -55,7 +55,8 @@ $PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 # Without feature table $PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' _img_info # With feature table containing bit 63
@@ -103,14 +104,16 @@ echo === Create image with unknown autoclear feature bit === echo _make_test_img 64M $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' echo echo === Repair image === echo _check_test_img -r all -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' # success, all done echo "*** done"
tests/qemu-iotests/036.out +3 -3
@@ -19,7 +19,7 @@ snapshot_offset 0x0 incompatible_features 0x8000000000000000 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000
@@ -53,7 +53,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x8000000000000000 -refcount_order 4 +refcount_order (filtered) header_length 104 Header extension:
@@ -81,7 +81,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104 Header extension:
Signature · 1 line
2.21.0
Re: [PATCH 01/18] iotests: Filter refcount_order in 036
Quoted 68 lines · Max Reitz
This test can run just fine with other values for
refcount_bits, so we should filter the value from qcow2.py's dump-header.(036 currently ignores user-specified image options, but that will be fixed in the next patch.)
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/036 | 9 ++++++--- tests/qemu-iotests/036.out | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-)tests/qemu-iotests/036 +6
-3@@ -55,7 +55,8 @@ $PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 # Without feature table $PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' _img_info # With feature table containing bit 63@@ -103,14 +104,16 @@ echo === Create image with unknown autoclear feature bit === echo _make_test_img 64M $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' echo echo === Repair image === echo _check_test_img -r all -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' # success, all done echo "*** done"tests/qemu-iotests/036.out +2
-2@@ -19,7 +19,7 @@ snapshot_offset 0x0 incompatible_features 0x8000000000000000 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000@@ -53,7 +53,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x8000000000000000 -refcount_order 4 +refcount_order (filtered) header_length 104 Header extension:
tests/qemu-iotests/036.out snapshot_offset 0x0 · line 87
Quoted 8 lines
tests/qemu-iotests/036.out +1
-1@@ -81,7 +81,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104 Header extension:
Minor notes:
1. Maybe put the sed command into a function to avoid duplication?
2. As I understand the test, it only checks the feature bits. So maybe instead of blacklisting some of the values, white list only the feature bits in the output?
Best regards,
Maxim Levitsky
Re: [PATCH 01/18] iotests: Filter refcount_order in 036
Quoted 76 lines · Maxim Levitsky
Quoted 75 lines · Max Reitz
This test can run just fine with other values for
refcount_bits, so we should filter the value from qcow2.py's dump-header.(036 currently ignores user-specified image options, but that will be fixed in the next patch.)
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/036 | 9 ++++++--- tests/qemu-iotests/036.out | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-)tests/qemu-iotests/036 +6
-3@@ -55,7 +55,8 @@ $PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 # Without feature table $PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' _img_info # With feature table containing bit 63@@ -103,14 +104,16 @@ echo === Create image with unknown autoclear feature bit === echo _make_test_img 64M $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' echo echo === Repair image === echo _check_test_img -r all -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' # success, all done echo "*** done"tests/qemu-iotests/036.out +3
-3@@ -19,7 +19,7 @@ snapshot_offset 0x0 incompatible_features 0x8000000000000000 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000@@ -53,7 +53,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x8000000000000000 -refcount_order 4 +refcount_order (filtered) header_length 104 Header extension:@@ -81,7 +81,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104
Quoted 5 lines
tests/qemu-iotests/036.out snapshot_offset 0x0 · line 87
Quoted 1 line
tests/qemu-iotests/036.out +0
-0Header extension:Minor notes:
1. Maybe put the sed command into a function to avoid duplication?
Hm, maybe, but that would increase the LoC, so I’m not sure whether it really would be a simplification.
Quoted 3 lines
2. As I understand the test, it only checks the feature bits. So maybe instead of blacklisting some of the values, white list only the feature bits in the output?
Hm. Seems reasonable, but then again I’d prefer a minimal change, and changing it to a whitelist would be more change...
Max
Re: [PATCH 01/18] iotests: Filter refcount_order in 036
Quoted 77 lines · Max Reitz
Quoted 76 lines · Maxim Levitsky
Quoted 75 lines · Max Reitz
This test can run just fine with other values for
refcount_bits, so we should filter the value from qcow2.py's dump-header.(036 currently ignores user-specified image options, but that will be fixed in the next patch.)
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/036 | 9 ++++++--- tests/qemu-iotests/036.out | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-)tests/qemu-iotests/036 +6
-3@@ -55,7 +55,8 @@ $PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 # Without feature table $PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' _img_info # With feature table containing bit 63@@ -103,14 +104,16 @@ echo === Create image with unknown autoclear feature bit === echo _make_test_img 64M $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' echo echo === Repair image === echo _check_test_img -r all -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' # success, all done echo "*** done"tests/qemu-iotests/036.out +3
-3@@ -19,7 +19,7 @@ snapshot_offset 0x0 incompatible_features 0x8000000000000000 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000@@ -53,7 +53,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x8000000000000000 -refcount_order 4 +refcount_order (filtered) header_length 104 Header extension:@@ -81,7 +81,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104
Quoted 8 lines
Quoted 5 lines
tests/qemu-iotests/036.out snapshot_offset 0x0 · line 87
Quoted 1 line
tests/qemu-iotests/036.out +0
-0Header extension:Minor notes:
1. Maybe put the sed command into a function to avoid duplication?
Hm, maybe, but that would increase the LoC, so I’m not sure whether it really would be a simplification.
IMHO, in my opinion, regardless of LOC, duplicated code is almost always bad. Common functions are mostly for the next guy that will be able to use them instead of searching through code to see how this is done there and there.
Quoted 7 lines
Quoted 4 lines
2. As I understand the test, it only checks the feature bits. So maybe instead of blacklisting some of the values, white list only the feature bits in the output?
Hm. Seems reasonable, but then again I’d prefer a minimal change, and changing it to a whitelist would be more change...
I don't think this is bad, again in my eyes, the code should be as friendly as possible for the next guy that will have to change it, so adding some more extra changes don't seem a problem to me.
Of course this is only my personal option and each approach has its own cons, and pros. This doesn't matter that much to me.
Best regards,
Maxim Levitsky
Re: [PATCH 01/18] iotests: Filter refcount_order in 036
Quoted 82 lines · Maxim Levitsky
Quoted 81 lines · Max Reitz
Quoted 80 lines · Maxim Levitsky
Quoted 68 lines · Max Reitz
This test can run just fine with other values for
refcount_bits, so we should filter the value from qcow2.py's dump-header.(036 currently ignores user-specified image options, but that will be fixed in the next patch.)
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/036 | 9 ++++++--- tests/qemu-iotests/036.out | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-)tests/qemu-iotests/036 +6
-3@@ -55,7 +55,8 @@ $PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 # Without feature table $PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' _img_info # With feature table containing bit 63@@ -103,14 +104,16 @@ echo === Create image with unknown autoclear feature bit === echo _make_test_img 64M $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' echo echo === Repair image === echo _check_test_img -r all -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' # success, all done echo "*** done"tests/qemu-iotests/036.out +2
-2@@ -19,7 +19,7 @@ snapshot_offset 0x0 incompatible_features 0x8000000000000000 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000@@ -53,7 +53,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x8000000000000000 -refcount_order 4 +refcount_order (filtered) header_length 104 Header extension:tests/qemu-iotests/036.out snapshot_offset 0x0 · line 87
Quoted 8 lines
tests/qemu-iotests/036.out +1
-1@@ -81,7 +81,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104 Header extension:Minor notes:
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
1. Maybe put the sed command into a function to avoid duplication?
Hm, maybe, but that would increase the LoC, so I’m not sure whether it really would be a simplification.
IMHO, in my opinion, regardless of LOC, duplicated code is almost always bad. Common functions are mostly for the next guy that will be able to use them instead of searching through code to see how this is done there and there.
In my experience, people write tests without scanning common.filter for whether anyone has written the same code already. See the _filter_qemu_img_check example in this series.
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
2. As I understand the test, it only checks the feature bits. So maybe instead of blacklisting some of the values, white list only the feature bits in the output?
Hm. Seems reasonable, but then again I’d prefer a minimal change, and changing it to a whitelist would be more change...
I don't think this is bad, again in my eyes, the code should be as friendly as possible for the next guy that will have to change it, so adding some more extra changes don't seem a problem to me.
In my eyes tests aren’t code.
Max
Quoted 6 lines
Of course this is only my personal option and each approach has its own cons, and pros. This doesn't matter that much to me.
Best regards,
Maxim Levitsky
Re: [PATCH 01/18] iotests: Filter refcount_order in 036
Quoted 88 lines · Max Reitz
Quoted 87 lines · Maxim Levitsky
Quoted 85 lines · Max Reitz
Quoted 76 lines · Maxim Levitsky
Quoted 75 lines · Max Reitz
This test can run just fine with other values for
refcount_bits, so we should filter the value from qcow2.py's dump-header.(036 currently ignores user-specified image options, but that will be fixed in the next patch.)
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/036 | 9 ++++++--- tests/qemu-iotests/036.out | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-)tests/qemu-iotests/036 +6
-3@@ -55,7 +55,8 @@ $PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 # Without feature table $PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' _img_info # With feature table containing bit 63@@ -103,14 +104,16 @@ echo === Create image with unknown autoclear feature bit === echo _make_test_img 64M $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' echo echo === Repair image === echo _check_test_img -r all -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' # success, all done echo "*** done"tests/qemu-iotests/036.out +3
-3@@ -19,7 +19,7 @@ snapshot_offset 0x0 incompatible_features 0x8000000000000000 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000@@ -53,7 +53,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x8000000000000000 -refcount_order 4 +refcount_order (filtered) header_length 104 Header extension:@@ -81,7 +81,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104Quoted 5 lines
tests/qemu-iotests/036.out snapshot_offset 0x0 · line 87
Quoted 1 line
tests/qemu-iotests/036.out +0
-0Header extension:Minor notes:
1. Maybe put the sed command into a function to avoid duplication?
Hm, maybe, but that would increase the LoC, so I’m not sure whether it really would be a simplification.
Quoted 7 lines
Quoted 3 lines
IMHO, in my opinion, regardless of LOC, duplicated code is almost always bad. Common functions are mostly for the next guy that will be able to use them instead of searching through code to see how this is done there and there.
In my experience, people write tests without scanning common.filter for whether anyone has written the same code already. See the
_filter_qemu_img_checkexample in this series.
Fair enough, but this can change.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
2. As I understand the test, it only checks the feature bits. So maybe instead of blacklisting some of the values, white list only the feature bits in the output?
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Hm. Seems reasonable, but then again I’d prefer a minimal change, and changing it to a whitelist would be more change...
I don't think this is bad, again in my eyes, the code should be as friendly as possible for the next guy that will have to change it, so adding some more extra changes don't seem a problem to me.
In my eyes tests aren’t code.
And yet, writing tests is commonly known as a task
that developers don't really like to do, so making that even a tiniest bit easier, is a good thing IMHO,
Anyway I won't argue about this too much, and on top of this, I think that this patch series does *lot* of improvements that do make it easier to write the tests.
Thanks for that, and I might also someday in the future do some refactoring for the iotests. The thing that I hate the most is that the tests don't have names....
Best regards,
Maxim Levitsky
Re: [PATCH 01/18] iotests: Filter refcount_order in 036
Quoted 89 lines · Maxim Levitsky
Quoted 88 lines · Max Reitz
Quoted 87 lines · Maxim Levitsky
Quoted 85 lines · Max Reitz
Quoted 76 lines · Maxim Levitsky
Quoted 75 lines · Max Reitz
This test can run just fine with other values for
refcount_bits, so we should filter the value from qcow2.py's dump-header.(036 currently ignores user-specified image options, but that will be fixed in the next patch.)
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/036 | 9 ++++++--- tests/qemu-iotests/036.out | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-)tests/qemu-iotests/036 +6
-3@@ -55,7 +55,8 @@ $PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 # Without feature table $PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' _img_info # With feature table containing bit 63@@ -103,14 +104,16 @@ echo === Create image with unknown autoclear feature bit === echo _make_test_img 64M $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' echo echo === Repair image === echo _check_test_img -r all -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' # success, all done echo "*** done"tests/qemu-iotests/036.out +3
-3@@ -19,7 +19,7 @@ snapshot_offset 0x0 incompatible_features 0x8000000000000000 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000@@ -53,7 +53,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x8000000000000000 -refcount_order 4 +refcount_order (filtered) header_length 104 Header extension:@@ -81,7 +81,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104Quoted 5 lines
tests/qemu-iotests/036.out snapshot_offset 0x0 · line 87
Quoted 1 line
tests/qemu-iotests/036.out +0
-0Header extension:Minor notes:
1. Maybe put the sed command into a function to avoid duplication?
Hm, maybe, but that would increase the LoC, so I’m not sure whether it really would be a simplification.
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
IMHO, in my opinion, regardless of LOC, duplicated code is almost always bad. Common functions are mostly for the next guy that will be able to use them instead of searching through code to see how this is done there and there.
In my experience, people write tests without scanning common.filter for whether anyone has written the same code already. See the
_filter_qemu_img_checkexample in this series.Fair enough, but this can change.
It won’t.
It only changes when people use standardized functions that filter automatically. And writing that made me look into common.rc, and ah yes, we have a _check_test_img. So the correct thing to do is not to use _filter_qemu_img_check (or to expect people to scan the filter file for filters), but to use _check_test_img there.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
2. As I understand the test, it only checks the feature bits. So maybe instead of blacklisting some of the values, white list only the feature bits in the output?
Hm. Seems reasonable, but then again I’d prefer a minimal change, and changing it to a whitelist would be more change...
I don't think this is bad, again in my eyes, the code should be as friendly as possible for the next guy that will have to change it, so adding some more extra changes don't seem a problem to me.
Quoted 5 lines
Quoted 1 line
In my eyes tests aren’t code.
And yet, writing tests is commonly known as a task
that developers don't really like to do, so making that even a tiniest bit easier, is a good thing IMHO,
My problem is precisely that I don’t see how such a suggestion makes it easier to write test code.
The easiest way to write a test is to just dump ad-hoc code into a bash file. Sometimes that doesn’t work because what you want to test is more complex, so then you use Python.
What I felt you were arguing about is changing existing test code, which is a completely different thing. In my experience, that happens much more rarely and is thus a thing we don’t need to optimize for. (And I’m saying this as the one who wrote this series which is just about changing existing test code.)
Max
Re: [PATCH 01/18] iotests: Filter refcount_order in 036
Quoted 133 lines · Max Reitz
Quoted 93 lines · Maxim Levitsky
Quoted 92 lines · Max Reitz
Quoted 90 lines · Maxim Levitsky
Quoted 77 lines · Max Reitz
Quoted 76 lines · Maxim Levitsky
Quoted 75 lines · Max Reitz
This test can run just fine with other values for
refcount_bits, so we should filter the value from qcow2.py's dump-header.(036 currently ignores user-specified image options, but that will be fixed in the next patch.)
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/036 | 9 ++++++--- tests/qemu-iotests/036.out | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-)tests/qemu-iotests/036 +6
-3@@ -55,7 +55,8 @@ $PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 # Without feature table $PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' _img_info # With feature table containing bit 63@@ -103,14 +104,16 @@ echo === Create image with unknown autoclear feature bit === echo _make_test_img 64M $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' echo echo === Repair image === echo _check_test_img -r all -$PYTHON qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header \ + | sed -e 's/^\(refcount_order\s*\).*/\1(filtered)/' # success, all done echo "*** done"tests/qemu-iotests/036.out +3
-3@@ -19,7 +19,7 @@ snapshot_offset 0x0 incompatible_features 0x8000000000000000 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000@@ -53,7 +53,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x8000000000000000 -refcount_order 4 +refcount_order (filtered) header_length 104 Header extension:@@ -81,7 +81,7 @@ snapshot_offset 0x0 incompatible_features 0x0 compatible_features 0x0 autoclear_features 0x0 -refcount_order 4 +refcount_order (filtered) header_length 104Quoted 8 lines
Quoted 5 lines
tests/qemu-iotests/036.out snapshot_offset 0x0 · line 87
Quoted 1 line
tests/qemu-iotests/036.out +0
-0Header extension:Minor notes:
1. Maybe put the sed command into a function to avoid duplication?
Hm, maybe, but that would increase the LoC, so I’m not sure whether it really would be a simplification.
IMHO, in my opinion, regardless of LOC, duplicated code is almost always bad. Common functions are mostly for the next guy that will be able to use them instead of searching through code to see how this is done there and there.
Quoted 5 lines
Quoted 3 lines
In my experience, people write tests without scanning common.filter for whether anyone has written the same code already. See the
_filter_qemu_img_checkexample in this series.Fair enough, but this can change.
It won’t.
It only changes when people use standardized functions that filter automatically. And writing that made me look into common.rc, and ah yes, we have a
_check_test_img. So the correct thing to do is not to use_filter_qemu_img_check(or to expect people to scan the filter file for filters), but to use_check_test_imgthere.Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
2. As I understand the test, it only checks the feature bits. So maybe instead of blacklisting some of the values, white list only the feature bits in the output?
Hm. Seems reasonable, but then again I’d prefer a minimal change, and changing it to a whitelist would be more change...
I don't think this is bad, again in my eyes, the code should be as friendly as possible for the next guy that will have to change it, so adding some more extra changes don't seem a problem to me.
Quoted 5 lines
Quoted 1 line
In my eyes tests aren’t code.
And yet, writing tests is commonly known as a task
that developers don't really like to do, so making that even a tiniest bit easier, is a good thing IMHO,My problem is precisely that I don’t see how such a suggestion makes it easier to write test code.
The easiest way to write a test is to just dump ad-hoc code into a bash file. Sometimes that doesn’t work because what you want to test is more complex, so then you use Python.
Quoted 5 lines
What I felt you were arguing about is changing existing test code, which is a completely different thing. In my experience, that happens much more rarely and is thus a thing we don’t need to optimize for. (And I’m saying this as the one who wrote this series which is just about changing existing test code.)
I won't argue on this! It all depends on lot and lot of things.
Best regards,
Maxim Levitsky
PATCH 2/18 iotests: Replace IMGOPTS by _unsupported_imgopts
In reply to Max ReitzSome tests require compat=1.1 and thus set IMGOPTS='compat=1.1' globally. That is not how it should be done; instead, they should simply set _unsupported_imgopts to compat=0.10 (compat=1.1 is the default anyway).
This makes the tests heed user-specified $IMGOPTS. Some do not work with all image options, though, so we need to disable them accordingly.
--- tests/qemu-iotests/036 | 3 +-- tests/qemu-iotests/060 | 4 ++-- tests/qemu-iotests/062 | 3 ++- tests/qemu-iotests/066 | 3 ++- tests/qemu-iotests/068 | 3 ++- tests/qemu-iotests/098 | 3 +-- 6 files changed, 10 insertions(+), 9 deletions(-)
tests/qemu-iotests/036 +1 -2
@@ -43,9 +43,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 _supported_proto file - # Only qcow2v3 and later supports feature bits -IMGOPTS="compat=1.1" +_unsupported_imgopts 'compat=0.10' echo echo === Image with unknown incompatible feature bit ===
tests/qemu-iotests/060 +2 -2
@@ -48,6 +48,8 @@ _filter_io_error() _supported_fmt qcow2 _supported_proto file _supported_os Linux +# These tests only work for compat=1.1 images with refcount_bits=16 +_unsupported_imgopts 'compat=0.10' 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' rt_offset=65536 # 0x10000 (XXX: just an assumption) rb_offset=131072 # 0x20000 (XXX: just an assumption)
@@ -55,8 +57,6 @@ l1_offset=196608 # 0x30000 (XXX: just an assumption) l2_offset=262144 # 0x40000 (XXX: just an assumption) l2_offset_after_snapshot=524288 # 0x80000 (XXX: just an assumption) -IMGOPTS="compat=1.1" - OPEN_RW="open -o overlap-check=all $TEST_IMG" # Overlap checks are done before write operations only, therefore opening an # image read-only makes the overlap-check option irrelevant
tests/qemu-iotests/062 +2 -1
@@ -40,8 +40,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic +# We need zero clusters and snapshots +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' -IMGOPTS="compat=1.1" IMG_SIZE=64M echo
tests/qemu-iotests/066 +2 -1
@@ -39,9 +39,10 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic +# Weneed zero clusters and snapshots +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' # Intentionally create an unaligned image -IMGOPTS="compat=1.1" IMG_SIZE=$((64 * 1024 * 1024 + 512)) echo
tests/qemu-iotests/068 +2 -1
@@ -39,8 +39,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic +# Internal snapshots are (currently) impossible with refcount_bits=1 +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' -IMGOPTS="compat=1.1" IMG_SIZE=128K case "$QEMU_DEFAULT_MACHINE" in
tests/qemu-iotests/098 +1 -2
@@ -40,8 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file - -IMGOPTS="compat=1.1" +_unsupported_imgopts 'compat=0.10' for event in l1_update empty_image_prepare reftable_update refblock_alloc; do
Signature · 1 line
2.21.0
Re: [PATCH 02/18] iotests: Replace IMGOPTS by _unsupported_imgopts
Quoted 75 lines · Max Reitz
Some tests require compat=1.1 and thus set IMGOPTS='compat=1.1' globally. That is not how it should be done; instead, they should simply set
_unsupported_imgoptsto compat=0.10 (compat=1.1 is the default anyway).This makes the tests heed user-specified $IMGOPTS. Some do not work with all image options, though, so we need to disable them accordingly.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/036 | 3 +-- tests/qemu-iotests/060 | 4 ++-- tests/qemu-iotests/062 | 3 ++- tests/qemu-iotests/066 | 3 ++- tests/qemu-iotests/068 | 3 ++- tests/qemu-iotests/098 | 3 +-- 6 files changed, 10 insertions(+), 9 deletions(-)tests/qemu-iotests/036 +1
-2@@ -43,9 +43,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 _supported_proto file - # Only qcow2v3 and later supports feature bits -IMGOPTS="compat=1.1" +_unsupported_imgopts 'compat=0.10' echo echo === Image with unknown incompatible feature bit ===tests/qemu-iotests/060 +2
-2@@ -48,6 +48,8 @@ _filter_io_error() _supported_fmt qcow2 _supported_proto file _supported_os Linux +# These tests only work for compat=1.1 images with refcount_bits=16 +_unsupported_imgopts 'compat=0.10' 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' rt_offset=65536 # 0x10000 (XXX: just an assumption) rb_offset=131072 # 0x20000 (XXX: just an assumption)@@ -55,8 +57,6 @@ l1_offset=196608 # 0x30000 (XXX: just an assumption) l2_offset=262144 # 0x40000 (XXX: just an assumption) l2_offset_after_snapshot=524288 # 0x80000 (XXX: just an assumption) -IMGOPTS="compat=1.1" - OPEN_RW="open -o overlap-check=all $TEST_IMG" # Overlap checks are done before write operations only, therefore opening an # image read-only makes the overlap-check option irrelevanttests/qemu-iotests/062 +2
-1@@ -40,8 +40,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic +# We need zero clusters and snapshots +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' -IMGOPTS="compat=1.1" IMG_SIZE=64M echotests/qemu-iotests/066 +0
-0
tests/qemu-iotests/066 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 42
Quoted 4 lines
tests/qemu-iotests/066 +1
-0@@ -39,9 +39,10 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic +# Weneed zero clusters and snapshots
Typo
Quoted 12 lines
tests/qemu-iotests/066 +1
-1+_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' # Intentionally create an unaligned image -IMGOPTS="compat=1.1" IMG_SIZE=$((64 * 1024 * 1024 + 512)) echotests/qemu-iotests/068 +0
-0
tests/qemu-iotests/068 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 42
Quoted 4 lines
tests/qemu-iotests/068 +1
-0@@ -39,8 +39,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic +# Internal snapshots are (currently) impossible with refcount_bits=1
Why currently? 1 bit will only allow to mark a cluser as used/unused which is not enough for any snapshots?
Quoted 11 lines
tests/qemu-iotests/068 +1
-1+_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' -IMGOPTS="compat=1.1" IMG_SIZE=128K case "$QEMU_DEFAULT_MACHINE" intests/qemu-iotests/098 +0
-0
tests/qemu-iotests/098 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 43
Quoted 6 lines
tests/qemu-iotests/098 +1
-2@@ -40,8 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file - -IMGOPTS="compat=1.1" +_unsupported_imgopts 'compat=0.10'
Any idea why? I am not familiar with qcow2 well enought to know but this misses a comment with justification.
tests/qemu-iotests/098 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 46
Quoted 3 lines
tests/qemu-iotests/098 +0
-0for event in l1_update empty_image_prepare reftable_update refblock_alloc; do
Best regards,
Maxim Levitsky
Re: [PATCH 02/18] iotests: Replace IMGOPTS by _unsupported_imgopts
Quoted 70 lines · Maxim Levitsky
Quoted 69 lines · Max Reitz
Some tests require compat=1.1 and thus set IMGOPTS='compat=1.1' globally. That is not how it should be done; instead, they should simply set
_unsupported_imgoptsto compat=0.10 (compat=1.1 is the default anyway).This makes the tests heed user-specified $IMGOPTS. Some do not work with all image options, though, so we need to disable them accordingly.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/036 | 3 +-- tests/qemu-iotests/060 | 4 ++-- tests/qemu-iotests/062 | 3 ++- tests/qemu-iotests/066 | 3 ++- tests/qemu-iotests/068 | 3 ++- tests/qemu-iotests/098 | 3 +-- 6 files changed, 10 insertions(+), 9 deletions(-)tests/qemu-iotests/036 +1
-2@@ -43,9 +43,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 _supported_proto file - # Only qcow2v3 and later supports feature bits -IMGOPTS="compat=1.1" +_unsupported_imgopts 'compat=0.10' echo echo === Image with unknown incompatible feature bit ===tests/qemu-iotests/060 +2
-2@@ -48,6 +48,8 @@ _filter_io_error() _supported_fmt qcow2 _supported_proto file _supported_os Linux +# These tests only work for compat=1.1 images with refcount_bits=16 +_unsupported_imgopts 'compat=0.10' 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' rt_offset=65536 # 0x10000 (XXX: just an assumption) rb_offset=131072 # 0x20000 (XXX: just an assumption)@@ -55,8 +57,6 @@ l1_offset=196608 # 0x30000 (XXX: just an assumption) l2_offset=262144 # 0x40000 (XXX: just an assumption) l2_offset_after_snapshot=524288 # 0x80000 (XXX: just an assumption) -IMGOPTS="compat=1.1" - OPEN_RW="open -o overlap-check=all $TEST_IMG" # Overlap checks are done before write operations only, therefore opening an # image read-only makes the overlap-check option irrelevanttests/qemu-iotests/062 +2
-1@@ -40,8 +40,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic +# We need zero clusters and snapshots +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' -IMGOPTS="compat=1.1" IMG_SIZE=64M
Quoted 11 lines
tests/qemu-iotests/066 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 42
Quoted 10 lines
tests/qemu-iotests/062 +0
-0echotests/qemu-iotests/066 +1
-0@@ -39,9 +39,10 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic +# Weneed zero clusters and snapshotsTypo
Indeed!
Quoted 6 lines
Quoted 6 lines
tests/qemu-iotests/066 +1
-1+_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' # Intentionally create an unaligned image -IMGOPTS="compat=1.1" IMG_SIZE=$((64 * 1024 * 1024 + 512))
Quoted 12 lines
tests/qemu-iotests/068 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 42
Quoted 10 lines
tests/qemu-iotests/066 +0
-0echotests/qemu-iotests/068 +1
-0@@ -39,8 +39,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic +# Internal snapshots are (currently) impossible with refcount_bits=1Why currently? 1 bit will only allow to mark a cluser as used/unused which is not enough for any snapshots?
It is, because in theory you can just copy the clusters at the time of snapshotting. We’ll never implement it, but, well...
Quoted 12 lines
Quoted 12 lines
tests/qemu-iotests/068 +1
-1+_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' -IMGOPTS="compat=1.1" IMG_SIZE=128K case "$QEMU_DEFAULT_MACHINE" intests/qemu-iotests/098 +0
-0@@ -40,8 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
Quoted 7 lines
tests/qemu-iotests/098 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 43
Quoted 5 lines
tests/qemu-iotests/098 +1
-2_supported_fmt qcow2 _supported_proto file - -IMGOPTS="compat=1.1" +_unsupported_imgopts 'compat=0.10'Any idea why? I am not familiar with qcow2 well enought to know but this misses a comment with justification.
Because the special bdrv_make_empty() version we want to test only works with qcow2 v3 images.
Quoted 8 lines
tests/qemu-iotests/098 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 46
Quoted 3 lines
tests/qemu-iotests/098 +0
-0for event in l1_update empty_image_prepare reftable_update refblock_alloc; doBest regards,
Maxim Levitsky
Thanks for reviewing!
Max
Re: [PATCH 02/18] iotests: Replace IMGOPTS by _unsupported_imgopts
Quoted 106 lines · Max Reitz
Quoted 70 lines · Maxim Levitsky
Quoted 69 lines · Max Reitz
Some tests require compat=1.1 and thus set IMGOPTS='compat=1.1' globally. That is not how it should be done; instead, they should simply set
_unsupported_imgoptsto compat=0.10 (compat=1.1 is the default anyway).This makes the tests heed user-specified $IMGOPTS. Some do not work with all image options, though, so we need to disable them accordingly.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/036 | 3 +-- tests/qemu-iotests/060 | 4 ++-- tests/qemu-iotests/062 | 3 ++- tests/qemu-iotests/066 | 3 ++- tests/qemu-iotests/068 | 3 ++- tests/qemu-iotests/098 | 3 +-- 6 files changed, 10 insertions(+), 9 deletions(-)tests/qemu-iotests/036 +1
-2@@ -43,9 +43,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 _supported_proto file - # Only qcow2v3 and later supports feature bits -IMGOPTS="compat=1.1" +_unsupported_imgopts 'compat=0.10' echo echo === Image with unknown incompatible feature bit ===tests/qemu-iotests/060 +2
-2@@ -48,6 +48,8 @@ _filter_io_error() _supported_fmt qcow2 _supported_proto file _supported_os Linux +# These tests only work for compat=1.1 images with refcount_bits=16 +_unsupported_imgopts 'compat=0.10' 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' rt_offset=65536 # 0x10000 (XXX: just an assumption) rb_offset=131072 # 0x20000 (XXX: just an assumption)@@ -55,8 +57,6 @@ l1_offset=196608 # 0x30000 (XXX: just an assumption) l2_offset=262144 # 0x40000 (XXX: just an assumption) l2_offset_after_snapshot=524288 # 0x80000 (XXX: just an assumption) -IMGOPTS="compat=1.1" - OPEN_RW="open -o overlap-check=all $TEST_IMG" # Overlap checks are done before write operations only, therefore opening an # image read-only makes the overlap-check option irrelevanttests/qemu-iotests/062 +2
-1@@ -40,8 +40,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic +# We need zero clusters and snapshots +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' -IMGOPTS="compat=1.1" IMG_SIZE=64MQuoted 12 lines
tests/qemu-iotests/066 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 42
Quoted 10 lines
tests/qemu-iotests/062 +0
-0echotests/qemu-iotests/066 +1
-0@@ -39,9 +39,10 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic +# Weneed zero clusters and snapshotsTypo
Indeed!
Quoted 6 lines
Quoted 6 lines
tests/qemu-iotests/066 +1
-1+_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' # Intentionally create an unaligned image -IMGOPTS="compat=1.1" IMG_SIZE=$((64 * 1024 * 1024 + 512))Quoted 13 lines
tests/qemu-iotests/068 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 42
Quoted 10 lines
tests/qemu-iotests/066 +0
-0echotests/qemu-iotests/068 +1
-0@@ -39,8 +39,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic +# Internal snapshots are (currently) impossible with refcount_bits=1Why currently? 1 bit will only allow to mark a cluser as used/unused which is not enough for any snapshots?
Quoted 2 lines
It is, because in theory you can just copy the clusters at the time of snapshotting. We’ll never implement it, but, well...
Fair enough, I didn't even thought of that. I fully agree that implementing this is silly.
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
tests/qemu-iotests/068 +1
-1+_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' -IMGOPTS="compat=1.1" IMG_SIZE=128K case "$QEMU_DEFAULT_MACHINE" intests/qemu-iotests/098 +0
-0@@ -40,8 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15Quoted 8 lines
tests/qemu-iotests/098 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 43
Quoted 5 lines
tests/qemu-iotests/098 +1
-2_supported_fmt qcow2 _supported_proto file - -IMGOPTS="compat=1.1" +_unsupported_imgopts 'compat=0.10'Any idea why? I am not familiar with qcow2 well enought to know but this misses a comment with justification.
Quoted 2 lines
Because the special
bdrv_make_empty()version we want to test only works with qcow2 v3 images.
Just to understand this, we have
compat=0.10, also known as v2, which is the classical qcow2 (and v1 is basically qcow) and then we have compat=1.1 which is also known as v3, and once upon a time was supposed to be called qcow3, but at the end remained qcow2.
Quoted 11 lines
Quoted 9 lines
tests/qemu-iotests/098 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 46
Quoted 4 lines
tests/qemu-iotests/098 +0
-0for event in l1_update empty_image_prepare reftable_update refblock_alloc; doBest regards,
Maxim LevitskyThanks for reviewing!
Thanks to you too!
I will focus more on reviewing in next few months, since I really don't do this enough.
Best regards,
Maxim Levitsky
Quoted 3 lines
Max
Re: [PATCH 02/18] iotests: Replace IMGOPTS by _unsupported_imgopts
Quoted 20 lines · Maxim Levitsky
Quoted 19 lines · Max Reitz
Quoted 18 lines · Maxim Levitsky
Quoted 17 lines · Max Reitz
Some tests require compat=1.1 and thus set IMGOPTS='compat=1.1' globally. That is not how it should be done; instead, they should simply set
_unsupported_imgoptsto compat=0.10 (compat=1.1 is the default anyway).This makes the tests heed user-specified $IMGOPTS. Some do not work with all image options, though, so we need to disable them accordingly.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/036 | 3 +-- tests/qemu-iotests/060 | 4 ++-- tests/qemu-iotests/062 | 3 ++- tests/qemu-iotests/066 | 3 ++- tests/qemu-iotests/068 | 3 ++- tests/qemu-iotests/098 | 3 +-- 6 files changed, 10 insertions(+), 9 deletions(-)
[...]
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 12 lines
tests/qemu-iotests/068 +1
-1+_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' -IMGOPTS="compat=1.1" IMG_SIZE=128K case "$QEMU_DEFAULT_MACHINE" intests/qemu-iotests/098 +0
-0tests/qemu-iotests/098 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 43
Quoted 6 lines
tests/qemu-iotests/098 +1
-2@@ -40,8 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file - -IMGOPTS="compat=1.1" +_unsupported_imgopts 'compat=0.10'Any idea why? I am not familiar with qcow2 well enought to know but this misses a comment with justification.
Quoted 7 lines
Quoted 2 lines
Because the special
bdrv_make_empty()version we want to test only works with qcow2 v3 images.Just to understand this, we have
compat=0.10, also known as v2, which is the classical qcow2 (and v1 is basically qcow) and then we have compat=1.1 which is also known as v3, and once upon a time was supposed to be called qcow3, but at the end remained qcow2.
Yep, that’s correct. If you want to, you can still call it qcow3. I wanted to do that at some point, but it turned out that nobody else does it.
Max
PATCH 3/18 iotests: Drop compat=1.1 in 050
In reply to Max ReitzIMGOPTS can never be empty for qcow2, because the check scripts adds compat=1.1 unless the user specified any compat option themselves. Thus, this block does not do anything and can be dropped.
--- tests/qemu-iotests/050 | 4 ---- 1 file changed, 4 deletions(-)
tests/qemu-iotests/050 +0 -4
@@ -41,10 +41,6 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 qed _supported_proto file -if test "$IMGFMT" = qcow2 && test $IMGOPTS = ""; then - IMGOPTS=compat=1.1 -fi - echo echo "== Creating images =="
Signature · 1 line
2.21.0
Re: [PATCH 03/18] iotests: Drop compat=1.1 in 050
Quoted 14 lines · Max Reitz
IMGOPTS can never be empty for qcow2, because the check scripts adds compat=1.1 unless the user specified any compat option themselves. Thus, this block does not do anything and can be dropped.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/050 | 4 ---- 1 file changed, 4 deletions(-)tests/qemu-iotests/050 +0
-0
tests/qemu-iotests/050 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 46
Quoted 10 lines
tests/qemu-iotests/050 +0
-4@@ -41,10 +41,6 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 qed _supported_proto file -if test "$IMGFMT" = qcow2 && test $IMGOPTS = ""; then - IMGOPTS=compat=1.1 -fi - echo echo "== Creating images =="
Best regards,
Maxim Levitsky
PATCH 4/18 iotests: Let _make_test_img parse its parameters
In reply to Max ReitzThis will allow us to add more options than just -b.
--- tests/qemu-iotests/common.rc | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
tests/qemu-iotests/common.rc +20 -8
@@ -282,12 +282,12 @@ _make_test_img() # extra qemu-img options can be added by tests # at least one argument (the image size) needs to be added local extra_img_options="" - local image_size=$* local optstr="" local img_name="" local use_backing=0 local backing_file="" local object_options="" + local misc_params=() if [ -n "$TEST_IMG_FILE" ]; then img_name=$TEST_IMG_FILE
@@ -303,11 +303,23 @@ _make_test_img() optstr=$(_optstr_add "$optstr" "key-secret=keysec0") fi - if [ "$1" = "-b" ]; then - use_backing=1 - backing_file=$2 - image_size=$3 - fi + for param; do + if [ "$use_backing" = "1" -a -z "$backing_file" ]; then + backing_file=$param + continue + fi + + case "$param" in + -b) + use_backing=1 + ;; + + *) + misc_params=("${misc_params[@]}" "$param") + ;; + esac + done + if [ \( "$IMGFMT" = "qcow2" -o "$IMGFMT" = "qed" \) -a -n "$CLUSTER_SIZE" ]; then optstr=$(_optstr_add "$optstr" "cluster_size=$CLUSTER_SIZE") fi
@@ -323,9 +335,9 @@ _make_test_img() # XXX(hch): have global image options? ( if [ $use_backing = 1 ]; then - $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" $image_size 2>&1 + $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" "${misc_params[@]}" 2>&1 else - $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" $image_size 2>&1 + $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" "${misc_params[@]}" 2>&1 fi ) | _filter_img_create
Signature · 1 line
2.21.0
Re: [PATCH 04/18] iotests: Let _make_test_img parse its parameters
Quoted 56 lines · Max Reitz
This will allow us to add more options than just -b.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/common.rc | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)tests/qemu-iotests/common.rc +18
-6@@ -282,12 +282,12 @@ _make_test_img() # extra qemu-img options can be added by tests # at least one argument (the image size) needs to be added local extra_img_options="" - local image_size=$* local optstr="" local img_name="" local use_backing=0 local backing_file="" local object_options="" + local misc_params=() if [ -n "$TEST_IMG_FILE" ]; then img_name=$TEST_IMG_FILE@@ -303,11 +303,23 @@ _make_test_img() optstr=$(_optstr_add "$optstr" "key-secret=keysec0") fi - if [ "$1" = "-b" ]; then - use_backing=1 - backing_file=$2 - image_size=$3 - fi + for param; do + if [ "$use_backing" = "1" -a -z "$backing_file" ]; then + backing_file=$param + continue + fi + + case "$param" in + -b) + use_backing=1 + ;; + + *) + misc_params=("${misc_params[@]}" "$param") + ;; + esac + done + if [ \( "$IMGFMT" = "qcow2" -o "$IMGFMT" = "qed" \) -a -n "$CLUSTER_SIZE" ]; then optstr=$(_optstr_add "$optstr" "cluster_size=$CLUSTER_SIZE") fi@@ -323,9 +335,9 @@ _make_test_img() # XXX(hch): have global image options?
tests/qemu-iotests/common.rc _make_test_img() · line 343
Quoted 10 lines
tests/qemu-iotests/common.rc +2
-2( if [ $use_backing = 1 ]; then - $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" $image_size 2>&1 + $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" "${misc_params[@]}" 2>&1 else - $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" $image_size 2>&1 + $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" "${misc_params[@]}" 2>&1 fi ) | _filter_img_create
Look all right as far as I understand that code, and this is a very welcome change.
Best regards,
Maxim Levitsky
PATCH 5/18 iotests: Add -o and --no-opts to _make_test_img
In reply to Max ReitzBlindly overriding IMGOPTS is suboptimal as this discards user-specified options. Whatever options the test needs should simply be appended.
Some tests do this (with IMGOPTS=$(_optstr_add "$IMGOPTS" "...")), but that is cumbersome. It’s simpler to just give _make_test_img an -o parameter with which tests can add options.
Some tests actually must override the user-specified options, though, for example when creating an image in a different format than the test $IMGFMT. For such cases, --no-opts allows clearing the current option list.
--- tests/qemu-iotests/common.rc | 13 +++++++++++++ 1 file changed, 13 insertions(+)
tests/qemu-iotests/common.rc +13 -0
@@ -287,6 +287,7 @@ _make_test_img() local use_backing=0 local backing_file="" local object_options="" + local opts_param=false local misc_params=() if [ -n "$TEST_IMG_FILE" ]; then
@@ -307,6 +308,10 @@ _make_test_img() if [ "$use_backing" = "1" -a -z "$backing_file" ]; then backing_file=$param continue + elif $opts_param; then + optstr=$(_optstr_add "$optstr" "$param") + opts_param=false + continue fi case "$param" in
@@ -314,6 +319,14 @@ _make_test_img() use_backing=1 ;; + -o) + opts_param=true + ;; + + --no-opts) + optstr="" + ;; + *) misc_params=("${misc_params[@]}" "$param") ;;
Signature · 1 line
2.21.0
Re: [PATCH 05/18] iotests: Add -o and --no-opts to _make_test_img
Quoted 45 lines · Max Reitz
Blindly overriding IMGOPTS is suboptimal as this discards user-specified options. Whatever options the test needs should simply be appended.
Some tests do this (with IMGOPTS=$(_optstr_add "$IMGOPTS" "...")), but that is cumbersome. It’s simpler to just give
_make_test_imgan -o parameter with which tests can add options.Some tests actually must override the user-specified options, though, for example when creating an image in a different format than the test $IMGFMT. For such cases, --no-opts allows clearing the current option list.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/common.rc | 13 +++++++++++++ 1 file changed, 13 insertions(+)tests/qemu-iotests/common.rc +6
-0@@ -287,6 +287,7 @@ _make_test_img() local use_backing=0 local backing_file="" local object_options="" + local opts_param=false local misc_params=() if [ -n "$TEST_IMG_FILE" ]; then@@ -307,6 +308,10 @@ _make_test_img() if [ "$use_backing" = "1" -a -z "$backing_file" ]; then backing_file=$param continue + elif $opts_param; then + optstr=$(_optstr_add "$optstr" "$param") + opts_param=false + continue fi case "$param" in@@ -314,6 +319,14 @@ _make_test_img() use_backing=1 ;; + -o)
tests/qemu-iotests/common.rc _make_test_img() · line 332
Quoted 10 lines
tests/qemu-iotests/common.rc +7
-0+ opts_param=true + ;; + + --no-opts) + optstr="" + ;; + *) misc_params=("${misc_params[@]}" "$param") ;;
Best regards,
Maxim Levitsky
PATCH 6/18 iotests: Inject space into -ocompat=0.10 in 051
In reply to Max ReitzIt did not matter before, but now that _make_test_img understands -o, we should use it properly here.
--- tests/qemu-iotests/051 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/051 +1 -1
@@ -157,7 +157,7 @@ echo echo === With version 2 images enabling lazy refcounts must fail === echo -_make_test_img -ocompat=0.10 $size +_make_test_img -o compat=0.10 $size run_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=on run_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=off
Signature · 1 line
2.21.0
Re: [PATCH 06/18] iotests: Inject space into -ocompat=0.10 in 051
Quoted 13 lines · Max Reitz
It did not matter before, but now that
_make_test_imgunderstands -o, we should use it properly here.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/051 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/qemu-iotests/051 +0
-0
tests/qemu-iotests/051 echo · line 163
Quoted 8 lines
tests/qemu-iotests/051 +1
-1@@ -157,7 +157,7 @@ echo echo === With version 2 images enabling lazy refcounts must fail === echo -_make_test_img -ocompat=0.10 $size +_make_test_img -o compat=0.10 $size run_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=on run_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=off
PATCH 7/18 iotests: Replace IMGOPTS= by -o
In reply to Max ReitzTests should not overwrite all user-supplied image options, but only add to it (which will effectively overwrite conflicting values). Accomplish this by passing options to _make_test_img via -o instead of $IMGOPTS.
For some tests, there is no functional change because they already only appended options to IMGOPTS. For these, this patch is just a simplification.
For others, this is a change, so they now heed user-specified $IMGOPTS. Some of those tests do not work with all image options, though, so we need to disable them accordingly.
--- tests/qemu-iotests/031 | 9 ++++--- tests/qemu-iotests/039 | 24 ++++++------------ tests/qemu-iotests/059 | 18 ++++++------- tests/qemu-iotests/060 | 6 ++--- tests/qemu-iotests/061 | 57 ++++++++++++++++++++++-------------------- tests/qemu-iotests/079 | 3 +-- tests/qemu-iotests/106 | 2 +- tests/qemu-iotests/108 | 2 +- tests/qemu-iotests/112 | 32 ++++++++++++------------ tests/qemu-iotests/115 | 3 +-- tests/qemu-iotests/121 | 6 ++--- tests/qemu-iotests/125 | 2 +- tests/qemu-iotests/137 | 2 +- tests/qemu-iotests/138 | 3 +-- tests/qemu-iotests/175 | 2 +- tests/qemu-iotests/190 | 2 +- tests/qemu-iotests/191 | 3 +-- tests/qemu-iotests/220 | 4 ++- tests/qemu-iotests/243 | 6 +++-- tests/qemu-iotests/244 | 10 +++++--- tests/qemu-iotests/250 | 3 +-- tests/qemu-iotests/265 | 2 +- 22 files changed, 100 insertions(+), 101 deletions(-)
tests/qemu-iotests/031 +6 -3
@@ -40,19 +40,22 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 _supported_proto file +# We want to test compat=0.10, which does not support refcount widths +# other than 16 +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' CLUSTER_SIZE=65536 # qcow2.py output depends on the exact options used, so override the command # line here as an exception -for IMGOPTS in "compat=0.10" "compat=1.1"; do +for compat in "compat=0.10" "compat=1.1"; do echo - echo ===== Testing with -o $IMGOPTS ===== + echo ===== Testing with -o $compat ===== echo echo === Create image with unknown header extension === echo - _make_test_img 64M + _make_test_img -o $compat 64M $PYTHON qcow2.py "$TEST_IMG" add-header-ext 0x12345678 "This is a test header extension" $PYTHON qcow2.py "$TEST_IMG" dump-header _check_test_img
tests/qemu-iotests/039 +8 -16
@@ -50,8 +50,7 @@ size=128M echo echo "== Checking that image is clean on shutdown ==" -IMGOPTS="compat=1.1,lazy_refcounts=on" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=on" $size $QEMU_IO -c "write -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io
@@ -62,8 +61,7 @@ _check_test_img echo echo "== Creating a dirty image file ==" -IMGOPTS="compat=1.1,lazy_refcounts=on" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=on" $size _NO_VALGRIND \ $QEMU_IO -c "write -P 0x5a 0 512" \
@@ -98,8 +96,7 @@ $QEMU_IO -c "read -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io echo echo "== Opening a dirty image read/write should repair it ==" -IMGOPTS="compat=1.1,lazy_refcounts=on" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=on" $size _NO_VALGRIND \ $QEMU_IO -c "write -P 0x5a 0 512" \
@@ -117,8 +114,7 @@ $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features echo echo "== Creating an image file with lazy_refcounts=off ==" -IMGOPTS="compat=1.1,lazy_refcounts=off" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=off" $size _NO_VALGRIND \ $QEMU_IO -c "write -P 0x5a 0 512" \
@@ -132,11 +128,9 @@ _check_test_img echo echo "== Committing to a backing file with lazy_refcounts=on ==" -IMGOPTS="compat=1.1,lazy_refcounts=on" -TEST_IMG="$TEST_IMG".base _make_test_img $size +TEST_IMG="$TEST_IMG".base _make_test_img -o "compat=1.1,lazy_refcounts=on" $size -IMGOPTS="compat=1.1,lazy_refcounts=on,backing_file=$TEST_IMG.base" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=on,backing_file=$TEST_IMG.base" $size $QEMU_IO -c "write 0 512" "$TEST_IMG" | _filter_qemu_io $QEMU_IMG commit "$TEST_IMG"
@@ -151,8 +145,7 @@ TEST_IMG="$TEST_IMG".base _check_test_img echo echo "== Changing lazy_refcounts setting at runtime ==" -IMGOPTS="compat=1.1,lazy_refcounts=off" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=off" $size _NO_VALGRIND \ $QEMU_IO -c "reopen -o lazy-refcounts=on" \
@@ -164,8 +157,7 @@ $QEMU_IO -c "reopen -o lazy-refcounts=on" \ $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features _check_test_img -IMGOPTS="compat=1.1,lazy_refcounts=on" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=on" $size _NO_VALGRIND \ $QEMU_IO -c "reopen -o lazy-refcounts=off" \
tests/qemu-iotests/059 +9 -9
@@ -70,18 +70,18 @@ poke_file "$TEST_IMG" "$grain_table_size_offset" "\x01\x00\x00\x00" echo echo "=== Testing monolithicFlat creation and opening ===" -IMGOPTS="subformat=monolithicFlat" _make_test_img 2G +_make_test_img -o "subformat=monolithicFlat" 2G _img_info _cleanup_test_img echo echo "=== Testing monolithicFlat with zeroed_grain ===" -IMGOPTS="subformat=monolithicFlat,zeroed_grain=on" _make_test_img 2G +_make_test_img -o "subformat=monolithicFlat,zeroed_grain=on" 2G _cleanup_test_img echo echo "=== Testing big twoGbMaxExtentFlat ===" -IMGOPTS="subformat=twoGbMaxExtentFlat" _make_test_img 1000G +_make_test_img -o "subformat=twoGbMaxExtentFlat" 1000G $QEMU_IMG info $TEST_IMG | _filter_testdir | sed -e 's/cid: [0-9]*/cid: XXXXXXXX/' _cleanup_test_img
@@ -101,13 +101,13 @@ _img_info echo echo "=== Testing truncated sparse ===" -IMGOPTS="subformat=monolithicSparse" _make_test_img 100G +_make_test_img -o "subformat=monolithicSparse" 100G truncate -s 10M $TEST_IMG _img_info echo echo "=== Converting to streamOptimized from image with small cluster size===" -TEST_IMG="$TEST_IMG.qcow2" IMGFMT=qcow2 IMGOPTS="cluster_size=4096" _make_test_img 1G +TEST_IMG="$TEST_IMG.qcow2" IMGFMT=qcow2 _make_test_img -o "cluster_size=4096" 1G $QEMU_IO -f qcow2 -c "write -P 0xa 0 512" "$TEST_IMG.qcow2" | _filter_qemu_io $QEMU_IO -f qcow2 -c "write -P 0xb 10240 512" "$TEST_IMG.qcow2" | _filter_qemu_io $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2" "$TEST_IMG" 2>&1
@@ -117,7 +117,7 @@ echo "=== Testing monolithicFlat with internally generated JSON file name ===" echo '--- blkdebug ---' # Should work, because bdrv_dirname() works fine with blkdebug -IMGOPTS="subformat=monolithicFlat" _make_test_img 64M +_make_test_img -o "subformat=monolithicFlat" 64M $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \ -c info \ 2>&1 \
@@ -126,7 +126,7 @@ _cleanup_test_img echo '--- quorum ---' # Should not work, because bdrv_dirname() does not work with quorum -IMGOPTS="subformat=monolithicFlat" _make_test_img 64M +_make_test_img -o "subformat=monolithicFlat" 64M cp "$TEST_IMG" "$TEST_IMG.orig" filename="json:{
@@ -161,7 +161,7 @@ _cleanup_test_img echo echo "=== Testing 4TB monolithicFlat creation and IO ===" -IMGOPTS="subformat=monolithicFlat" _make_test_img 4T +_make_test_img -o "subformat=monolithicFlat" 4T _img_info $QEMU_IO -c "write -P 0xa 900G 512" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "read -v 900G 1024" "$TEST_IMG" | _filter_qemu_io
@@ -170,7 +170,7 @@ _cleanup_test_img echo echo "=== Testing qemu-img map on extents ===" for fmt in monolithicSparse twoGbMaxExtentSparse; do - IMGOPTS="subformat=$fmt" _make_test_img 31G + _make_test_img -o "subformat=$fmt" 31G $QEMU_IO -c "write 65024 1k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "write 2147483136 1k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "write 5G 1k" "$TEST_IMG" | _filter_qemu_io
tests/qemu-iotests/060 +3 -3
@@ -158,7 +158,7 @@ $QEMU_IO -c 'write 0k 64k' "$BACKING_IMG" | _filter_qemu_io # compat=0.10 is required in order to make the following discard actually # unallocate the sector rather than make it a zero sector - we want COW, after # all. -IMGOPTS='compat=0.10' _make_test_img -b "$BACKING_IMG" 1G +_make_test_img -o 'compat=0.10' -b "$BACKING_IMG" 1G # Write two clusters, the second one enforces creation of an L2 table after # the first data cluster. $QEMU_IO -c 'write 0k 64k' -c 'write 512M 64k' "$TEST_IMG" | _filter_qemu_io
@@ -398,7 +398,7 @@ echo echo "=== Discarding a non-covered in-bounds refblock ===" echo -IMGOPTS='refcount_bits=1' _make_test_img 64M +_make_test_img -o 'refcount_bits=1' 64M # Pretend there's a refblock somewhere where there is no refblock to # cover it (but the covering refblock has a valid index in the
@@ -422,7 +422,7 @@ echo echo "=== Discarding a refblock covered by an unaligned refblock ===" echo -IMGOPTS='refcount_bits=1' _make_test_img 64M +_make_test_img -o 'refcount_bits=1' 64M # Same as above poke_file "$TEST_IMG" "$(($rt_offset+8))" "\x00\x00\x00\x10\x00\x00\x00\x00"
tests/qemu-iotests/061 +30 -27
187 lines not on this page · raw message
tests/qemu-iotests/079 +1 -2
@@ -44,8 +44,7 @@ echo cluster_sizes="16384 32768 65536 131072 262144 524288 1048576 2097152 4194304" for s in $cluster_sizes; do - IMGOPTS=$(_optstr_add "$IMGOPTS" "preallocation=metadata,cluster_size=$s") \ - _make_test_img 4G + _make_test_img -o "preallocation=metadata,cluster_size=$s" 4G done # success, all done
tests/qemu-iotests/106 +1 -1
@@ -51,7 +51,7 @@ for create_mode in off falloc full; do echo echo "--- create_mode=$create_mode growth_mode=$growth_mode ---" - IMGOPTS="preallocation=$create_mode" _make_test_img ${CREATION_SIZE}K + _make_test_img -o "preallocation=$create_mode" ${CREATION_SIZE}K $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K expected_size=0
tests/qemu-iotests/108 +1 -1
@@ -65,7 +65,7 @@ echo echo '=== Repairing unreferenced data cluster in new refblock area ===' echo -IMGOPTS='cluster_size=512' _make_test_img 64M +_make_test_img -o 'cluster_size=512' 64M # Allocate the first 128 kB in the image (first refblock) $QEMU_IO -c 'write 0 0x1b200' "$TEST_IMG" | _filter_qemu_io # should be 131072 == 0x20000
tests/qemu-iotests/112 +16 -16
@@ -53,20 +53,20 @@ echo '=== refcount_bits limits ===' echo # Must be positive (non-zero) -IMGOPTS="$IMGOPTS,refcount_bits=0" _make_test_img 64M +_make_test_img -o "refcount_bits=0" 64M # Must be positive (non-negative) -IMGOPTS="$IMGOPTS,refcount_bits=-1" _make_test_img 64M +_make_test_img -o "refcount_bits=-1" 64M # May not exceed 64 -IMGOPTS="$IMGOPTS,refcount_bits=128" _make_test_img 64M +_make_test_img -o "refcount_bits=128" 64M # Must be a power of two -IMGOPTS="$IMGOPTS,refcount_bits=42" _make_test_img 64M +_make_test_img -o "refcount_bits=42" 64M # 1 is the minimum -IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M +_make_test_img -o "refcount_bits=1" 64M print_refcount_bits # 64 is the maximum -IMGOPTS="$IMGOPTS,refcount_bits=64" _make_test_img 64M +_make_test_img -o "refcount_bits=64" 64M print_refcount_bits # 16 is the default
@@ -78,19 +78,19 @@ echo '=== refcount_bits and compat=0.10 ===' echo # Should work -IMGOPTS="$IMGOPTS,compat=0.10,refcount_bits=16" _make_test_img 64M +_make_test_img -o "compat=0.10,refcount_bits=16" 64M print_refcount_bits # Should not work -IMGOPTS="$IMGOPTS,compat=0.10,refcount_bits=1" _make_test_img 64M -IMGOPTS="$IMGOPTS,compat=0.10,refcount_bits=64" _make_test_img 64M +_make_test_img -o "compat=0.10,refcount_bits=1" 64M +_make_test_img -o "compat=0.10,refcount_bits=64" 64M echo echo '=== Snapshot limit on refcount_bits=1 ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M +_make_test_img -o "refcount_bits=1" 64M print_refcount_bits $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io
@@ -106,7 +106,7 @@ echo echo '=== Snapshot limit on refcount_bits=2 ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=2" _make_test_img 64M +_make_test_img -o "refcount_bits=2" 64M print_refcount_bits $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io
@@ -124,7 +124,7 @@ echo echo '=== Compressed clusters with refcount_bits=1 ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M +_make_test_img -o "refcount_bits=1" 64M print_refcount_bits # Both should fit into a single host cluster; instead of failing to increase the
@@ -140,7 +140,7 @@ echo echo '=== MSb set in 64 bit refcount ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=64" _make_test_img 64M +_make_test_img -o "refcount_bits=64" 64M print_refcount_bits $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io
@@ -158,7 +158,7 @@ echo echo '=== Snapshot on maximum 64 bit refcount value ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=64" _make_test_img 64M +_make_test_img -o "refcount_bits=64" 64M print_refcount_bits $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io
@@ -239,7 +239,7 @@ echo echo '=== Testing too many references for check ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M +_make_test_img -o "refcount_bits=1" 64M print_refcount_bits # This cluster should be created at 0x50000
@@ -262,7 +262,7 @@ echo echo '=== Multiple walks necessary during amend ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=1,cluster_size=512" _make_test_img 64k +_make_test_img -o "refcount_bits=1,cluster_size=512" 64k # Cluster 0 is the image header, clusters 1 to 4 are used by the L1 table, a # single L2 table, the reftable and a single refblock. This creates 58 data
tests/qemu-iotests/115 +1 -2
@@ -64,8 +64,7 @@ echo # least 256 MB. We can achieve that by using preallocation=metadata for an image # which has a guest disk size of 256 MB. -IMGOPTS="$IMGOPTS,refcount_bits=64,cluster_size=512,preallocation=metadata" \ - _make_test_img 256M +_make_test_img -o "refcount_bits=64,cluster_size=512,preallocation=metadata" 256M # We know for sure that the L1 and refcount tables do not overlap with any other # structure because the metadata overlap checks would have caught that case.
tests/qemu-iotests/121 +3 -3
@@ -50,7 +50,7 @@ echo # Preallocation speeds up the write operation, but preallocating everything will # destroy the purpose of the write; so preallocate one KB less than what would # cause a reftable growth... -IMGOPTS='preallocation=metadata,cluster_size=1k' _make_test_img 64512K +_make_test_img -o 'preallocation=metadata,cluster_size=1k' 64512K # ...and make the image the desired size afterwards. $QEMU_IMG resize "$TEST_IMG" 65M
@@ -73,7 +73,7 @@ echo echo '--- Test 2 ---' echo -IMGOPTS='preallocation=metadata,cluster_size=1k' _make_test_img 64513K +_make_test_img -o 'preallocation=metadata,cluster_size=1k' 64513K # This results in an L1 table growth which in turn results in some clusters at # the start of the image becoming free $QEMU_IMG resize "$TEST_IMG" 65M
@@ -96,7 +96,7 @@ echo echo '=== Allocating a new refcount block must not leave holes in the image ===' echo -IMGOPTS='cluster_size=512,refcount_bits=16' _make_test_img 1M +_make_test_img -o 'cluster_size=512,refcount_bits=16' 1M # This results in an image with 256 used clusters: the qcow2 header, # the refcount table, one refcount block, the L1 table, four L2 tables
tests/qemu-iotests/125 +1 -1
@@ -114,7 +114,7 @@ for GROWTH_SIZE in 16 48 80; do for growth_mode in off metadata falloc full; do echo "--- cluster_size=$cluster_size growth_size=$GROWTH_SIZE create_mode=$create_mode growth_mode=$growth_mode ---" - IMGOPTS="preallocation=$create_mode,cluster_size=$cluster_size" _make_test_img ${CREATION_SIZE} + _make_test_img -o "preallocation=$create_mode,cluster_size=$cluster_size" ${CREATION_SIZE} $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K host_size_0=$(get_image_size_on_host)
tests/qemu-iotests/137 +1 -1
@@ -117,7 +117,7 @@ $QEMU_IO \ -c "reopen -o cache-clean-interval=-1" \ "$TEST_IMG" | _filter_qemu_io -IMGOPTS="cluster_size=256k" _make_test_img 32P +_make_test_img -o "cluster_size=256k" 32P $QEMU_IO \ -c "reopen -o l2-cache-entry-size=512,l2-cache-size=1T" \ "$TEST_IMG" | _filter_qemu_io
tests/qemu-iotests/138 +1 -2
@@ -45,8 +45,7 @@ echo echo '=== Check on an image with a multiple of 2^32 clusters ===' echo -IMGOPTS=$(_optstr_add "$IMGOPTS" "cluster_size=512") \ - _make_test_img 512 +_make_test_img -o "cluster_size=512" 512 # Allocate L2 table $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io
tests/qemu-iotests/175 +1 -1
@@ -95,7 +95,7 @@ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_block for mode in off full falloc; do echo echo "== creating image with preallocation $mode ==" - IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt + _make_test_img -o preallocation=$mode $size | _filter_imgfmt stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size done
tests/qemu-iotests/190 +1 -1
@@ -45,7 +45,7 @@ _supported_proto file echo "== Huge file ==" echo -IMGOPTS='cluster_size=2M' _make_test_img 2T +_make_test_img -o 'cluster_size=2M' 2T $QEMU_IMG measure -O raw -f qcow2 "$TEST_IMG" $QEMU_IMG measure -O qcow2 -o cluster_size=64k -f qcow2 "$TEST_IMG"
tests/qemu-iotests/191 +1 -2
@@ -51,8 +51,7 @@ echo === Preparing and starting VM === echo TEST_IMG="${TEST_IMG}.base" _make_test_img $size -IMGOPTS=$(_optstr_add "$IMGOPTS" "backing_fmt=$IMGFMT") \ - TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base" +TEST_IMG="${TEST_IMG}.mid" _make_test_img -o "backing_fmt=$IMGFMT" -b "${TEST_IMG}.base" _make_test_img -b "${TEST_IMG}.mid" TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid"
tests/qemu-iotests/220 +3 -1
@@ -37,6 +37,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux +# To use a different refcount width but 16 bits we need compat=1.1 +_unsupported_imgopts 'compat=0.10' echo "== Creating huge file =="
@@ -46,7 +48,7 @@ if ! truncate --size=513T "$TEST_IMG"; then _notrun "file system on $TEST_DIR does not support large enough files" fi rm "$TEST_IMG" -IMGOPTS='cluster_size=2M,refcount_bits=1' _make_test_img 513T +_make_test_img -o 'cluster_size=2M,refcount_bits=1' 513T echo "== Populating refcounts ==" # We want an image with 256M refcounts * 2M clusters = 512T referenced.
tests/qemu-iotests/243 +4 -2
@@ -40,6 +40,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux +# External data files do not work with compat=0.10 +_unsupported_imgopts 'compat=0.10' for mode in off metadata falloc full; do
@@ -47,7 +49,7 @@ for mode in off metadata falloc full; do echo "=== preallocation=$mode ===" echo - IMGOPTS="preallocation=$mode" _make_test_img 64M + _make_test_img -o "preallocation=$mode" 64M printf "File size: " du -b $TEST_IMG | cut -f1
@@ -64,7 +66,7 @@ for mode in off metadata falloc full; do echo "=== External data file: preallocation=$mode ===" echo - IMGOPTS="data_file=$TEST_IMG.data,preallocation=$mode" _make_test_img 64M + _make_test_img -o "data_file=$TEST_IMG.data,preallocation=$mode" 64M echo -n "qcow2 file size: " du -b $TEST_IMG | cut -f1
tests/qemu-iotests/244 +6 -4
@@ -41,13 +41,15 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux +# External data files do not work with compat=0.10 +_unsupported_imgopts 'compat=0.10' echo echo "=== Create and open image with external data file ===" echo echo "With data file name in the image:" -IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M +_make_test_img -o "data_file=$TEST_IMG.data" 64M _check_test_img $QEMU_IO -c "open $TEST_IMG" -c "read -P 0 0 64k" 2>&1 | _filter_qemu_io | _filter_testdir
@@ -104,7 +106,7 @@ echo echo "=== Standalone image with external data file (efficient) ===" echo -IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M +_make_test_img -o "data_file=$TEST_IMG.data" 64M echo -n "qcow2 file size before I/O: " du -b $TEST_IMG | cut -f1
@@ -154,7 +156,7 @@ echo echo "=== Standalone image with external data file (valid raw) ===" echo -IMGOPTS="data_file=$TEST_IMG.data,data_file_raw=on" _make_test_img 64M +_make_test_img -o "data_file=$TEST_IMG.data,data_file_raw=on" 64M echo -n "qcow2 file size before I/O: " du -b $TEST_IMG | cut -f1
@@ -187,7 +189,7 @@ echo echo "=== bdrv_co_block_status test for file and offset=0 ===" echo -IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M +_make_test_img -o "data_file=$TEST_IMG.data" 64M $QEMU_IO -c 'write -P 0x11 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c 'read -P 0x11 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
tests/qemu-iotests/250 +1 -2
@@ -55,9 +55,8 @@ disk_usage() } size=2100M -IMGOPTS="cluster_size=1M,preallocation=metadata" -_make_test_img $size +_make_test_img -o "cluster_size=1M,preallocation=metadata" $size $QEMU_IO -c 'discard 0 10M' -c 'discard 2090M 10M' \ -c 'write 2090M 10M' -c 'write 0 10M' "$TEST_IMG" | _filter_qemu_io
tests/qemu-iotests/265 +1 -1
@@ -41,7 +41,7 @@ _supported_os Linux echo '--- Writing to the image ---' # Reduce cluster size so we get more and quicker I/O -IMGOPTS='cluster_size=4096' _make_test_img 1M +_make_test_img -o 'cluster_size=4096' 1M (for ((kb = 1024 - 4; kb >= 0; kb -= 4)); do \ echo "aio_write -P 42 $((kb + 1))k 2k"; \ done) \
Signature · 1 line
2.21.0
Re: [PATCH 07/18] iotests: Replace IMGOPTS= by -o
Quoted 43 lines · Max Reitz
Tests should not overwrite all user-supplied image options, but only add to it (which will effectively overwrite conflicting values). Accomplish this by passing options to
_make_test_imgvia -o instead of $IMGOPTS.For some tests, there is no functional change because they already only appended options to IMGOPTS. For these, this patch is just a simplification.
For others, this is a change, so they now heed user-specified $IMGOPTS. Some of those tests do not work with all image options, though, so we need to disable them accordingly.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/031 | 9 ++++--- tests/qemu-iotests/039 | 24 ++++++------------ tests/qemu-iotests/059 | 18 ++++++------- tests/qemu-iotests/060 | 6 ++--- tests/qemu-iotests/061 | 57 ++++++++++++++++++++++-------------------- tests/qemu-iotests/079 | 3 +-- tests/qemu-iotests/106 | 2 +- tests/qemu-iotests/108 | 2 +- tests/qemu-iotests/112 | 32 ++++++++++++------------ tests/qemu-iotests/115 | 3 +-- tests/qemu-iotests/121 | 6 ++--- tests/qemu-iotests/125 | 2 +- tests/qemu-iotests/137 | 2 +- tests/qemu-iotests/138 | 3 +-- tests/qemu-iotests/175 | 2 +- tests/qemu-iotests/190 | 2 +- tests/qemu-iotests/191 | 3 +-- tests/qemu-iotests/220 | 4 ++- tests/qemu-iotests/243 | 6 +++-- tests/qemu-iotests/244 | 10 +++++--- tests/qemu-iotests/250 | 3 +-- tests/qemu-iotests/265 | 2 +- 22 files changed, 100 insertions(+), 101 deletions(-)tests/qemu-iotests/031 +0
-0
tests/qemu-iotests/031 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 45
Quoted 6 lines
tests/qemu-iotests/031 +3
-0@@ -40,19 +40,22 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 _supported_proto file +# We want to test compat=0.10, which does not support refcount widths +# other than 16 +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)'
OK
Quoted 24 lines
tests/qemu-iotests/031 +3
-3CLUSTER_SIZE=65536 # qcow2.py output depends on the exact options used, so override the command # line here as an exception -for IMGOPTS in "compat=0.10" "compat=1.1"; do +for compat in "compat=0.10" "compat=1.1"; do echo - echo ===== Testing with -o $IMGOPTS ===== + echo ===== Testing with -o $compat ===== echo echo === Create image with unknown header extension === echo - _make_test_img 64M + _make_test_img -o $compat 64M $PYTHON qcow2.py "$TEST_IMG" add-header-ext 0x12345678 "This is a test header extension" $PYTHON qcow2.py "$TEST_IMG" dump-header _check_test_imgtests/qemu-iotests/039 +0
-0
tests/qemu-iotests/039 size=128M · line 53
Quoted 6 lines
tests/qemu-iotests/039 +1
-2@@ -50,8 +50,7 @@ size=128M echo echo "== Checking that image is clean on shutdown ==" -IMGOPTS="compat=1.1,lazy_refcounts=on" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=on" $size
Any reason for compat=1.1 here? Other that it was before like that.
Quoted 782 lines
tests/qemu-iotests/039 +7
-14$QEMU_IO -c "write -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io@@ -62,8 +61,7 @@ _check_test_img echo echo "== Creating a dirty image file ==" -IMGOPTS="compat=1.1,lazy_refcounts=on" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=on" $size _NO_VALGRIND \ $QEMU_IO -c "write -P 0x5a 0 512" \@@ -98,8 +96,7 @@ $QEMU_IO -c "read -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io echo echo "== Opening a dirty image read/write should repair it ==" -IMGOPTS="compat=1.1,lazy_refcounts=on" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=on" $size _NO_VALGRIND \ $QEMU_IO -c "write -P 0x5a 0 512" \@@ -117,8 +114,7 @@ $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features echo echo "== Creating an image file with lazy_refcounts=off ==" -IMGOPTS="compat=1.1,lazy_refcounts=off" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=off" $size _NO_VALGRIND \ $QEMU_IO -c "write -P 0x5a 0 512" \@@ -132,11 +128,9 @@ _check_test_img echo echo "== Committing to a backing file with lazy_refcounts=on ==" -IMGOPTS="compat=1.1,lazy_refcounts=on" -TEST_IMG="$TEST_IMG".base _make_test_img $size +TEST_IMG="$TEST_IMG".base _make_test_img -o "compat=1.1,lazy_refcounts=on" $size -IMGOPTS="compat=1.1,lazy_refcounts=on,backing_file=$TEST_IMG.base" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=on,backing_file=$TEST_IMG.base" $size $QEMU_IO -c "write 0 512" "$TEST_IMG" | _filter_qemu_io $QEMU_IMG commit "$TEST_IMG"@@ -151,8 +145,7 @@ TEST_IMG="$TEST_IMG".base _check_test_img echo echo "== Changing lazy_refcounts setting at runtime ==" -IMGOPTS="compat=1.1,lazy_refcounts=off" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=off" $size _NO_VALGRIND \ $QEMU_IO -c "reopen -o lazy-refcounts=on" \@@ -164,8 +157,7 @@ $QEMU_IO -c "reopen -o lazy-refcounts=on" \ $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features _check_test_img -IMGOPTS="compat=1.1,lazy_refcounts=on" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=on" $size _NO_VALGRIND \ $QEMU_IO -c "reopen -o lazy-refcounts=off" \tests/qemu-iotests/059 +9
-9@@ -70,18 +70,18 @@ poke_file "$TEST_IMG" "$grain_table_size_offset" "\x01\x00\x00\x00" echo echo "=== Testing monolithicFlat creation and opening ===" -IMGOPTS="subformat=monolithicFlat" _make_test_img 2G +_make_test_img -o "subformat=monolithicFlat" 2G _img_info _cleanup_test_img echo echo "=== Testing monolithicFlat with zeroed_grain ===" -IMGOPTS="subformat=monolithicFlat,zeroed_grain=on" _make_test_img 2G +_make_test_img -o "subformat=monolithicFlat,zeroed_grain=on" 2G _cleanup_test_img echo echo "=== Testing big twoGbMaxExtentFlat ===" -IMGOPTS="subformat=twoGbMaxExtentFlat" _make_test_img 1000G +_make_test_img -o "subformat=twoGbMaxExtentFlat" 1000G $QEMU_IMG info $TEST_IMG | _filter_testdir | sed -e 's/cid: [0-9]*/cid: XXXXXXXX/' _cleanup_test_img@@ -101,13 +101,13 @@ _img_info echo echo "=== Testing truncated sparse ===" -IMGOPTS="subformat=monolithicSparse" _make_test_img 100G +_make_test_img -o "subformat=monolithicSparse" 100G truncate -s 10M $TEST_IMG _img_info echo echo "=== Converting to streamOptimized from image with small cluster size===" -TEST_IMG="$TEST_IMG.qcow2" IMGFMT=qcow2 IMGOPTS="cluster_size=4096" _make_test_img 1G +TEST_IMG="$TEST_IMG.qcow2" IMGFMT=qcow2 _make_test_img -o "cluster_size=4096" 1G $QEMU_IO -f qcow2 -c "write -P 0xa 0 512" "$TEST_IMG.qcow2" | _filter_qemu_io $QEMU_IO -f qcow2 -c "write -P 0xb 10240 512" "$TEST_IMG.qcow2" | _filter_qemu_io $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2" "$TEST_IMG" 2>&1@@ -117,7 +117,7 @@ echo "=== Testing monolithicFlat with internally generated JSON file name ===" echo '--- blkdebug ---' # Should work, because bdrv_dirname() works fine with blkdebug -IMGOPTS="subformat=monolithicFlat" _make_test_img 64M +_make_test_img -o "subformat=monolithicFlat" 64M $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \ -c info \ 2>&1 \@@ -126,7 +126,7 @@ _cleanup_test_img echo '--- quorum ---' # Should not work, because bdrv_dirname() does not work with quorum -IMGOPTS="subformat=monolithicFlat" _make_test_img 64M +_make_test_img -o "subformat=monolithicFlat" 64M cp "$TEST_IMG" "$TEST_IMG.orig" filename="json:{@@ -161,7 +161,7 @@ _cleanup_test_img echo echo "=== Testing 4TB monolithicFlat creation and IO ===" -IMGOPTS="subformat=monolithicFlat" _make_test_img 4T +_make_test_img -o "subformat=monolithicFlat" 4T _img_info $QEMU_IO -c "write -P 0xa 900G 512" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "read -v 900G 1024" "$TEST_IMG" | _filter_qemu_io@@ -170,7 +170,7 @@ _cleanup_test_img echo echo "=== Testing qemu-img map on extents ===" for fmt in monolithicSparse twoGbMaxExtentSparse; do - IMGOPTS="subformat=$fmt" _make_test_img 31G + _make_test_img -o "subformat=$fmt" 31G $QEMU_IO -c "write 65024 1k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "write 2147483136 1k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "write 5G 1k" "$TEST_IMG" | _filter_qemu_iotests/qemu-iotests/060 +3
-3@@ -158,7 +158,7 @@ $QEMU_IO -c 'write 0k 64k' "$BACKING_IMG" | _filter_qemu_io # compat=0.10 is required in order to make the following discard actually # unallocate the sector rather than make it a zero sector - we want COW, after # all. -IMGOPTS='compat=0.10' _make_test_img -b "$BACKING_IMG" 1G +_make_test_img -o 'compat=0.10' -b "$BACKING_IMG" 1G # Write two clusters, the second one enforces creation of an L2 table after # the first data cluster. $QEMU_IO -c 'write 0k 64k' -c 'write 512M 64k' "$TEST_IMG" | _filter_qemu_io@@ -398,7 +398,7 @@ echo echo "=== Discarding a non-covered in-bounds refblock ===" echo -IMGOPTS='refcount_bits=1' _make_test_img 64M +_make_test_img -o 'refcount_bits=1' 64M # Pretend there's a refblock somewhere where there is no refblock to # cover it (but the covering refblock has a valid index in the@@ -422,7 +422,7 @@ echo echo "=== Discarding a refblock covered by an unaligned refblock ===" echo -IMGOPTS='refcount_bits=1' _make_test_img 64M +_make_test_img -o 'refcount_bits=1' 64M # Same as above poke_file "$TEST_IMG" "$(($rt_offset+8))" "\x00\x00\x00\x10\x00\x00\x00\x00"tests/qemu-iotests/061 +30
-27@@ -41,11 +41,14 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux +# Conversion between different compat versions can only really work +# with refcount_bits=16 +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' echo echo "=== Testing version downgrade with zero expansion ===" echo -IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M +_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io $PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"@@ -56,7 +59,7 @@ _check_test_img echo echo "=== Testing version downgrade with zero expansion and 4K cache entries ===" echo -IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M +_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "write -z 32M 128k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io@@ -72,7 +75,7 @@ _check_test_img echo echo "=== Testing dirty version downgrade ===" echo -IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M +_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M _NO_VALGRIND \ $QEMU_IO -c "write -P 0x2a 0 128k" -c flush \ -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io@@ -85,7 +88,7 @@ _check_test_img echo echo "=== Testing version downgrade with unknown compat/autoclear flags ===" echo -IMGOPTS="compat=1.1" _make_test_img 64M +_make_test_img -o "compat=1.1" 64M $PYTHON qcow2.py "$TEST_IMG" set-feature-bit compatible 42 $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 42 $PYTHON qcow2.py "$TEST_IMG" dump-header@@ -96,7 +99,7 @@ _check_test_img echo echo "=== Testing version upgrade and resize ===" echo -IMGOPTS="compat=0.10" _make_test_img 64M +_make_test_img -o "compat=0.10" 64M $QEMU_IO -c "write -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io $PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "compat=1.1,lazy_refcounts=on,size=128M" "$TEST_IMG"@@ -107,7 +110,7 @@ _check_test_img echo echo "=== Testing dirty lazy_refcounts=off ===" echo -IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M +_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M _NO_VALGRIND \ $QEMU_IO -c "write -P 0x2a 0 128k" -c flush \ -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io@@ -120,8 +123,8 @@ _check_test_img echo echo "=== Testing backing file ===" echo -IMGOPTS="compat=1.1" _make_test_img 64M -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 64M +_make_test_img -o "compat=1.1" 64M +TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io $QEMU_IMG amend -o "backing_file=$TEST_IMG.base,backing_fmt=qcow2" "$TEST_IMG"@@ -131,7 +134,7 @@ _check_test_img echo echo "=== Testing invalid configurations ===" echo -IMGOPTS="compat=0.10" _make_test_img 64M +_make_test_img -o "compat=0.10" 64M $QEMU_IMG amend -o "lazy_refcounts=on" "$TEST_IMG" $QEMU_IMG amend -o "compat=1.1" "$TEST_IMG" # actually valid $QEMU_IMG amend -o "compat=0.10,lazy_refcounts=on" "$TEST_IMG"@@ -144,7 +147,7 @@ $QEMU_IMG amend -o "preallocation=on" "$TEST_IMG" echo echo "=== Testing correct handling of unset value ===" echo -IMGOPTS="compat=1.1,cluster_size=1k" _make_test_img 64M +_make_test_img -o "compat=1.1,cluster_size=1k" 64M echo "Should work:" $QEMU_IMG amend -o "lazy_refcounts=on" "$TEST_IMG" echo "Should not work:" # Just to know which of these tests actually fails@@ -153,7 +156,7 @@ $QEMU_IMG amend -o "cluster_size=64k" "$TEST_IMG" echo echo "=== Testing zero expansion on inactive clusters ===" echo -IMGOPTS="compat=1.1" _make_test_img 64M +_make_test_img -o "compat=1.1" 64M $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io $QEMU_IMG snapshot -c foo "$TEST_IMG" $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io@@ -167,7 +170,7 @@ $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io echo echo "=== Testing zero expansion on shared L2 table ===" echo -IMGOPTS="compat=1.1" _make_test_img 64M +_make_test_img -o "compat=1.1" 64M $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io $QEMU_IMG snapshot -c foo "$TEST_IMG" $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"@@ -180,9 +183,9 @@ $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io echo echo "=== Testing zero expansion on backed image ===" echo -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 64M +TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io -IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 64M +_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 64M $QEMU_IO -c "read -P 0x2a 0 128k" -c "write -z 0 64k" "$TEST_IMG" | _filter_qemu_io $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" _check_test_img@@ -191,9 +194,9 @@ $QEMU_IO -c "read -P 0 0 64k" -c "read -P 0x2a 64k 64k" "$TEST_IMG" | _filter_qe echo echo "=== Testing zero expansion on backed inactive clusters ===" echo -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 64M +TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io -IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 64M +_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 64M $QEMU_IO -c "write -z 0 64k" "$TEST_IMG" | _filter_qemu_io $QEMU_IMG snapshot -c foo "$TEST_IMG" $QEMU_IO -c "write -P 0x42 0 128k" "$TEST_IMG" | _filter_qemu_io@@ -207,9 +210,9 @@ $QEMU_IO -c "read -P 0 0 64k" -c "read -P 0x2a 64k 64k" "$TEST_IMG" | _filter_qe echo echo "=== Testing zero expansion on backed image with shared L2 table ===" echo -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 64M +TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io -IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 64M +_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 64M $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io $QEMU_IMG snapshot -c foo "$TEST_IMG" $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"@@ -222,7 +225,7 @@ $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io echo echo "=== Testing preallocated zero expansion on full image ===" echo -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG" _make_test_img 64M +TEST_IMG="$TEST_IMG" _make_test_img -o "compat=1.1" 64M $QEMU_IO -c "write -P 0x2a 0 64M" "$TEST_IMG" -c "write -z 0 64M" | _filter_qemu_io $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" _check_test_img@@ -231,8 +234,8 @@ $QEMU_IO -c "read -P 0 0 64M" "$TEST_IMG" | _filter_qemu_io echo echo "=== Testing progress report without snapshot ===" echo -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 4G -IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 4G +TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 4G +_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 4G $QEMU_IO -c "write -z 0 64k" \ -c "write -z 1G 64k" \ -c "write -z 2G 64k" \@@ -243,8 +246,8 @@ _check_test_img echo echo "=== Testing progress report with snapshot ===" echo -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 4G -IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 4G +TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 4G +_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 4G $QEMU_IO -c "write -z 0 64k" \ -c "write -z 1G 64k" \ -c "write -z 2G 64k" \@@ -256,7 +259,7 @@ _check_test_img echo echo "=== Testing version downgrade with external data file ===" echo -IMGOPTS="compat=1.1,data_file=$TEST_IMG.data" _make_test_img 64M +_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data" 64M $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" _img_info --format-specific _check_test_img@@ -264,11 +267,11 @@ _check_test_img echo echo "=== Try changing the external data file ===" echo -IMGOPTS="compat=1.1" _make_test_img 64M +_make_test_img -o "compat=1.1" 64M $QEMU_IMG amend -o "data_file=foo" "$TEST_IMG" echo -IMGOPTS="compat=1.1,data_file=$TEST_IMG.data" _make_test_img 64M +_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data" 64M $QEMU_IMG amend -o "data_file=foo" "$TEST_IMG" _img_info --format-specific TEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info --format-specific --image-opts@@ -281,7 +284,7 @@ TEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info - echo echo "=== Clearing and setting data-file-raw ===" echo -IMGOPTS="compat=1.1,data_file=$TEST_IMG.data,data_file_raw=on" _make_test_img 64M +_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data,data_file_raw=on" 64M $QEMU_IMG amend -o "data_file_raw=on" "$TEST_IMG" _img_info --format-specific _check_test_imgtests/qemu-iotests/079 +1
-2@@ -44,8 +44,7 @@ echo cluster_sizes="16384 32768 65536 131072 262144 524288 1048576 2097152 4194304" for s in $cluster_sizes; do - IMGOPTS=$(_optstr_add "$IMGOPTS" "preallocation=metadata,cluster_size=$s") \ - _make_test_img 4G + _make_test_img -o "preallocation=metadata,cluster_size=$s" 4G done # success, all donetests/qemu-iotests/106 +1
-1@@ -51,7 +51,7 @@ for create_mode in off falloc full; do echo echo "--- create_mode=$create_mode growth_mode=$growth_mode ---" - IMGOPTS="preallocation=$create_mode" _make_test_img ${CREATION_SIZE}K + _make_test_img -o "preallocation=$create_mode" ${CREATION_SIZE}K $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K expected_size=0tests/qemu-iotests/108 +1
-1@@ -65,7 +65,7 @@ echo echo '=== Repairing unreferenced data cluster in new refblock area ===' echo -IMGOPTS='cluster_size=512' _make_test_img 64M +_make_test_img -o 'cluster_size=512' 64M # Allocate the first 128 kB in the image (first refblock) $QEMU_IO -c 'write 0 0x1b200' "$TEST_IMG" | _filter_qemu_io # should be 131072 == 0x20000tests/qemu-iotests/112 +16
-16@@ -53,20 +53,20 @@ echo '=== refcount_bits limits ===' echo # Must be positive (non-zero) -IMGOPTS="$IMGOPTS,refcount_bits=0" _make_test_img 64M +_make_test_img -o "refcount_bits=0" 64M # Must be positive (non-negative) -IMGOPTS="$IMGOPTS,refcount_bits=-1" _make_test_img 64M +_make_test_img -o "refcount_bits=-1" 64M # May not exceed 64 -IMGOPTS="$IMGOPTS,refcount_bits=128" _make_test_img 64M +_make_test_img -o "refcount_bits=128" 64M # Must be a power of two -IMGOPTS="$IMGOPTS,refcount_bits=42" _make_test_img 64M +_make_test_img -o "refcount_bits=42" 64M # 1 is the minimum -IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M +_make_test_img -o "refcount_bits=1" 64M print_refcount_bits # 64 is the maximum -IMGOPTS="$IMGOPTS,refcount_bits=64" _make_test_img 64M +_make_test_img -o "refcount_bits=64" 64M print_refcount_bits # 16 is the default@@ -78,19 +78,19 @@ echo '=== refcount_bits and compat=0.10 ===' echo # Should work -IMGOPTS="$IMGOPTS,compat=0.10,refcount_bits=16" _make_test_img 64M +_make_test_img -o "compat=0.10,refcount_bits=16" 64M print_refcount_bits # Should not work -IMGOPTS="$IMGOPTS,compat=0.10,refcount_bits=1" _make_test_img 64M -IMGOPTS="$IMGOPTS,compat=0.10,refcount_bits=64" _make_test_img 64M +_make_test_img -o "compat=0.10,refcount_bits=1" 64M +_make_test_img -o "compat=0.10,refcount_bits=64" 64M echo echo '=== Snapshot limit on refcount_bits=1 ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M +_make_test_img -o "refcount_bits=1" 64M print_refcount_bits $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io@@ -106,7 +106,7 @@ echo echo '=== Snapshot limit on refcount_bits=2 ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=2" _make_test_img 64M +_make_test_img -o "refcount_bits=2" 64M print_refcount_bits $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io@@ -124,7 +124,7 @@ echo echo '=== Compressed clusters with refcount_bits=1 ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M +_make_test_img -o "refcount_bits=1" 64M print_refcount_bits # Both should fit into a single host cluster; instead of failing to increase the@@ -140,7 +140,7 @@ echo echo '=== MSb set in 64 bit refcount ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=64" _make_test_img 64M +_make_test_img -o "refcount_bits=64" 64M print_refcount_bits $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io@@ -158,7 +158,7 @@ echo echo '=== Snapshot on maximum 64 bit refcount value ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=64" _make_test_img 64M +_make_test_img -o "refcount_bits=64" 64M print_refcount_bits $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io@@ -239,7 +239,7 @@ echo echo '=== Testing too many references for check ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M +_make_test_img -o "refcount_bits=1" 64M print_refcount_bits # This cluster should be created at 0x50000@@ -262,7 +262,7 @@ echo echo '=== Multiple walks necessary during amend ===' echo -IMGOPTS="$IMGOPTS,refcount_bits=1,cluster_size=512" _make_test_img 64k +_make_test_img -o "refcount_bits=1,cluster_size=512" 64k # Cluster 0 is the image header, clusters 1 to 4 are used by the L1 table, a # single L2 table, the reftable and a single refblock. This creates 58 datatests/qemu-iotests/115 +1
-2@@ -64,8 +64,7 @@ echo # least 256 MB. We can achieve that by using preallocation=metadata for an image # which has a guest disk size of 256 MB. -IMGOPTS="$IMGOPTS,refcount_bits=64,cluster_size=512,preallocation=metadata" \ - _make_test_img 256M +_make_test_img -o "refcount_bits=64,cluster_size=512,preallocation=metadata" 256M # We know for sure that the L1 and refcount tables do not overlap with any other # structure because the metadata overlap checks would have caught that case.tests/qemu-iotests/121 +3
-3@@ -50,7 +50,7 @@ echo # Preallocation speeds up the write operation, but preallocating everything will # destroy the purpose of the write; so preallocate one KB less than what would # cause a reftable growth... -IMGOPTS='preallocation=metadata,cluster_size=1k' _make_test_img 64512K +_make_test_img -o 'preallocation=metadata,cluster_size=1k' 64512K # ...and make the image the desired size afterwards. $QEMU_IMG resize "$TEST_IMG" 65M@@ -73,7 +73,7 @@ echo echo '--- Test 2 ---' echo -IMGOPTS='preallocation=metadata,cluster_size=1k' _make_test_img 64513K +_make_test_img -o 'preallocation=metadata,cluster_size=1k' 64513K # This results in an L1 table growth which in turn results in some clusters at # the start of the image becoming free $QEMU_IMG resize "$TEST_IMG" 65M@@ -96,7 +96,7 @@ echo echo '=== Allocating a new refcount block must not leave holes in the image ===' echo -IMGOPTS='cluster_size=512,refcount_bits=16' _make_test_img 1M +_make_test_img -o 'cluster_size=512,refcount_bits=16' 1M # This results in an image with 256 used clusters: the qcow2 header, # the refcount table, one refcount block, the L1 table, four L2 tablestests/qemu-iotests/125 +1
-1@@ -114,7 +114,7 @@ for GROWTH_SIZE in 16 48 80; do for growth_mode in off metadata falloc full; do echo "--- cluster_size=$cluster_size growth_size=$GROWTH_SIZE create_mode=$create_mode growth_mode=$growth_mode ---" - IMGOPTS="preallocation=$create_mode,cluster_size=$cluster_size" _make_test_img ${CREATION_SIZE} + _make_test_img -o "preallocation=$create_mode,cluster_size=$cluster_size" ${CREATION_SIZE} $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K host_size_0=$(get_image_size_on_host)tests/qemu-iotests/137 +1
-1@@ -117,7 +117,7 @@ $QEMU_IO \ -c "reopen -o cache-clean-interval=-1" \ "$TEST_IMG" | _filter_qemu_io -IMGOPTS="cluster_size=256k" _make_test_img 32P +_make_test_img -o "cluster_size=256k" 32P $QEMU_IO \ -c "reopen -o l2-cache-entry-size=512,l2-cache-size=1T" \ "$TEST_IMG" | _filter_qemu_iotests/qemu-iotests/138 +1
-2@@ -45,8 +45,7 @@ echo echo '=== Check on an image with a multiple of 2^32 clusters ===' echo -IMGOPTS=$(_optstr_add "$IMGOPTS" "cluster_size=512") \ - _make_test_img 512 +_make_test_img -o "cluster_size=512" 512 # Allocate L2 table $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_iotests/qemu-iotests/175 +1
-1@@ -95,7 +95,7 @@ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_block for mode in off full falloc; do echo echo "== creating image with preallocation $mode ==" - IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt + _make_test_img -o preallocation=$mode $size | _filter_imgfmt stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size donetests/qemu-iotests/190 +1
-1@@ -45,7 +45,7 @@ _supported_proto file echo "== Huge file ==" echo -IMGOPTS='cluster_size=2M' _make_test_img 2T +_make_test_img -o 'cluster_size=2M' 2T $QEMU_IMG measure -O raw -f qcow2 "$TEST_IMG" $QEMU_IMG measure -O qcow2 -o cluster_size=64k -f qcow2 "$TEST_IMG"tests/qemu-iotests/191 +1
-2@@ -51,8 +51,7 @@ echo === Preparing and starting VM === echo TEST_IMG="${TEST_IMG}.base" _make_test_img $size -IMGOPTS=$(_optstr_add "$IMGOPTS" "backing_fmt=$IMGFMT") \ - TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base" +TEST_IMG="${TEST_IMG}.mid" _make_test_img -o "backing_fmt=$IMGFMT" -b "${TEST_IMG}.base" _make_test_img -b "${TEST_IMG}.mid" TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid"tests/qemu-iotests/220 +3
-1@@ -37,6 +37,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux +# To use a different refcount width but 16 bits we need compat=1.1 +_unsupported_imgopts 'compat=0.10' echo "== Creating huge file =="@@ -46,7 +48,7 @@ if ! truncate --size=513T "$TEST_IMG"; then _notrun "file system on $TEST_DIR does not support large enough files" fi rm "$TEST_IMG" -IMGOPTS='cluster_size=2M,refcount_bits=1' _make_test_img 513T +_make_test_img -o 'cluster_size=2M,refcount_bits=1' 513T echo "== Populating refcounts ==" # We want an image with 256M refcounts * 2M clusters = 512T referenced.tests/qemu-iotests/243 +4
-2@@ -40,6 +40,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux +# External data files do not work with compat=0.10 +_unsupported_imgopts 'compat=0.10' for mode in off metadata falloc full; do@@ -47,7 +49,7 @@ for mode in off metadata falloc full; do echo "=== preallocation=$mode ===" echo - IMGOPTS="preallocation=$mode" _make_test_img 64M + _make_test_img -o "preallocation=$mode" 64M printf "File size: " du -b $TEST_IMG | cut -f1@@ -64,7 +66,7 @@ for mode in off metadata falloc full; do echo "=== External data file: preallocation=$mode ===" echo - IMGOPTS="data_file=$TEST_IMG.data,preallocation=$mode" _make_test_img 64M + _make_test_img -o "data_file=$TEST_IMG.data,preallocation=$mode" 64M echo -n "qcow2 file size: " du -b $TEST_IMG | cut -f1tests/qemu-iotests/244 +6
-4@@ -41,13 +41,15 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux +# External data files do not work with compat=0.10 +_unsupported_imgopts 'compat=0.10' echo echo "=== Create and open image with external data file ===" echo echo "With data file name in the image:" -IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M +_make_test_img -o "data_file=$TEST_IMG.data" 64M _check_test_img $QEMU_IO -c "open $TEST_IMG" -c "read -P 0 0 64k" 2>&1 | _filter_qemu_io | _filter_testdir@@ -104,7 +106,7 @@ echo echo "=== Standalone image with external data file (efficient) ===" echo -IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M +_make_test_img -o "data_file=$TEST_IMG.data" 64M echo -n "qcow2 file size before I/O: " du -b $TEST_IMG | cut -f1@@ -154,7 +156,7 @@ echo echo "=== Standalone image with external data file (valid raw) ===" echo -IMGOPTS="data_file=$TEST_IMG.data,data_file_raw=on" _make_test_img 64M +_make_test_img -o "data_file=$TEST_IMG.data,data_file_raw=on" 64M echo -n "qcow2 file size before I/O: " du -b $TEST_IMG | cut -f1@@ -187,7 +189,7 @@ echo echo "=== bdrv_co_block_status test for file and offset=0 ===" echo -IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M +_make_test_img -o "data_file=$TEST_IMG.data" 64M $QEMU_IO -c 'write -P 0x11 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c 'read -P 0x11 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_iotests/qemu-iotests/250 +1
-2@@ -55,9 +55,8 @@ disk_usage() } size=2100M -IMGOPTS="cluster_size=1M,preallocation=metadata" -_make_test_img $size +_make_test_img -o "cluster_size=1M,preallocation=metadata" $size $QEMU_IO -c 'discard 0 10M' -c 'discard 2090M 10M' \ -c 'write 2090M 10M' -c 'write 0 10M' "$TEST_IMG" | _filter_qemu_iotests/qemu-iotests/265 +0
-0
tests/qemu-iotests/265 _supported_os Linux · line 47
Quoted 8 lines
tests/qemu-iotests/265 +1
-1@@ -41,7 +41,7 @@ _supported_os Linux echo '--- Writing to the image ---' # Reduce cluster size so we get more and quicker I/O -IMGOPTS='cluster_size=4096' _make_test_img 1M +_make_test_img -o 'cluster_size=4096' 1M (for ((kb = 1024 - 4; kb >= 0; kb -= 4)); do \ echo "aio_write -P 42 $((kb + 1))k 2k"; \ done) \
Looks all right, but the patch is large, and I might have missed something. I don't know the iotests well enough to be sure.
Best regards,
Maxim Levitsky
Re: [PATCH 07/18] iotests: Replace IMGOPTS= by -o
Quoted 38 lines · Maxim Levitsky
Quoted 37 lines · Max Reitz
Tests should not overwrite all user-supplied image options, but only add to it (which will effectively overwrite conflicting values). Accomplish this by passing options to
_make_test_imgvia -o instead of $IMGOPTS.For some tests, there is no functional change because they already only appended options to IMGOPTS. For these, this patch is just a simplification.
For others, this is a change, so they now heed user-specified $IMGOPTS. Some of those tests do not work with all image options, though, so we need to disable them accordingly.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/031 | 9 ++++--- tests/qemu-iotests/039 | 24 ++++++------------ tests/qemu-iotests/059 | 18 ++++++------- tests/qemu-iotests/060 | 6 ++--- tests/qemu-iotests/061 | 57 ++++++++++++++++++++++-------------------- tests/qemu-iotests/079 | 3 +-- tests/qemu-iotests/106 | 2 +- tests/qemu-iotests/108 | 2 +- tests/qemu-iotests/112 | 32 ++++++++++++------------ tests/qemu-iotests/115 | 3 +-- tests/qemu-iotests/121 | 6 ++--- tests/qemu-iotests/125 | 2 +- tests/qemu-iotests/137 | 2 +- tests/qemu-iotests/138 | 3 +-- tests/qemu-iotests/175 | 2 +- tests/qemu-iotests/190 | 2 +- tests/qemu-iotests/191 | 3 +-- tests/qemu-iotests/220 | 4 ++- tests/qemu-iotests/243 | 6 +++-- tests/qemu-iotests/244 | 10 +++++--- tests/qemu-iotests/250 | 3 +-- tests/qemu-iotests/265 | 2 +- 22 files changed, 100 insertions(+), 101 deletions(-)
[...]
Quoted 8 lines
Quoted 8 lines
tests/qemu-iotests/039 +0
-0@@ -50,8 +50,7 @@ size=128M echo echo "== Checking that image is clean on shutdown =="
Quoted 4 lines
tests/qemu-iotests/039 size=128M · line 53
Quoted 3 lines
tests/qemu-iotests/039 +1
-2-IMGOPTS="compat=1.1,lazy_refcounts=on" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=on" $sizeAny reason for compat=1.1 here? Other that it was before like that.
Lazy refcounts only work with qcow2 v3 (compat=1.1).
Max
Re: [PATCH 07/18] iotests: Replace IMGOPTS= by -o
Quoted 50 lines · Max Reitz
Quoted 38 lines · Maxim Levitsky
Quoted 37 lines · Max Reitz
Tests should not overwrite all user-supplied image options, but only add to it (which will effectively overwrite conflicting values). Accomplish this by passing options to
_make_test_imgvia -o instead of $IMGOPTS.For some tests, there is no functional change because they already only appended options to IMGOPTS. For these, this patch is just a simplification.
For others, this is a change, so they now heed user-specified $IMGOPTS. Some of those tests do not work with all image options, though, so we need to disable them accordingly.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/031 | 9 ++++--- tests/qemu-iotests/039 | 24 ++++++------------ tests/qemu-iotests/059 | 18 ++++++------- tests/qemu-iotests/060 | 6 ++--- tests/qemu-iotests/061 | 57 ++++++++++++++++++++++-------------------- tests/qemu-iotests/079 | 3 +-- tests/qemu-iotests/106 | 2 +- tests/qemu-iotests/108 | 2 +- tests/qemu-iotests/112 | 32 ++++++++++++------------ tests/qemu-iotests/115 | 3 +-- tests/qemu-iotests/121 | 6 ++--- tests/qemu-iotests/125 | 2 +- tests/qemu-iotests/137 | 2 +- tests/qemu-iotests/138 | 3 +-- tests/qemu-iotests/175 | 2 +- tests/qemu-iotests/190 | 2 +- tests/qemu-iotests/191 | 3 +-- tests/qemu-iotests/220 | 4 ++- tests/qemu-iotests/243 | 6 +++-- tests/qemu-iotests/244 | 10 +++++--- tests/qemu-iotests/250 | 3 +-- tests/qemu-iotests/265 | 2 +- 22 files changed, 100 insertions(+), 101 deletions(-)[...]
Quoted 8 lines
Quoted 8 lines
tests/qemu-iotests/039 +0
-0@@ -50,8 +50,7 @@ size=128M echo echo "== Checking that image is clean on shutdown =="
Quoted 7 lines
Quoted 5 lines
tests/qemu-iotests/039 size=128M · line 53
Quoted 3 lines
tests/qemu-iotests/039 +1
-2-IMGOPTS="compat=1.1,lazy_refcounts=on" -_make_test_img $size +_make_test_img -o "compat=1.1,lazy_refcounts=on" $sizeAny reason for compat=1.1 here? Other that it was before like that.
Lazy refcounts only work with qcow2 v3 (compat=1.1).
Agree, sorry for not noticing this.
Best regards,
Maxim Levitsky
Quoted 3 lines
Max
PATCH 8/18 iotests: Replace IMGOPTS='' by --no-opts
In reply to Max Reitz--- tests/qemu-iotests/071 | 4 ++-- tests/qemu-iotests/174 | 2 +- tests/qemu-iotests/178 | 4 ++-- tests/qemu-iotests/197 | 4 ++-- tests/qemu-iotests/215 | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-)
tests/qemu-iotests/071 +2 -2
@@ -58,7 +58,7 @@ echo echo "=== Testing blkverify through filename ===" echo -TEST_IMG="$TEST_IMG.base" IMGOPTS="" IMGFMT="raw" _make_test_img $IMG_SIZE |\ +TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\ _filter_imgfmt _make_test_img $IMG_SIZE $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
@@ -73,7 +73,7 @@ echo echo "=== Testing blkverify through file blockref ===" echo -TEST_IMG="$TEST_IMG.base" IMGOPTS="" IMGFMT="raw" _make_test_img $IMG_SIZE |\ +TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\ _filter_imgfmt _make_test_img $IMG_SIZE $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base,file.test.driver=$IMGFMT,file.test.file.filename=$TEST_IMG" \
tests/qemu-iotests/174 +1 -1
@@ -40,7 +40,7 @@ _unsupported_fmt raw size=256K -IMGFMT=raw IMGKEYSECRET= IMGOPTS= _make_test_img $size | _filter_imgfmt +IMGFMT=raw IMGKEYSECRET= _make_test_img --no-opts $size | _filter_imgfmt echo echo "== reading wrong format should fail =="
tests/qemu-iotests/178 +2 -2
@@ -62,8 +62,8 @@ $QEMU_IMG measure -O foo "$TEST_IMG" # unknown image file format make_test_img_with_fmt() { # Shadow global variables within this function - local IMGFMT="$1" IMGOPTS="" - _make_test_img "$2" + local IMGFMT="$1" + _make_test_img --no-opts "$2" } qemu_io_with_fmt() {
tests/qemu-iotests/197 +2 -2
@@ -66,8 +66,8 @@ if [ "$IMGFMT" = "vpc" ]; then fi _make_test_img 4G $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io -IMGPROTO=file IMGFMT=qcow2 IMGOPTS= TEST_IMG_FILE="$TEST_WRAP" \ - _make_test_img -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create +IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \ + _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io # Ensure that a read of two clusters, but where one is already allocated,
tests/qemu-iotests/215 +2 -2
@@ -63,8 +63,8 @@ if [ "$IMGFMT" = "vpc" ]; then fi _make_test_img 4G $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io -IMGPROTO=file IMGFMT=qcow2 IMGOPTS= TEST_IMG_FILE="$TEST_WRAP" \ - _make_test_img -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create +IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \ + _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io # Ensure that a read of two clusters, but where one is already allocated,
Signature · 1 line
2.21.0
Re: [PATCH 08/18] iotests: Replace IMGOPTS='' by --no-opts
Quoted 79 lines · Max Reitz
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/071 | 4 ++-- tests/qemu-iotests/174 | 2 +- tests/qemu-iotests/178 | 4 ++-- tests/qemu-iotests/197 | 4 ++-- tests/qemu-iotests/215 | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-)tests/qemu-iotests/071 +2
-2@@ -58,7 +58,7 @@ echo echo "=== Testing blkverify through filename ===" echo -TEST_IMG="$TEST_IMG.base" IMGOPTS="" IMGFMT="raw" _make_test_img $IMG_SIZE |\ +TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\ _filter_imgfmt _make_test_img $IMG_SIZE $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \@@ -73,7 +73,7 @@ echo echo "=== Testing blkverify through file blockref ===" echo -TEST_IMG="$TEST_IMG.base" IMGOPTS="" IMGFMT="raw" _make_test_img $IMG_SIZE |\ +TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\ _filter_imgfmt _make_test_img $IMG_SIZE $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base,file.test.driver=$IMGFMT,file.test.file.filename=$TEST_IMG" \tests/qemu-iotests/174 +1
-1@@ -40,7 +40,7 @@ _unsupported_fmt raw size=256K -IMGFMT=raw IMGKEYSECRET= IMGOPTS= _make_test_img $size | _filter_imgfmt +IMGFMT=raw IMGKEYSECRET= _make_test_img --no-opts $size | _filter_imgfmt echo echo "== reading wrong format should fail =="tests/qemu-iotests/178 +2
-2@@ -62,8 +62,8 @@ $QEMU_IMG measure -O foo "$TEST_IMG" # unknown image file format make_test_img_with_fmt() { # Shadow global variables within this function - local IMGFMT="$1" IMGOPTS="" - _make_test_img "$2" + local IMGFMT="$1" + _make_test_img --no-opts "$2" } qemu_io_with_fmt() {tests/qemu-iotests/197 +2
-2@@ -66,8 +66,8 @@ if [ "$IMGFMT" = "vpc" ]; then fi _make_test_img 4G $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io -IMGPROTO=file IMGFMT=qcow2 IMGOPTS= TEST_IMG_FILE="$TEST_WRAP" \ - _make_test_img -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create +IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \ + _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io # Ensure that a read of two clusters, but where one is already allocated,tests/qemu-iotests/215 +0
-0
tests/qemu-iotests/215 if [ "$IMGFMT" = "vpc" ]; then · line 70
Quoted 10 lines
tests/qemu-iotests/215 +2
-2@@ -63,8 +63,8 @@ if [ "$IMGFMT" = "vpc" ]; then fi _make_test_img 4G $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io -IMGPROTO=file IMGFMT=qcow2 IMGOPTS= TEST_IMG_FILE="$TEST_WRAP" \ - _make_test_img -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create +IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \ + _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io # Ensure that a read of two clusters, but where one is already allocated,
PATCH 9/18 iotests: Drop IMGOPTS use in 267
In reply to Max ReitzOverwriting IMGOPTS means ignoring all user-supplied options, which is not what we want. Replace the current IMGOPTS use by a new BACKING_FILE variable.
--- tests/qemu-iotests/267 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
tests/qemu-iotests/267 +8 -4
@@ -68,7 +68,11 @@ size=128M run_test() { - _make_test_img $size + if [ -n "$BACKING_FILE" ]; then + _make_test_img -b "$BACKING_FILE" $size + else + _make_test_img $size + fi printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu "$@" | _filter_date }
@@ -119,12 +123,12 @@ echo TEST_IMG="$TEST_IMG.base" _make_test_img $size -IMGOPTS="backing_file=$TEST_IMG.base" \ +BACKING_FILE="$TEST_IMG.base" \ run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ -blockdev driver=file,filename="$TEST_IMG",node-name=file \ -blockdev driver=$IMGFMT,file=file,backing=backing-file,node-name=fmt -IMGOPTS="backing_file=$TEST_IMG.base" \ +BACKING_FILE="$TEST_IMG.base" \ run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \ -blockdev driver=file,filename="$TEST_IMG",node-name=file \
@@ -141,7 +145,7 @@ echo echo "=== -blockdev with NBD server on the backing file ===" echo -IMGOPTS="backing_file=$TEST_IMG.base" _make_test_img $size +_make_test_img -b "$TEST_IMG.base" $size cat <<EOF | nbd_server_start unix:$TEST_DIR/nbd nbd_server_add -w backing-fmt
Signature · 1 line
2.21.0
Re: [PATCH 09/18] iotests: Drop IMGOPTS use in 267
Quoted 42 lines · Max Reitz
Overwriting IMGOPTS means ignoring all user-supplied options, which is not what we want. Replace the current IMGOPTS use by a new
BACKING_FILEvariable.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/267 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)tests/qemu-iotests/267 +7
-3@@ -68,7 +68,11 @@ size=128M run_test() { - _make_test_img $size + if [ -n "$BACKING_FILE" ]; then + _make_test_img -b "$BACKING_FILE" $size + else + _make_test_img $size + fi printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu "$@" | _filter_date }@@ -119,12 +123,12 @@ echo TEST_IMG="$TEST_IMG.base" _make_test_img $size -IMGOPTS="backing_file=$TEST_IMG.base" \ +BACKING_FILE="$TEST_IMG.base" \ run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ -blockdev driver=file,filename="$TEST_IMG",node-name=file \ -blockdev driver=$IMGFMT,file=file,backing=backing-file,node-name=fmt -IMGOPTS="backing_file=$TEST_IMG.base" \ +BACKING_FILE="$TEST_IMG.base" \ run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \ -blockdev driver=file,filename="$TEST_IMG",node-name=file \
tests/qemu-iotests/267 echo · line 151
Quoted 8 lines
tests/qemu-iotests/267 +1
-1@@ -141,7 +145,7 @@ echo echo "=== -blockdev with NBD server on the backing file ===" echo -IMGOPTS="backing_file=$TEST_IMG.base" _make_test_img $size +_make_test_img -b "$TEST_IMG.base" $size cat <<EOF | nbd_server_start unix:$TEST_DIR/nbd nbd_server_add -w backing-fmt
qemu's master (pulled today), don't have iotest 267, you probably based this on some not yet merged branch. Or I made some mistake with pulling the master branch.
Best regards,
Maxim Levitsky
Re: [PATCH 09/18] iotests: Drop IMGOPTS use in 267
Quoted 46 lines · Maxim Levitsky
Quoted 45 lines · Max Reitz
Overwriting IMGOPTS means ignoring all user-supplied options, which is not what we want. Replace the current IMGOPTS use by a new
BACKING_FILEvariable.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/267 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)tests/qemu-iotests/267 +7
-3@@ -68,7 +68,11 @@ size=128M run_test() { - _make_test_img $size + if [ -n "$BACKING_FILE" ]; then + _make_test_img -b "$BACKING_FILE" $size + else + _make_test_img $size + fi printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu "$@" | _filter_date }@@ -119,12 +123,12 @@ echo TEST_IMG="$TEST_IMG.base" _make_test_img $size -IMGOPTS="backing_file=$TEST_IMG.base" \ +BACKING_FILE="$TEST_IMG.base" \ run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ -blockdev driver=file,filename="$TEST_IMG",node-name=file \ -blockdev driver=$IMGFMT,file=file,backing=backing-file,node-name=fmt -IMGOPTS="backing_file=$TEST_IMG.base" \ +BACKING_FILE="$TEST_IMG.base" \ run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \ -blockdev driver=file,filename="$TEST_IMG",node-name=file \@@ -141,7 +145,7 @@ echo echo "=== -blockdev with NBD server on the backing file ===" echo
Quoted 9 lines
tests/qemu-iotests/267 echo · line 151
Quoted 5 lines
tests/qemu-iotests/267 +1
-1-IMGOPTS="backing_file=$TEST_IMG.base" _make_test_img $size +_make_test_img -b "$TEST_IMG.base" $size cat <<EOF | nbd_server_start unix:$TEST_DIR/nbd nbd_server_add -w backing-fmtqemu's master (pulled today), don't have iotest 267, you probably based this on some not yet merged branch. Or I made some mistake with pulling the master branch.
Yep, it’s only in Kevin’s block branch (and thus mine, too). He sent a pull request for it, which was rejected though (because this test is broken on anything but x64, but that doesn’t stop this patch).
Max
Re: [PATCH 09/18] iotests: Drop IMGOPTS use in 267
Quoted 57 lines · Max Reitz
Quoted 46 lines · Maxim Levitsky
Quoted 45 lines · Max Reitz
Overwriting IMGOPTS means ignoring all user-supplied options, which is not what we want. Replace the current IMGOPTS use by a new
BACKING_FILEvariable.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/267 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)tests/qemu-iotests/267 +7
-3@@ -68,7 +68,11 @@ size=128M run_test() { - _make_test_img $size + if [ -n "$BACKING_FILE" ]; then + _make_test_img -b "$BACKING_FILE" $size + else + _make_test_img $size + fi printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu "$@" | _filter_date }@@ -119,12 +123,12 @@ echo TEST_IMG="$TEST_IMG.base" _make_test_img $size -IMGOPTS="backing_file=$TEST_IMG.base" \ +BACKING_FILE="$TEST_IMG.base" \ run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ -blockdev driver=file,filename="$TEST_IMG",node-name=file \ -blockdev driver=$IMGFMT,file=file,backing=backing-file,node-name=fmt -IMGOPTS="backing_file=$TEST_IMG.base" \ +BACKING_FILE="$TEST_IMG.base" \ run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \ -blockdev driver=file,filename="$TEST_IMG",node-name=file \@@ -141,7 +145,7 @@ echo echo "=== -blockdev with NBD server on the backing file ===" echoQuoted 9 lines
tests/qemu-iotests/267 echo · line 151
Quoted 5 lines
tests/qemu-iotests/267 +1
-1-IMGOPTS="backing_file=$TEST_IMG.base" _make_test_img $size +_make_test_img -b "$TEST_IMG.base" $size cat <<EOF | nbd_server_start unix:$TEST_DIR/nbd nbd_server_add -w backing-fmtqemu's master (pulled today), don't have iotest 267, you probably based this on some not yet merged branch. Or I made some mistake with pulling the master branch.
Quoted 4 lines
Yep, it’s only in Kevin’s block branch (and thus mine, too). He sent a pull request for it, which was rejected though (because this test is broken on anything but x64, but that doesn’t stop this patch).
I figured out that it must be something like that. Being lazy, I would like to ask if we have maybe a list of these branches somewhere in the wiki?
Best regards,
Maxim Levitsky
Re: [PATCH 09/18] iotests: Drop IMGOPTS use in 267
Quoted 58 lines · Maxim Levitsky
Quoted 57 lines · Max Reitz
Quoted 55 lines · Maxim Levitsky
Quoted 42 lines · Max Reitz
Overwriting IMGOPTS means ignoring all user-supplied options, which is not what we want. Replace the current IMGOPTS use by a new
BACKING_FILEvariable.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/267 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)tests/qemu-iotests/267 +7
-3@@ -68,7 +68,11 @@ size=128M run_test() { - _make_test_img $size + if [ -n "$BACKING_FILE" ]; then + _make_test_img -b "$BACKING_FILE" $size + else + _make_test_img $size + fi printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu "$@" | _filter_date }@@ -119,12 +123,12 @@ echo TEST_IMG="$TEST_IMG.base" _make_test_img $size -IMGOPTS="backing_file=$TEST_IMG.base" \ +BACKING_FILE="$TEST_IMG.base" \ run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ -blockdev driver=file,filename="$TEST_IMG",node-name=file \ -blockdev driver=$IMGFMT,file=file,backing=backing-file,node-name=fmt -IMGOPTS="backing_file=$TEST_IMG.base" \ +BACKING_FILE="$TEST_IMG.base" \ run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \ -blockdev driver=file,filename="$TEST_IMG",node-name=file \tests/qemu-iotests/267 echo · line 151
Quoted 8 lines
tests/qemu-iotests/267 +1
-1@@ -141,7 +145,7 @@ echo echo "=== -blockdev with NBD server on the backing file ===" echo -IMGOPTS="backing_file=$TEST_IMG.base" _make_test_img $size +_make_test_img -b "$TEST_IMG.base" $size cat <<EOF | nbd_server_start unix:$TEST_DIR/nbd nbd_server_add -w backing-fmtqemu's master (pulled today), don't have iotest 267, you probably based this on some not yet merged branch. Or I made some mistake with pulling the master branch.
Quoted 8 lines
Quoted 4 lines
Yep, it’s only in Kevin’s block branch (and thus mine, too). He sent a pull request for it, which was rejected though (because this test is broken on anything but x64, but that doesn’t stop this patch).
I figured out that it must be something like that. Being lazy, I would like to ask if we have maybe a list of these branches somewhere in the wiki?
The MAINTAINERS file has at least Kevin’s branch:
$ scripts/get_maintainer.pl --scm --no-email --no-l -f block git https://repo.or.cz/qemu/kevin.git block
Max
Re: [PATCH 09/18] iotests: Drop IMGOPTS use in 267
Quoted 64 lines · Max Reitz
Quoted 63 lines · Maxim Levitsky
Quoted 61 lines · Max Reitz
Quoted 46 lines · Maxim Levitsky
Quoted 45 lines · Max Reitz
Overwriting IMGOPTS means ignoring all user-supplied options, which is not what we want. Replace the current IMGOPTS use by a new
BACKING_FILEvariable.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/267 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)tests/qemu-iotests/267 +7
-3@@ -68,7 +68,11 @@ size=128M run_test() { - _make_test_img $size + if [ -n "$BACKING_FILE" ]; then + _make_test_img -b "$BACKING_FILE" $size + else + _make_test_img $size + fi printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu "$@" | _filter_date }@@ -119,12 +123,12 @@ echo TEST_IMG="$TEST_IMG.base" _make_test_img $size -IMGOPTS="backing_file=$TEST_IMG.base" \ +BACKING_FILE="$TEST_IMG.base" \ run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ -blockdev driver=file,filename="$TEST_IMG",node-name=file \ -blockdev driver=$IMGFMT,file=file,backing=backing-file,node-name=fmt -IMGOPTS="backing_file=$TEST_IMG.base" \ +BACKING_FILE="$TEST_IMG.base" \ run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \ -blockdev driver=file,filename="$TEST_IMG",node-name=file \@@ -141,7 +145,7 @@ echo echo "=== -blockdev with NBD server on the backing file ===" echoQuoted 9 lines
tests/qemu-iotests/267 echo · line 151
Quoted 5 lines
tests/qemu-iotests/267 +1
-1-IMGOPTS="backing_file=$TEST_IMG.base" _make_test_img $size +_make_test_img -b "$TEST_IMG.base" $size cat <<EOF | nbd_server_start unix:$TEST_DIR/nbd nbd_server_add -w backing-fmtqemu's master (pulled today), don't have iotest 267, you probably based this on some not yet merged branch. Or I made some mistake with pulling the master branch.
Yep, it’s only in Kevin’s block branch (and thus mine, too). He sent a pull request for it, which was rejected though (because this test is broken on anything but x64, but that doesn’t stop this patch).
Quoted 8 lines
Quoted 3 lines
I figured out that it must be something like that. Being lazy, I would like to ask if we have maybe a list of these branches somewhere in the wiki?
The
MAINTAINERSfile has at least Kevin’s branch:$ scripts/get_maintainer.pl --scm --no-email --no-l -f block git https://repo.or.cz/qemu/kevin.git block
Thank you!
I didn't knew that MAINTAINERS contain git branches these day.
Best regards,
Maxim Levitsky
PATCH 10/18 iotests: Avoid qemu-img create
In reply to Max ReitzUse _make_test_img whenever possible. This way, we will not ignore user-specified image options.
--- tests/qemu-iotests/094 | 2 +- tests/qemu-iotests/111 | 3 +-- tests/qemu-iotests/123 | 2 +- tests/qemu-iotests/153 | 2 +- tests/qemu-iotests/200 | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-)
tests/qemu-iotests/094 +1 -1
@@ -45,7 +45,7 @@ _supported_proto nbd _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" _make_test_img 64M -$QEMU_IMG create -f $IMGFMT "$TEST_DIR/source.$IMGFMT" 64M | _filter_img_create +TEST_IMG_FILE="$TEST_DIR/source.$IMGFMT" IMGPROTO=file _make_test_img 64M _launch_qemu -drive if=none,id=src,file="$TEST_DIR/source.$IMGFMT",format=raw \ -nodefaults
tests/qemu-iotests/111 +1 -2
@@ -41,8 +41,7 @@ _supported_fmt qed qcow qcow2 vmdk _supported_proto file _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" -$QEMU_IMG create -f $IMGFMT -b "$TEST_IMG.inexistent" "$TEST_IMG" 2>&1 \ - | _filter_testdir | _filter_imgfmt +_make_test_img -b "$TEST_IMG.inexistent" # success, all done echo '*** done'
tests/qemu-iotests/123 +1 -1
@@ -44,7 +44,7 @@ _supported_os Linux SRC_IMG="$TEST_DIR/source.$IMGFMT" _make_test_img 1M -$QEMU_IMG create -f $IMGFMT "$SRC_IMG" 1M | _filter_img_create +TEST_IMG_FILE=$SRC_IMG IMGPROTO=file _make_test_img 1M $QEMU_IO -c 'write -P 42 0 1M' "$SRC_IMG" | _filter_qemu_io
tests/qemu-iotests/153 +1 -1
@@ -98,7 +98,7 @@ for opts1 in "" "read-only=on" "read-only=on,force-share=on"; do echo echo "== Creating test image ==" - $QEMU_IMG create -f $IMGFMT "${TEST_IMG}" -b ${TEST_IMG}.base | _filter_img_create + _make_test_img -b "${TEST_IMG}.base" echo echo "== Launching QEMU, opts: '$opts1' =="
tests/qemu-iotests/200 +2 -2
@@ -46,8 +46,8 @@ _supported_proto file BACKING_IMG="${TEST_DIR}/backing.img" TEST_IMG="${TEST_DIR}/test.img" -${QEMU_IMG} create -f $IMGFMT "${BACKING_IMG}" 512M | _filter_img_create -${QEMU_IMG} create -f $IMGFMT -F $IMGFMT "${TEST_IMG}" -b "${BACKING_IMG}" 512M | _filter_img_create +TEST_IMG="$BACKING_IMG" _make_test_img 512M +_make_test_img -F $IMGFMT -b "$BACKING_IMG" 512M ${QEMU_IO} -c "write -P 0xa5 512 300M" "${BACKING_IMG}" | _filter_qemu_io
Signature · 1 line
2.21.0
Re: [PATCH 10/18] iotests: Avoid qemu-img create
Quoted 70 lines · Max Reitz
Use
_make_test_imgwhenever possible. This way, we will not ignore user-specified image options.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/094 | 2 +- tests/qemu-iotests/111 | 3 +-- tests/qemu-iotests/123 | 2 +- tests/qemu-iotests/153 | 2 +- tests/qemu-iotests/200 | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-)tests/qemu-iotests/094 +1
-1@@ -45,7 +45,7 @@ _supported_proto nbd _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" _make_test_img 64M -$QEMU_IMG create -f $IMGFMT "$TEST_DIR/source.$IMGFMT" 64M | _filter_img_create +TEST_IMG_FILE="$TEST_DIR/source.$IMGFMT" IMGPROTO=file _make_test_img 64M _launch_qemu -drive if=none,id=src,file="$TEST_DIR/source.$IMGFMT",format=raw \ -nodefaultstests/qemu-iotests/111 +1
-2@@ -41,8 +41,7 @@ _supported_fmt qed qcow qcow2 vmdk _supported_proto file _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" -$QEMU_IMG create -f $IMGFMT -b "$TEST_IMG.inexistent" "$TEST_IMG" 2>&1 \ - | _filter_testdir | _filter_imgfmt +_make_test_img -b "$TEST_IMG.inexistent" # success, all done echo '*** done'tests/qemu-iotests/123 +1
-1@@ -44,7 +44,7 @@ _supported_os Linux SRC_IMG="$TEST_DIR/source.$IMGFMT" _make_test_img 1M -$QEMU_IMG create -f $IMGFMT "$SRC_IMG" 1M | _filter_img_create +TEST_IMG_FILE=$SRC_IMG IMGPROTO=file _make_test_img 1M $QEMU_IO -c 'write -P 42 0 1M' "$SRC_IMG" | _filter_qemu_iotests/qemu-iotests/153 +1
-1@@ -98,7 +98,7 @@ for opts1 in "" "read-only=on" "read-only=on,force-share=on"; do echo echo "== Creating test image ==" - $QEMU_IMG create -f $IMGFMT "${TEST_IMG}" -b ${TEST_IMG}.base | _filter_img_create + _make_test_img -b "${TEST_IMG}.base" echo echo "== Launching QEMU, opts: '$opts1' =="tests/qemu-iotests/200 +0
-0
tests/qemu-iotests/200 _supported_proto file · line 53
Quoted 10 lines
tests/qemu-iotests/200 +2
-2@@ -46,8 +46,8 @@ _supported_proto file BACKING_IMG="${TEST_DIR}/backing.img" TEST_IMG="${TEST_DIR}/test.img" -${QEMU_IMG} create -f $IMGFMT "${BACKING_IMG}" 512M | _filter_img_create -${QEMU_IMG} create -f $IMGFMT -F $IMGFMT "${TEST_IMG}" -b "${BACKING_IMG}" 512M | _filter_img_create +TEST_IMG="$BACKING_IMG" _make_test_img 512M +_make_test_img -F $IMGFMT -b "$BACKING_IMG" 512M ${QEMU_IO} -c "write -P 0xa5 512 300M" "${BACKING_IMG}" | _filter_qemu_io
PATCH 11/18 iotests: Use _rm_test_img for deleting test images
In reply to Max ReitzJust rm will not delete external data files. Use _rm_test_img every time we delete a test image.
(In the process, clean up the indentation of every _cleanup() this patch touches.)
((Also, use quotes consistently. I am happy to see unquoted instances like "rm -rf $TEST_DIR/..." go.))
--- tests/qemu-iotests/005 | 2 +- tests/qemu-iotests/019 | 6 +++--- tests/qemu-iotests/020 | 6 +++--- tests/qemu-iotests/024 | 10 +++++----- tests/qemu-iotests/028 | 2 +- tests/qemu-iotests/029 | 2 +- tests/qemu-iotests/043 | 4 +++- tests/qemu-iotests/048 | 2 +- tests/qemu-iotests/050 | 4 ++-- tests/qemu-iotests/053 | 4 ++-- tests/qemu-iotests/058 | 2 +- tests/qemu-iotests/059 | 2 +- tests/qemu-iotests/061 | 2 +- tests/qemu-iotests/063 | 6 ++++-- tests/qemu-iotests/069 | 2 +- tests/qemu-iotests/074 | 2 +- tests/qemu-iotests/080 | 2 +- tests/qemu-iotests/081 | 6 +++--- tests/qemu-iotests/085 | 9 ++++++--- tests/qemu-iotests/088 | 2 +- tests/qemu-iotests/092 | 2 +- tests/qemu-iotests/094 | 2 +- tests/qemu-iotests/095 | 5 +++-- tests/qemu-iotests/099 | 7 ++++--- tests/qemu-iotests/109 | 4 ++-- tests/qemu-iotests/110 | 4 ++-- tests/qemu-iotests/122 | 6 ++++-- tests/qemu-iotests/123 | 2 +- tests/qemu-iotests/141 | 4 +++- tests/qemu-iotests/142 | 2 +- tests/qemu-iotests/144 | 4 +++- tests/qemu-iotests/153 | 10 +++------- tests/qemu-iotests/156 | 8 ++++++-- tests/qemu-iotests/159 | 2 +- tests/qemu-iotests/160 | 3 ++- tests/qemu-iotests/161 | 4 ++-- tests/qemu-iotests/170 | 2 +- tests/qemu-iotests/172 | 6 +++--- tests/qemu-iotests/173 | 3 ++- tests/qemu-iotests/178 | 2 +- tests/qemu-iotests/182 | 2 +- tests/qemu-iotests/183 | 2 +- tests/qemu-iotests/185 | 4 ++-- tests/qemu-iotests/187 | 6 +++--- tests/qemu-iotests/190 | 2 +- tests/qemu-iotests/191 | 6 +++--- tests/qemu-iotests/195 | 2 +- tests/qemu-iotests/197 | 2 +- tests/qemu-iotests/200 | 3 ++- tests/qemu-iotests/215 | 2 +- tests/qemu-iotests/225 | 2 +- tests/qemu-iotests/229 | 3 ++- tests/qemu-iotests/232 | 4 +++- tests/qemu-iotests/243 | 2 +- tests/qemu-iotests/244 | 4 ++-- tests/qemu-iotests/247 | 4 +++- tests/qemu-iotests/249 | 4 ++-- tests/qemu-iotests/252 | 2 +- 58 files changed, 119 insertions(+), 96 deletions(-)
tests/qemu-iotests/005 +1 -1
@@ -62,7 +62,7 @@ if [ "$IMGFMT" = "raw" ]; then if ! truncate --size=5T "$TEST_IMG"; then _notrun "file system on $TEST_DIR does not support large enough files" fi - rm "$TEST_IMG" + _rm_test_img "$TEST_IMG" fi echo
tests/qemu-iotests/019 +3 -3
@@ -30,9 +30,9 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_IMG.base" - rm -f "$TEST_IMG.orig" + _cleanup_test_img + _rm_test_img "$TEST_IMG.base" + _rm_test_img "$TEST_IMG.orig" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/020 +3 -3
@@ -28,9 +28,9 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_IMG.base" - rm -f "$TEST_IMG.orig" + _cleanup_test_img + _rm_test_img "$TEST_IMG.base" + _rm_test_img "$TEST_IMG.orig" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/024 +5 -5
@@ -29,12 +29,12 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_DIR/t.$IMGFMT.base_old" - rm -f "$TEST_DIR/t.$IMGFMT.base_new" + _rm_test_img "$TEST_DIR/t.$IMGFMT.base_old" + _rm_test_img "$TEST_DIR/t.$IMGFMT.base_new" - rm -f "$TEST_DIR/subdir/t.$IMGFMT" - rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_old" - rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_new" + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT" + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_old" + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_new" rmdir "$TEST_DIR/subdir" 2> /dev/null } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/028 +1 -1
@@ -32,7 +32,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_qemu - rm -f "${TEST_IMG}.copy" + _rm_test_img "${TEST_IMG}.copy" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/029 +1 -1
@@ -28,7 +28,7 @@ status=1 # failure is the default! _cleanup() { - rm -f $TEST_IMG.snap + _rm_test_img "$TEST_IMG.snap" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/043 +3 -1
@@ -29,7 +29,9 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG".[123].base + for img in "$TEST_IMG".[123].base; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/048 +1 -1
@@ -31,7 +31,7 @@ _cleanup() { echo "Cleanup" _cleanup_test_img - rm "${TEST_IMG_FILE2}" + _rm_test_img "${TEST_IMG_FILE2}" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/050 +2 -2
@@ -29,8 +29,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.old" - rm -f "$TEST_IMG.new" + _rm_test_img "$TEST_IMG.old" + _rm_test_img "$TEST_IMG.new" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/053 +2 -2
@@ -28,8 +28,8 @@ status=1 # failure is the default! _cleanup() { - rm -f "$TEST_IMG.orig" - _cleanup_test_img + _rm_test_img "$TEST_IMG.orig" + _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/058 +1 -1
@@ -42,7 +42,7 @@ _cleanup() { nbd_server_stop _cleanup_test_img - rm -f "$converted_image" + _rm_test_img "$converted_image" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/059 +1 -1
@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.qcow2" + IMGFMT=qcow2 _rm_test_img "$TEST_IMG.qcow2" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/061 +1 -1
@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f $TEST_IMG.data + _rm_test_img "$TEST_IMG.data" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/063 +4 -2
@@ -29,8 +29,10 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_IMG.orig" "$TEST_IMG.raw1" "$TEST_IMG.raw2" + _cleanup_test_img + for img in "$TEST_IMG".{orig,raw1,raw2,target}; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/069 +1 -1
@@ -47,7 +47,7 @@ echo "=== Creating an image with a backing file and deleting that file ===" echo TEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE _make_test_img -b "$TEST_IMG.base" $IMG_SIZE -rm -f "$TEST_IMG.base" +_rm_test_img "$TEST_IMG.base" # Just open the image and close it right again (this should print an error message) $QEMU_IO -c quit "$TEST_IMG" 2>&1 | _filter_testdir | _filter_imgfmt
tests/qemu-iotests/074 +1 -1
@@ -31,7 +31,7 @@ _cleanup() { echo "Cleanup" _cleanup_test_img - rm "${TEST_IMG2}" + _rm_test_img "${TEST_IMG2}" rm -f "$TEST_DIR/blkdebug.conf" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/080 +1 -1
@@ -28,7 +28,7 @@ status=1 # failure is the default! _cleanup() { - rm -f $TEST_IMG.snap + _rm_test_img "$TEST_IMG.snap" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/081 +3 -3
@@ -28,9 +28,9 @@ status=1 # failure is the default! _cleanup() { - rm -rf $TEST_DIR/1.raw - rm -rf $TEST_DIR/2.raw - rm -rf $TEST_DIR/3.raw + _rm_test_img "$TEST_DIR/1.raw" + _rm_test_img "$TEST_DIR/2.raw" + _rm_test_img "$TEST_DIR/3.raw" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/085 +6 -3
@@ -41,10 +41,13 @@ _cleanup() _cleanup_qemu for i in $(seq 1 ${SNAPSHOTS}) do - rm -f "${TEST_DIR}/${i}-${snapshot_virt0}" - rm -f "${TEST_DIR}/${i}-${snapshot_virt1}" + _rm_test_img "${TEST_DIR}/${i}-${snapshot_virt0}" + _rm_test_img "${TEST_DIR}/${i}-${snapshot_virt1}" + done + for img in "${TEST_IMG}".{1,2,base} + do + _rm_test_img "$img" done - rm -f "${TEST_IMG}" "${TEST_IMG}.1" "${TEST_IMG}.2" "${TEST_IMG}.base" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/088 +1 -1
@@ -28,7 +28,7 @@ status=1 # failure is the default! _cleanup() { - rm -f $TEST_IMG.snap + _rm_test_img "$TEST_IMG.snap" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/092 +1 -1
@@ -28,7 +28,7 @@ status=1 # failure is the default! _cleanup() { - rm -f $TEST_IMG.snap + _rm_test_img "$TEST_IMG.snap" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/094 +1 -1
@@ -30,7 +30,7 @@ _cleanup() { _cleanup_qemu _cleanup_test_img - rm -f "$TEST_DIR/source.$IMGFMT" + _rm_test_img "$TEST_DIR/source.$IMGFMT" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/095 +3 -2
@@ -32,8 +32,9 @@ status=1 # failure is the default! _cleanup() { _cleanup_qemu - rm -f "${TEST_IMG}.base" "${TEST_IMG}.snp1" - _cleanup_test_img + _rm_test_img "${TEST_IMG}.base" + _rm_test_img "${TEST_IMG}.snp1" + _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/099 +4 -3
@@ -29,7 +29,10 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img + _cleanup_test_img + _rm_test_img "$TEST_IMG.compare" + rm -f "$TEST_DIR/blkdebug.conf" + } trap "_cleanup; exit \$status" 0 1 2 3 15
@@ -121,8 +124,6 @@ echo test_qemu "file.driver=blkdebug,file.image.filename=$TEST_IMG" -rm -f "$TEST_IMG.compare" "$TEST_DIR/blkdebug.conf" - # success, all done echo "*** done" rm -f $seq.full
tests/qemu-iotests/109 +2 -2
@@ -29,8 +29,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_qemu - rm -f $TEST_IMG.src - _cleanup_test_img + _rm_test_img "$TEST_IMG.src" + _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/110 +2 -2
@@ -28,8 +28,8 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_IMG.copy" + _cleanup_test_img + _rm_test_img "$TEST_IMG.copy" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/122 +4 -2
@@ -28,8 +28,10 @@ status=1 # failure is the default! _cleanup() { - rm -f "$TEST_IMG".[123] - _cleanup_test_img + for img in "$TEST_IMG".[123]; do + _rm_test_img "$img" + done + _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/123 +1 -1
@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$SRC_IMG" + _rm_test_img "$SRC_IMG" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/141 +3 -1
@@ -30,7 +30,9 @@ _cleanup() { _cleanup_qemu _cleanup_test_img - rm -f "$TEST_DIR"/{b,m,o}.$IMGFMT + for img in "$TEST_DIR"/{b,m,o}.$IMGFMT; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/142 +1 -1
@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f $TEST_IMG.snap + _rm_test_img "$TEST_IMG.snap" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/144 +3 -1
@@ -34,7 +34,9 @@ TMP_SNAP2=${TEST_DIR}/tmp2.qcow2 _cleanup() { _cleanup_qemu - rm -f "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}" + for img in "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}"; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/153 +3 -7
@@ -30,13 +30,9 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "${TEST_IMG}.base" - rm -f "${TEST_IMG}.overlay" - rm -f "${TEST_IMG}.convert" - rm -f "${TEST_IMG}.a" - rm -f "${TEST_IMG}.b" - rm -f "${TEST_IMG}.c" - rm -f "${TEST_IMG}.lnk" + for img in "${TEST_IMG}".{base,overlay,convert,a,b,c,lnk}; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/156 +6 -2
@@ -37,7 +37,9 @@ status=1 # failure is the default! _cleanup() { _cleanup_qemu - rm -f "$TEST_IMG"{,.target}{,.backing,.overlay} + for img in "$TEST_IMG"{,.target}{,.backing,.overlay}; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15
@@ -120,7 +122,9 @@ _send_qemu_cmd $QEMU_HANDLE \ '"status": "null"' # Remove the source images -rm -f "$TEST_IMG{,.backing,.overlay}" +for img in "$TEST_IMG{,.backing,.overlay}"; do + _rm_test_img "$img" +done echo
tests/qemu-iotests/159 +1 -1
@@ -28,7 +28,7 @@ status=1 _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.out" + _rm_test_img "$TEST_IMG.out" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/160 +2 -1
@@ -28,7 +28,8 @@ status=1 _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.out" "$TEST_IMG.out.dd" + _rm_test_img "$TEST_IMG.out" + _rm_test_img "$TEST_IMG.out.dd" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/161 +2 -2
@@ -30,8 +30,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.base" - rm -f "$TEST_IMG.int" + _rm_test_img "$TEST_IMG.base" + _rm_test_img "$TEST_IMG.int" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/170 +1 -1
@@ -28,7 +28,7 @@ status=1 _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.out" + _rm_test_img "$TEST_IMG.out" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/172 +3 -3
@@ -28,9 +28,9 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_IMG.2" - rm -f "$TEST_IMG.3" + _cleanup_test_img + _rm_test_img "$TEST_IMG.2" + _rm_test_img "$TEST_IMG.3" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/173 +2 -1
@@ -29,7 +29,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_qemu - rm -f "${QEMU_TEST_DIR}/image.base" "${QEMU_TEST_DIR}/image.snp1" + _rm_test_img "${TEST_DIR}/image.base" + _rm_test_img "${TEST_DIR}/image.snp1" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/178 +1 -1
@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.converted" + _rm_test_img "$TEST_IMG.converted" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/182 +1 -1
@@ -30,7 +30,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.overlay" + _rm_test_img "$TEST_IMG.overlay" rm -f "$TEST_DIR/nbd.socket" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/183 +1 -1
@@ -31,7 +31,7 @@ MIG_SOCKET="${TEST_DIR}/migrate" _cleanup() { rm -f "${MIG_SOCKET}" - rm -f "${TEST_IMG}.dest" + _rm_test_img "${TEST_IMG}.dest" _cleanup_test_img _cleanup_qemu }
tests/qemu-iotests/185 +2 -2
@@ -28,8 +28,8 @@ status=1 # failure is the default! _cleanup() { - rm -f "${TEST_IMG}.mid" - rm -f "${TEST_IMG}.copy" + _rm_test_img "${TEST_IMG}.mid" + _rm_test_img "${TEST_IMG}.copy" _cleanup_test_img _cleanup_qemu }
tests/qemu-iotests/187 +3 -3
@@ -28,9 +28,9 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_IMG.2" - rm -f "$TEST_IMG.3" + _cleanup_test_img + _rm_test_img "$TEST_IMG.2" + _rm_test_img "$TEST_IMG.3" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/190 +1 -1
@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.converted" + _rm_test_img "$TEST_IMG.converted" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/191 +3 -3
@@ -28,9 +28,9 @@ status=1 # failure is the default! _cleanup() { - rm -f "${TEST_IMG}.mid" - rm -f "${TEST_IMG}.ovl2" - rm -f "${TEST_IMG}.ovl3" + _rm_test_img "${TEST_IMG}.mid" + _rm_test_img "${TEST_IMG}.ovl2" + _rm_test_img "${TEST_IMG}.ovl3" _cleanup_test_img _cleanup_qemu }
tests/qemu-iotests/195 +1 -1
@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.mid" + _rm_test_img "$TEST_IMG.mid" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/197 +1 -1
@@ -43,7 +43,7 @@ esac _cleanup() { _cleanup_test_img - rm -f "$TEST_WRAP" + _rm_test_img "$TEST_WRAP" rm -f "$BLKDBG_CONF" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/200 +2 -1
@@ -31,7 +31,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_qemu - rm -f "${TEST_IMG}" "${BACKING_IMG}" + _rm_test_img "${TEST_IMG}" + _rm_test_img "${BACKING_IMG}" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/215 +1 -1
@@ -40,7 +40,7 @@ esac _cleanup() { _cleanup_test_img - rm -f "$TEST_WRAP" + _rm_test_img "$TEST_WRAP" rm -f "$BLKDBG_CONF" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/225 +1 -1
@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.not_base" + _rm_test_img "$TEST_IMG.not_base" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/229 +2 -1
@@ -31,7 +31,8 @@ _cleanup() { _cleanup_qemu _cleanup_test_img - rm -f "$TEST_IMG" "$DEST_IMG" + _rm_test_img "$TEST_IMG" + _rm_test_img "$DEST_IMG" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/232 +3 -1
@@ -29,7 +29,9 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f $TEST_IMG.[01234] + for img in "$TEST_IMG".[01234]; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/243 +1 -1
@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f $TEST_IMG.data + _rm_test_img "$TEST_IMG.data" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/244 +2 -2
@@ -29,8 +29,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f $TEST_IMG.data - rm -f $TEST_IMG.src + _rm_test_img "$TEST_IMG.data" + _rm_test_img "$TEST_IMG.src" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/247 +3 -1
@@ -29,7 +29,9 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f $TEST_IMG.[01234] + for img in "$TEST_IMG".[01234]; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/249 +2 -2
@@ -30,8 +30,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.base" - rm -f "$TEST_IMG.int" + _rm_test_img "$TEST_IMG.base" + _rm_test_img "$TEST_IMG.int" } trap "_cleanup; exit \$status" 0 1 2 3 15
tests/qemu-iotests/252 +1 -1
@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.base_new" + _rm_test_img "$TEST_IMG.base_new" } trap "_cleanup; exit \$status" 0 1 2 3 15
Signature · 1 line
2.21.0
Re: [PATCH 11/18] iotests: Use _rm_test_img for deleting test images
Quoted 932 lines · Max Reitz
Just rm will not delete external data files. Use
_rm_test_imgevery time we delete a test image.(In the process, clean up the indentation of every
_cleanup()this patch touches.)((Also, use quotes consistently. I am happy to see unquoted instances like "rm -rf $TEST_DIR/..." go.))
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/005 | 2 +- tests/qemu-iotests/019 | 6 +++--- tests/qemu-iotests/020 | 6 +++--- tests/qemu-iotests/024 | 10 +++++----- tests/qemu-iotests/028 | 2 +- tests/qemu-iotests/029 | 2 +- tests/qemu-iotests/043 | 4 +++- tests/qemu-iotests/048 | 2 +- tests/qemu-iotests/050 | 4 ++-- tests/qemu-iotests/053 | 4 ++-- tests/qemu-iotests/058 | 2 +- tests/qemu-iotests/059 | 2 +- tests/qemu-iotests/061 | 2 +- tests/qemu-iotests/063 | 6 ++++-- tests/qemu-iotests/069 | 2 +- tests/qemu-iotests/074 | 2 +- tests/qemu-iotests/080 | 2 +- tests/qemu-iotests/081 | 6 +++--- tests/qemu-iotests/085 | 9 ++++++--- tests/qemu-iotests/088 | 2 +- tests/qemu-iotests/092 | 2 +- tests/qemu-iotests/094 | 2 +- tests/qemu-iotests/095 | 5 +++-- tests/qemu-iotests/099 | 7 ++++--- tests/qemu-iotests/109 | 4 ++-- tests/qemu-iotests/110 | 4 ++-- tests/qemu-iotests/122 | 6 ++++-- tests/qemu-iotests/123 | 2 +- tests/qemu-iotests/141 | 4 +++- tests/qemu-iotests/142 | 2 +- tests/qemu-iotests/144 | 4 +++- tests/qemu-iotests/153 | 10 +++------- tests/qemu-iotests/156 | 8 ++++++-- tests/qemu-iotests/159 | 2 +- tests/qemu-iotests/160 | 3 ++- tests/qemu-iotests/161 | 4 ++-- tests/qemu-iotests/170 | 2 +- tests/qemu-iotests/172 | 6 +++--- tests/qemu-iotests/173 | 3 ++- tests/qemu-iotests/178 | 2 +- tests/qemu-iotests/182 | 2 +- tests/qemu-iotests/183 | 2 +- tests/qemu-iotests/185 | 4 ++-- tests/qemu-iotests/187 | 6 +++--- tests/qemu-iotests/190 | 2 +- tests/qemu-iotests/191 | 6 +++--- tests/qemu-iotests/195 | 2 +- tests/qemu-iotests/197 | 2 +- tests/qemu-iotests/200 | 3 ++- tests/qemu-iotests/215 | 2 +- tests/qemu-iotests/225 | 2 +- tests/qemu-iotests/229 | 3 ++- tests/qemu-iotests/232 | 4 +++- tests/qemu-iotests/243 | 2 +- tests/qemu-iotests/244 | 4 ++-- tests/qemu-iotests/247 | 4 +++- tests/qemu-iotests/249 | 4 ++-- tests/qemu-iotests/252 | 2 +- 58 files changed, 119 insertions(+), 96 deletions(-)tests/qemu-iotests/005 +1
-1@@ -62,7 +62,7 @@ if [ "$IMGFMT" = "raw" ]; then if ! truncate --size=5T "$TEST_IMG"; then _notrun "file system on $TEST_DIR does not support large enough files" fi - rm "$TEST_IMG" + _rm_test_img "$TEST_IMG" fi echotests/qemu-iotests/019 +3
-3@@ -30,9 +30,9 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_IMG.base" - rm -f "$TEST_IMG.orig" + _cleanup_test_img + _rm_test_img "$TEST_IMG.base" + _rm_test_img "$TEST_IMG.orig" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/020 +3
-3@@ -28,9 +28,9 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_IMG.base" - rm -f "$TEST_IMG.orig" + _cleanup_test_img + _rm_test_img "$TEST_IMG.base" + _rm_test_img "$TEST_IMG.orig" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/024 +5
-5@@ -29,12 +29,12 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_DIR/t.$IMGFMT.base_old" - rm -f "$TEST_DIR/t.$IMGFMT.base_new" + _rm_test_img "$TEST_DIR/t.$IMGFMT.base_old" + _rm_test_img "$TEST_DIR/t.$IMGFMT.base_new" - rm -f "$TEST_DIR/subdir/t.$IMGFMT" - rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_old" - rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_new" + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT" + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_old" + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_new" rmdir "$TEST_DIR/subdir" 2> /dev/null } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/028 +1
-1@@ -32,7 +32,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_qemu - rm -f "${TEST_IMG}.copy" + _rm_test_img "${TEST_IMG}.copy" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/029 +1
-1@@ -28,7 +28,7 @@ status=1 # failure is the default! _cleanup() { - rm -f $TEST_IMG.snap + _rm_test_img "$TEST_IMG.snap" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/043 +3
-1@@ -29,7 +29,9 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG".[123].base + for img in "$TEST_IMG".[123].base; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/048 +1
-1@@ -31,7 +31,7 @@ _cleanup() { echo "Cleanup" _cleanup_test_img - rm "${TEST_IMG_FILE2}" + _rm_test_img "${TEST_IMG_FILE2}" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/050 +2
-2@@ -29,8 +29,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.old" - rm -f "$TEST_IMG.new" + _rm_test_img "$TEST_IMG.old" + _rm_test_img "$TEST_IMG.new" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/053 +2
-2@@ -28,8 +28,8 @@ status=1 # failure is the default! _cleanup() { - rm -f "$TEST_IMG.orig" - _cleanup_test_img + _rm_test_img "$TEST_IMG.orig" + _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/058 +1
-1@@ -42,7 +42,7 @@ _cleanup() { nbd_server_stop _cleanup_test_img - rm -f "$converted_image" + _rm_test_img "$converted_image" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/059 +1
-1@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.qcow2" + IMGFMT=qcow2 _rm_test_img "$TEST_IMG.qcow2" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/061 +1
-1@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f $TEST_IMG.data + _rm_test_img "$TEST_IMG.data" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/063 +4
-2@@ -29,8 +29,10 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_IMG.orig" "$TEST_IMG.raw1" "$TEST_IMG.raw2" + _cleanup_test_img + for img in "$TEST_IMG".{orig,raw1,raw2,target}; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/069 +1
-1@@ -47,7 +47,7 @@ echo "=== Creating an image with a backing file and deleting that file ===" echo TEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE _make_test_img -b "$TEST_IMG.base" $IMG_SIZE -rm -f "$TEST_IMG.base" +_rm_test_img "$TEST_IMG.base" # Just open the image and close it right again (this should print an error message) $QEMU_IO -c quit "$TEST_IMG" 2>&1 | _filter_testdir | _filter_imgfmttests/qemu-iotests/074 +1
-1@@ -31,7 +31,7 @@ _cleanup() { echo "Cleanup" _cleanup_test_img - rm "${TEST_IMG2}" + _rm_test_img "${TEST_IMG2}" rm -f "$TEST_DIR/blkdebug.conf" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/080 +1
-1@@ -28,7 +28,7 @@ status=1 # failure is the default! _cleanup() { - rm -f $TEST_IMG.snap + _rm_test_img "$TEST_IMG.snap" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/081 +3
-3@@ -28,9 +28,9 @@ status=1 # failure is the default! _cleanup() { - rm -rf $TEST_DIR/1.raw - rm -rf $TEST_DIR/2.raw - rm -rf $TEST_DIR/3.raw + _rm_test_img "$TEST_DIR/1.raw" + _rm_test_img "$TEST_DIR/2.raw" + _rm_test_img "$TEST_DIR/3.raw" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/085 +6
-3@@ -41,10 +41,13 @@ _cleanup() _cleanup_qemu for i in $(seq 1 ${SNAPSHOTS}) do - rm -f "${TEST_DIR}/${i}-${snapshot_virt0}" - rm -f "${TEST_DIR}/${i}-${snapshot_virt1}" + _rm_test_img "${TEST_DIR}/${i}-${snapshot_virt0}" + _rm_test_img "${TEST_DIR}/${i}-${snapshot_virt1}" + done + for img in "${TEST_IMG}".{1,2,base} + do + _rm_test_img "$img" done - rm -f "${TEST_IMG}" "${TEST_IMG}.1" "${TEST_IMG}.2" "${TEST_IMG}.base" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/088 +1
-1@@ -28,7 +28,7 @@ status=1 # failure is the default! _cleanup() { - rm -f $TEST_IMG.snap + _rm_test_img "$TEST_IMG.snap" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/092 +1
-1@@ -28,7 +28,7 @@ status=1 # failure is the default! _cleanup() { - rm -f $TEST_IMG.snap + _rm_test_img "$TEST_IMG.snap" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/094 +1
-1@@ -30,7 +30,7 @@ _cleanup() { _cleanup_qemu _cleanup_test_img - rm -f "$TEST_DIR/source.$IMGFMT" + _rm_test_img "$TEST_DIR/source.$IMGFMT" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/095 +3
-2@@ -32,8 +32,9 @@ status=1 # failure is the default! _cleanup() { _cleanup_qemu - rm -f "${TEST_IMG}.base" "${TEST_IMG}.snp1" - _cleanup_test_img + _rm_test_img "${TEST_IMG}.base" + _rm_test_img "${TEST_IMG}.snp1" + _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/099 +4
-3@@ -29,7 +29,10 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img + _cleanup_test_img + _rm_test_img "$TEST_IMG.compare" + rm -f "$TEST_DIR/blkdebug.conf" + } trap "_cleanup; exit \$status" 0 1 2 3 15@@ -121,8 +124,6 @@ echo test_qemu "file.driver=blkdebug,file.image.filename=$TEST_IMG" -rm -f "$TEST_IMG.compare" "$TEST_DIR/blkdebug.conf" - # success, all done echo "*** done" rm -f $seq.fulltests/qemu-iotests/109 +2
-2@@ -29,8 +29,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_qemu - rm -f $TEST_IMG.src - _cleanup_test_img + _rm_test_img "$TEST_IMG.src" + _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/110 +2
-2@@ -28,8 +28,8 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_IMG.copy" + _cleanup_test_img + _rm_test_img "$TEST_IMG.copy" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/122 +4
-2@@ -28,8 +28,10 @@ status=1 # failure is the default! _cleanup() { - rm -f "$TEST_IMG".[123] - _cleanup_test_img + for img in "$TEST_IMG".[123]; do + _rm_test_img "$img" + done + _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/123 +1
-1@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$SRC_IMG" + _rm_test_img "$SRC_IMG" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/141 +3
-1@@ -30,7 +30,9 @@ _cleanup() { _cleanup_qemu _cleanup_test_img - rm -f "$TEST_DIR"/{b,m,o}.$IMGFMT + for img in "$TEST_DIR"/{b,m,o}.$IMGFMT; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/142 +1
-1@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f $TEST_IMG.snap + _rm_test_img "$TEST_IMG.snap" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/144 +3
-1@@ -34,7 +34,9 @@ TMP_SNAP2=${TEST_DIR}/tmp2.qcow2 _cleanup() { _cleanup_qemu - rm -f "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}" + for img in "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}"; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/153 +3
-7@@ -30,13 +30,9 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "${TEST_IMG}.base" - rm -f "${TEST_IMG}.overlay" - rm -f "${TEST_IMG}.convert" - rm -f "${TEST_IMG}.a" - rm -f "${TEST_IMG}.b" - rm -f "${TEST_IMG}.c" - rm -f "${TEST_IMG}.lnk" + for img in "${TEST_IMG}".{base,overlay,convert,a,b,c,lnk}; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/156 +6
-2@@ -37,7 +37,9 @@ status=1 # failure is the default! _cleanup() { _cleanup_qemu - rm -f "$TEST_IMG"{,.target}{,.backing,.overlay} + for img in "$TEST_IMG"{,.target}{,.backing,.overlay}; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15@@ -120,7 +122,9 @@ _send_qemu_cmd $QEMU_HANDLE \ '"status": "null"' # Remove the source images -rm -f "$TEST_IMG{,.backing,.overlay}" +for img in "$TEST_IMG{,.backing,.overlay}"; do + _rm_test_img "$img" +done echotests/qemu-iotests/159 +1
-1@@ -28,7 +28,7 @@ status=1 _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.out" + _rm_test_img "$TEST_IMG.out" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/160 +2
-1@@ -28,7 +28,8 @@ status=1 _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.out" "$TEST_IMG.out.dd" + _rm_test_img "$TEST_IMG.out" + _rm_test_img "$TEST_IMG.out.dd" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/161 +2
-2@@ -30,8 +30,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.base" - rm -f "$TEST_IMG.int" + _rm_test_img "$TEST_IMG.base" + _rm_test_img "$TEST_IMG.int" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/170 +1
-1@@ -28,7 +28,7 @@ status=1 _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.out" + _rm_test_img "$TEST_IMG.out" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/172 +3
-3@@ -28,9 +28,9 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_IMG.2" - rm -f "$TEST_IMG.3" + _cleanup_test_img + _rm_test_img "$TEST_IMG.2" + _rm_test_img "$TEST_IMG.3" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/173 +2
-1@@ -29,7 +29,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_qemu - rm -f "${QEMU_TEST_DIR}/image.base" "${QEMU_TEST_DIR}/image.snp1" + _rm_test_img "${TEST_DIR}/image.base" + _rm_test_img "${TEST_DIR}/image.snp1" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/178 +1
-1@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.converted" + _rm_test_img "$TEST_IMG.converted" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/182 +1
-1@@ -30,7 +30,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.overlay" + _rm_test_img "$TEST_IMG.overlay" rm -f "$TEST_DIR/nbd.socket" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/183 +1
-1@@ -31,7 +31,7 @@ MIG_SOCKET="${TEST_DIR}/migrate" _cleanup() { rm -f "${MIG_SOCKET}" - rm -f "${TEST_IMG}.dest" + _rm_test_img "${TEST_IMG}.dest" _cleanup_test_img _cleanup_qemu }tests/qemu-iotests/185 +2
-2@@ -28,8 +28,8 @@ status=1 # failure is the default! _cleanup() { - rm -f "${TEST_IMG}.mid" - rm -f "${TEST_IMG}.copy" + _rm_test_img "${TEST_IMG}.mid" + _rm_test_img "${TEST_IMG}.copy" _cleanup_test_img _cleanup_qemu }tests/qemu-iotests/187 +3
-3@@ -28,9 +28,9 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_IMG.2" - rm -f "$TEST_IMG.3" + _cleanup_test_img + _rm_test_img "$TEST_IMG.2" + _rm_test_img "$TEST_IMG.3" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/190 +1
-1@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.converted" + _rm_test_img "$TEST_IMG.converted" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/191 +3
-3@@ -28,9 +28,9 @@ status=1 # failure is the default! _cleanup() { - rm -f "${TEST_IMG}.mid" - rm -f "${TEST_IMG}.ovl2" - rm -f "${TEST_IMG}.ovl3" + _rm_test_img "${TEST_IMG}.mid" + _rm_test_img "${TEST_IMG}.ovl2" + _rm_test_img "${TEST_IMG}.ovl3" _cleanup_test_img _cleanup_qemu }tests/qemu-iotests/195 +1
-1@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.mid" + _rm_test_img "$TEST_IMG.mid" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/197 +1
-1@@ -43,7 +43,7 @@ esac _cleanup() { _cleanup_test_img - rm -f "$TEST_WRAP" + _rm_test_img "$TEST_WRAP" rm -f "$BLKDBG_CONF" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/200 +2
-1@@ -31,7 +31,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_qemu - rm -f "${TEST_IMG}" "${BACKING_IMG}" + _rm_test_img "${TEST_IMG}" + _rm_test_img "${BACKING_IMG}" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/215 +1
-1@@ -40,7 +40,7 @@ esac _cleanup() { _cleanup_test_img - rm -f "$TEST_WRAP" + _rm_test_img "$TEST_WRAP" rm -f "$BLKDBG_CONF" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/225 +1
-1@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.not_base" + _rm_test_img "$TEST_IMG.not_base" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/229 +2
-1@@ -31,7 +31,8 @@ _cleanup() { _cleanup_qemu _cleanup_test_img - rm -f "$TEST_IMG" "$DEST_IMG" + _rm_test_img "$TEST_IMG" + _rm_test_img "$DEST_IMG" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/232 +3
-1@@ -29,7 +29,9 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f $TEST_IMG.[01234] + for img in "$TEST_IMG".[01234]; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/243 +1
-1@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f $TEST_IMG.data + _rm_test_img "$TEST_IMG.data" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/244 +2
-2@@ -29,8 +29,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f $TEST_IMG.data - rm -f $TEST_IMG.src + _rm_test_img "$TEST_IMG.data" + _rm_test_img "$TEST_IMG.src" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/247 +3
-1@@ -29,7 +29,9 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f $TEST_IMG.[01234] + for img in "$TEST_IMG".[01234]; do + _rm_test_img "$img" + done } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/249 +2
-2@@ -30,8 +30,8 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.base" - rm -f "$TEST_IMG.int" + _rm_test_img "$TEST_IMG.base" + _rm_test_img "$TEST_IMG.int" } trap "_cleanup; exit \$status" 0 1 2 3 15tests/qemu-iotests/252 +0
-0
tests/qemu-iotests/252 status=1 # failure is the default! · line 35
Quoted 8 lines
tests/qemu-iotests/252 +1
-1@@ -29,7 +29,7 @@ status=1 # failure is the default! _cleanup() { _cleanup_test_img - rm -f "$TEST_IMG.base_new" + _rm_test_img "$TEST_IMG.base_new" } trap "_cleanup; exit \$status" 0 1 2 3 15
The patch is large, thus I can't be sure I can check all of it, but overall looks good to me.
Best regards,
Maxim Levitsky
PATCH 12/18 iotests: Avoid cp/mv of test images
In reply to Max ReitzThis will not work with external data files, so try to get tests working without it as far as possible.
--- tests/qemu-iotests/063 | 12 ++++-------- tests/qemu-iotests/063.out | 3 ++- tests/qemu-iotests/085 | 9 +++------ tests/qemu-iotests/085.out | 8 ++++---- 4 files changed, 13 insertions(+), 19 deletions(-)
tests/qemu-iotests/063 +4 -8
@@ -51,15 +51,13 @@ _unsupported_imgopts "subformat=monolithicFlat" \ _make_test_img 4M echo "== Testing conversion with -n fails with no target file ==" -# check .orig file does not exist -rm -f "$TEST_IMG.orig" if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" >/dev/null 2>&1; then exit 1 fi echo "== Testing conversion with -n succeeds with a target file ==" -rm -f "$TEST_IMG.orig" -cp "$TEST_IMG" "$TEST_IMG.orig" +_rm_test_img "$TEST_IMG.orig" +TEST_IMG="$TEST_IMG.orig" _make_test_img 4M if ! $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" ; then exit 1 fi
@@ -85,10 +83,8 @@ fi _check_test_img echo "== Testing conversion to a smaller file fails ==" -rm -f "$TEST_IMG.orig" -mv "$TEST_IMG" "$TEST_IMG.orig" -_make_test_img 2M -if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG.orig" "$TEST_IMG" >/dev/null 2>&1; then +TEST_IMG="$TEST_IMG.target" _make_test_img 2M +if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.target" >/dev/null 2>&1; then exit 1 fi
tests/qemu-iotests/063.out +2 -1
@@ -2,11 +2,12 @@ QA output created by 063 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304 == Testing conversion with -n fails with no target file == == Testing conversion with -n succeeds with a target file == +Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=IMGFMT size=4194304 == Testing conversion to raw is the same after conversion with -n == == Testing conversion back to original format == No errors were found on the image. == Testing conversion to a smaller file fails == -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152 +Formatting 'TEST_DIR/t.IMGFMT.target', fmt=IMGFMT size=2097152 == Regression testing for copy offloading bug == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 Formatting 'TEST_DIR/t.IMGFMT.target', fmt=IMGFMT size=1048576
tests/qemu-iotests/085 +3 -6
@@ -105,8 +105,7 @@ add_snapshot_image() { base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}" snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}" - _make_test_img -u -b "${base_image}" "$size" - mv "${TEST_IMG}" "${snapshot_file}" + TEST_IMG=$snapshot_file _make_test_img -u -b "${base_image}" "$size" do_blockdev_add "$1" "'backing': null, " "${snapshot_file}" }
@@ -122,10 +121,8 @@ blockdev_snapshot() size=128M -_make_test_img $size -mv "${TEST_IMG}" "${TEST_IMG}.1" -_make_test_img $size -mv "${TEST_IMG}" "${TEST_IMG}.2" +TEST_IMG="$TEST_IMG.1" _make_test_img $size +TEST_IMG="$TEST_IMG.2" _make_test_img $size echo echo === Running QEMU ===
tests/qemu-iotests/085.out +4 -4
@@ -1,6 +1,6 @@ QA output created by 085 -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 +Formatting 'TEST_DIR/t.IMGFMT.1', fmt=IMGFMT size=134217728 +Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=134217728 === Running QEMU ===
@@ -55,10 +55,10 @@ Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_fil === Create a couple of snapshots using blockdev-snapshot === -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT +Formatting 'TEST_DIR/11-snapshot-v0.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT {"return": {}} {"return": {}} -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT +Formatting 'TEST_DIR/12-snapshot-v0.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT {"return": {}} {"return": {}}
Signature · 1 line
2.21.0
Re: [PATCH 12/18] iotests: Avoid cp/mv of test images
Quoted 107 lines · Max Reitz
This will not work with external data files, so try to get tests working without it as far as possible.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/063 | 12 ++++-------- tests/qemu-iotests/063.out | 3 ++- tests/qemu-iotests/085 | 9 +++------ tests/qemu-iotests/085.out | 8 ++++---- 4 files changed, 13 insertions(+), 19 deletions(-)tests/qemu-iotests/063 +4
-8@@ -51,15 +51,13 @@ _unsupported_imgopts "subformat=monolithicFlat" \ _make_test_img 4M echo "== Testing conversion with -n fails with no target file ==" -# check .orig file does not exist -rm -f "$TEST_IMG.orig" if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" >/dev/null 2>&1; then exit 1 fi echo "== Testing conversion with -n succeeds with a target file ==" -rm -f "$TEST_IMG.orig" -cp "$TEST_IMG" "$TEST_IMG.orig" +_rm_test_img "$TEST_IMG.orig" +TEST_IMG="$TEST_IMG.orig" _make_test_img 4M if ! $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" ; then exit 1 fi@@ -85,10 +83,8 @@ fi _check_test_img echo "== Testing conversion to a smaller file fails ==" -rm -f "$TEST_IMG.orig" -mv "$TEST_IMG" "$TEST_IMG.orig" -_make_test_img 2M -if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG.orig" "$TEST_IMG" >/dev/null 2>&1; then +TEST_IMG="$TEST_IMG.target" _make_test_img 2M +if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.target" >/dev/null 2>&1; then exit 1 fitests/qemu-iotests/063.out +2
-1@@ -2,11 +2,12 @@ QA output created by 063 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304 == Testing conversion with -n fails with no target file == == Testing conversion with -n succeeds with a target file == +Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=IMGFMT size=4194304 == Testing conversion to raw is the same after conversion with -n == == Testing conversion back to original format == No errors were found on the image. == Testing conversion to a smaller file fails == -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152 +Formatting 'TEST_DIR/t.IMGFMT.target', fmt=IMGFMT size=2097152 == Regression testing for copy offloading bug == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 Formatting 'TEST_DIR/t.IMGFMT.target', fmt=IMGFMT size=1048576tests/qemu-iotests/085 +3
-6@@ -105,8 +105,7 @@ add_snapshot_image() { base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}" snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}" - _make_test_img -u -b "${base_image}" "$size" - mv "${TEST_IMG}" "${snapshot_file}" + TEST_IMG=$snapshot_file _make_test_img -u -b "${base_image}" "$size" do_blockdev_add "$1" "'backing': null, " "${snapshot_file}" }@@ -122,10 +121,8 @@ blockdev_snapshot() size=128M -_make_test_img $size -mv "${TEST_IMG}" "${TEST_IMG}.1" -_make_test_img $size -mv "${TEST_IMG}" "${TEST_IMG}.2" +TEST_IMG="$TEST_IMG.1" _make_test_img $size +TEST_IMG="$TEST_IMG.2" _make_test_img $size echo echo === Running QEMU ===tests/qemu-iotests/085.out +2
-2@@ -1,6 +1,6 @@ QA output created by 085 -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 +Formatting 'TEST_DIR/t.IMGFMT.1', fmt=IMGFMT size=134217728 +Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=134217728 === Running QEMU ===@@ -55,10 +55,10 @@ Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_fil === Create a couple of snapshots using blockdev-snapshot ===
tests/qemu-iotests/085.out Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_fil · line 64
Quoted 10 lines
tests/qemu-iotests/085.out +2
-2-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT +Formatting 'TEST_DIR/11-snapshot-v0.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT {"return": {}} {"return": {}} -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT +Formatting 'TEST_DIR/12-snapshot-v0.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT {"return": {}} {"return": {}}
Looks good.
PATCH 13/18 iotests: Make 091 work with data_file
In reply to Max ReitzThe image end offset as reported by qemu-img check is different when using an external data file; we do not care about its value here, so we can just filter it.
--- tests/qemu-iotests/091 | 3 ++- tests/qemu-iotests/091.out | 1 - 2 files changed, 2 insertions(+), 2 deletions(-)
tests/qemu-iotests/091 +2 -1
@@ -101,7 +101,8 @@ echo "Check image pattern" ${QEMU_IO} -c "read -P 0x22 0 4M" "${TEST_IMG}" | _filter_testdir | _filter_qemu_io echo "Running 'qemu-img check -r all \$TEST_IMG'" -"${QEMU_IMG}" check -r all "${TEST_IMG}" 2>&1 | _filter_testdir | _filter_qemu +"${QEMU_IMG}" check -r all "${TEST_IMG}" 2>&1 | _filter_testdir | _filter_qemu \ + | sed '/Image end offset/d' echo "*** done" rm -f $seq.full
tests/qemu-iotests/091.out +0 -1
@@ -24,5 +24,4 @@ read 4194304/4194304 bytes at offset 0 Running 'qemu-img check -r all $TEST_IMG' No errors were found on the image. 80/16384 = 0.49% allocated, 0.00% fragmented, 0.00% compressed clusters -Image end offset: 5570560 *** done
Signature · 1 line
2.21.0
Re: [PATCH 13/18] iotests: Make 091 work with data_file
Quoted 15 lines · Max Reitz
The image end offset as reported by qemu-img check is different when using an external data file; we do not care about its value here, so we can just filter it.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/091 | 3 ++- tests/qemu-iotests/091.out | 1 - 2 files changed, 2 insertions(+), 2 deletions(-)tests/qemu-iotests/091 +0
-0
tests/qemu-iotests/091 echo "Check image pattern" · line 105
Quoted 6 lines
tests/qemu-iotests/091 +2
-1@@ -101,7 +101,8 @@ echo "Check image pattern" ${QEMU_IO} -c "read -P 0x22 0 4M" "${TEST_IMG}" | _filter_testdir | _filter_qemu_io echo "Running 'qemu-img check -r all \$TEST_IMG'" -"${QEMU_IMG}" check -r all "${TEST_IMG}" 2>&1 | _filter_testdir | _filter_qemu +"${QEMU_IMG}" check -r all "${TEST_IMG}" 2>&1 | _filter_testdir | _filter_qemu \ + | sed '/Image end offset/d'
Maybe use _filter_qemu_img_check instead? I see it actually filters this already.
tests/qemu-iotests/091.out read 4194304/4194304 bytes at offset 0 · line 27
Quoted 13 lines
tests/qemu-iotests/091 +0
-0echo "*** done" rm -f $seq.fulltests/qemu-iotests/091.out +0
-1@@ -24,5 +24,4 @@ read 4194304/4194304 bytes at offset 0 Running 'qemu-img check -r all $TEST_IMG' No errors were found on the image. 80/16384 = 0.49% allocated, 0.00% fragmented, 0.00% compressed clusters -Image end offset: 5570560 *** done
Best regards,
Maxim Levitsky
Re: [PATCH 13/18] iotests: Make 091 work with data_file
Quoted 18 lines · Maxim Levitsky
Quoted 17 lines · Max Reitz
The image end offset as reported by qemu-img check is different when using an external data file; we do not care about its value here, so we can just filter it.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/091 | 3 ++- tests/qemu-iotests/091.out | 1 - 2 files changed, 2 insertions(+), 2 deletions(-)tests/qemu-iotests/091 +0
-0@@ -101,7 +101,8 @@ echo "Check image pattern" ${QEMU_IO} -c "read -P 0x22 0 4M" "${TEST_IMG}" | _filter_testdir | _filter_qemu_io
Quoted 6 lines
tests/qemu-iotests/091 echo "Check image pattern" · line 105
Quoted 4 lines
tests/qemu-iotests/091 +2
-1echo "Running 'qemu-img check -r all \$TEST_IMG'" -"${QEMU_IMG}" check -r all "${TEST_IMG}" 2>&1 | _filter_testdir | _filter_qemu +"${QEMU_IMG}" check -r all "${TEST_IMG}" 2>&1 | _filter_testdir | _filter_qemu \ + | sed '/Image end offset/d'Maybe use
_filter_qemu_img_checkinstead? I see it actually filters this already.
Uh, nice. Will do, thanks.
Max
PATCH 14/18 iotests: Make 110 work with data_file
In reply to Max ReitzThe only difference is that the json:{} filename of the image looks different. We actually do not care about that filename in this test, we are only interested in (1) that there is a json:{} filename, and (2) whether the backing filename can be constructed.
So just filter out the json:{} data, thus making this test pass both with and without data_file.
--- tests/qemu-iotests/110 | 7 +++++-- tests/qemu-iotests/110.out | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-)
tests/qemu-iotests/110 +5 -2
@@ -67,6 +67,7 @@ echo # Across blkdebug without a config file, you cannot reconstruct filenames, so # qemu is incapable of knowing the directory of the top image from the filename # alone. However, using bdrv_dirname(), it should still work. +# (Filter out the json:{} filename so this test works with external data files) TEST_IMG="json:{ 'driver': '$IMGFMT', 'file': {
@@ -82,7 +83,8 @@ TEST_IMG="json:{ } ] } -}" _img_info | _filter_img_info | grep -v 'backing file format' +}" _img_info | _filter_img_info | grep -v 'backing file format' \ + | sed -e 's#^image: json:.*#image: json:{ /* filtered */ }#' echo echo '=== Backing name is always relative to the backed image ==='
@@ -114,7 +116,8 @@ TEST_IMG="json:{ } ] } -}" _img_info | _filter_img_info | grep -v 'backing file format' +}" _img_info | _filter_img_info | grep -v 'backing file format' \ + | sed -e 's#^image: json:.*#image: json:{ /* filtered */ }#' # success, all done
tests/qemu-iotests/110.out +2 -2
@@ -11,7 +11,7 @@ backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base) === Non-reconstructable filename === -image: json:{"driver": "IMGFMT", "file": {"set-state.0.event": "read_aio", "image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "set-state.0.new_state": 42}} +image: json:{ /* filtered */ } file format: IMGFMT virtual size: 64 MiB (67108864 bytes) backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base)
@@ -22,7 +22,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=t.IMGFMT.b === Nodes without a common directory === -image: json:{"driver": "IMGFMT", "file": {"children": [{"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.copy"}], "driver": "quorum", "vote-threshold": 1}} +image: json:{ /* filtered */ } file format: IMGFMT virtual size: 64 MiB (67108864 bytes) backing file: t.IMGFMT.base (cannot determine actual path)
Signature · 1 line
2.21.0
Re: [PATCH 14/18] iotests: Make 110 work with data_file
Quoted 68 lines · Max Reitz
The only difference is that the json:{} filename of the image looks different. We actually do not care about that filename in this test, we are only interested in (1) that there is a json:{} filename, and (2) whether the backing filename can be constructed.
So just filter out the json:{} data, thus making this test pass both with and without
data_file.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/110 | 7 +++++-- tests/qemu-iotests/110.out | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-)tests/qemu-iotests/110 +5
-2@@ -67,6 +67,7 @@ echo # Across blkdebug without a config file, you cannot reconstruct filenames, so # qemu is incapable of knowing the directory of the top image from the filename # alone. However, using bdrv_dirname(), it should still work. +# (Filter out the json:{} filename so this test works with external data files) TEST_IMG="json:{ 'driver': '$IMGFMT', 'file': {@@ -82,7 +83,8 @@ TEST_IMG="json:{ } ] } -}" _img_info | _filter_img_info | grep -v 'backing file format' +}" _img_info | _filter_img_info | grep -v 'backing file format' \ + | sed -e 's#^image: json:.*#image: json:{ /* filtered */ }#' echo echo '=== Backing name is always relative to the backed image ==='@@ -114,7 +116,8 @@ TEST_IMG="json:{ } ] } -}" _img_info | _filter_img_info | grep -v 'backing file format' +}" _img_info | _filter_img_info | grep -v 'backing file format' \ + | sed -e 's#^image: json:.*#image: json:{ /* filtered */ }#' # success, all donetests/qemu-iotests/110.out +2
-2@@ -11,7 +11,7 @@ backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base) === Non-reconstructable filename === -image: json:{"driver": "IMGFMT", "file": {"set-state.0.event": "read_aio", "image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "set-state.0.new_state": 42}} +image: json:{ /* filtered */ } file format: IMGFMT virtual size: 64 MiB (67108864 bytes) backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base)@@ -22,7 +22,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=t.IMGFMT.b === Nodes without a common directory === -image: json:{"driver": "IMGFMT", "file": {"children": [{"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.copy"}], "driver": "quorum", "vote- threshold": 1}} +image: json:{ /* filtered */ } file format: IMGFMT virtual size: 64 MiB (67108864 bytes)
Quoted 1 line
backing file: t.IMGFMT.base (cannot determine actual path)
Again, maybe put that into the common.filter, so new tests won't need to copy&paste this? Also maybe remove the image name completely from output, thus not needing the more complex regex?
Best regards,
Maxim Levitsky
Re: [PATCH 14/18] iotests: Make 110 work with data_file
Quoted 64 lines · Maxim Levitsky
Quoted 63 lines · Max Reitz
The only difference is that the json:{} filename of the image looks different. We actually do not care about that filename in this test, we are only interested in (1) that there is a json:{} filename, and (2) whether the backing filename can be constructed.
So just filter out the json:{} data, thus making this test pass both with and without
data_file.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/110 | 7 +++++-- tests/qemu-iotests/110.out | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-)tests/qemu-iotests/110 +5
-2@@ -67,6 +67,7 @@ echo # Across blkdebug without a config file, you cannot reconstruct filenames, so # qemu is incapable of knowing the directory of the top image from the filename # alone. However, using bdrv_dirname(), it should still work. +# (Filter out the json:{} filename so this test works with external data files) TEST_IMG="json:{ 'driver': '$IMGFMT', 'file': {@@ -82,7 +83,8 @@ TEST_IMG="json:{ } ] } -}" _img_info | _filter_img_info | grep -v 'backing file format' +}" _img_info | _filter_img_info | grep -v 'backing file format' \ + | sed -e 's#^image: json:.*#image: json:{ /* filtered */ }#' echo echo '=== Backing name is always relative to the backed image ==='@@ -114,7 +116,8 @@ TEST_IMG="json:{ } ] } -}" _img_info | _filter_img_info | grep -v 'backing file format' +}" _img_info | _filter_img_info | grep -v 'backing file format' \ + | sed -e 's#^image: json:.*#image: json:{ /* filtered */ }#' # success, all donetests/qemu-iotests/110.out +1
-1@@ -11,7 +11,7 @@ backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base) === Non-reconstructable filename === -image: json:{"driver": "IMGFMT", "file": {"set-state.0.event": "read_aio", "image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "set-state.0.new_state": 42}} +image: json:{ /* filtered */ } file format: IMGFMT virtual size: 64 MiB (67108864 bytes) backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base)@@ -22,7 +22,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=t.IMGFMT.b === Nodes without a common directory ===
Quoted 8 lines
Quoted 6 lines
tests/qemu-iotests/110.out +1
-1-image: json:{"driver": "IMGFMT", "file": {"children": [{"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.copy"}], "driver": "quorum", "vote- threshold": 1}} +image: json:{ /* filtered */ } file format: IMGFMT virtual size: 64 MiB (67108864 bytes)backing file: t.IMGFMT.base (cannot determine actual path)
Again, maybe put that into the common.filter, so new tests won't need to copy&paste this?
Good idea.
Quoted 1 line
Also maybe remove the image name completely from output, thus not needing the more complex regex?
I’d prefer to still see that there is a json:{} filename instead of a plain one. (This is important in this test because for plain filenames, it’s generally easy to reconstruct the backing file path; it’s only difficult for json:{} filenames.)
Max
Re: [PATCH 14/18] iotests: Make 110 work with data_file
Quoted 74 lines · Max Reitz
Quoted 64 lines · Maxim Levitsky
Quoted 63 lines · Max Reitz
The only difference is that the json:{} filename of the image looks different. We actually do not care about that filename in this test, we are only interested in (1) that there is a json:{} filename, and (2) whether the backing filename can be constructed.
So just filter out the json:{} data, thus making this test pass both with and without
data_file.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/110 | 7 +++++-- tests/qemu-iotests/110.out | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-)tests/qemu-iotests/110 +5
-2@@ -67,6 +67,7 @@ echo # Across blkdebug without a config file, you cannot reconstruct filenames, so # qemu is incapable of knowing the directory of the top image from the filename # alone. However, using bdrv_dirname(), it should still work. +# (Filter out the json:{} filename so this test works with external data files) TEST_IMG="json:{ 'driver': '$IMGFMT', 'file': {@@ -82,7 +83,8 @@ TEST_IMG="json:{ } ] } -}" _img_info | _filter_img_info | grep -v 'backing file format' +}" _img_info | _filter_img_info | grep -v 'backing file format' \ + | sed -e 's#^image: json:.*#image: json:{ /* filtered */ }#' echo echo '=== Backing name is always relative to the backed image ==='@@ -114,7 +116,8 @@ TEST_IMG="json:{ } ] } -}" _img_info | _filter_img_info | grep -v 'backing file format' +}" _img_info | _filter_img_info | grep -v 'backing file format' \ + | sed -e 's#^image: json:.*#image: json:{ /* filtered */ }#' # success, all donetests/qemu-iotests/110.out +1
-1@@ -11,7 +11,7 @@ backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base) === Non-reconstructable filename === -image: json:{"driver": "IMGFMT", "file": {"set-state.0.event": "read_aio", "image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "set-state.0.new_state": 42}} +image: json:{ /* filtered */ } file format: IMGFMT virtual size: 64 MiB (67108864 bytes) backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base)@@ -22,7 +22,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=t.IMGFMT.b === Nodes without a common directory ===Quoted 8 lines
Quoted 6 lines
tests/qemu-iotests/110.out +1
-1-image: json:{"driver": "IMGFMT", "file": {"children": [{"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.copy"}], "driver": "quorum", "vote- threshold": 1}} +image: json:{ /* filtered */ } file format: IMGFMT virtual size: 64 MiB (67108864 bytes)backing file: t.IMGFMT.base (cannot determine actual path)
Again, maybe put that into the common.filter, so new tests won't need to copy&paste this?
Quoted 8 lines
Good idea.
Quoted 1 line
Also maybe remove the image name completely from output, thus not needing the more complex regex?
I’d prefer to still see that there is a json:{} filename instead of a plain one. (This is important in this test because for plain filenames, it’s generally easy to reconstruct the backing file path; it’s only difficult for json:{} filenames.)
All right, seems good.
Best regards,
Maxim Levitsky
Quoted 3 lines
Max
PATCH 15/18 iotests: Make 137 work with data_file
In reply to Max ReitzWhen using an external data file, there are no refcounts for data clusters. We thus have to adjust the corruption test in this patch to not be based around a data cluster allocation, but the L2 table allocation (L2 tables are still refcounted with external data files).
Doing so means this test works both with and without external data files.
--- tests/qemu-iotests/137 | 10 ++++++---- tests/qemu-iotests/137.out | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-)
tests/qemu-iotests/137 +6 -4
@@ -138,14 +138,16 @@ $QEMU_IO \ "$TEST_IMG" 2>&1 | _filter_qemu_io # The dirty bit must not be set -$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +# (Filter the external data file bit) +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features \ + | sed -e 's/0x4/0x0/' # Similarly we can test whether corruption detection has been enabled: -# Create L1/L2, overwrite first entry in refcount block, allocate something. +# Create L1, overwrite refcounts, force allocation of L2 by writing +# data. # Disabling the checks should fail, so the corruption must be detected. _make_test_img 64M -$QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io -poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00" +poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00\x00\x00\x00\x00\x00\x00" $QEMU_IO \ -c "reopen -o overlap-check=none,lazy-refcounts=42" \ -c "write 64k 64k" \
tests/qemu-iotests/137.out +1 -3
@@ -38,9 +38,7 @@ wrote 512/512 bytes at offset 0 ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) incompatible_features 0x0 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 -wrote 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) qemu-io: Parameter 'lazy-refcounts' expects 'on' or 'off' -qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with qcow2_header); further corruption events will be suppressed +qcow2: Marking image as corrupt: Preventing invalid allocation of L2 table at offset 0; further corruption events will be suppressed write failed: Input/output error *** done
Signature · 1 line
2.21.0
Re: [PATCH 15/18] iotests: Make 137 work with data_file
Quoted 19 lines · Max Reitz
When using an external data file, there are no refcounts for data clusters. We thus have to adjust the corruption test in this patch to not be based around a data cluster allocation, but the L2 table allocation (L2 tables are still refcounted with external data files).
Doing so means this test works both with and without external data files.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/137 | 10 ++++++---- tests/qemu-iotests/137.out | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-)tests/qemu-iotests/137 +0
-0
tests/qemu-iotests/137 $QEMU_IO \ · line 143
Quoted 7 lines
tests/qemu-iotests/137 +3
-1@@ -138,14 +138,16 @@ $QEMU_IO \ "$TEST_IMG" 2>&1 | _filter_qemu_io # The dirty bit must not be set -$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +# (Filter the external data file bit) +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features \ + | sed -e 's/0x4/0x0/'
Maybe it is better to filter all the feature bits, but the dirty bit, since only it is needed here, so that when we start running tests with more features, we won't need to do this again?
tests/qemu-iotests/137 $QEMU_IO \ · line 150
Quoted 10 lines
tests/qemu-iotests/137 +3
-3# Similarly we can test whether corruption detection has been enabled: -# Create L1/L2, overwrite first entry in refcount block, allocate something. +# Create L1, overwrite refcounts, force allocation of L2 by writing +# data. # Disabling the checks should fail, so the corruption must be detected. _make_test_img 64M -$QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io -poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00" +poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00\x00\x00\x00\x00\x00\x00"
I am wondering if there is any better way to do this (regardless of this patch), Basically the above code pokes into the 3rd cluster on the disk I *think*, and I don't understand why it has to contain refcounts. Hmm...
First cluster I can guess will have the header, 2nd cluster probably L1 table, and 3rd, refcounts? If so, the test should specify that it needs 64K clusters, because the day will come when we will need to test this as well, but I guess in a separate patch,
Quoted 8 lines
tests/qemu-iotests/137 +0
-0$QEMU_IO \ -c "reopen -o overlap-check=none,lazy-refcounts=42" \ -c "write 64k 64k" \tests/qemu-iotests/137.out +0
-0
tests/qemu-iotests/137.out wrote 512/512 bytes at offset 0 · line 44
Quoted 10 lines
tests/qemu-iotests/137.out +1
-3@@ -38,9 +38,7 @@ wrote 512/512 bytes at offset 0 ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) incompatible_features 0x0 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 -wrote 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) qemu-io: Parameter 'lazy-refcounts' expects 'on' or 'off' -qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with qcow2_header); further corruption events will be suppressed +qcow2: Marking image as corrupt: Preventing invalid allocation of L2 table at offset 0; further corruption events will be suppressed write failed: Input/output error *** done
Best regards,
Maxim Levitsky
Re: [PATCH 15/18] iotests: Make 137 work with data_file
Quoted 22 lines · Maxim Levitsky
Quoted 21 lines · Max Reitz
When using an external data file, there are no refcounts for data clusters. We thus have to adjust the corruption test in this patch to not be based around a data cluster allocation, but the L2 table allocation (L2 tables are still refcounted with external data files).
Doing so means this test works both with and without external data files.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/137 | 10 ++++++---- tests/qemu-iotests/137.out | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-)tests/qemu-iotests/137 +0
-0@@ -138,14 +138,16 @@ $QEMU_IO \ "$TEST_IMG" 2>&1 | _filter_qemu_io
Quoted 8 lines
tests/qemu-iotests/137 $QEMU_IO \ · line 143
Quoted 5 lines
tests/qemu-iotests/137 +3
-1# The dirty bit must not be set -$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +# (Filter the external data file bit) +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features \ + | sed -e 's/0x4/0x0/'Maybe it is better to filter all the feature bits, but the dirty bit, since only it is needed here, so that when we start running tests with more features, we won't need to do this again?
I’d hate a filter s/[02468ace]$/no dirty bit/ though.
Quoted 17 lines
tests/qemu-iotests/137 $QEMU_IO \ · line 150
Quoted 10 lines
tests/qemu-iotests/137 +3
-3# Similarly we can test whether corruption detection has been enabled: -# Create L1/L2, overwrite first entry in refcount block, allocate something. +# Create L1, overwrite refcounts, force allocation of L2 by writing +# data. # Disabling the checks should fail, so the corruption must be detected. _make_test_img 64M -$QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io -poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00" +poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00\x00\x00\x00\x00\x00\x00"I am wondering if there is any better way to do this (regardless of this patch), Basically the above code pokes into the 3rd cluster on the disk I *think*, and I don't understand why it has to contain refcounts. Hmm...
First cluster I can guess will have the header, 2nd cluster probably L1 table, and 3rd, refcounts? If so, the test should specify that it needs 64K clusters, because the day will come when we will need to test this as well, but I guess in a separate patch,
When that day comes, a whole lot of other stuff will break, too.
Max
Re: [PATCH 15/18] iotests: Make 137 work with data_file
Quoted 33 lines · Max Reitz
Quoted 22 lines · Maxim Levitsky
Quoted 21 lines · Max Reitz
When using an external data file, there are no refcounts for data clusters. We thus have to adjust the corruption test in this patch to not be based around a data cluster allocation, but the L2 table allocation (L2 tables are still refcounted with external data files).
Doing so means this test works both with and without external data files.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/137 | 10 ++++++---- tests/qemu-iotests/137.out | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-)tests/qemu-iotests/137 +0
-0@@ -138,14 +138,16 @@ $QEMU_IO \ "$TEST_IMG" 2>&1 | _filter_qemu_ioQuoted 9 lines
tests/qemu-iotests/137 $QEMU_IO \ · line 143
Quoted 5 lines
tests/qemu-iotests/137 +3
-1# The dirty bit must not be set -$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +# (Filter the external data file bit) +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features \ + | sed -e 's/0x4/0x0/'Maybe it is better to filter all the feature bits, but the dirty bit, since only it is needed here, so that when we start running tests with more features, we won't need to do this again?
Quoted 1 line
I’d hate a filter s/[02468ace]$/no dirty bit/ though.
Nothing a helper function can't solve IMHO, I would convert this to a number, and then check bitwise the bit 2, assuming that is the dirty bit) Again, note that my approach to code is to make it as easy as possible for the next guy to change, so I am noticing such places. Eventually someone of us, will be that next guy. Then again, I don't mind leaving this as is, just noting this.
Quoted 19 lines
Quoted 18 lines
tests/qemu-iotests/137 $QEMU_IO \ · line 150
Quoted 11 lines
tests/qemu-iotests/137 +3
-3# Similarly we can test whether corruption detection has been enabled: -# Create L1/L2, overwrite first entry in refcount block, allocate something. +# Create L1, overwrite refcounts, force allocation of L2 by writing +# data. # Disabling the checks should fail, so the corruption must be detected. _make_test_img 64M -$QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io -poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00" +poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00\x00\x00\x00\x00\x00\x00"I am wondering if there is any better way to do this (regardless of this patch), Basically the above code pokes into the 3rd cluster on the disk I *think*, and I don't understand why it has to contain refcounts. Hmm...
First cluster I can guess will have the header, 2nd cluster probably L1 table, and 3rd, refcounts? If so, the test should specify that it needs 64K clusters, because the day will come when we will need to test this as well, but I guess in a separate patch,
Quoted 1 line
When that day comes, a whole lot of other stuff will break, too.
I guess so, won't argue about this one.
Best regards,
Maxim Levitsky
Quoted 3 lines
Max
Re: [PATCH 15/18] iotests: Make 137 work with data_file
Quoted 34 lines · Maxim Levitsky
Quoted 33 lines · Max Reitz
Quoted 31 lines · Maxim Levitsky
Quoted 19 lines · Max Reitz
When using an external data file, there are no refcounts for data clusters. We thus have to adjust the corruption test in this patch to not be based around a data cluster allocation, but the L2 table allocation (L2 tables are still refcounted with external data files).
Doing so means this test works both with and without external data files.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/137 | 10 ++++++---- tests/qemu-iotests/137.out | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-)tests/qemu-iotests/137 +0
-0tests/qemu-iotests/137 $QEMU_IO \ · line 143
Quoted 7 lines
tests/qemu-iotests/137 +3
-1@@ -138,14 +138,16 @@ $QEMU_IO \ "$TEST_IMG" 2>&1 | _filter_qemu_io # The dirty bit must not be set -$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +# (Filter the external data file bit) +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features \ + | sed -e 's/0x4/0x0/'Maybe it is better to filter all the feature bits, but the dirty bit, since only it is needed here, so that when we start running tests with more features, we won't need to do this again?
Quoted 6 lines
Quoted 1 line
I’d hate a filter s/[02468ace]$/no dirty bit/ though.
Nothing a helper function can't solve IMHO, I would convert this to a number, and then check bitwise the bit 2, assuming that is the dirty bit) Again, note that my approach to code is to make it as easy as possible for the next guy to change, so I am noticing such places. Eventually someone of us, will be that next guy. Then again, I don't mind leaving this as is, just noting this.
Again, my approach to tests is that they aren’t classical code.
This is a very personal opinion, but I have found that tests that have the most ad-hoc code with the least function calls are the easiest to work with.
Tests that have a whole lot of infrastructure and try to have nice code are a horror to work with because you first have to understand how they work.
Tests should be simple, not complex. Some ad-hoc filters do not make them complex as long as it’s obvious what they do.
Also, the correct approach here is not to do number crunching in bash. It is to change qcow2.py to emit more easily filterable information.
Max
Re: [PATCH 15/18] iotests: Make 137 work with data_file
Quoted 45 lines · Max Reitz
Quoted 34 lines · Maxim Levitsky
Quoted 33 lines · Max Reitz
Quoted 31 lines · Maxim Levitsky
Quoted 19 lines · Max Reitz
When using an external data file, there are no refcounts for data clusters. We thus have to adjust the corruption test in this patch to not be based around a data cluster allocation, but the L2 table allocation (L2 tables are still refcounted with external data files).
Doing so means this test works both with and without external data files.
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/137 | 10 ++++++---- tests/qemu-iotests/137.out | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-)tests/qemu-iotests/137 +0
-0tests/qemu-iotests/137 $QEMU_IO \ · line 143
Quoted 7 lines
tests/qemu-iotests/137 +3
-1@@ -138,14 +138,16 @@ $QEMU_IO \ "$TEST_IMG" 2>&1 | _filter_qemu_io # The dirty bit must not be set -$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +# (Filter the external data file bit) +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features \ + | sed -e 's/0x4/0x0/'Maybe it is better to filter all the feature bits, but the dirty bit, since only it is needed here, so that when we start running tests with more features, we won't need to do this again?
Quoted 7 lines
Quoted 1 line
I’d hate a filter s/[02468ace]$/no dirty bit/ though.
Nothing a helper function can't solve IMHO, I would convert this to a number, and then check bitwise the bit 2, assuming that is the dirty bit) Again, note that my approach to code is to make it as easy as possible for the next guy to change, so I am noticing such places. Eventually someone of us, will be that next guy. Then again, I don't mind leaving this as is, just noting this.
Again, my approach to tests is that they aren’t classical code.
Quoted 7 lines
This is a very personal opinion, but I have found that tests that have the most ad-hoc code with the least function calls are the easiest to work with.
Tests that have a whole lot of infrastructure and try to have nice code are a horror to work with because you first have to understand how they work.
I guess everything should be in balance, but I understand very well what you mean.
Quoted 3 lines
Tests should be simple, not complex. Some ad-hoc filters do not make them complex as long as it’s obvious what they do.
Yea, but the point is that it makes it harder to test new features,
that slightly change the output of the tests, and break various tests that hardcode unneeded things.
Pretty much exactly what this patch series does,
is to remove some of the ad-hoc stuff to make the
tests work with a new feature.
A bit more generic tests, might be able
to reduce this work. Anyway I won't argue with this as well, its all matter of balance, both extremes are no doubt bad.
Quoted 4 lines
Also, the correct approach here is not to do number crunching in bash. It is to change
qcow2.pyto emit more easily filterable information.
100% agree.
Quoted 3 lines
Max
Best regards,
Maxim Levitsky
PATCH 16/18 iotests: Make 198 work with data_file
In reply to Max ReitzWe do not care about the json:{} filenames here, so we can just filter them out and thus make the test work both with and without external data files.
--- tests/qemu-iotests/198 | 6 ++++-- tests/qemu-iotests/198.out | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-)
tests/qemu-iotests/198 +4 -2
@@ -92,13 +92,15 @@ echo echo "== checking image base ==" $QEMU_IMG info --image-opts $IMGSPECBASE | _filter_img_info --format-specific \ | sed -e "/^disk size:/ D" -e '/refcount bits:/ D' -e '/compat:/ D' \ - -e '/lazy refcounts:/ D' -e '/corrupt:/ D' + -e '/lazy refcounts:/ D' -e '/corrupt:/ D' -e '/^\s*data file/ D' \ + -e 's#image: json:.*#image: json:{ /* filtered */ }#' echo echo "== checking image layer ==" $QEMU_IMG info --image-opts $IMGSPECLAYER | _filter_img_info --format-specific \ | sed -e "/^disk size:/ D" -e '/refcount bits:/ D' -e '/compat:/ D' \ - -e '/lazy refcounts:/ D' -e '/corrupt:/ D' + -e '/lazy refcounts:/ D' -e '/corrupt:/ D' -e '/^\s*data file/ D' \ + -e 's#image: json:.*#image: json:{ /* filtered */ }#' # success, all done
tests/qemu-iotests/198.out +2 -2
@@ -32,7 +32,7 @@ read 16777216/16777216 bytes at offset 0 16 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) == checking image base == -image: json:{"encrypt.key-secret": "sec0", "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}} +image: json:{ /* filtered */ } file format: IMGFMT virtual size: 16 MiB (16777216 bytes) Format specific information:
@@ -74,7 +74,7 @@ Format specific information: master key iters: 1024 == checking image layer == -image: json:{"encrypt.key-secret": "sec1", "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}} +image: json:{ /* filtered */ } file format: IMGFMT virtual size: 16 MiB (16777216 bytes) backing file: TEST_DIR/t.IMGFMT.base
Signature · 1 line
2.21.0
Re: [PATCH 16/18] iotests: Make 198 work with data_file
Quoted 3 lines · Max Reitz
We do not care about the json:{} filenames here, so we can just filter them out and thus make the test work both with and without external data files.
Same comment as for iotest 110, this is more justification to move this outside to reduce duplication.
Best regards,
Maxim Levitsky
Quoted 51 lines
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/198 | 6 ++++-- tests/qemu-iotests/198.out | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-)tests/qemu-iotests/198 +4
-2@@ -92,13 +92,15 @@ echo echo "== checking image base ==" $QEMU_IMG info --image-opts $IMGSPECBASE | _filter_img_info --format-specific \ | sed -e "/^disk size:/ D" -e '/refcount bits:/ D' -e '/compat:/ D' \ - -e '/lazy refcounts:/ D' -e '/corrupt:/ D' + -e '/lazy refcounts:/ D' -e '/corrupt:/ D' -e '/^\s*data file/ D' \ + -e 's#image: json:.*#image: json:{ /* filtered */ }#' echo echo "== checking image layer ==" $QEMU_IMG info --image-opts $IMGSPECLAYER | _filter_img_info --format-specific \ | sed -e "/^disk size:/ D" -e '/refcount bits:/ D' -e '/compat:/ D' \ - -e '/lazy refcounts:/ D' -e '/corrupt:/ D' + -e '/lazy refcounts:/ D' -e '/corrupt:/ D' -e '/^\s*data file/ D' \ + -e 's#image: json:.*#image: json:{ /* filtered */ }#' # success, all donetests/qemu-iotests/198.out +2
-2@@ -32,7 +32,7 @@ read 16777216/16777216 bytes at offset 0 16 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) == checking image base == -image: json:{"encrypt.key-secret": "sec0", "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}} +image: json:{ /* filtered */ } file format: IMGFMT virtual size: 16 MiB (16777216 bytes) Format specific information:@@ -74,7 +74,7 @@ Format specific information: master key iters: 1024 == checking image layer == -image: json:{"encrypt.key-secret": "sec1", "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}} +image: json:{ /* filtered */ } file format: IMGFMT virtual size: 16 MiB (16777216 bytes) backing file: TEST_DIR/t.IMGFMT.base
PATCH 17/18 iotests: Disable data_file where it cannot be used
In reply to Max Reitz--- tests/qemu-iotests/007 | 5 +++-- tests/qemu-iotests/014 | 2 ++ tests/qemu-iotests/015 | 5 +++-- tests/qemu-iotests/026 | 5 ++++- tests/qemu-iotests/029 | 5 +++-- tests/qemu-iotests/031 | 6 +++--- tests/qemu-iotests/036 | 5 +++-- tests/qemu-iotests/039 | 3 +++ tests/qemu-iotests/046 | 2 ++ tests/qemu-iotests/048 | 2 ++ tests/qemu-iotests/051 | 5 +++-- tests/qemu-iotests/058 | 5 +++-- tests/qemu-iotests/060 | 6 ++++-- tests/qemu-iotests/061 | 6 ++++-- tests/qemu-iotests/062 | 2 +- tests/qemu-iotests/066 | 2 +- tests/qemu-iotests/067 | 6 ++++-- tests/qemu-iotests/068 | 5 +++-- tests/qemu-iotests/071 | 3 +++ tests/qemu-iotests/073 | 2 ++ tests/qemu-iotests/074 | 2 ++ tests/qemu-iotests/080 | 5 +++-- tests/qemu-iotests/090 | 2 ++ tests/qemu-iotests/098 | 4 +++- tests/qemu-iotests/099 | 3 ++- tests/qemu-iotests/103 | 5 +++-- tests/qemu-iotests/108 | 6 ++++-- tests/qemu-iotests/112 | 5 +++-- tests/qemu-iotests/114 | 2 ++ tests/qemu-iotests/121 | 3 +++ tests/qemu-iotests/138 | 2 ++ tests/qemu-iotests/156 | 2 ++ tests/qemu-iotests/176 | 7 +++++-- tests/qemu-iotests/191 | 2 ++ tests/qemu-iotests/201 | 6 +++--- tests/qemu-iotests/214 | 3 ++- tests/qemu-iotests/217 | 3 ++- tests/qemu-iotests/220 | 5 +++-- tests/qemu-iotests/243 | 6 ++++-- tests/qemu-iotests/244 | 5 +++-- tests/qemu-iotests/250 | 2 ++ tests/qemu-iotests/267 | 5 +++-- 42 files changed, 116 insertions(+), 51 deletions(-)
tests/qemu-iotests/007 +3 -2
@@ -41,8 +41,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic # refcount_bits must be at least 4 so we can create ten internal snapshots -# (1 bit supports none, 2 bits support two, 4 bits support 14) -_unsupported_imgopts 'refcount_bits=\(1\|2\)[^0-9]' +# (1 bit supports none, 2 bits support two, 4 bits support 14); +# snapshot are generally impossible with external data files +_unsupported_imgopts 'refcount_bits=\(1\|2\)[^0-9]' data_file echo echo "creating image"
tests/qemu-iotests/014 +2 -0
@@ -43,6 +43,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux +# Compression and snapshots do not work with external data files +_unsupported_imgopts data_file TEST_OFFSETS="0 4294967296" TEST_OPS="writev read write readv"
tests/qemu-iotests/015 +3 -2
@@ -40,8 +40,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # actually any format that supports snapshots _supported_fmt qcow2 _supported_proto generic -# Internal snapshots are (currently) impossible with refcount_bits=1 -_unsupported_imgopts 'refcount_bits=1[^0-9]' +# Internal snapshots are (currently) impossible with refcount_bits=1, +# and generally impossible with external data files +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file echo echo "creating image"
tests/qemu-iotests/026 +4 -1
@@ -49,7 +49,10 @@ _supported_cache_modes writethrough none # 32 and 64 bits do not work either, however, due to different leaked cluster # count on error. # Thus, the only remaining option is refcount_bits=16. -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' +# +# As for data_file, none of the refcount tests can work for it. +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' \ + data_file echo "Errors while writing 128 kB" echo
tests/qemu-iotests/029 +3 -2
@@ -42,8 +42,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic _unsupported_proto vxhs -# Internal snapshots are (currently) impossible with refcount_bits=1 -_unsupported_imgopts 'refcount_bits=1[^0-9]' +# Internal snapshots are (currently) impossible with refcount_bits=1, +# and generally impossible with external data files +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file offset_size=24 offset_l1_size=36
tests/qemu-iotests/031 +3 -3
@@ -40,9 +40,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 _supported_proto file -# We want to test compat=0.10, which does not support refcount widths -# other than 16 -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' +# We want to test compat=0.10, which does not support external data +# files or refcount widths other than 16 +_unsupported_imgopts data_file 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' CLUSTER_SIZE=65536
tests/qemu-iotests/036 +3 -2
@@ -43,8 +43,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 _supported_proto file -# Only qcow2v3 and later supports feature bits -_unsupported_imgopts 'compat=0.10' +# Only qcow2v3 and later supports feature bits; +# qcow2.py does not support external data files +_unsupported_imgopts 'compat=0.10' data_file echo echo === Image with unknown incompatible feature bit ===
tests/qemu-iotests/039 +3 -0
@@ -44,6 +44,9 @@ _supported_proto file _supported_os Linux _default_cache_mode writethrough _supported_cache_modes writethrough +# Some of these test cases expect no external data file so that all +# clusters are part of the qcow2 image and refcounted +_unsupported_imgopts data_file size=128M
tests/qemu-iotests/046 +2 -0
@@ -38,6 +38,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file +# data_file does not support compressed clusters +_unsupported_imgopts data_file CLUSTER_SIZE=64k size=128M
tests/qemu-iotests/048 +2 -0
@@ -49,6 +49,8 @@ _compare() _supported_fmt raw qcow2 qed luks _supported_proto file _supported_os Linux +# Using 'cp' is incompatible with external data files +_unsupported_imgopts data_file # Remove once all tests are fixed to use TEST_IMG_FILE # correctly and common.rc sets it unconditionally
tests/qemu-iotests/051 +3 -2
@@ -39,8 +39,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file # A compat=0.10 image is created in this test which does not support anything -# other than refcount_bits=16 -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' +# other than refcount_bits=16; +# it also will not support an external data file +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file do_run_qemu() {
tests/qemu-iotests/058 +3 -2
@@ -56,8 +56,9 @@ _supported_fmt qcow2 _supported_proto file _supported_os Linux _require_command QEMU_NBD -# Internal snapshots are (currently) impossible with refcount_bits=1 -_unsupported_imgopts 'refcount_bits=1[^0-9]' +# Internal snapshots are (currently) impossible with refcount_bits=1, +# and generally impossible with external data files +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file nbd_snapshot_img="nbd:unix:$nbd_unix_socket"
tests/qemu-iotests/060 +4 -2
@@ -48,8 +48,10 @@ _filter_io_error() _supported_fmt qcow2 _supported_proto file _supported_os Linux -# These tests only work for compat=1.1 images with refcount_bits=16 -_unsupported_imgopts 'compat=0.10' 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' +# These tests only work for compat=1.1 images without an external +# data file with refcount_bits=16 +_unsupported_imgopts 'compat=0.10' data_file \ + 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' rt_offset=65536 # 0x10000 (XXX: just an assumption) rb_offset=131072 # 0x20000 (XXX: just an assumption)
tests/qemu-iotests/061 +4 -2
@@ -42,8 +42,10 @@ _supported_fmt qcow2 _supported_proto file _supported_os Linux # Conversion between different compat versions can only really work -# with refcount_bits=16 -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' +# with refcount_bits=16; +# we have explicit tests for data_file here, but the whole test does +# not work with it +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file echo echo "=== Testing version downgrade with zero expansion ==="
tests/qemu-iotests/062 +1 -1
@@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic # We need zero clusters and snapshots -_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' data_file IMG_SIZE=64M
tests/qemu-iotests/066 +1 -1
@@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic # Weneed zero clusters and snapshots -_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' data_file # Intentionally create an unaligned image IMG_SIZE=$((64 * 1024 * 1024 + 512))
tests/qemu-iotests/067 +4 -2
@@ -32,8 +32,10 @@ status=1 # failure is the default! _supported_fmt qcow2 _supported_proto file -# Because anything other than 16 would change the output of query-block -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' +# Because anything other than 16 would change the output of query-block, +# and external data files would change the output of +# query-named-block-ndoes +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file do_run_qemu() {
tests/qemu-iotests/068 +3 -2
@@ -39,8 +39,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # This tests qocw2-specific low-level functionality _supported_fmt qcow2 _supported_proto generic -# Internal snapshots are (currently) impossible with refcount_bits=1 -_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' +# Internal snapshots are (currently) impossible with refcount_bits=1, +# and generally impossible with external data files +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' data_file IMG_SIZE=128K
tests/qemu-iotests/071 +3 -0
@@ -39,6 +39,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _require_drivers blkdebug blkverify +# blkdebug can only inject errors on bs->file, not on the data_file, +# so thie test does not work with external data files +_unsupported_imgopts data_file do_run_qemu() {
tests/qemu-iotests/073 +2 -0
@@ -39,6 +39,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic _unsupported_proto vxhs +# External data files do not support compressed clusters +_unsupported_imgopts data_file CLUSTER_SIZE=64k size=128M
tests/qemu-iotests/074 +2 -0
@@ -50,6 +50,8 @@ _compare() _supported_fmt qcow2 _supported_proto file _supported_os Linux +# blkdebug can only inject errors on bs->file +_unsupported_imgopts data_file # Setup test basic parameters TEST_IMG2=$TEST_IMG.2
tests/qemu-iotests/080 +3 -2
@@ -40,9 +40,10 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux -# - Internal snapshots are (currently) impossible with refcount_bits=1 +# - Internal snapshots are (currently) impossible with refcount_bits=1, +# and generally impossible with external data files # - This is generally a test for compat=1.1 images -_unsupported_imgopts 'refcount_bits=1[^0-9]' 'compat=0.10' +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file 'compat=0.10' header_size=104
tests/qemu-iotests/090 +2 -0
@@ -38,6 +38,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file nfs +# External data files do not support compressed clusters +_unsupported_imgopts data_file IMG_SIZE=128K
tests/qemu-iotests/098 +3 -1
@@ -40,7 +40,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file -_unsupported_imgopts 'compat=0.10' +# blkdebug can only inject errors on bs->file, so external data files +# do not work with this test +_unsupported_imgopts 'compat=0.10' data_file for event in l1_update empty_image_prepare reftable_update refblock_alloc; do
tests/qemu-iotests/099 +2 -1
@@ -46,8 +46,9 @@ _supported_fmt qcow qcow2 qed vdi vhdx vmdk vpc _supported_proto file _supported_os Linux _require_drivers blkdebug blkverify +# data_file would change the json:{} filenames _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ - "subformat=twoGbMaxExtentSparse" + "subformat=twoGbMaxExtentSparse" data_file do_run_qemu() {
tests/qemu-iotests/103 +3 -2
@@ -38,8 +38,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file nfs -# Internal snapshots are (currently) impossible with refcount_bits=1 -_unsupported_imgopts 'refcount_bits=1[^0-9]' +# Internal snapshots are (currently) impossible with refcount_bits=1, +# and generally impossible with external data files +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file IMG_SIZE=64K
tests/qemu-iotests/108 +4 -2
@@ -41,8 +41,10 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux -# This test directly modifies a refblock so it relies on refcount_bits being 16 -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' +# This test directly modifies a refblock so it relies on refcount_bits being 16; +# and the low-level modification it performs are not tuned for external data +# files +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file echo echo '=== Repairing an image without any refcount table ==='
tests/qemu-iotests/112 +3 -2
@@ -40,8 +40,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file # This test will set refcount_bits on its own which would conflict with the -# manual setting; compat will be overridden as well -_unsupported_imgopts refcount_bits 'compat=0.10' +# manual setting; compat will be overridden as well; +# and external data files do not work well with our refcount testing +_unsupported_imgopts refcount_bits 'compat=0.10' data_file print_refcount_bits() {
tests/qemu-iotests/114 +2 -0
@@ -39,6 +39,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic _unsupported_proto vxhs +# qcow2.py does not work too well with external data files +_unsupported_imgopts data_file TEST_IMG="$TEST_IMG.base" _make_test_img 64M
tests/qemu-iotests/121 +3 -0
@@ -39,6 +39,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux +# Refcount structures are used much differently with external data +# files +_unsupported_imgopts data_file echo echo '=== New refcount structures may not conflict with existing structures ==='
tests/qemu-iotests/138 +2 -0
@@ -40,6 +40,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux +# These refcount calculations do not work with external data files +_unsupported_imgopts data_file echo echo '=== Check on an image with a multiple of 2^32 clusters ==='
tests/qemu-iotests/156 +2 -0
@@ -51,6 +51,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 qed _supported_proto generic _unsupported_proto vxhs +# Copying files around with cp does not work with external data files +_unsupported_imgopts data_file # Create source disk TEST_IMG="$TEST_IMG.backing" _make_test_img 1M
tests/qemu-iotests/176 +5 -2
@@ -47,8 +47,11 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux -# Persistent dirty bitmaps require compat=1.1 -_unsupported_imgopts 'compat=0.10' +# Persistent dirty bitmaps require compat=1.1; +# Internal snapshots forbid using an external data file +# (they work with refcount_bits=1 here, though, because there actually +# is no data when creating the snapshot) +_unsupported_imgopts 'compat=0.10' data_file run_qemu() {
tests/qemu-iotests/191 +2 -0
@@ -43,6 +43,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file +# An external data file would change the query-named-block-nodes output +_unsupported_imgopts data_file size=64M
tests/qemu-iotests/201 +3 -3
@@ -43,9 +43,9 @@ _supported_fmt qcow2 _supported_proto generic _supported_os Linux -# Internal snapshots are (currently) impossible with refcount_bits=1 -# This was taken from test 080 -_unsupported_imgopts 'refcount_bits=1[^0-9]' +# Internal snapshots are (currently) impossible with refcount_bits=1, +# and generally impossible with external data files +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file size=64M _make_test_img $size
tests/qemu-iotests/214 +2 -1
@@ -39,7 +39,8 @@ _supported_proto file # Repairing the corrupted image requires qemu-img check to store a # refcount up to 3, which requires at least two refcount bits. -_unsupported_imgopts 'refcount_bits=1[^0-9]' +# External data files do not support compressed clusters. +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file echo
tests/qemu-iotests/217 +2 -1
@@ -40,7 +40,8 @@ _supported_proto file # This test needs clusters with at least a refcount of 2 so that # OFLAG_COPIED is not set. refcount_bits=1 is therefore unsupported. -_unsupported_imgopts 'refcount_bits=1[^0-9]' +# (As are external data files.) +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file echo echo '=== Simulating an I/O error during snapshot deletion ==='
tests/qemu-iotests/220 +3 -2
@@ -37,8 +37,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux -# To use a different refcount width but 16 bits we need compat=1.1 -_unsupported_imgopts 'compat=0.10' +# To use a different refcount width but 16 bits we need compat=1.1, +# and external data files do not support compressed clusters. +_unsupported_imgopts 'compat=0.10' data_file echo "== Creating huge file =="
tests/qemu-iotests/243 +4 -2
@@ -40,8 +40,10 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux -# External data files do not work with compat=0.10 -_unsupported_imgopts 'compat=0.10' +# External data files do not work with compat=0.10, and because there +# is an explicit case for external data files here, we cannot allow +# the user to specify whether to use one +_unsupported_imgopts 'compat=0.10' data_file for mode in off metadata falloc full; do
tests/qemu-iotests/244 +3 -2
@@ -41,8 +41,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux -# External data files do not work with compat=0.10 -_unsupported_imgopts 'compat=0.10' +# External data files do not work with compat=0.10, and because we use +# our own external data file, we cannot let the user specify one +_unsupported_imgopts 'compat=0.10' data_file echo echo "=== Create and open image with external data file ==="
tests/qemu-iotests/250 +2 -0
@@ -39,6 +39,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux +# This test does not make much sense with external data files +_unsupported_imgopts data_file # This test checks that qcow2_process_discards does not truncate a discard # request > 2G.
tests/qemu-iotests/267 +3 -2
@@ -41,8 +41,9 @@ _supported_fmt qcow2 _supported_proto file _supported_os Linux -# Internal snapshots are (currently) impossible with refcount_bits=1 -_unsupported_imgopts 'refcount_bits=1[^0-9]' +# Internal snapshots are (currently) impossible with refcount_bits=1, +# and generally impossible with external data files +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file do_run_qemu() {
Signature · 1 line
2.21.0
Re: [PATCH 17/18] iotests: Disable data_file where it cannot be used
Quoted 37 lines · Max Reitz
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/007 | 5 +++-- tests/qemu-iotests/014 | 2 ++ tests/qemu-iotests/015 | 5 +++-- tests/qemu-iotests/026 | 5 ++++- tests/qemu-iotests/029 | 5 +++-- tests/qemu-iotests/031 | 6 +++--- tests/qemu-iotests/036 | 5 +++-- tests/qemu-iotests/039 | 3 +++ tests/qemu-iotests/046 | 2 ++ tests/qemu-iotests/048 | 2 ++ tests/qemu-iotests/051 | 5 +++-- tests/qemu-iotests/058 | 5 +++-- tests/qemu-iotests/060 | 6 ++++-- tests/qemu-iotests/061 | 6 ++++-- tests/qemu-iotests/062 | 2 +- tests/qemu-iotests/066 | 2 +- tests/qemu-iotests/067 | 6 ++++-- tests/qemu-iotests/068 | 5 +++-- tests/qemu-iotests/071 | 3 +++ tests/qemu-iotests/073 | 2 ++ tests/qemu-iotests/074 | 2 ++ tests/qemu-iotests/080 | 5 +++-- tests/qemu-iotests/090 | 2 ++ tests/qemu-iotests/098 | 4 +++- tests/qemu-iotests/099 | 3 ++- tests/qemu-iotests/103 | 5 +++-- tests/qemu-iotests/108 | 6 ++++-- tests/qemu-iotests/112 | 5 +++-- tests/qemu-iotests/114 | 2 ++ tests/qemu-iotests/121 | 3 +++ tests/qemu-iotests/138 | 2 ++ tests/qemu-iotests/156 | 2 ++ tests/qemu-iotests/176 | 7 +++++-- tests/qemu-iotests/191 | 2 ++ tests/qemu-iotests/201 | 6 +++---
Quoted 9 lines
tests/qemu-iotests/214 | 3 ++- tests/qemu-iotests/217 | 3 ++- tests/qemu-iotests/220 | 5 +++-- tests/qemu-iotests/243 | 6 ++++-- tests/qemu-iotests/244 | 5 +++-- tests/qemu-iotests/250 | 2 ++ tests/qemu-iotests/267 | 5 +++-- 42 files changed, 116 insertions(+), 51 deletions(-)
No iotest 267 on master branch, same as patch 9
Best regards,
Maxim Levitsky
PATCH 18/18 iotests: Allow check -o data_file
In reply to Max ReitzThe problem with allowing the data_file option is that you want to use a different data file per image used in the test. Therefore, we need to allow patterns like -o data_file='$TEST_IMG.data_file'.
Then, we need to filter it out from qemu-img map, qemu-img create, and remove the data file in _rm_test_img.
--- tests/qemu-iotests/common.filter | 21 +++++++++++++++++++-- tests/qemu-iotests/common.rc | 10 +++++++++- 2 files changed, 28 insertions(+), 3 deletions(-)
tests/qemu-iotests/common.filter +19 -2
@@ -115,7 +115,15 @@ _filter_actual_image_size() # replace driver-specific options in the "Formatting..." line _filter_img_create() { - $SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ + data_file_filter=() + if echo "$IMGOPTS" | grep -q 'data_file='; then + data_file=$(echo "$IMGOPTS" | sed -e 's/.*\(data_file=[^,]*\).*/\1/' \ + -e "s#\\\$TEST_IMG#$TEST_IMG#") + data_file_filter=(-e "s# $data_file##") + fi + + $SED "${data_file_filter[@]}" \ + -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ -e "s#$TEST_DIR#TEST_DIR#g" \ -e "s#$IMGFMT#IMGFMT#g" \
@@ -198,9 +206,18 @@ _filter_img_info() # human and json output _filter_qemu_img_map() { + data_file_filter=() + if echo "$IMGOPTS" | grep -q 'data_file='; then + data_file_pattern=$(echo "$IMGOPTS" | sed -e 's/.*data_file=\([^,]*\).*/\1/' \ + -e 's#\$TEST_IMG#\\(.*\\)#') + data_file_filter=(-e "s#$data_file_pattern#\\1#") + fi + $SED -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \ -e 's/"offset": [0-9]\+/"offset": OFFSET/g' \ - -e 's/Mapped to *//' | _filter_testdir | _filter_imgfmt + -e 's/Mapped to *//' \ + "${data_file_filter[@]}" \ + | _filter_testdir | _filter_imgfmt } _filter_nbd()
tests/qemu-iotests/common.rc +9 -1
@@ -297,7 +297,8 @@ _make_test_img() fi if [ -n "$IMGOPTS" ]; then - optstr=$(_optstr_add "$optstr" "$IMGOPTS") + imgopts_expanded=$(echo "$IMGOPTS" | sed -e "s#\\\$TEST_IMG#$img_name#") + optstr=$(_optstr_add "$optstr" "$imgopts_expanded") fi if [ -n "$IMGKEYSECRET" ]; then object_options="--object secret,id=keysec0,data=$IMGKEYSECRET"
@@ -376,6 +377,13 @@ _rm_test_img() # Remove all the extents for vmdk "$QEMU_IMG" info "$img" 2>/dev/null | grep 'filename:' | cut -f 2 -d: \ | xargs -I {} rm -f "{}" + elif [ "$IMGFMT" = "qcow2" ]; then + # Remove external data file + if echo "$IMGOPTS" | grep -q 'data_file='; then + data_file=$(echo "$IMGOPTS" | sed -e 's/.*data_file=\([^,]*\).*/\1/' \ + -e "s#\\\$TEST_IMG#$img#") + rm -f "$data_file" + fi fi rm -f "$img" }
Signature · 1 line
2.21.0
Re: [PATCH 18/18] iotests: Allow check -o data_file
Quoted 18 lines · Max Reitz
The problem with allowing the
data_fileoption is that you want to use a different data file per image used in the test. Therefore, we need to allow patterns like -o data_file='$TEST_IMG.data_file'.Then, we need to filter it out from qemu-img map, qemu-img create, and remove the data file in
_rm_test_img.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/common.filter | 21 +++++++++++++++++++-- tests/qemu-iotests/common.rc | 10 +++++++++- 2 files changed, 28 insertions(+), 3 deletions(-)tests/qemu-iotests/common.filter +0
-0
tests/qemu-iotests/common.filter _filter_actual_image_size() · line 121
Quoted 8 lines
tests/qemu-iotests/common.filter +4
-1@@ -115,7 +115,15 @@ _filter_actual_image_size() # replace driver-specific options in the "Formatting..." line _filter_img_create() { - $SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ + data_file_filter=() + if echo "$IMGOPTS" | grep -q 'data_file='; then + data_file=$(echo "$IMGOPTS" | sed -e 's/.*\(data_file=[^,]*\).*/\1/' \ + -e "s#\\\$TEST_IMG#$TEST_IMG#")
Could you maybe add a comment on this regular expression, similar to what is in the commit message?
tests/qemu-iotests/common.filter _filter_actual_image_size() · line 122
Quoted 1 line
tests/qemu-iotests/common.filter +1
-0+ data_file_filter=(-e "s# $data_file##")
Why to use array here? A variable would work too I think.
Quoted 8 lines
tests/qemu-iotests/common.filter +4
-0+ fi + + $SED "${data_file_filter[@]}" \ + -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ -e "s#$TEST_DIR#TEST_DIR#g" \ -e "s#$IMGFMT#IMGFMT#g" \
tests/qemu-iotests/common.filter _filter_img_info() · line 213
Quoted 8 lines
tests/qemu-iotests/common.filter +5
-0@@ -198,9 +206,18 @@ _filter_img_info() # human and json output _filter_qemu_img_map() { + data_file_filter=() + if echo "$IMGOPTS" | grep -q 'data_file='; then + data_file_pattern=$(echo "$IMGOPTS" | sed -e 's/.*data_file=\([^,]*\).*/\1/' \ + -e 's#\$TEST_IMG#\\(.*\\)#') + data_file_filter=(-e "s#$data_file_pattern#\\1#")
Seems to do the same thing, but in slightly different way. Maybe make a function to avoid duplication?
I am not 100% sure though.
Quoted 16 lines
tests/qemu-iotests/common.filter +5
-1+ fi + $SED -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \ -e 's/"offset": [0-9]\+/"offset": OFFSET/g' \ - -e 's/Mapped to *//' | _filter_testdir | _filter_imgfmt + -e 's/Mapped to *//' \ + "${data_file_filter[@]}" \ + | _filter_testdir | _filter_imgfmt } _filter_nbd()tests/qemu-iotests/common.rc +0
-0
tests/qemu-iotests/common.rc _make_test_img() · line 301
Quoted 6 lines
tests/qemu-iotests/common.rc +2
-1@@ -297,7 +297,8 @@ _make_test_img() fi if [ -n "$IMGOPTS" ]; then - optstr=$(_optstr_add "$optstr" "$IMGOPTS") + imgopts_expanded=$(echo "$IMGOPTS" | sed -e "s#\\\$TEST_IMG#$img_name#") + optstr=$(_optstr_add "$optstr" "$imgopts_expanded")
Also a comment explaining why this is needed would be welcome.
tests/qemu-iotests/common.rc _rm_test_img() · line 384
Quoted 12 lines
tests/qemu-iotests/common.rc +5
-0fi if [ -n "$IMGKEYSECRET" ]; then object_options="--object secret,id=keysec0,data=$IMGKEYSECRET"@@ -376,6 +377,13 @@ _rm_test_img() # Remove all the extents for vmdk "$QEMU_IMG" info "$img" 2>/dev/null | grep 'filename:' | cut -f 2 -d: \ | xargs -I {} rm -f "{}" + elif [ "$IMGFMT" = "qcow2" ]; then + # Remove external data file + if echo "$IMGOPTS" | grep -q 'data_file='; then + data_file=$(echo "$IMGOPTS" | sed -e 's/.*data_file=\([^,]*\).*/\1/' \ + -e "s#\\\$TEST_IMG#$img#")
Same here, even more evidence that it would be nice to move this to a common function. Again, I am not 100% sure that this is the same regex, but it looks like that.
tests/qemu-iotests/common.rc _rm_test_img() · line 389
Quoted 5 lines
tests/qemu-iotests/common.rc +2
-0+ rm -f "$data_file" + fi fi rm -f "$img" }
Best regards,
Maxim Levitsky
Re: [PATCH 18/18] iotests: Allow check -o data_file
Quoted 30 lines · Maxim Levitsky
Quoted 18 lines · Max Reitz
The problem with allowing the
data_fileoption is that you want to use a different data file per image used in the test. Therefore, we need to allow patterns like -o data_file='$TEST_IMG.data_file'.Then, we need to filter it out from qemu-img map, qemu-img create, and remove the data file in
_rm_test_img.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/common.filter | 21 +++++++++++++++++++-- tests/qemu-iotests/common.rc | 10 +++++++++- 2 files changed, 28 insertions(+), 3 deletions(-)tests/qemu-iotests/common.filter +0
-0tests/qemu-iotests/common.filter _filter_actual_image_size() · line 121
Quoted 8 lines
tests/qemu-iotests/common.filter +4
-1@@ -115,7 +115,15 @@ _filter_actual_image_size() # replace driver-specific options in the "Formatting..." line _filter_img_create() { - $SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ + data_file_filter=() + if echo "$IMGOPTS" | grep -q 'data_file='; then + data_file=$(echo "$IMGOPTS" | sed -e 's/.*\(data_file=[^,]*\).*/\1/' \ + -e "s#\\\$TEST_IMG#$TEST_IMG#")Could you maybe add a comment on this regular expression, similar to what is in the commit message?
Quoted 2 lines
tests/qemu-iotests/common.filter _filter_actual_image_size() · line 122
Quoted 1 line
tests/qemu-iotests/common.filter +1
-0+ data_file_filter=(-e "s# $data_file##")Why to use array here? A variable would work too I think.
Because I find it to be much simpler to quote correctly.
Quoted 9 lines
Quoted 9 lines
tests/qemu-iotests/common.filter +4
-0+ fi + + $SED "${data_file_filter[@]}" \ + -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ -e "s#$TEST_DIR#TEST_DIR#g" \ -e "s#$IMGFMT#IMGFMT#g" \@@ -198,9 +206,18 @@ _filter_img_info() # human and json output
Quoted 8 lines
tests/qemu-iotests/common.filter _filter_img_info() · line 213
Quoted 7 lines
tests/qemu-iotests/common.filter +5
-0_filter_qemu_img_map() { + data_file_filter=() + if echo "$IMGOPTS" | grep -q 'data_file='; then + data_file_pattern=$(echo "$IMGOPTS" | sed -e 's/.*data_file=\([^,]*\).*/\1/' \ + -e 's#\$TEST_IMG#\\(.*\\)#') + data_file_filter=(-e "s#$data_file_pattern#\\1#")Seems to do the same thing, but in slightly different way.
It does a very different thing, in that it creates a sed pattern.
I’d first need to get comfortable with the thought of having a common function _data_file_from_imgopts and then pass a '\(.*\)' to it, which would look weird.
Or maybe even a '\\(.*\\)', because I’d still have to take the sed escaping into account, even in that function’s caller, which is weird, too.
Quoted 27 lines
Maybe make a function to avoid duplication?
I am not 100% sure though.Quoted 16 lines
tests/qemu-iotests/common.filter +5
-1+ fi + $SED -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \ -e 's/"offset": [0-9]\+/"offset": OFFSET/g' \ - -e 's/Mapped to *//' | _filter_testdir | _filter_imgfmt + -e 's/Mapped to *//' \ + "${data_file_filter[@]}" \ + | _filter_testdir | _filter_imgfmt } _filter_nbd()tests/qemu-iotests/common.rc +0
-0tests/qemu-iotests/common.rc _make_test_img() · line 301
Quoted 6 lines
tests/qemu-iotests/common.rc +2
-1@@ -297,7 +297,8 @@ _make_test_img() fi if [ -n "$IMGOPTS" ]; then - optstr=$(_optstr_add "$optstr" "$IMGOPTS") + imgopts_expanded=$(echo "$IMGOPTS" | sed -e "s#\\\$TEST_IMG#$img_name#") + optstr=$(_optstr_add "$optstr" "$imgopts_expanded")Also a comment explaining why this is needed would be welcome.
Quoted 13 lines
tests/qemu-iotests/common.rc _rm_test_img() · line 384
Quoted 12 lines
tests/qemu-iotests/common.rc +5
-0fi if [ -n "$IMGKEYSECRET" ]; then object_options="--object secret,id=keysec0,data=$IMGKEYSECRET"@@ -376,6 +377,13 @@ _rm_test_img() # Remove all the extents for vmdk "$QEMU_IMG" info "$img" 2>/dev/null | grep 'filename:' | cut -f 2 -d: \ | xargs -I {} rm -f "{}" + elif [ "$IMGFMT" = "qcow2" ]; then + # Remove external data file + if echo "$IMGOPTS" | grep -q 'data_file='; then + data_file=$(echo "$IMGOPTS" | sed -e 's/.*data_file=\([^,]*\).*/\1/' \ + -e "s#\\\$TEST_IMG#$img#")Same here, even more evidence that it would be nice to move this to a common function.
I’m not sure whether it’s more evidence because it would increase LoC. I may or may not do it.
Max
Quoted 12 lines
Again, I am not 100% sure that this is the same regex, but it looks like that.
tests/qemu-iotests/common.rc _rm_test_img() · line 389
Quoted 5 lines
tests/qemu-iotests/common.rc +2
-0+ rm -f "$data_file" + fi fi rm -f "$img" }Best regards,
Maxim Levitsky