1 | The following changes since commit f17783e706ab9c7b3a2b69cf48e4f0ba40664f54: | 1 | The following changes since commit eb6490f544388dd24c0d054a96dd304bc7284450: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20191220' into staging (2020-01-03 18:50:33 +0000) | 3 | Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20200703' into staging (2020-07-04 16:08:41 +0100) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/XanClic/qemu.git tags/pull-block-2020-01-06 | 7 | https://github.com/XanClic/qemu.git tags/pull-block-2020-07-06 |
8 | 8 | ||
9 | for you to fetch changes up to 503ca1262bab2c11c533a4816d1ff4297d4f58a6: | 9 | for you to fetch changes up to 365fed5111b06d31c1632af63c7528dfe49d62a2: |
10 | 10 | ||
11 | backup-top: Begin drain earlier (2020-01-06 14:26:23 +0100) | 11 | qed: Simplify backing reads (2020-07-06 10:34:14 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches: | 14 | Block patches for 5.1: |
15 | - Minor fixes and tests from the freeze period (too minor to be included | 15 | - LUKS keyslot amendment |
16 | in 4.2) | 16 | (+ patches to make the iotests pass on non-Linux systems, and to keep |
17 | - Allow many bash iotests to test qcow2's external data file feature | 17 | the tests passing for qcow v1, and to skip LUKS tests (including |
18 | - Add compress filter driver | 18 | qcow2 LUKS) when the built qemu does not support it) |
19 | - Fix Python iotests after 6f6e1698a6 | 19 | - Refactoring in the block layer: Drop the basically unnecessary |
20 | - Fix for the backup job | 20 | unallocated_blocks_are_zero field from BlockDriverInfo |
21 | - Fix qcow2 preallocation when the image size is not a multiple of the | ||
22 | cluster size | ||
23 | - Fix in block-copy code | ||
21 | 24 | ||
22 | ---------------------------------------------------------------- | 25 | ---------------------------------------------------------------- |
23 | Andrey Shinkevich (3): | 26 | Alberto Garcia (1): |
24 | block: introduce compress filter driver | 27 | qcow2: Fix preallocation on images with unaligned sizes |
25 | qcow2: Allow writing compressed data of multiple clusters | ||
26 | tests/qemu-iotests: add case to write compressed data of multiple | ||
27 | clusters | ||
28 | 28 | ||
29 | Max Reitz (28): | 29 | Eric Blake (1): |
30 | block: Add bdrv_qapi_perm_to_blk_perm() | 30 | qed: Simplify backing reads |
31 | block: Use bdrv_qapi_perm_to_blk_perm() | ||
32 | blkdebug: Allow taking/unsharing permissions | ||
33 | iotests: Add @error to wait_until_completed | ||
34 | iotests: Add test for failing mirror complete | ||
35 | iotests: s/qocw2/qcow2/ | ||
36 | iotests/qcow2.py: Add dump-header-exts | ||
37 | iotests/qcow2.py: Split feature fields into bits | ||
38 | iotests: Add _filter_json_filename | ||
39 | iotests: Filter refcount_order in 036 | ||
40 | iotests: Replace IMGOPTS by _unsupported_imgopts | ||
41 | iotests: Drop compat=1.1 in 050 | ||
42 | iotests: Let _make_test_img parse its parameters | ||
43 | iotests: Add -o and --no-opts to _make_test_img | ||
44 | iotests: Inject space into -ocompat=0.10 in 051 | ||
45 | iotests: Replace IMGOPTS= by -o | ||
46 | iotests: Replace IMGOPTS='' by --no-opts | ||
47 | iotests: Drop IMGOPTS use in 267 | ||
48 | iotests: Avoid qemu-img create | ||
49 | iotests: Use _rm_test_img for deleting test images | ||
50 | iotests: Avoid cp/mv of test images | ||
51 | iotests: Make 091 work with data_file | ||
52 | iotests: Make 110 work with data_file | ||
53 | iotests: Make 137 work with data_file | ||
54 | iotests: Make 198 work with data_file | ||
55 | iotests: Disable data_file where it cannot be used | ||
56 | iotests: Allow check -o data_file | ||
57 | backup-top: Begin drain earlier | ||
58 | 31 | ||
59 | PanNengyuan (1): | 32 | Max Reitz (5): |
60 | throttle-groups: fix memory leak in throttle_group_set_limit: | 33 | iotests: Make _filter_img_create more active |
34 | iotests/common.rc: Add _require_working_luks | ||
35 | iotests.py: Add qemu_img_pipe_and_status() | ||
36 | iotests.py: Add (verify|has)_working_luks() | ||
37 | iotests: Check whether luks works | ||
61 | 38 | ||
62 | Philippe Mathieu-Daudé (1): | 39 | Maxim Levitsky (14): |
63 | tests/qemu-iotests: Update tests to recent desugarized -accel option | 40 | iotests: filter few more luks specific create options |
41 | qcrypto/core: add generic infrastructure for crypto options amendment | ||
42 | qcrypto/luks: implement encryption key management | ||
43 | block/amend: add 'force' option | ||
44 | block/amend: separate amend and create options for qemu-img | ||
45 | block/amend: refactor qcow2 amend options | ||
46 | block/crypto: rename two functions | ||
47 | block/crypto: implement the encryption key management | ||
48 | block/qcow2: extend qemu-img amend interface with crypto options | ||
49 | iotests: qemu-img tests for luks key management | ||
50 | block/core: add generic infrastructure for x-blockdev-amend qmp | ||
51 | command | ||
52 | block/crypto: implement blockdev-amend | ||
53 | block/qcow2: implement blockdev-amend | ||
54 | iotests: add tests for blockdev-amend | ||
64 | 55 | ||
65 | Vladimir Sementsov-Ogievskiy (1): | 56 | Vladimir Sementsov-Ogievskiy (10): |
66 | qcow2-bitmaps: fix qcow2_can_store_new_dirty_bitmap | 57 | block/block-copy: block_copy_dirty_clusters: fix failure check |
58 | qemu-img: convert: don't use unallocated_blocks_are_zero | ||
59 | block: inline bdrv_unallocated_blocks_are_zero() | ||
60 | block/vdi: return ZERO block-status when appropriate | ||
61 | block/vpc: return ZERO block-status when appropriate | ||
62 | block/crypto: drop unallocated_blocks_are_zero | ||
63 | block/iscsi: drop unallocated_blocks_are_zero | ||
64 | block/file-posix: drop unallocated_blocks_are_zero | ||
65 | block/vhdx: drop unallocated_blocks_are_zero | ||
66 | block: drop unallocated_blocks_are_zero | ||
67 | 67 | ||
68 | block.c | 47 +++++---- | 68 | docs/tools/qemu-img.rst | 5 +- |
69 | block/Makefile.objs | 1 + | 69 | qapi/block-core.json | 68 +++++ |
70 | block/backup-top.c | 4 +- | 70 | qapi/crypto.json | 73 +++++- |
71 | block/blkdebug.c | 93 ++++++++++++++++- | 71 | qapi/job.json | 4 +- |
72 | block/filter-compress.c | 168 +++++++++++++++++++++++++++++++ | 72 | block/crypto.h | 37 +++ |
73 | block/qcow2-bitmap.c | 41 ++++---- | 73 | block/qed.h | 1 - |
74 | block/qcow2.c | 102 ++++++++++++++----- | 74 | crypto/blockpriv.h | 8 + |
75 | block/throttle-groups.c | 4 +- | 75 | include/block/block.h | 7 +- |
76 | include/block/block.h | 1 + | 76 | include/block/block_int.h | 36 ++- |
77 | qapi/block-core.json | 24 ++++- | 77 | include/crypto/block.h | 22 ++ |
78 | tests/qemu-iotests/007 | 5 +- | 78 | block.c | 19 +- |
79 | tests/qemu-iotests/014 | 2 + | 79 | block/amend.c | 113 +++++++++ |
80 | tests/qemu-iotests/015 | 5 +- | 80 | block/block-copy.c | 4 +- |
81 | tests/qemu-iotests/019 | 6 +- | 81 | block/crypto.c | 207 +++++++++++++-- |
82 | tests/qemu-iotests/020 | 6 +- | 82 | block/file-posix.c | 3 - |
83 | tests/qemu-iotests/024 | 10 +- | 83 | block/io.c | 8 +- |
84 | tests/qemu-iotests/026 | 5 +- | 84 | block/iscsi.c | 1 - |
85 | tests/qemu-iotests/028 | 2 +- | 85 | block/qcow2.c | 350 +++++++++++++++----------- |
86 | tests/qemu-iotests/029 | 7 +- | 86 | block/qed.c | 65 +---- |
87 | tests/qemu-iotests/031 | 9 +- | 87 | block/vdi.c | 3 +- |
88 | tests/qemu-iotests/031.out | 36 +++---- | 88 | block/vhdx.c | 3 - |
89 | tests/qemu-iotests/036 | 15 +-- | 89 | block/vpc.c | 3 +- |
90 | tests/qemu-iotests/036.out | 66 ++---------- | 90 | crypto/block-luks.c | 416 ++++++++++++++++++++++++++++++- |
91 | tests/qemu-iotests/039 | 27 ++--- | 91 | crypto/block.c | 29 +++ |
92 | tests/qemu-iotests/039.out | 22 ++-- | 92 | qemu-img.c | 48 ++-- |
93 | tests/qemu-iotests/041 | 44 ++++++++ | 93 | block/Makefile.objs | 2 +- |
94 | tests/qemu-iotests/041.out | 4 +- | 94 | qemu-img-cmds.hx | 4 +- |
95 | tests/qemu-iotests/043 | 4 +- | 95 | tests/qemu-iotests/049.out | 102 ++++---- |
96 | tests/qemu-iotests/046 | 2 + | 96 | tests/qemu-iotests/061.out | 12 +- |
97 | tests/qemu-iotests/048 | 4 +- | 97 | tests/qemu-iotests/082.out | 185 ++++---------- |
98 | tests/qemu-iotests/050 | 8 +- | 98 | tests/qemu-iotests/085.out | 38 +-- |
99 | tests/qemu-iotests/051 | 7 +- | 99 | tests/qemu-iotests/087 | 1 + |
100 | tests/qemu-iotests/053 | 4 +- | 100 | tests/qemu-iotests/087.out | 6 +- |
101 | tests/qemu-iotests/058 | 7 +- | 101 | tests/qemu-iotests/112.out | 2 +- |
102 | tests/qemu-iotests/059 | 20 ++-- | 102 | tests/qemu-iotests/125 | 24 ++ |
103 | tests/qemu-iotests/060 | 14 +-- | 103 | tests/qemu-iotests/125.out | 9 + |
104 | tests/qemu-iotests/060.out | 20 ++-- | 104 | tests/qemu-iotests/134.out | 2 +- |
105 | tests/qemu-iotests/061 | 63 ++++++------ | 105 | tests/qemu-iotests/141 | 2 +- |
106 | tests/qemu-iotests/061.out | 72 ++++++------- | 106 | tests/qemu-iotests/144.out | 4 +- |
107 | tests/qemu-iotests/062 | 5 +- | 107 | tests/qemu-iotests/146 | 60 +++-- |
108 | tests/qemu-iotests/063 | 18 ++-- | 108 | tests/qemu-iotests/146.out | 405 ++++++++++++++++++++++++++++-- |
109 | tests/qemu-iotests/063.out | 3 +- | 109 | tests/qemu-iotests/153 | 9 +- |
110 | tests/qemu-iotests/066 | 7 +- | 110 | tests/qemu-iotests/158.out | 4 +- |
111 | tests/qemu-iotests/067 | 6 +- | 111 | tests/qemu-iotests/178 | 1 + |
112 | tests/qemu-iotests/068 | 6 +- | 112 | tests/qemu-iotests/182.out | 2 +- |
113 | tests/qemu-iotests/069 | 2 +- | 113 | tests/qemu-iotests/185.out | 8 +- |
114 | tests/qemu-iotests/071 | 7 +- | 114 | tests/qemu-iotests/188 | 1 + |
115 | tests/qemu-iotests/073 | 4 + | 115 | tests/qemu-iotests/188.out | 2 +- |
116 | tests/qemu-iotests/074 | 4 +- | 116 | tests/qemu-iotests/189 | 1 + |
117 | tests/qemu-iotests/079 | 3 +- | 117 | tests/qemu-iotests/189.out | 4 +- |
118 | tests/qemu-iotests/080 | 7 +- | 118 | tests/qemu-iotests/198 | 1 + |
119 | tests/qemu-iotests/081 | 6 +- | ||
120 | tests/qemu-iotests/085 | 18 ++-- | ||
121 | tests/qemu-iotests/085.out | 8 +- | ||
122 | tests/qemu-iotests/088 | 2 +- | ||
123 | tests/qemu-iotests/090 | 2 + | ||
124 | tests/qemu-iotests/091 | 2 +- | ||
125 | tests/qemu-iotests/091.out | 2 - | ||
126 | tests/qemu-iotests/092 | 2 +- | ||
127 | tests/qemu-iotests/094 | 4 +- | ||
128 | tests/qemu-iotests/095 | 5 +- | ||
129 | tests/qemu-iotests/098 | 6 +- | ||
130 | tests/qemu-iotests/099 | 10 +- | ||
131 | tests/qemu-iotests/103 | 5 +- | ||
132 | tests/qemu-iotests/106 | 2 +- | ||
133 | tests/qemu-iotests/108 | 10 +- | ||
134 | tests/qemu-iotests/109 | 4 +- | ||
135 | tests/qemu-iotests/110 | 11 +- | ||
136 | tests/qemu-iotests/110.out | 4 +- | ||
137 | tests/qemu-iotests/111 | 3 +- | ||
138 | tests/qemu-iotests/112 | 37 +++---- | ||
139 | tests/qemu-iotests/114 | 2 + | ||
140 | tests/qemu-iotests/115 | 3 +- | ||
141 | tests/qemu-iotests/121 | 9 +- | ||
142 | tests/qemu-iotests/122 | 6 +- | ||
143 | tests/qemu-iotests/123 | 4 +- | ||
144 | tests/qemu-iotests/125 | 2 +- | ||
145 | tests/qemu-iotests/137 | 17 +++- | ||
146 | tests/qemu-iotests/137.out | 6 +- | ||
147 | tests/qemu-iotests/138 | 8 +- | ||
148 | tests/qemu-iotests/141 | 4 +- | ||
149 | tests/qemu-iotests/142 | 2 +- | ||
150 | tests/qemu-iotests/144 | 4 +- | ||
151 | tests/qemu-iotests/153 | 12 +-- | ||
152 | tests/qemu-iotests/156 | 10 +- | ||
153 | tests/qemu-iotests/159 | 2 +- | ||
154 | tests/qemu-iotests/160 | 3 +- | ||
155 | tests/qemu-iotests/161 | 4 +- | ||
156 | tests/qemu-iotests/170 | 2 +- | ||
157 | tests/qemu-iotests/172 | 6 +- | ||
158 | tests/qemu-iotests/173 | 3 +- | ||
159 | tests/qemu-iotests/174 | 2 +- | ||
160 | tests/qemu-iotests/175 | 2 +- | ||
161 | tests/qemu-iotests/176 | 7 +- | ||
162 | tests/qemu-iotests/178 | 6 +- | ||
163 | tests/qemu-iotests/182 | 2 +- | ||
164 | tests/qemu-iotests/183 | 2 +- | ||
165 | tests/qemu-iotests/185 | 4 +- | ||
166 | tests/qemu-iotests/187 | 6 +- | ||
167 | tests/qemu-iotests/190 | 4 +- | ||
168 | tests/qemu-iotests/191 | 11 +- | ||
169 | tests/qemu-iotests/195 | 2 +- | ||
170 | tests/qemu-iotests/197 | 6 +- | ||
171 | tests/qemu-iotests/198 | 6 +- | ||
172 | tests/qemu-iotests/198.out | 4 +- | 119 | tests/qemu-iotests/198.out | 4 +- |
173 | tests/qemu-iotests/200 | 7 +- | 120 | tests/qemu-iotests/206 | 1 + |
174 | tests/qemu-iotests/201 | 6 +- | 121 | tests/qemu-iotests/255.out | 8 +- |
175 | tests/qemu-iotests/214 | 46 ++++++++- | 122 | tests/qemu-iotests/263 | 1 + |
176 | tests/qemu-iotests/214.out | 14 +++ | 123 | tests/qemu-iotests/263.out | 4 +- |
177 | tests/qemu-iotests/215 | 6 +- | 124 | tests/qemu-iotests/274.out | 46 ++-- |
178 | tests/qemu-iotests/217 | 3 +- | 125 | tests/qemu-iotests/280.out | 2 +- |
179 | tests/qemu-iotests/220 | 5 +- | 126 | tests/qemu-iotests/284 | 1 + |
180 | tests/qemu-iotests/225 | 2 +- | 127 | tests/qemu-iotests/284.out | 6 +- |
181 | tests/qemu-iotests/229 | 3 +- | 128 | tests/qemu-iotests/293 | 208 ++++++++++++++++ |
182 | tests/qemu-iotests/232 | 4 +- | 129 | tests/qemu-iotests/293.out | 99 ++++++++ |
183 | tests/qemu-iotests/235 | 2 +- | 130 | tests/qemu-iotests/294 | 90 +++++++ |
184 | tests/qemu-iotests/243 | 10 +- | 131 | tests/qemu-iotests/294.out | 30 +++ |
185 | tests/qemu-iotests/244 | 15 +-- | 132 | tests/qemu-iotests/295 | 280 +++++++++++++++++++++ |
186 | tests/qemu-iotests/247 | 4 +- | 133 | tests/qemu-iotests/295.out | 40 +++ |
187 | tests/qemu-iotests/249 | 4 +- | 134 | tests/qemu-iotests/296 | 234 +++++++++++++++++ |
188 | tests/qemu-iotests/250 | 5 +- | 135 | tests/qemu-iotests/296.out | 33 +++ |
189 | tests/qemu-iotests/252 | 2 +- | 136 | tests/qemu-iotests/common.filter | 106 ++++++-- |
190 | tests/qemu-iotests/261 | 5 +- | 137 | tests/qemu-iotests/common.rc | 30 +++ |
191 | tests/qemu-iotests/265 | 2 +- | 138 | tests/qemu-iotests/group | 4 + |
192 | tests/qemu-iotests/267 | 17 ++-- | 139 | tests/qemu-iotests/iotests.py | 84 +++++-- |
193 | tests/qemu-iotests/273 | 3 + | 140 | 72 files changed, 3103 insertions(+), 632 deletions(-) |
194 | tests/qemu-iotests/check | 6 +- | 141 | create mode 100644 block/amend.c |
195 | tests/qemu-iotests/common.filter | 47 ++++++++- | 142 | create mode 100755 tests/qemu-iotests/293 |
196 | tests/qemu-iotests/common.rc | 63 ++++++++++-- | 143 | create mode 100644 tests/qemu-iotests/293.out |
197 | tests/qemu-iotests/iotests.py | 18 ++-- | 144 | create mode 100755 tests/qemu-iotests/294 |
198 | tests/qemu-iotests/qcow2.py | 23 ++++- | 145 | create mode 100644 tests/qemu-iotests/294.out |
199 | 131 files changed, 1139 insertions(+), 552 deletions(-) | 146 | create mode 100755 tests/qemu-iotests/295 |
200 | create mode 100644 block/filter-compress.c | 147 | create mode 100644 tests/qemu-iotests/295.out |
148 | create mode 100755 tests/qemu-iotests/296 | ||
149 | create mode 100644 tests/qemu-iotests/296.out | ||
201 | 150 | ||
202 | -- | 151 | -- |
203 | 2.24.1 | 152 | 2.26.2 |
204 | 153 | ||
205 | 154 | diff view generated by jsdifflib |
1 | When dropping backup-top, we need to drain the node before freeing the | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | BlockCopyState. Otherwise, requests may still be in flight and then the | ||
3 | assertion in shres_destroy() will fail. | ||
4 | 2 | ||
5 | (This becomes visible in intermittent failure of 056.) | 3 | ret may be > 0 on success path at this point. Fix assertion, which may |
4 | crash currently. | ||
6 | 5 | ||
7 | Cc: qemu-stable@nongnu.org | 6 | Fixes: 4ce5dd3e9b5ee0fac18625860eb3727399ee965e |
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
9 | Message-id: 20191219182638.104621-1-mreitz@redhat.com | 8 | Message-Id: <20200526181347.489557-1-vsementsov@virtuozzo.com> |
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 9 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
11 | --- | 10 | --- |
12 | block/backup-top.c | 4 ++-- | 11 | block/block-copy.c | 4 +++- |
13 | 1 file changed, 2 insertions(+), 2 deletions(-) | 12 | 1 file changed, 3 insertions(+), 1 deletion(-) |
14 | 13 | ||
15 | diff --git a/block/backup-top.c b/block/backup-top.c | 14 | diff --git a/block/block-copy.c b/block/block-copy.c |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/block/backup-top.c | 16 | --- a/block/block-copy.c |
18 | +++ b/block/backup-top.c | 17 | +++ b/block/block-copy.c |
19 | @@ -XXX,XX +XXX,XX @@ void bdrv_backup_top_drop(BlockDriverState *bs) | 18 | @@ -XXX,XX +XXX,XX @@ out: |
20 | BDRVBackupTopState *s = bs->opaque; | 19 | * block_copy_task_run. If it fails, it means some task already failed |
21 | AioContext *aio_context = bdrv_get_aio_context(bs); | 20 | * for real reason, let's return first failure. |
22 | 21 | * Still, assert that we don't rewrite failure by success. | |
23 | - block_copy_state_free(s->bcs); | 22 | + * |
24 | - | 23 | + * Note: ret may be positive here because of block-status result. |
25 | aio_context_acquire(aio_context); | 24 | */ |
26 | 25 | - assert(ret == 0 || aio_task_pool_status(aio) < 0); | |
27 | bdrv_drained_begin(bs); | 26 | + assert(ret >= 0 || aio_task_pool_status(aio) < 0); |
28 | 27 | ret = aio_task_pool_status(aio); | |
29 | + block_copy_state_free(s->bcs); | 28 | |
30 | + | 29 | aio_task_pool_free(aio); |
31 | s->active = false; | ||
32 | bdrv_child_refresh_perms(bs, bs->backing, &error_abort); | ||
33 | bdrv_replace_node(bs, backing_bs(bs), &error_abort); | ||
34 | -- | 30 | -- |
35 | 2.24.1 | 31 | 2.26.2 |
36 | 32 | ||
37 | 33 | diff view generated by jsdifflib |
1 | Tests should not overwrite all user-supplied image options, but only add | 1 | From: Alberto Garcia <berto@igalia.com> |
---|---|---|---|
2 | to it (which will effectively overwrite conflicting values). Accomplish | ||
3 | this by passing options to _make_test_img via -o instead of $IMGOPTS. | ||
4 | 2 | ||
5 | For some tests, there is no functional change because they already only | 3 | When resizing an image with qcow2_co_truncate() using the falloc or |
6 | appended options to IMGOPTS. For these, this patch is just a | 4 | full preallocation modes the code assumes that both the old and new |
7 | simplification. | 5 | sizes are cluster-aligned. |
8 | 6 | ||
9 | For others, this is a change, so they now heed user-specified $IMGOPTS. | 7 | There are two problems with this: |
10 | Some of those tests do not work with all image options, though, so we | ||
11 | need to disable them accordingly. | ||
12 | 8 | ||
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 9 | 1) The calculation of how many clusters are involved does not always |
14 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 10 | get the right result. |
15 | Message-id: 20191107163708.833192-12-mreitz@redhat.com | 11 | |
12 | Example: creating a 60KB image and resizing it (with | ||
13 | preallocation=full) to 80KB won't allocate the second cluster. | ||
14 | |||
15 | 2) No copy-on-write is performed, so in the previous example if | ||
16 | there is a backing file then the first 60KB of the first cluster | ||
17 | won't be filled with data from the backing file. | ||
18 | |||
19 | This patch fixes both issues. | ||
20 | |||
21 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
22 | Message-Id: <20200617140036.20311-1-berto@igalia.com> | ||
23 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 24 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
17 | --- | 25 | --- |
18 | tests/qemu-iotests/031 | 9 ++++--- | 26 | block/qcow2.c | 17 ++++++++++++++--- |
19 | tests/qemu-iotests/039 | 24 ++++++------------ | 27 | tests/qemu-iotests/125 | 24 ++++++++++++++++++++++++ |
20 | tests/qemu-iotests/059 | 18 ++++++------- | 28 | tests/qemu-iotests/125.out | 9 +++++++++ |
21 | tests/qemu-iotests/060 | 6 ++--- | 29 | 3 files changed, 47 insertions(+), 3 deletions(-) |
22 | tests/qemu-iotests/061 | 57 ++++++++++++++++++++++-------------------- | ||
23 | tests/qemu-iotests/079 | 3 +-- | ||
24 | tests/qemu-iotests/106 | 2 +- | ||
25 | tests/qemu-iotests/108 | 2 +- | ||
26 | tests/qemu-iotests/112 | 32 ++++++++++++------------ | ||
27 | tests/qemu-iotests/115 | 3 +-- | ||
28 | tests/qemu-iotests/121 | 6 ++--- | ||
29 | tests/qemu-iotests/125 | 2 +- | ||
30 | tests/qemu-iotests/137 | 2 +- | ||
31 | tests/qemu-iotests/138 | 3 +-- | ||
32 | tests/qemu-iotests/175 | 2 +- | ||
33 | tests/qemu-iotests/190 | 2 +- | ||
34 | tests/qemu-iotests/191 | 3 +-- | ||
35 | tests/qemu-iotests/220 | 4 ++- | ||
36 | tests/qemu-iotests/243 | 6 +++-- | ||
37 | tests/qemu-iotests/244 | 10 +++++--- | ||
38 | tests/qemu-iotests/250 | 3 +-- | ||
39 | tests/qemu-iotests/265 | 2 +- | ||
40 | 22 files changed, 100 insertions(+), 101 deletions(-) | ||
41 | 30 | ||
42 | diff --git a/tests/qemu-iotests/031 b/tests/qemu-iotests/031 | 31 | diff --git a/block/qcow2.c b/block/qcow2.c |
43 | index XXXXXXX..XXXXXXX 100755 | 32 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/tests/qemu-iotests/031 | 33 | --- a/block/qcow2.c |
45 | +++ b/tests/qemu-iotests/031 | 34 | +++ b/block/qcow2.c |
46 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 35 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, |
47 | # This tests qcow2-specific low-level functionality | 36 | old_file_size = ROUND_UP(old_file_size, s->cluster_size); |
48 | _supported_fmt qcow2 | 37 | } |
49 | _supported_proto file | 38 | |
50 | +# We want to test compat=0.10, which does not support refcount widths | 39 | - nb_new_data_clusters = DIV_ROUND_UP(offset - old_length, |
51 | +# other than 16 | 40 | - s->cluster_size); |
52 | +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | 41 | + nb_new_data_clusters = (ROUND_UP(offset, s->cluster_size) - |
53 | 42 | + start_of_cluster(s, old_length)) >> s->cluster_bits; | |
54 | CLUSTER_SIZE=65536 | 43 | |
55 | 44 | /* This is an overestimation; we will not actually allocate space for | |
56 | # qcow2.py output depends on the exact options used, so override the command | 45 | * these in the file but just make sure the new refcount structures are |
57 | # line here as an exception | 46 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset, |
58 | -for IMGOPTS in "compat=0.10" "compat=1.1"; do | 47 | int64_t nb_clusters = MIN( |
59 | +for compat in "compat=0.10" "compat=1.1"; do | 48 | nb_new_data_clusters, |
60 | 49 | s->l2_slice_size - offset_to_l2_slice_index(s, guest_offset)); | |
61 | echo | 50 | - QCowL2Meta allocation = { |
62 | - echo ===== Testing with -o $IMGOPTS ===== | 51 | + unsigned cow_start_length = offset_into_cluster(s, guest_offset); |
63 | + echo ===== Testing with -o $compat ===== | 52 | + QCowL2Meta allocation; |
64 | echo | 53 | + guest_offset = start_of_cluster(s, guest_offset); |
65 | echo === Create image with unknown header extension === | 54 | + allocation = (QCowL2Meta) { |
66 | echo | 55 | .offset = guest_offset, |
67 | - _make_test_img 64M | 56 | .alloc_offset = host_offset, |
68 | + _make_test_img -o $compat 64M | 57 | .nb_clusters = nb_clusters, |
69 | $PYTHON qcow2.py "$TEST_IMG" add-header-ext 0x12345678 "This is a test header extension" | 58 | + .cow_start = { |
70 | $PYTHON qcow2.py "$TEST_IMG" dump-header | 59 | + .offset = 0, |
71 | _check_test_img | 60 | + .nb_bytes = cow_start_length, |
72 | diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 | 61 | + }, |
73 | index XXXXXXX..XXXXXXX 100755 | 62 | + .cow_end = { |
74 | --- a/tests/qemu-iotests/039 | 63 | + .offset = nb_clusters << s->cluster_bits, |
75 | +++ b/tests/qemu-iotests/039 | 64 | + .nb_bytes = 0, |
76 | @@ -XXX,XX +XXX,XX @@ size=128M | 65 | + }, |
77 | echo | 66 | }; |
78 | echo "== Checking that image is clean on shutdown ==" | 67 | qemu_co_queue_init(&allocation.dependent_requests); |
79 | 68 | ||
80 | -IMGOPTS="compat=1.1,lazy_refcounts=on" | ||
81 | -_make_test_img $size | ||
82 | +_make_test_img -o "compat=1.1,lazy_refcounts=on" $size | ||
83 | |||
84 | $QEMU_IO -c "write -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io | ||
85 | |||
86 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
87 | echo | ||
88 | echo "== Creating a dirty image file ==" | ||
89 | |||
90 | -IMGOPTS="compat=1.1,lazy_refcounts=on" | ||
91 | -_make_test_img $size | ||
92 | +_make_test_img -o "compat=1.1,lazy_refcounts=on" $size | ||
93 | |||
94 | _NO_VALGRIND \ | ||
95 | $QEMU_IO -c "write -P 0x5a 0 512" \ | ||
96 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "read -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io | ||
97 | echo | ||
98 | echo "== Opening a dirty image read/write should repair it ==" | ||
99 | |||
100 | -IMGOPTS="compat=1.1,lazy_refcounts=on" | ||
101 | -_make_test_img $size | ||
102 | +_make_test_img -o "compat=1.1,lazy_refcounts=on" $size | ||
103 | |||
104 | _NO_VALGRIND \ | ||
105 | $QEMU_IO -c "write -P 0x5a 0 512" \ | ||
106 | @@ -XXX,XX +XXX,XX @@ $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features | ||
107 | echo | ||
108 | echo "== Creating an image file with lazy_refcounts=off ==" | ||
109 | |||
110 | -IMGOPTS="compat=1.1,lazy_refcounts=off" | ||
111 | -_make_test_img $size | ||
112 | +_make_test_img -o "compat=1.1,lazy_refcounts=off" $size | ||
113 | |||
114 | _NO_VALGRIND \ | ||
115 | $QEMU_IO -c "write -P 0x5a 0 512" \ | ||
116 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
117 | echo | ||
118 | echo "== Committing to a backing file with lazy_refcounts=on ==" | ||
119 | |||
120 | -IMGOPTS="compat=1.1,lazy_refcounts=on" | ||
121 | -TEST_IMG="$TEST_IMG".base _make_test_img $size | ||
122 | +TEST_IMG="$TEST_IMG".base _make_test_img -o "compat=1.1,lazy_refcounts=on" $size | ||
123 | |||
124 | -IMGOPTS="compat=1.1,lazy_refcounts=on,backing_file=$TEST_IMG.base" | ||
125 | -_make_test_img $size | ||
126 | +_make_test_img -o "compat=1.1,lazy_refcounts=on,backing_file=$TEST_IMG.base" $size | ||
127 | |||
128 | $QEMU_IO -c "write 0 512" "$TEST_IMG" | _filter_qemu_io | ||
129 | $QEMU_IMG commit "$TEST_IMG" | ||
130 | @@ -XXX,XX +XXX,XX @@ TEST_IMG="$TEST_IMG".base _check_test_img | ||
131 | echo | ||
132 | echo "== Changing lazy_refcounts setting at runtime ==" | ||
133 | |||
134 | -IMGOPTS="compat=1.1,lazy_refcounts=off" | ||
135 | -_make_test_img $size | ||
136 | +_make_test_img -o "compat=1.1,lazy_refcounts=off" $size | ||
137 | |||
138 | _NO_VALGRIND \ | ||
139 | $QEMU_IO -c "reopen -o lazy-refcounts=on" \ | ||
140 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "reopen -o lazy-refcounts=on" \ | ||
141 | $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features | ||
142 | _check_test_img | ||
143 | |||
144 | -IMGOPTS="compat=1.1,lazy_refcounts=on" | ||
145 | -_make_test_img $size | ||
146 | +_make_test_img -o "compat=1.1,lazy_refcounts=on" $size | ||
147 | |||
148 | _NO_VALGRIND \ | ||
149 | $QEMU_IO -c "reopen -o lazy-refcounts=off" \ | ||
150 | diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 | ||
151 | index XXXXXXX..XXXXXXX 100755 | ||
152 | --- a/tests/qemu-iotests/059 | ||
153 | +++ b/tests/qemu-iotests/059 | ||
154 | @@ -XXX,XX +XXX,XX @@ poke_file "$TEST_IMG" "$grain_table_size_offset" "\x01\x00\x00\x00" | ||
155 | |||
156 | echo | ||
157 | echo "=== Testing monolithicFlat creation and opening ===" | ||
158 | -IMGOPTS="subformat=monolithicFlat" _make_test_img 2G | ||
159 | +_make_test_img -o "subformat=monolithicFlat" 2G | ||
160 | _img_info | ||
161 | _cleanup_test_img | ||
162 | |||
163 | echo | ||
164 | echo "=== Testing monolithicFlat with zeroed_grain ===" | ||
165 | -IMGOPTS="subformat=monolithicFlat,zeroed_grain=on" _make_test_img 2G | ||
166 | +_make_test_img -o "subformat=monolithicFlat,zeroed_grain=on" 2G | ||
167 | _cleanup_test_img | ||
168 | |||
169 | echo | ||
170 | echo "=== Testing big twoGbMaxExtentFlat ===" | ||
171 | -IMGOPTS="subformat=twoGbMaxExtentFlat" _make_test_img 1000G | ||
172 | +_make_test_img -o "subformat=twoGbMaxExtentFlat" 1000G | ||
173 | $QEMU_IMG info $TEST_IMG | _filter_testdir | sed -e 's/cid: [0-9]*/cid: XXXXXXXX/' | ||
174 | _cleanup_test_img | ||
175 | |||
176 | @@ -XXX,XX +XXX,XX @@ _img_info | ||
177 | |||
178 | echo | ||
179 | echo "=== Testing truncated sparse ===" | ||
180 | -IMGOPTS="subformat=monolithicSparse" _make_test_img 100G | ||
181 | +_make_test_img -o "subformat=monolithicSparse" 100G | ||
182 | truncate -s 10M $TEST_IMG | ||
183 | _img_info | ||
184 | |||
185 | echo | ||
186 | echo "=== Converting to streamOptimized from image with small cluster size===" | ||
187 | -TEST_IMG="$TEST_IMG.qcow2" IMGFMT=qcow2 IMGOPTS="cluster_size=4096" _make_test_img 1G | ||
188 | +TEST_IMG="$TEST_IMG.qcow2" IMGFMT=qcow2 _make_test_img -o "cluster_size=4096" 1G | ||
189 | $QEMU_IO -f qcow2 -c "write -P 0xa 0 512" "$TEST_IMG.qcow2" | _filter_qemu_io | ||
190 | $QEMU_IO -f qcow2 -c "write -P 0xb 10240 512" "$TEST_IMG.qcow2" | _filter_qemu_io | ||
191 | $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2" "$TEST_IMG" 2>&1 | ||
192 | @@ -XXX,XX +XXX,XX @@ echo "=== Testing monolithicFlat with internally generated JSON file name ===" | ||
193 | |||
194 | echo '--- blkdebug ---' | ||
195 | # Should work, because bdrv_dirname() works fine with blkdebug | ||
196 | -IMGOPTS="subformat=monolithicFlat" _make_test_img 64M | ||
197 | +_make_test_img -o "subformat=monolithicFlat" 64M | ||
198 | $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \ | ||
199 | -c info \ | ||
200 | 2>&1 \ | ||
201 | @@ -XXX,XX +XXX,XX @@ _cleanup_test_img | ||
202 | |||
203 | echo '--- quorum ---' | ||
204 | # Should not work, because bdrv_dirname() does not work with quorum | ||
205 | -IMGOPTS="subformat=monolithicFlat" _make_test_img 64M | ||
206 | +_make_test_img -o "subformat=monolithicFlat" 64M | ||
207 | cp "$TEST_IMG" "$TEST_IMG.orig" | ||
208 | |||
209 | filename="json:{ | ||
210 | @@ -XXX,XX +XXX,XX @@ _cleanup_test_img | ||
211 | |||
212 | echo | ||
213 | echo "=== Testing 4TB monolithicFlat creation and IO ===" | ||
214 | -IMGOPTS="subformat=monolithicFlat" _make_test_img 4T | ||
215 | +_make_test_img -o "subformat=monolithicFlat" 4T | ||
216 | _img_info | ||
217 | $QEMU_IO -c "write -P 0xa 900G 512" "$TEST_IMG" | _filter_qemu_io | ||
218 | $QEMU_IO -c "read -v 900G 1024" "$TEST_IMG" | _filter_qemu_io | ||
219 | @@ -XXX,XX +XXX,XX @@ _cleanup_test_img | ||
220 | echo | ||
221 | echo "=== Testing qemu-img map on extents ===" | ||
222 | for fmt in monolithicSparse twoGbMaxExtentSparse; do | ||
223 | - IMGOPTS="subformat=$fmt" _make_test_img 31G | ||
224 | + _make_test_img -o "subformat=$fmt" 31G | ||
225 | $QEMU_IO -c "write 65024 1k" "$TEST_IMG" | _filter_qemu_io | ||
226 | $QEMU_IO -c "write 2147483136 1k" "$TEST_IMG" | _filter_qemu_io | ||
227 | $QEMU_IO -c "write 5G 1k" "$TEST_IMG" | _filter_qemu_io | ||
228 | diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 | ||
229 | index XXXXXXX..XXXXXXX 100755 | ||
230 | --- a/tests/qemu-iotests/060 | ||
231 | +++ b/tests/qemu-iotests/060 | ||
232 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c 'write 0k 64k' "$BACKING_IMG" | _filter_qemu_io | ||
233 | # compat=0.10 is required in order to make the following discard actually | ||
234 | # unallocate the sector rather than make it a zero sector - we want COW, after | ||
235 | # all. | ||
236 | -IMGOPTS='compat=0.10' _make_test_img -b "$BACKING_IMG" 1G | ||
237 | +_make_test_img -o 'compat=0.10' -b "$BACKING_IMG" 1G | ||
238 | # Write two clusters, the second one enforces creation of an L2 table after | ||
239 | # the first data cluster. | ||
240 | $QEMU_IO -c 'write 0k 64k' -c 'write 512M 64k' "$TEST_IMG" | _filter_qemu_io | ||
241 | @@ -XXX,XX +XXX,XX @@ echo | ||
242 | echo "=== Discarding a non-covered in-bounds refblock ===" | ||
243 | echo | ||
244 | |||
245 | -IMGOPTS='refcount_bits=1' _make_test_img 64M | ||
246 | +_make_test_img -o 'refcount_bits=1' 64M | ||
247 | |||
248 | # Pretend there's a refblock somewhere where there is no refblock to | ||
249 | # cover it (but the covering refblock has a valid index in the | ||
250 | @@ -XXX,XX +XXX,XX @@ echo | ||
251 | echo "=== Discarding a refblock covered by an unaligned refblock ===" | ||
252 | echo | ||
253 | |||
254 | -IMGOPTS='refcount_bits=1' _make_test_img 64M | ||
255 | +_make_test_img -o 'refcount_bits=1' 64M | ||
256 | |||
257 | # Same as above | ||
258 | poke_file "$TEST_IMG" "$(($rt_offset+8))" "\x00\x00\x00\x10\x00\x00\x00\x00" | ||
259 | diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 | ||
260 | index XXXXXXX..XXXXXXX 100755 | ||
261 | --- a/tests/qemu-iotests/061 | ||
262 | +++ b/tests/qemu-iotests/061 | ||
263 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
264 | _supported_fmt qcow2 | ||
265 | _supported_proto file | ||
266 | _supported_os Linux | ||
267 | +# Conversion between different compat versions can only really work | ||
268 | +# with refcount_bits=16 | ||
269 | +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
270 | |||
271 | echo | ||
272 | echo "=== Testing version downgrade with zero expansion ===" | ||
273 | echo | ||
274 | -IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M | ||
275 | +_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M | ||
276 | $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io | ||
277 | $PYTHON qcow2.py "$TEST_IMG" dump-header | ||
278 | $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" | ||
279 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
280 | echo | ||
281 | echo "=== Testing version downgrade with zero expansion and 4K cache entries ===" | ||
282 | echo | ||
283 | -IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M | ||
284 | +_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M | ||
285 | $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io | ||
286 | $QEMU_IO -c "write -z 32M 128k" "$TEST_IMG" | _filter_qemu_io | ||
287 | $QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io | ||
288 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
289 | echo | ||
290 | echo "=== Testing dirty version downgrade ===" | ||
291 | echo | ||
292 | -IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M | ||
293 | +_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M | ||
294 | _NO_VALGRIND \ | ||
295 | $QEMU_IO -c "write -P 0x2a 0 128k" -c flush \ | ||
296 | -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io | ||
297 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
298 | echo | ||
299 | echo "=== Testing version downgrade with unknown compat/autoclear flags ===" | ||
300 | echo | ||
301 | -IMGOPTS="compat=1.1" _make_test_img 64M | ||
302 | +_make_test_img -o "compat=1.1" 64M | ||
303 | $PYTHON qcow2.py "$TEST_IMG" set-feature-bit compatible 42 | ||
304 | $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 42 | ||
305 | $PYTHON qcow2.py "$TEST_IMG" dump-header | ||
306 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
307 | echo | ||
308 | echo "=== Testing version upgrade and resize ===" | ||
309 | echo | ||
310 | -IMGOPTS="compat=0.10" _make_test_img 64M | ||
311 | +_make_test_img -o "compat=0.10" 64M | ||
312 | $QEMU_IO -c "write -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io | ||
313 | $PYTHON qcow2.py "$TEST_IMG" dump-header | ||
314 | $QEMU_IMG amend -o "compat=1.1,lazy_refcounts=on,size=128M" "$TEST_IMG" | ||
315 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
316 | echo | ||
317 | echo "=== Testing dirty lazy_refcounts=off ===" | ||
318 | echo | ||
319 | -IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M | ||
320 | +_make_test_img -o "compat=1.1,lazy_refcounts=on" 64M | ||
321 | _NO_VALGRIND \ | ||
322 | $QEMU_IO -c "write -P 0x2a 0 128k" -c flush \ | ||
323 | -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io | ||
324 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
325 | echo | ||
326 | echo "=== Testing backing file ===" | ||
327 | echo | ||
328 | -IMGOPTS="compat=1.1" _make_test_img 64M | ||
329 | -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 64M | ||
330 | +_make_test_img -o "compat=1.1" 64M | ||
331 | +TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M | ||
332 | $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io | ||
333 | $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io | ||
334 | $QEMU_IMG amend -o "backing_file=$TEST_IMG.base,backing_fmt=qcow2" "$TEST_IMG" | ||
335 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
336 | echo | ||
337 | echo "=== Testing invalid configurations ===" | ||
338 | echo | ||
339 | -IMGOPTS="compat=0.10" _make_test_img 64M | ||
340 | +_make_test_img -o "compat=0.10" 64M | ||
341 | $QEMU_IMG amend -o "lazy_refcounts=on" "$TEST_IMG" | ||
342 | $QEMU_IMG amend -o "compat=1.1" "$TEST_IMG" # actually valid | ||
343 | $QEMU_IMG amend -o "compat=0.10,lazy_refcounts=on" "$TEST_IMG" | ||
344 | @@ -XXX,XX +XXX,XX @@ $QEMU_IMG amend -o "preallocation=on" "$TEST_IMG" | ||
345 | echo | ||
346 | echo "=== Testing correct handling of unset value ===" | ||
347 | echo | ||
348 | -IMGOPTS="compat=1.1,cluster_size=1k" _make_test_img 64M | ||
349 | +_make_test_img -o "compat=1.1,cluster_size=1k" 64M | ||
350 | echo "Should work:" | ||
351 | $QEMU_IMG amend -o "lazy_refcounts=on" "$TEST_IMG" | ||
352 | echo "Should not work:" # Just to know which of these tests actually fails | ||
353 | @@ -XXX,XX +XXX,XX @@ $QEMU_IMG amend -o "cluster_size=64k" "$TEST_IMG" | ||
354 | echo | ||
355 | echo "=== Testing zero expansion on inactive clusters ===" | ||
356 | echo | ||
357 | -IMGOPTS="compat=1.1" _make_test_img 64M | ||
358 | +_make_test_img -o "compat=1.1" 64M | ||
359 | $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io | ||
360 | $QEMU_IMG snapshot -c foo "$TEST_IMG" | ||
361 | $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io | ||
362 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io | ||
363 | echo | ||
364 | echo "=== Testing zero expansion on shared L2 table ===" | ||
365 | echo | ||
366 | -IMGOPTS="compat=1.1" _make_test_img 64M | ||
367 | +_make_test_img -o "compat=1.1" 64M | ||
368 | $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io | ||
369 | $QEMU_IMG snapshot -c foo "$TEST_IMG" | ||
370 | $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" | ||
371 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io | ||
372 | echo | ||
373 | echo "=== Testing zero expansion on backed image ===" | ||
374 | echo | ||
375 | -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 64M | ||
376 | +TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M | ||
377 | $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io | ||
378 | -IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 64M | ||
379 | +_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 64M | ||
380 | $QEMU_IO -c "read -P 0x2a 0 128k" -c "write -z 0 64k" "$TEST_IMG" | _filter_qemu_io | ||
381 | $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" | ||
382 | _check_test_img | ||
383 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "read -P 0 0 64k" -c "read -P 0x2a 64k 64k" "$TEST_IMG" | _filter_qe | ||
384 | echo | ||
385 | echo "=== Testing zero expansion on backed inactive clusters ===" | ||
386 | echo | ||
387 | -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 64M | ||
388 | +TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M | ||
389 | $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io | ||
390 | -IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 64M | ||
391 | +_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 64M | ||
392 | $QEMU_IO -c "write -z 0 64k" "$TEST_IMG" | _filter_qemu_io | ||
393 | $QEMU_IMG snapshot -c foo "$TEST_IMG" | ||
394 | $QEMU_IO -c "write -P 0x42 0 128k" "$TEST_IMG" | _filter_qemu_io | ||
395 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "read -P 0 0 64k" -c "read -P 0x2a 64k 64k" "$TEST_IMG" | _filter_qe | ||
396 | echo | ||
397 | echo "=== Testing zero expansion on backed image with shared L2 table ===" | ||
398 | echo | ||
399 | -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 64M | ||
400 | +TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M | ||
401 | $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io | ||
402 | -IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 64M | ||
403 | +_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 64M | ||
404 | $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io | ||
405 | $QEMU_IMG snapshot -c foo "$TEST_IMG" | ||
406 | $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" | ||
407 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io | ||
408 | echo | ||
409 | echo "=== Testing preallocated zero expansion on full image ===" | ||
410 | echo | ||
411 | -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG" _make_test_img 64M | ||
412 | +TEST_IMG="$TEST_IMG" _make_test_img -o "compat=1.1" 64M | ||
413 | $QEMU_IO -c "write -P 0x2a 0 64M" "$TEST_IMG" -c "write -z 0 64M" | _filter_qemu_io | ||
414 | $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" | ||
415 | _check_test_img | ||
416 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "read -P 0 0 64M" "$TEST_IMG" | _filter_qemu_io | ||
417 | echo | ||
418 | echo "=== Testing progress report without snapshot ===" | ||
419 | echo | ||
420 | -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 4G | ||
421 | -IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 4G | ||
422 | +TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 4G | ||
423 | +_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 4G | ||
424 | $QEMU_IO -c "write -z 0 64k" \ | ||
425 | -c "write -z 1G 64k" \ | ||
426 | -c "write -z 2G 64k" \ | ||
427 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
428 | echo | ||
429 | echo "=== Testing progress report with snapshot ===" | ||
430 | echo | ||
431 | -IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 4G | ||
432 | -IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 4G | ||
433 | +TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 4G | ||
434 | +_make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 4G | ||
435 | $QEMU_IO -c "write -z 0 64k" \ | ||
436 | -c "write -z 1G 64k" \ | ||
437 | -c "write -z 2G 64k" \ | ||
438 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
439 | echo | ||
440 | echo "=== Testing version downgrade with external data file ===" | ||
441 | echo | ||
442 | -IMGOPTS="compat=1.1,data_file=$TEST_IMG.data" _make_test_img 64M | ||
443 | +_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data" 64M | ||
444 | $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" | ||
445 | _img_info --format-specific | ||
446 | _check_test_img | ||
447 | @@ -XXX,XX +XXX,XX @@ _check_test_img | ||
448 | echo | ||
449 | echo "=== Try changing the external data file ===" | ||
450 | echo | ||
451 | -IMGOPTS="compat=1.1" _make_test_img 64M | ||
452 | +_make_test_img -o "compat=1.1" 64M | ||
453 | $QEMU_IMG amend -o "data_file=foo" "$TEST_IMG" | ||
454 | |||
455 | echo | ||
456 | -IMGOPTS="compat=1.1,data_file=$TEST_IMG.data" _make_test_img 64M | ||
457 | +_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data" 64M | ||
458 | $QEMU_IMG amend -o "data_file=foo" "$TEST_IMG" | ||
459 | _img_info --format-specific | ||
460 | TEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info --format-specific --image-opts | ||
461 | @@ -XXX,XX +XXX,XX @@ TEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info - | ||
462 | echo | ||
463 | echo "=== Clearing and setting data-file-raw ===" | ||
464 | echo | ||
465 | -IMGOPTS="compat=1.1,data_file=$TEST_IMG.data,data_file_raw=on" _make_test_img 64M | ||
466 | +_make_test_img -o "compat=1.1,data_file=$TEST_IMG.data,data_file_raw=on" 64M | ||
467 | $QEMU_IMG amend -o "data_file_raw=on" "$TEST_IMG" | ||
468 | _img_info --format-specific | ||
469 | _check_test_img | ||
470 | diff --git a/tests/qemu-iotests/079 b/tests/qemu-iotests/079 | ||
471 | index XXXXXXX..XXXXXXX 100755 | ||
472 | --- a/tests/qemu-iotests/079 | ||
473 | +++ b/tests/qemu-iotests/079 | ||
474 | @@ -XXX,XX +XXX,XX @@ echo | ||
475 | cluster_sizes="16384 32768 65536 131072 262144 524288 1048576 2097152 4194304" | ||
476 | |||
477 | for s in $cluster_sizes; do | ||
478 | - IMGOPTS=$(_optstr_add "$IMGOPTS" "preallocation=metadata,cluster_size=$s") \ | ||
479 | - _make_test_img 4G | ||
480 | + _make_test_img -o "preallocation=metadata,cluster_size=$s" 4G | ||
481 | done | ||
482 | |||
483 | # success, all done | ||
484 | diff --git a/tests/qemu-iotests/106 b/tests/qemu-iotests/106 | ||
485 | index XXXXXXX..XXXXXXX 100755 | ||
486 | --- a/tests/qemu-iotests/106 | ||
487 | +++ b/tests/qemu-iotests/106 | ||
488 | @@ -XXX,XX +XXX,XX @@ for create_mode in off falloc full; do | ||
489 | echo | ||
490 | echo "--- create_mode=$create_mode growth_mode=$growth_mode ---" | ||
491 | |||
492 | - IMGOPTS="preallocation=$create_mode" _make_test_img ${CREATION_SIZE}K | ||
493 | + _make_test_img -o "preallocation=$create_mode" ${CREATION_SIZE}K | ||
494 | $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K | ||
495 | |||
496 | expected_size=0 | ||
497 | diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108 | ||
498 | index XXXXXXX..XXXXXXX 100755 | ||
499 | --- a/tests/qemu-iotests/108 | ||
500 | +++ b/tests/qemu-iotests/108 | ||
501 | @@ -XXX,XX +XXX,XX @@ echo | ||
502 | echo '=== Repairing unreferenced data cluster in new refblock area ===' | ||
503 | echo | ||
504 | |||
505 | -IMGOPTS='cluster_size=512' _make_test_img 64M | ||
506 | +_make_test_img -o 'cluster_size=512' 64M | ||
507 | # Allocate the first 128 kB in the image (first refblock) | ||
508 | $QEMU_IO -c 'write 0 0x1b200' "$TEST_IMG" | _filter_qemu_io | ||
509 | # should be 131072 == 0x20000 | ||
510 | diff --git a/tests/qemu-iotests/112 b/tests/qemu-iotests/112 | ||
511 | index XXXXXXX..XXXXXXX 100755 | ||
512 | --- a/tests/qemu-iotests/112 | ||
513 | +++ b/tests/qemu-iotests/112 | ||
514 | @@ -XXX,XX +XXX,XX @@ echo '=== refcount_bits limits ===' | ||
515 | echo | ||
516 | |||
517 | # Must be positive (non-zero) | ||
518 | -IMGOPTS="$IMGOPTS,refcount_bits=0" _make_test_img 64M | ||
519 | +_make_test_img -o "refcount_bits=0" 64M | ||
520 | # Must be positive (non-negative) | ||
521 | -IMGOPTS="$IMGOPTS,refcount_bits=-1" _make_test_img 64M | ||
522 | +_make_test_img -o "refcount_bits=-1" 64M | ||
523 | # May not exceed 64 | ||
524 | -IMGOPTS="$IMGOPTS,refcount_bits=128" _make_test_img 64M | ||
525 | +_make_test_img -o "refcount_bits=128" 64M | ||
526 | # Must be a power of two | ||
527 | -IMGOPTS="$IMGOPTS,refcount_bits=42" _make_test_img 64M | ||
528 | +_make_test_img -o "refcount_bits=42" 64M | ||
529 | |||
530 | # 1 is the minimum | ||
531 | -IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M | ||
532 | +_make_test_img -o "refcount_bits=1" 64M | ||
533 | print_refcount_bits | ||
534 | |||
535 | # 64 is the maximum | ||
536 | -IMGOPTS="$IMGOPTS,refcount_bits=64" _make_test_img 64M | ||
537 | +_make_test_img -o "refcount_bits=64" 64M | ||
538 | print_refcount_bits | ||
539 | |||
540 | # 16 is the default | ||
541 | @@ -XXX,XX +XXX,XX @@ echo '=== refcount_bits and compat=0.10 ===' | ||
542 | echo | ||
543 | |||
544 | # Should work | ||
545 | -IMGOPTS="$IMGOPTS,compat=0.10,refcount_bits=16" _make_test_img 64M | ||
546 | +_make_test_img -o "compat=0.10,refcount_bits=16" 64M | ||
547 | print_refcount_bits | ||
548 | |||
549 | # Should not work | ||
550 | -IMGOPTS="$IMGOPTS,compat=0.10,refcount_bits=1" _make_test_img 64M | ||
551 | -IMGOPTS="$IMGOPTS,compat=0.10,refcount_bits=64" _make_test_img 64M | ||
552 | +_make_test_img -o "compat=0.10,refcount_bits=1" 64M | ||
553 | +_make_test_img -o "compat=0.10,refcount_bits=64" 64M | ||
554 | |||
555 | |||
556 | echo | ||
557 | echo '=== Snapshot limit on refcount_bits=1 ===' | ||
558 | echo | ||
559 | |||
560 | -IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M | ||
561 | +_make_test_img -o "refcount_bits=1" 64M | ||
562 | print_refcount_bits | ||
563 | |||
564 | $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io | ||
565 | @@ -XXX,XX +XXX,XX @@ echo | ||
566 | echo '=== Snapshot limit on refcount_bits=2 ===' | ||
567 | echo | ||
568 | |||
569 | -IMGOPTS="$IMGOPTS,refcount_bits=2" _make_test_img 64M | ||
570 | +_make_test_img -o "refcount_bits=2" 64M | ||
571 | print_refcount_bits | ||
572 | |||
573 | $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io | ||
574 | @@ -XXX,XX +XXX,XX @@ echo | ||
575 | echo '=== Compressed clusters with refcount_bits=1 ===' | ||
576 | echo | ||
577 | |||
578 | -IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M | ||
579 | +_make_test_img -o "refcount_bits=1" 64M | ||
580 | print_refcount_bits | ||
581 | |||
582 | # Both should fit into a single host cluster; instead of failing to increase the | ||
583 | @@ -XXX,XX +XXX,XX @@ echo | ||
584 | echo '=== MSb set in 64 bit refcount ===' | ||
585 | echo | ||
586 | |||
587 | -IMGOPTS="$IMGOPTS,refcount_bits=64" _make_test_img 64M | ||
588 | +_make_test_img -o "refcount_bits=64" 64M | ||
589 | print_refcount_bits | ||
590 | |||
591 | $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io | ||
592 | @@ -XXX,XX +XXX,XX @@ echo | ||
593 | echo '=== Snapshot on maximum 64 bit refcount value ===' | ||
594 | echo | ||
595 | |||
596 | -IMGOPTS="$IMGOPTS,refcount_bits=64" _make_test_img 64M | ||
597 | +_make_test_img -o "refcount_bits=64" 64M | ||
598 | print_refcount_bits | ||
599 | |||
600 | $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io | ||
601 | @@ -XXX,XX +XXX,XX @@ echo | ||
602 | echo '=== Testing too many references for check ===' | ||
603 | echo | ||
604 | |||
605 | -IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M | ||
606 | +_make_test_img -o "refcount_bits=1" 64M | ||
607 | print_refcount_bits | ||
608 | |||
609 | # This cluster should be created at 0x50000 | ||
610 | @@ -XXX,XX +XXX,XX @@ echo | ||
611 | echo '=== Multiple walks necessary during amend ===' | ||
612 | echo | ||
613 | |||
614 | -IMGOPTS="$IMGOPTS,refcount_bits=1,cluster_size=512" _make_test_img 64k | ||
615 | +_make_test_img -o "refcount_bits=1,cluster_size=512" 64k | ||
616 | |||
617 | # Cluster 0 is the image header, clusters 1 to 4 are used by the L1 table, a | ||
618 | # single L2 table, the reftable and a single refblock. This creates 58 data | ||
619 | diff --git a/tests/qemu-iotests/115 b/tests/qemu-iotests/115 | ||
620 | index XXXXXXX..XXXXXXX 100755 | ||
621 | --- a/tests/qemu-iotests/115 | ||
622 | +++ b/tests/qemu-iotests/115 | ||
623 | @@ -XXX,XX +XXX,XX @@ echo | ||
624 | # least 256 MB. We can achieve that by using preallocation=metadata for an image | ||
625 | # which has a guest disk size of 256 MB. | ||
626 | |||
627 | -IMGOPTS="$IMGOPTS,refcount_bits=64,cluster_size=512,preallocation=metadata" \ | ||
628 | - _make_test_img 256M | ||
629 | +_make_test_img -o "refcount_bits=64,cluster_size=512,preallocation=metadata" 256M | ||
630 | |||
631 | # We know for sure that the L1 and refcount tables do not overlap with any other | ||
632 | # structure because the metadata overlap checks would have caught that case. | ||
633 | diff --git a/tests/qemu-iotests/121 b/tests/qemu-iotests/121 | ||
634 | index XXXXXXX..XXXXXXX 100755 | ||
635 | --- a/tests/qemu-iotests/121 | ||
636 | +++ b/tests/qemu-iotests/121 | ||
637 | @@ -XXX,XX +XXX,XX @@ echo | ||
638 | # Preallocation speeds up the write operation, but preallocating everything will | ||
639 | # destroy the purpose of the write; so preallocate one KB less than what would | ||
640 | # cause a reftable growth... | ||
641 | -IMGOPTS='preallocation=metadata,cluster_size=1k' _make_test_img 64512K | ||
642 | +_make_test_img -o 'preallocation=metadata,cluster_size=1k' 64512K | ||
643 | # ...and make the image the desired size afterwards. | ||
644 | $QEMU_IMG resize "$TEST_IMG" 65M | ||
645 | |||
646 | @@ -XXX,XX +XXX,XX @@ echo | ||
647 | echo '--- Test 2 ---' | ||
648 | echo | ||
649 | |||
650 | -IMGOPTS='preallocation=metadata,cluster_size=1k' _make_test_img 64513K | ||
651 | +_make_test_img -o 'preallocation=metadata,cluster_size=1k' 64513K | ||
652 | # This results in an L1 table growth which in turn results in some clusters at | ||
653 | # the start of the image becoming free | ||
654 | $QEMU_IMG resize "$TEST_IMG" 65M | ||
655 | @@ -XXX,XX +XXX,XX @@ echo | ||
656 | echo '=== Allocating a new refcount block must not leave holes in the image ===' | ||
657 | echo | ||
658 | |||
659 | -IMGOPTS='cluster_size=512,refcount_bits=16' _make_test_img 1M | ||
660 | +_make_test_img -o 'cluster_size=512,refcount_bits=16' 1M | ||
661 | |||
662 | # This results in an image with 256 used clusters: the qcow2 header, | ||
663 | # the refcount table, one refcount block, the L1 table, four L2 tables | ||
664 | diff --git a/tests/qemu-iotests/125 b/tests/qemu-iotests/125 | 69 | diff --git a/tests/qemu-iotests/125 b/tests/qemu-iotests/125 |
665 | index XXXXXXX..XXXXXXX 100755 | 70 | index XXXXXXX..XXXXXXX 100755 |
666 | --- a/tests/qemu-iotests/125 | 71 | --- a/tests/qemu-iotests/125 |
667 | +++ b/tests/qemu-iotests/125 | 72 | +++ b/tests/qemu-iotests/125 |
668 | @@ -XXX,XX +XXX,XX @@ for GROWTH_SIZE in 16 48 80; do | 73 | @@ -XXX,XX +XXX,XX @@ for GROWTH_SIZE in 16 48 80; do |
669 | for growth_mode in off metadata falloc full; do | ||
670 | echo "--- cluster_size=$cluster_size growth_size=$GROWTH_SIZE create_mode=$create_mode growth_mode=$growth_mode ---" | ||
671 | |||
672 | - IMGOPTS="preallocation=$create_mode,cluster_size=$cluster_size" _make_test_img ${CREATION_SIZE} | ||
673 | + _make_test_img -o "preallocation=$create_mode,cluster_size=$cluster_size" ${CREATION_SIZE} | ||
674 | $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K | ||
675 | |||
676 | host_size_0=$(get_image_size_on_host) | ||
677 | diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 | ||
678 | index XXXXXXX..XXXXXXX 100755 | ||
679 | --- a/tests/qemu-iotests/137 | ||
680 | +++ b/tests/qemu-iotests/137 | ||
681 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO \ | ||
682 | -c "reopen -o cache-clean-interval=-1" \ | ||
683 | "$TEST_IMG" | _filter_qemu_io | ||
684 | |||
685 | -IMGOPTS="cluster_size=256k" _make_test_img 32P | ||
686 | +_make_test_img -o "cluster_size=256k" 32P | ||
687 | $QEMU_IO \ | ||
688 | -c "reopen -o l2-cache-entry-size=512,l2-cache-size=1T" \ | ||
689 | "$TEST_IMG" | _filter_qemu_io | ||
690 | diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138 | ||
691 | index XXXXXXX..XXXXXXX 100755 | ||
692 | --- a/tests/qemu-iotests/138 | ||
693 | +++ b/tests/qemu-iotests/138 | ||
694 | @@ -XXX,XX +XXX,XX @@ echo | ||
695 | echo '=== Check on an image with a multiple of 2^32 clusters ===' | ||
696 | echo | ||
697 | |||
698 | -IMGOPTS=$(_optstr_add "$IMGOPTS" "cluster_size=512") \ | ||
699 | - _make_test_img 512 | ||
700 | +_make_test_img -o "cluster_size=512" 512 | ||
701 | |||
702 | # Allocate L2 table | ||
703 | $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io | ||
704 | diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175 | ||
705 | index XXXXXXX..XXXXXXX 100755 | ||
706 | --- a/tests/qemu-iotests/175 | ||
707 | +++ b/tests/qemu-iotests/175 | ||
708 | @@ -XXX,XX +XXX,XX @@ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_block | ||
709 | for mode in off full falloc; do | ||
710 | echo | ||
711 | echo "== creating image with preallocation $mode ==" | ||
712 | - IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt | ||
713 | + _make_test_img -o preallocation=$mode $size | _filter_imgfmt | ||
714 | stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size | ||
715 | done | 74 | done |
716 | 75 | done | |
717 | diff --git a/tests/qemu-iotests/190 b/tests/qemu-iotests/190 | 76 | |
718 | index XXXXXXX..XXXXXXX 100755 | 77 | +# Test image resizing using preallocation and unaligned offsets |
719 | --- a/tests/qemu-iotests/190 | 78 | +$QEMU_IMG create -f raw "$TEST_IMG.base" 128k | _filter_img_create |
720 | +++ b/tests/qemu-iotests/190 | 79 | +$QEMU_IO -c 'write -q -P 1 0 128k' -f raw "$TEST_IMG.base" |
721 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | 80 | +for orig_size in 31k 33k; do |
722 | echo "== Huge file ==" | 81 | + echo "--- Resizing image from $orig_size to 96k ---" |
723 | echo | 82 | + _make_test_img -F raw -b "$TEST_IMG.base" -o cluster_size=64k "$orig_size" |
724 | 83 | + $QEMU_IMG resize -f "$IMGFMT" --preallocation=full "$TEST_IMG" 96k | |
725 | -IMGOPTS='cluster_size=2M' _make_test_img 2T | 84 | + # The first part of the image should contain data from the backing file |
726 | +_make_test_img -o 'cluster_size=2M' 2T | 85 | + $QEMU_IO -c "read -q -P 1 0 ${orig_size}" "$TEST_IMG" |
727 | 86 | + # The resized part of the image should contain zeroes | |
728 | $QEMU_IMG measure -O raw -f qcow2 "$TEST_IMG" | 87 | + $QEMU_IO -c "read -q -P 0 ${orig_size} 63k" "$TEST_IMG" |
729 | $QEMU_IMG measure -O qcow2 -o cluster_size=64k -f qcow2 "$TEST_IMG" | 88 | + # If the image does not have an external data file we can also verify its |
730 | diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 | 89 | + # actual size. The resized image should have 7 clusters: |
731 | index XXXXXXX..XXXXXXX 100755 | 90 | + # header, L1 table, L2 table, refcount table, refcount block, 2 data clusters |
732 | --- a/tests/qemu-iotests/191 | 91 | + if ! _get_data_file "$TEST_IMG" > /dev/null; then |
733 | +++ b/tests/qemu-iotests/191 | 92 | + expected_file_length=$((65536 * 7)) |
734 | @@ -XXX,XX +XXX,XX @@ echo === Preparing and starting VM === | 93 | + file_length=$(stat -c '%s' "$TEST_IMG_FILE") |
735 | echo | 94 | + if [ "$file_length" != "$expected_file_length" ]; then |
736 | 95 | + echo "ERROR: file length $file_length (expected $expected_file_length)" | |
737 | TEST_IMG="${TEST_IMG}.base" _make_test_img $size | 96 | + fi |
738 | -IMGOPTS=$(_optstr_add "$IMGOPTS" "backing_fmt=$IMGFMT") \ | 97 | + fi |
739 | - TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base" | 98 | + echo |
740 | +TEST_IMG="${TEST_IMG}.mid" _make_test_img -o "backing_fmt=$IMGFMT" -b "${TEST_IMG}.base" | 99 | +done |
741 | _make_test_img -b "${TEST_IMG}.mid" | 100 | + |
742 | TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid" | 101 | # success, all done |
743 | 102 | echo '*** done' | |
744 | diff --git a/tests/qemu-iotests/220 b/tests/qemu-iotests/220 | 103 | rm -f $seq.full |
745 | index XXXXXXX..XXXXXXX 100755 | 104 | diff --git a/tests/qemu-iotests/125.out b/tests/qemu-iotests/125.out |
746 | --- a/tests/qemu-iotests/220 | 105 | index XXXXXXX..XXXXXXX 100644 |
747 | +++ b/tests/qemu-iotests/220 | 106 | --- a/tests/qemu-iotests/125.out |
748 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 107 | +++ b/tests/qemu-iotests/125.out |
749 | _supported_fmt qcow2 | 108 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 |
750 | _supported_proto file | 109 | wrote 81920/81920 bytes at offset 2048000 |
751 | _supported_os Linux | 110 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
752 | +# To use a different refcount width but 16 bits we need compat=1.1 | 111 | |
753 | +_unsupported_imgopts 'compat=0.10' | 112 | +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=raw size=131072 |
754 | 113 | +--- Resizing image from 31k to 96k --- | |
755 | echo "== Creating huge file ==" | 114 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=31744 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw |
756 | 115 | +Image resized. | |
757 | @@ -XXX,XX +XXX,XX @@ echo "== Creating huge file ==" | 116 | + |
758 | # of a HUGE (but very sparse) file. tmpfs works, ext4 does not. | 117 | +--- Resizing image from 33k to 96k --- |
759 | _require_large_file 513T | 118 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33792 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw |
760 | 119 | +Image resized. | |
761 | -IMGOPTS='cluster_size=2M,refcount_bits=1' _make_test_img 513T | 120 | + |
762 | +_make_test_img -o 'cluster_size=2M,refcount_bits=1' 513T | 121 | *** done |
763 | |||
764 | echo "== Populating refcounts ==" | ||
765 | # We want an image with 256M refcounts * 2M clusters = 512T referenced. | ||
766 | diff --git a/tests/qemu-iotests/243 b/tests/qemu-iotests/243 | ||
767 | index XXXXXXX..XXXXXXX 100755 | ||
768 | --- a/tests/qemu-iotests/243 | ||
769 | +++ b/tests/qemu-iotests/243 | ||
770 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
771 | _supported_fmt qcow2 | ||
772 | _supported_proto file | ||
773 | _supported_os Linux | ||
774 | +# External data files do not work with compat=0.10 | ||
775 | +_unsupported_imgopts 'compat=0.10' | ||
776 | |||
777 | for mode in off metadata falloc full; do | ||
778 | |||
779 | @@ -XXX,XX +XXX,XX @@ for mode in off metadata falloc full; do | ||
780 | echo "=== preallocation=$mode ===" | ||
781 | echo | ||
782 | |||
783 | - IMGOPTS="preallocation=$mode" _make_test_img 64M | ||
784 | + _make_test_img -o "preallocation=$mode" 64M | ||
785 | |||
786 | printf "File size: " | ||
787 | du -b $TEST_IMG | cut -f1 | ||
788 | @@ -XXX,XX +XXX,XX @@ for mode in off metadata falloc full; do | ||
789 | echo "=== External data file: preallocation=$mode ===" | ||
790 | echo | ||
791 | |||
792 | - IMGOPTS="data_file=$TEST_IMG.data,preallocation=$mode" _make_test_img 64M | ||
793 | + _make_test_img -o "data_file=$TEST_IMG.data,preallocation=$mode" 64M | ||
794 | |||
795 | echo -n "qcow2 file size: " | ||
796 | du -b $TEST_IMG | cut -f1 | ||
797 | diff --git a/tests/qemu-iotests/244 b/tests/qemu-iotests/244 | ||
798 | index XXXXXXX..XXXXXXX 100755 | ||
799 | --- a/tests/qemu-iotests/244 | ||
800 | +++ b/tests/qemu-iotests/244 | ||
801 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
802 | _supported_fmt qcow2 | ||
803 | _supported_proto file | ||
804 | _supported_os Linux | ||
805 | +# External data files do not work with compat=0.10 | ||
806 | +_unsupported_imgopts 'compat=0.10' | ||
807 | |||
808 | echo | ||
809 | echo "=== Create and open image with external data file ===" | ||
810 | echo | ||
811 | |||
812 | echo "With data file name in the image:" | ||
813 | -IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M | ||
814 | +_make_test_img -o "data_file=$TEST_IMG.data" 64M | ||
815 | _check_test_img | ||
816 | |||
817 | $QEMU_IO -c "open $TEST_IMG" -c "read -P 0 0 64k" 2>&1 | _filter_qemu_io | _filter_testdir | ||
818 | @@ -XXX,XX +XXX,XX @@ echo | ||
819 | echo "=== Standalone image with external data file (efficient) ===" | ||
820 | echo | ||
821 | |||
822 | -IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M | ||
823 | +_make_test_img -o "data_file=$TEST_IMG.data" 64M | ||
824 | |||
825 | echo -n "qcow2 file size before I/O: " | ||
826 | du -b $TEST_IMG | cut -f1 | ||
827 | @@ -XXX,XX +XXX,XX @@ echo | ||
828 | echo "=== Standalone image with external data file (valid raw) ===" | ||
829 | echo | ||
830 | |||
831 | -IMGOPTS="data_file=$TEST_IMG.data,data_file_raw=on" _make_test_img 64M | ||
832 | +_make_test_img -o "data_file=$TEST_IMG.data,data_file_raw=on" 64M | ||
833 | |||
834 | echo -n "qcow2 file size before I/O: " | ||
835 | du -b $TEST_IMG | cut -f1 | ||
836 | @@ -XXX,XX +XXX,XX @@ echo | ||
837 | echo "=== bdrv_co_block_status test for file and offset=0 ===" | ||
838 | echo | ||
839 | |||
840 | -IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M | ||
841 | +_make_test_img -o "data_file=$TEST_IMG.data" 64M | ||
842 | |||
843 | $QEMU_IO -c 'write -P 0x11 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io | ||
844 | $QEMU_IO -c 'read -P 0x11 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io | ||
845 | diff --git a/tests/qemu-iotests/250 b/tests/qemu-iotests/250 | ||
846 | index XXXXXXX..XXXXXXX 100755 | ||
847 | --- a/tests/qemu-iotests/250 | ||
848 | +++ b/tests/qemu-iotests/250 | ||
849 | @@ -XXX,XX +XXX,XX @@ disk_usage() | ||
850 | } | ||
851 | |||
852 | size=2100M | ||
853 | -IMGOPTS="cluster_size=1M,preallocation=metadata" | ||
854 | |||
855 | -_make_test_img $size | ||
856 | +_make_test_img -o "cluster_size=1M,preallocation=metadata" $size | ||
857 | $QEMU_IO -c 'discard 0 10M' -c 'discard 2090M 10M' \ | ||
858 | -c 'write 2090M 10M' -c 'write 0 10M' "$TEST_IMG" | _filter_qemu_io | ||
859 | |||
860 | diff --git a/tests/qemu-iotests/265 b/tests/qemu-iotests/265 | ||
861 | index XXXXXXX..XXXXXXX 100755 | ||
862 | --- a/tests/qemu-iotests/265 | ||
863 | +++ b/tests/qemu-iotests/265 | ||
864 | @@ -XXX,XX +XXX,XX @@ _supported_os Linux | ||
865 | echo '--- Writing to the image ---' | ||
866 | |||
867 | # Reduce cluster size so we get more and quicker I/O | ||
868 | -IMGOPTS='cluster_size=4096' _make_test_img 1M | ||
869 | +_make_test_img -o 'cluster_size=4096' 1M | ||
870 | (for ((kb = 1024 - 4; kb >= 0; kb -= 4)); do \ | ||
871 | echo "aio_write -P 42 $((kb + 1))k 2k"; \ | ||
872 | done) \ | ||
873 | -- | 122 | -- |
874 | 2.24.1 | 123 | 2.26.2 |
875 | 124 | ||
876 | 125 | diff view generated by jsdifflib |
1 | The problem with allowing the data_file option is that you want to use a | 1 | Right now, _filter_img_create just filters out everything that looks |
---|---|---|---|
2 | different data file per image used in the test. Therefore, we need to | 2 | format-dependent, and applies some filename filters. That means that we |
3 | allow patterns like -o data_file='$TEST_IMG.data_file'. | 3 | have to add another filter line every time some format gets a new |
4 | 4 | creation option. This can be avoided by instead discarding everything | |
5 | Then, we need to filter it out from qemu-img map, qemu-img create, and | 5 | and just keeping what we know is format-independent (format, size, |
6 | remove the data file in _rm_test_img. | 6 | backing file, encryption information[1], preallocation) or just |
7 | interesting to have in the reference output (external data file path). | ||
8 | |||
9 | Furthermore, we probably want to sort these options. Format drivers are | ||
10 | not required to define them in any specific order, so the output is | ||
11 | effectively random (although this has never bothered us until now). We | ||
12 | need a specific order for our reference outputs, though. Unfortunately, | ||
13 | just using a plain "sort" would change a lot of existing reference | ||
14 | outputs, so we have to pre-filter the option keys to keep our existing | ||
15 | order (fmt, size, backing*, data, encryption info, preallocation). | ||
16 | |||
17 | Finally, this makes it difficult for _filter_img_create to automagically | ||
18 | work for QMP output. Thus, this patch adds a separate | ||
19 | _filter_img_create_for_qmp function that echos every line verbatim that | ||
20 | does not start with "Formatting", and pipes those "Formatting" lines to | ||
21 | _filter_img_create. | ||
22 | |||
23 | [1] Actually, the only thing that is really important is whether | ||
24 | encryption is enabled or not. A patch by Maxim thus removes all | ||
25 | other "encrypt.*" options from the output: | ||
26 | https://lists.nongnu.org/archive/html/qemu-block/2020-06/msg00339.html | ||
27 | But that patch needs to come later so we can get away with changing | ||
28 | as few reference outputs in this patch here as possible. | ||
7 | 29 | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 30 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
31 | Message-Id: <20200625125548.870061-2-mreitz@redhat.com> | ||
9 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 32 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> |
10 | Message-id: 20191107163708.833192-23-mreitz@redhat.com | ||
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
12 | --- | 33 | --- |
13 | tests/qemu-iotests/common.filter | 23 +++++++++++++++++++++-- | 34 | tests/qemu-iotests/112.out | 2 +- |
14 | tests/qemu-iotests/common.rc | 22 +++++++++++++++++++++- | 35 | tests/qemu-iotests/141 | 2 +- |
15 | 2 files changed, 42 insertions(+), 3 deletions(-) | 36 | tests/qemu-iotests/153 | 9 ++- |
16 | 37 | tests/qemu-iotests/common.filter | 109 ++++++++++++++++++++++++------- | |
38 | 4 files changed, 91 insertions(+), 31 deletions(-) | ||
39 | |||
40 | diff --git a/tests/qemu-iotests/112.out b/tests/qemu-iotests/112.out | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/tests/qemu-iotests/112.out | ||
43 | +++ b/tests/qemu-iotests/112.out | ||
44 | @@ -XXX,XX +XXX,XX @@ QA output created by 112 | ||
45 | qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits | ||
46 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
47 | qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits | ||
48 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 refcount_bits=-1 | ||
49 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
50 | qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits | ||
51 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
52 | qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits | ||
53 | diff --git a/tests/qemu-iotests/141 b/tests/qemu-iotests/141 | ||
54 | index XXXXXXX..XXXXXXX 100755 | ||
55 | --- a/tests/qemu-iotests/141 | ||
56 | +++ b/tests/qemu-iotests/141 | ||
57 | @@ -XXX,XX +XXX,XX @@ test_blockjob() | ||
58 | _send_qemu_cmd $QEMU_HANDLE \ | ||
59 | "$1" \ | ||
60 | "$2" \ | ||
61 | - | _filter_img_create | _filter_qmp_empty_return | ||
62 | + | _filter_img_create_in_qmp | _filter_qmp_empty_return | ||
63 | |||
64 | # We want this to return an error because the block job is still running | ||
65 | _send_qemu_cmd $QEMU_HANDLE \ | ||
66 | diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153 | ||
67 | index XXXXXXX..XXXXXXX 100755 | ||
68 | --- a/tests/qemu-iotests/153 | ||
69 | +++ b/tests/qemu-iotests/153 | ||
70 | @@ -XXX,XX +XXX,XX @@ done | ||
71 | |||
72 | echo | ||
73 | echo "== Creating ${TEST_IMG}.[abc] ==" | _filter_testdir | ||
74 | -( | ||
75 | - $QEMU_IMG create -f qcow2 "${TEST_IMG}.a" -b "${TEST_IMG}" | ||
76 | - $QEMU_IMG create -f qcow2 "${TEST_IMG}.b" -b "${TEST_IMG}" | ||
77 | - $QEMU_IMG create -f qcow2 "${TEST_IMG}.c" -b "${TEST_IMG}.b" | ||
78 | -) | _filter_img_create | ||
79 | +$QEMU_IMG create -f qcow2 "${TEST_IMG}.a" -b "${TEST_IMG}" | _filter_img_create | ||
80 | +$QEMU_IMG create -f qcow2 "${TEST_IMG}.b" -b "${TEST_IMG}" | _filter_img_create | ||
81 | +$QEMU_IMG create -f qcow2 "${TEST_IMG}.c" -b "${TEST_IMG}.b" \ | ||
82 | + | _filter_img_create | ||
83 | |||
84 | echo | ||
85 | echo "== Two devices sharing the same file in backing chain ==" | ||
17 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter | 86 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter |
18 | index XXXXXXX..XXXXXXX 100644 | 87 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/tests/qemu-iotests/common.filter | 88 | --- a/tests/qemu-iotests/common.filter |
20 | +++ b/tests/qemu-iotests/common.filter | 89 | +++ b/tests/qemu-iotests/common.filter |
21 | @@ -XXX,XX +XXX,XX @@ _filter_actual_image_size() | 90 | @@ -XXX,XX +XXX,XX @@ _filter_actual_image_size() |
22 | # replace driver-specific options in the "Formatting..." line | 91 | # replace driver-specific options in the "Formatting..." line |
23 | _filter_img_create() | 92 | _filter_img_create() |
24 | { | 93 | { |
25 | - $SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ | 94 | - data_file_filter=() |
26 | + data_file_filter=() | 95 | - if data_file=$(_get_data_file "$TEST_IMG"); then |
27 | + if data_file=$(_get_data_file "$TEST_IMG"); then | 96 | - data_file_filter=(-e "s# data_file=$data_file##") |
28 | + data_file_filter=(-e "s# data_file=$data_file##") | 97 | + # Split the line into the pre-options part ($filename_part, which |
29 | + fi | 98 | + # precedes ", fmt=") and the options part ($options, which starts |
30 | + | 99 | + # with "fmt=") |
31 | + $SED "${data_file_filter[@]}" \ | 100 | + # (And just echo everything before the first "^Formatting") |
32 | + -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ | 101 | + readarray formatting_line < <($SED -e 's/, fmt=/\n/') |
102 | + | ||
103 | + filename_part='' | ||
104 | + options='' | ||
105 | + lines=${#formatting_line[@]} | ||
106 | + for ((i = 0; i < $lines; i++)); do | ||
107 | + line=${formatting_line[i]} | ||
108 | + unset formatting_line[i] | ||
109 | + | ||
110 | + filename_part="$filename_part$line" | ||
111 | + | ||
112 | + if echo "$line" | grep -q '^Formatting'; then | ||
113 | + next_i=$((i + 1)) | ||
114 | + if [ -n "${formatting_line[next_i]}" ]; then | ||
115 | + options="fmt=${formatting_line[@]}" | ||
116 | + fi | ||
117 | + break | ||
118 | + fi | ||
119 | + done | ||
120 | + | ||
121 | + # Set grep_data_file to '\|data_file' to keep it; make it empty | ||
122 | + # to drop it. | ||
123 | + # We want to drop it if it is part of the global $IMGOPTS, and we | ||
124 | + # want to keep it otherwise (if the test specifically wants to | ||
125 | + # test data files). | ||
126 | + grep_data_file=(-e data_file) | ||
127 | + if _get_data_file "$TEST_IMG" > /dev/null; then | ||
128 | + grep_data_file=() | ||
129 | fi | ||
130 | |||
131 | - $SED "${data_file_filter[@]}" \ | ||
132 | + filename_filters=( | ||
133 | -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ | ||
33 | -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ | 134 | -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ |
34 | -e "s#$TEST_DIR#TEST_DIR#g" \ | 135 | -e "s#$TEST_DIR#TEST_DIR#g" \ |
35 | -e "s#$SOCK_DIR#SOCK_DIR#g" \ | 136 | -e "s#$SOCK_DIR#SOCK_DIR#g" \ |
36 | @@ -XXX,XX +XXX,XX @@ _filter_img_info() | 137 | -e "s#$IMGFMT#IMGFMT#g" \ |
37 | # human and json output | 138 | -e 's#nbd:127.0.0.1:[0-9]\\+#TEST_DIR/t.IMGFMT#g' \ |
38 | _filter_qemu_img_map() | 139 | - -e 's#nbd+unix:///\??socket=SOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g' \ |
39 | { | 140 | - -e "s# encryption=off##g" \ |
40 | + # Assuming the data_file value in $IMGOPTS contains a '$TEST_IMG', | 141 | - -e "s# cluster_size=[0-9]\\+##g" \ |
41 | + # create a filter that replaces the data file name by $TEST_IMG. | 142 | - -e "s# table_size=[0-9]\\+##g" \ |
42 | + # Example: | 143 | - -e "s# compat=[^ ]*##g" \ |
43 | + # In $IMGOPTS: 'data_file=$TEST_IMG.data_file' | 144 | - -e "s# compat6=\\(on\\|off\\)##g" \ |
44 | + # Then data_file_pattern == '\(.*\).data_file' | 145 | - -e "s# static=\\(on\\|off\\)##g" \ |
45 | + # And data_file_filter == -e 's#\(.*\).data_file#\1# | 146 | - -e "s# zeroed_grain=\\(on\\|off\\)##g" \ |
46 | + data_file_filter=() | 147 | - -e "s# subformat=[^ ]*##g" \ |
47 | + if data_file_pattern=$(_get_data_file '\\(.*\\)'); then | 148 | - -e "s# adapter_type=[^ ]*##g" \ |
48 | + data_file_filter=(-e "s#$data_file_pattern#\\1#") | 149 | - -e "s# hwversion=[^ ]*##g" \ |
150 | - -e "s# lazy_refcounts=\\(on\\|off\\)##g" \ | ||
151 | - -e "s# block_size=[0-9]\\+##g" \ | ||
152 | - -e "s# block_state_zero=\\(on\\|off\\)##g" \ | ||
153 | - -e "s# log_size=[0-9]\\+##g" \ | ||
154 | - -e "s# refcount_bits=[0-9]\\+##g" \ | ||
155 | - -e "s# key-secret=[a-zA-Z0-9]\\+##g" \ | ||
156 | - -e "s# iter-time=[0-9]\\+##g" \ | ||
157 | - -e "s# force_size=\\(on\\|off\\)##g" \ | ||
158 | - -e "s# compression_type=[a-zA-Z0-9]\\+##g" | ||
159 | + -e 's#nbd+unix:///\??socket=SOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g' | ||
160 | + ) | ||
161 | + | ||
162 | + filename_part=$(echo "$filename_part" | $SED "${filename_filters[@]}") | ||
163 | + | ||
164 | + # Break the option line before each option (preserving pre-existing | ||
165 | + # line breaks by replacing them by \0 and restoring them at the end), | ||
166 | + # then filter out the options we want to keep and sort them according | ||
167 | + # to some order that all block drivers used at the time of writing | ||
168 | + # this function. | ||
169 | + options=$( | ||
170 | + echo "$options" \ | ||
171 | + | tr '\n' '\0' \ | ||
172 | + | $SED -e 's/ \([a-z0-9_.-]*\)=/\n\1=/g' \ | ||
173 | + | grep -a -e '^fmt' -e '^size' -e '^backing' -e '^preallocation' \ | ||
174 | + -e '^encrypt' "${grep_data_file[@]}" \ | ||
175 | + | $SED "${filename_filters[@]}" \ | ||
176 | + -e 's/^\(fmt\)/0-\1/' \ | ||
177 | + -e 's/^\(size\)/1-\1/' \ | ||
178 | + -e 's/^\(backing\)/2-\1/' \ | ||
179 | + -e 's/^\(data_file\)/3-\1/' \ | ||
180 | + -e 's/^\(encryption\)/4-\1/' \ | ||
181 | + -e 's/^\(encrypt\.format\)/5-\1/' \ | ||
182 | + -e 's/^\(encrypt\.key-secret\)/6-\1/' \ | ||
183 | + -e 's/^\(encrypt\.iter-time\)/7-\1/' \ | ||
184 | + -e 's/^\(preallocation\)/8-\1/' \ | ||
185 | + | sort \ | ||
186 | + | $SED -e 's/^[0-9]-//' \ | ||
187 | + | tr '\n\0' ' \n' \ | ||
188 | + | $SED -e 's/^ *$//' -e 's/ *$//' | ||
189 | + ) | ||
190 | + | ||
191 | + if [ -n "$options" ]; then | ||
192 | + echo "$filename_part, $options" | ||
193 | + elif [ -n "$filename_part" ]; then | ||
194 | + echo "$filename_part" | ||
49 | + fi | 195 | + fi |
50 | + | 196 | +} |
51 | $SED -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \ | 197 | + |
52 | -e 's/"offset": [0-9]\+/"offset": OFFSET/g' \ | 198 | +# Filter the "Formatting..." line in QMP output (leaving the QMP output |
53 | - -e 's/Mapped to *//' | _filter_testdir | _filter_imgfmt | 199 | +# untouched) |
54 | + -e 's/Mapped to *//' \ | 200 | +# (In contrast to _filter_img_create(), this function does not support |
55 | + "${data_file_filter[@]}" \ | 201 | +# multi-line Formatting output) |
56 | + | _filter_testdir | _filter_imgfmt | 202 | +_filter_img_create_in_qmp() |
203 | +{ | ||
204 | + while read -r line; do | ||
205 | + if echo "$line" | grep -q '^Formatting'; then | ||
206 | + echo "$line" | _filter_img_create | ||
207 | + else | ||
208 | + echo "$line" | ||
209 | + fi | ||
210 | + done | ||
57 | } | 211 | } |
58 | 212 | ||
59 | _filter_nbd() | 213 | _filter_img_create_size() |
60 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/tests/qemu-iotests/common.rc | ||
63 | +++ b/tests/qemu-iotests/common.rc | ||
64 | @@ -XXX,XX +XXX,XX @@ _stop_nbd_server() | ||
65 | fi | ||
66 | } | ||
67 | |||
68 | +# Gets the data_file value from IMGOPTS and replaces the '$TEST_IMG' | ||
69 | +# pattern by '$1' | ||
70 | +# Caution: The replacement is done with sed, so $1 must be escaped | ||
71 | +# properly. (The delimiter is '#'.) | ||
72 | +_get_data_file() | ||
73 | +{ | ||
74 | + if ! echo "$IMGOPTS" | grep -q 'data_file='; then | ||
75 | + return 1 | ||
76 | + fi | ||
77 | + | ||
78 | + echo "$IMGOPTS" | sed -e 's/.*data_file=\([^,]*\).*/\1/' \ | ||
79 | + | sed -e "s#\\\$TEST_IMG#$1#" | ||
80 | +} | ||
81 | + | ||
82 | _make_test_img() | ||
83 | { | ||
84 | # extra qemu-img options can be added by tests | ||
85 | @@ -XXX,XX +XXX,XX @@ _make_test_img() | ||
86 | fi | ||
87 | |||
88 | if [ -n "$IMGOPTS" ]; then | ||
89 | - optstr=$(_optstr_add "$optstr" "$IMGOPTS") | ||
90 | + imgopts_expanded=$(echo "$IMGOPTS" | sed -e "s#\\\$TEST_IMG#$img_name#") | ||
91 | + optstr=$(_optstr_add "$optstr" "$imgopts_expanded") | ||
92 | fi | ||
93 | if [ -n "$IMGKEYSECRET" ]; then | ||
94 | object_options="--object secret,id=keysec0,data=$IMGKEYSECRET" | ||
95 | @@ -XXX,XX +XXX,XX @@ _rm_test_img() | ||
96 | # Remove all the extents for vmdk | ||
97 | "$QEMU_IMG" info "$img" 2>/dev/null | grep 'filename:' | cut -f 2 -d: \ | ||
98 | | xargs -I {} rm -f "{}" | ||
99 | + elif [ "$IMGFMT" = "qcow2" ]; then | ||
100 | + # Remove external data file | ||
101 | + if data_file=$(_get_data_file "$img"); then | ||
102 | + rm -f "$data_file" | ||
103 | + fi | ||
104 | fi | ||
105 | rm -f "$img" | ||
106 | } | ||
107 | -- | 214 | -- |
108 | 2.24.1 | 215 | 2.26.2 |
109 | 216 | ||
110 | 217 | diff view generated by jsdifflib |
1 | We do not care about the json:{} filenames here, so we can just filter | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | them out and thus make the test work both with and without external data | 2 | |
3 | files. | 3 | This allows more tests to be able to have same output on both qcow2 luks encrypted images |
4 | 4 | and raw luks images | |
5 | |||
6 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
6 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 8 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> |
7 | Message-id: 20191107163708.833192-21-mreitz@redhat.com | 9 | Message-Id: <20200625125548.870061-3-mreitz@redhat.com> |
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | --- | 10 | --- |
10 | tests/qemu-iotests/198 | 6 ++++-- | 11 | tests/qemu-iotests/087.out | 6 +++--- |
11 | tests/qemu-iotests/198.out | 4 ++-- | 12 | tests/qemu-iotests/134.out | 2 +- |
12 | 2 files changed, 6 insertions(+), 4 deletions(-) | 13 | tests/qemu-iotests/158.out | 4 ++-- |
13 | 14 | tests/qemu-iotests/188.out | 2 +- | |
14 | diff --git a/tests/qemu-iotests/198 b/tests/qemu-iotests/198 | 15 | tests/qemu-iotests/189.out | 4 ++-- |
15 | index XXXXXXX..XXXXXXX 100755 | 16 | tests/qemu-iotests/198.out | 4 ++-- |
16 | --- a/tests/qemu-iotests/198 | 17 | tests/qemu-iotests/263.out | 4 ++-- |
17 | +++ b/tests/qemu-iotests/198 | 18 | tests/qemu-iotests/284.out | 6 +++--- |
18 | @@ -XXX,XX +XXX,XX @@ echo | 19 | tests/qemu-iotests/common.filter | 5 +---- |
19 | echo "== checking image base ==" | 20 | 9 files changed, 17 insertions(+), 20 deletions(-) |
20 | $QEMU_IMG info --image-opts $IMGSPECBASE | _filter_img_info --format-specific \ | 21 | |
21 | | sed -e "/^disk size:/ D" -e '/refcount bits:/ D' -e '/compat:/ D' \ | 22 | diff --git a/tests/qemu-iotests/087.out b/tests/qemu-iotests/087.out |
22 | - -e '/lazy refcounts:/ D' -e '/corrupt:/ D' | 23 | index XXXXXXX..XXXXXXX 100644 |
23 | + -e '/lazy refcounts:/ D' -e '/corrupt:/ D' -e '/^\s*data file/ D' \ | 24 | --- a/tests/qemu-iotests/087.out |
24 | + | _filter_json_filename | 25 | +++ b/tests/qemu-iotests/087.out |
25 | 26 | @@ -XXX,XX +XXX,XX @@ QMP_VERSION | |
26 | echo | 27 | |
27 | echo "== checking image layer ==" | 28 | === Encrypted image QCow === |
28 | $QEMU_IMG info --image-opts $IMGSPECLAYER | _filter_img_info --format-specific \ | 29 | |
29 | | sed -e "/^disk size:/ D" -e '/refcount bits:/ D' -e '/compat:/ D' \ | 30 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on encrypt.key-secret=sec0 |
30 | - -e '/lazy refcounts:/ D' -e '/corrupt:/ D' | 31 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on |
31 | + -e '/lazy refcounts:/ D' -e '/corrupt:/ D' -e '/^\s*data file/ D' \ | 32 | Testing: |
32 | + | _filter_json_filename | 33 | QMP_VERSION |
33 | 34 | {"return": {}} | |
34 | 35 | @@ -XXX,XX +XXX,XX @@ QMP_VERSION | |
35 | # success, all done | 36 | |
37 | === Encrypted image LUKS === | ||
38 | |||
39 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encrypt.format=luks encrypt.key-secret=sec0 | ||
40 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
41 | Testing: | ||
42 | QMP_VERSION | ||
43 | {"return": {}} | ||
44 | @@ -XXX,XX +XXX,XX @@ QMP_VERSION | ||
45 | |||
46 | === Missing driver === | ||
47 | |||
48 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on encrypt.key-secret=sec0 | ||
49 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on | ||
50 | Testing: -S | ||
51 | QMP_VERSION | ||
52 | {"return": {}} | ||
53 | diff --git a/tests/qemu-iotests/134.out b/tests/qemu-iotests/134.out | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/tests/qemu-iotests/134.out | ||
56 | +++ b/tests/qemu-iotests/134.out | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | QA output created by 134 | ||
59 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on encrypt.key-secret=sec0 | ||
60 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on | ||
61 | |||
62 | == reading whole image == | ||
63 | read 134217728/134217728 bytes at offset 0 | ||
64 | diff --git a/tests/qemu-iotests/158.out b/tests/qemu-iotests/158.out | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/tests/qemu-iotests/158.out | ||
67 | +++ b/tests/qemu-iotests/158.out | ||
68 | @@ -XXX,XX +XXX,XX @@ | ||
69 | QA output created by 158 | ||
70 | == create base == | ||
71 | -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=134217728 encryption=on encrypt.key-secret=sec0 | ||
72 | +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=134217728 encryption=on | ||
73 | |||
74 | == writing whole image == | ||
75 | wrote 134217728/134217728 bytes at offset 0 | ||
76 | @@ -XXX,XX +XXX,XX @@ wrote 134217728/134217728 bytes at offset 0 | ||
77 | read 134217728/134217728 bytes at offset 0 | ||
78 | 128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
79 | == create overlay == | ||
80 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base encryption=on encrypt.key-secret=sec0 | ||
81 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base encryption=on | ||
82 | |||
83 | == writing part of a cluster == | ||
84 | wrote 1024/1024 bytes at offset 0 | ||
85 | diff --git a/tests/qemu-iotests/188.out b/tests/qemu-iotests/188.out | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/tests/qemu-iotests/188.out | ||
88 | +++ b/tests/qemu-iotests/188.out | ||
89 | @@ -XXX,XX +XXX,XX @@ | ||
90 | QA output created by 188 | ||
91 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=16777216 encrypt.format=luks encrypt.key-secret=sec0 encrypt.iter-time=10 | ||
92 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=16777216 | ||
93 | |||
94 | == reading whole image == | ||
95 | read 16777216/16777216 bytes at offset 0 | ||
96 | diff --git a/tests/qemu-iotests/189.out b/tests/qemu-iotests/189.out | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/tests/qemu-iotests/189.out | ||
99 | +++ b/tests/qemu-iotests/189.out | ||
100 | @@ -XXX,XX +XXX,XX @@ | ||
101 | QA output created by 189 | ||
102 | == create base == | ||
103 | -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=16777216 encrypt.format=luks encrypt.key-secret=sec0 encrypt.iter-time=10 | ||
104 | +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=16777216 | ||
105 | |||
106 | == writing whole image == | ||
107 | wrote 16777216/16777216 bytes at offset 0 | ||
108 | @@ -XXX,XX +XXX,XX @@ wrote 16777216/16777216 bytes at offset 0 | ||
109 | read 16777216/16777216 bytes at offset 0 | ||
110 | 16 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
111 | == create overlay == | ||
112 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=16777216 backing_file=TEST_DIR/t.IMGFMT.base encrypt.format=luks encrypt.key-secret=sec1 encrypt.iter-time=10 | ||
113 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=16777216 backing_file=TEST_DIR/t.IMGFMT.base | ||
114 | |||
115 | == writing part of a cluster == | ||
116 | wrote 1024/1024 bytes at offset 0 | ||
36 | diff --git a/tests/qemu-iotests/198.out b/tests/qemu-iotests/198.out | 117 | diff --git a/tests/qemu-iotests/198.out b/tests/qemu-iotests/198.out |
37 | index XXXXXXX..XXXXXXX 100644 | 118 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/tests/qemu-iotests/198.out | 119 | --- a/tests/qemu-iotests/198.out |
39 | +++ b/tests/qemu-iotests/198.out | 120 | +++ b/tests/qemu-iotests/198.out |
40 | @@ -XXX,XX +XXX,XX @@ read 16777216/16777216 bytes at offset 0 | 121 | @@ -XXX,XX +XXX,XX @@ |
122 | QA output created by 198 | ||
123 | == create base == | ||
124 | -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=16777216 encrypt.format=luks encrypt.key-secret=sec0 encrypt.iter-time=10 | ||
125 | +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=16777216 | ||
126 | |||
127 | == writing whole image base == | ||
128 | wrote 16777216/16777216 bytes at offset 0 | ||
41 | 16 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 129 | 16 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
42 | 130 | == create overlay == | |
43 | == checking image base == | 131 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=16777216 backing_file=TEST_DIR/t.IMGFMT.base encrypt.format=luks encrypt.key-secret=sec1 encrypt.iter-time=10 |
44 | -image: json:{"encrypt.key-secret": "sec0", "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}} | 132 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=16777216 backing_file=TEST_DIR/t.IMGFMT.base |
45 | +image: json:{ /* filtered */ } | 133 | |
46 | file format: IMGFMT | 134 | == writing whole image layer == |
47 | virtual size: 16 MiB (16777216 bytes) | 135 | wrote 16777216/16777216 bytes at offset 0 |
48 | Format specific information: | 136 | diff --git a/tests/qemu-iotests/263.out b/tests/qemu-iotests/263.out |
49 | @@ -XXX,XX +XXX,XX @@ Format specific information: | 137 | index XXXXXXX..XXXXXXX 100644 |
50 | master key iters: 1024 | 138 | --- a/tests/qemu-iotests/263.out |
51 | 139 | +++ b/tests/qemu-iotests/263.out | |
52 | == checking image layer == | 140 | @@ -XXX,XX +XXX,XX @@ QA output created by 263 |
53 | -image: json:{"encrypt.key-secret": "sec1", "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}} | 141 | |
54 | +image: json:{ /* filtered */ } | 142 | testing LUKS qcow2 encryption |
55 | file format: IMGFMT | 143 | |
56 | virtual size: 16 MiB (16777216 bytes) | 144 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 encrypt.format=luks encrypt.key-secret=sec0 encrypt.iter-time=10 |
57 | backing file: TEST_DIR/t.IMGFMT.base | 145 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 |
146 | == reading the whole image == | ||
147 | read 1048576/1048576 bytes at offset 0 | ||
148 | 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
149 | @@ -XXX,XX +XXX,XX @@ read 982528/982528 bytes at offset 66048 | ||
150 | |||
151 | testing legacy AES qcow2 encryption | ||
152 | |||
153 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 encrypt.format=aes encrypt.key-secret=sec0 | ||
154 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 | ||
155 | == reading the whole image == | ||
156 | read 1048576/1048576 bytes at offset 0 | ||
157 | 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
158 | diff --git a/tests/qemu-iotests/284.out b/tests/qemu-iotests/284.out | ||
159 | index XXXXXXX..XXXXXXX 100644 | ||
160 | --- a/tests/qemu-iotests/284.out | ||
161 | +++ b/tests/qemu-iotests/284.out | ||
162 | @@ -XXX,XX +XXX,XX @@ QA output created by 284 | ||
163 | |||
164 | testing LUKS qcow2 encryption | ||
165 | |||
166 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 encrypt.format=luks encrypt.key-secret=sec0 encrypt.iter-time=10 | ||
167 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 | ||
168 | |||
169 | == cluster size 512 | ||
170 | == checking image refcounts == | ||
171 | @@ -XXX,XX +XXX,XX @@ wrote 1/1 bytes at offset 512 | ||
172 | |||
173 | == rechecking image refcounts == | ||
174 | No errors were found on the image. | ||
175 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 encrypt.format=luks encrypt.key-secret=sec0 encrypt.iter-time=10 | ||
176 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 | ||
177 | |||
178 | == cluster size 2048 | ||
179 | == checking image refcounts == | ||
180 | @@ -XXX,XX +XXX,XX @@ wrote 1/1 bytes at offset 2048 | ||
181 | |||
182 | == rechecking image refcounts == | ||
183 | No errors were found on the image. | ||
184 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 encrypt.format=luks encrypt.key-secret=sec0 encrypt.iter-time=10 | ||
185 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 | ||
186 | |||
187 | == cluster size 32768 | ||
188 | == checking image refcounts == | ||
189 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter | ||
190 | index XXXXXXX..XXXXXXX 100644 | ||
191 | --- a/tests/qemu-iotests/common.filter | ||
192 | +++ b/tests/qemu-iotests/common.filter | ||
193 | @@ -XXX,XX +XXX,XX @@ _filter_img_create() | ||
194 | | tr '\n' '\0' \ | ||
195 | | $SED -e 's/ \([a-z0-9_.-]*\)=/\n\1=/g' \ | ||
196 | | grep -a -e '^fmt' -e '^size' -e '^backing' -e '^preallocation' \ | ||
197 | - -e '^encrypt' "${grep_data_file[@]}" \ | ||
198 | + -e '^encryption' "${grep_data_file[@]}" \ | ||
199 | | $SED "${filename_filters[@]}" \ | ||
200 | -e 's/^\(fmt\)/0-\1/' \ | ||
201 | -e 's/^\(size\)/1-\1/' \ | ||
202 | -e 's/^\(backing\)/2-\1/' \ | ||
203 | -e 's/^\(data_file\)/3-\1/' \ | ||
204 | -e 's/^\(encryption\)/4-\1/' \ | ||
205 | - -e 's/^\(encrypt\.format\)/5-\1/' \ | ||
206 | - -e 's/^\(encrypt\.key-secret\)/6-\1/' \ | ||
207 | - -e 's/^\(encrypt\.iter-time\)/7-\1/' \ | ||
208 | -e 's/^\(preallocation\)/8-\1/' \ | ||
209 | | sort \ | ||
210 | | $SED -e 's/^[0-9]-//' \ | ||
58 | -- | 211 | -- |
59 | 2.24.1 | 212 | 2.26.2 |
60 | 213 | ||
61 | 214 | diff view generated by jsdifflib |
1 | Blindly overriding IMGOPTS is suboptimal as this discards user-specified | 1 | That the luks driver is present is little indication on whether it is |
---|---|---|---|
2 | options. Whatever options the test needs should simply be appended. | 2 | actually working. Without the crypto libraries linked in, it does not |
3 | 3 | work. So add this function, which tries to create a luks image to see | |
4 | Some tests do this (with IMGOPTS=$(_optstr_add "$IMGOPTS" "...")), but | 4 | whether that actually works. |
5 | that is cumbersome. It’s simpler to just give _make_test_img an -o | ||
6 | parameter with which tests can add options. | ||
7 | |||
8 | Some tests actually must override the user-specified options, though, | ||
9 | for example when creating an image in a different format than the test | ||
10 | $IMGFMT. For such cases, --no-opts allows clearing the current option | ||
11 | list. | ||
12 | 5 | ||
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 6 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
7 | Message-Id: <20200625125548.870061-4-mreitz@redhat.com> | ||
14 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 8 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> |
15 | Message-id: 20191107163708.833192-10-mreitz@redhat.com | ||
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
17 | --- | 9 | --- |
18 | tests/qemu-iotests/common.rc | 13 +++++++++++++ | 10 | tests/qemu-iotests/common.rc | 27 +++++++++++++++++++++++++++ |
19 | 1 file changed, 13 insertions(+) | 11 | 1 file changed, 27 insertions(+) |
20 | 12 | ||
21 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | 13 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc |
22 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/tests/qemu-iotests/common.rc | 15 | --- a/tests/qemu-iotests/common.rc |
24 | +++ b/tests/qemu-iotests/common.rc | 16 | +++ b/tests/qemu-iotests/common.rc |
25 | @@ -XXX,XX +XXX,XX @@ _make_test_img() | 17 | @@ -XXX,XX +XXX,XX @@ _unsupported_imgopts() |
26 | local use_backing=0 | 18 | done |
27 | local backing_file="" | 19 | } |
28 | local object_options="" | 20 | |
29 | + local opts_param=false | 21 | +# Caution: Overwrites $TEST_DIR/t.luks |
30 | local misc_params=() | 22 | +_require_working_luks() |
31 | 23 | +{ | |
32 | if [ -n "$TEST_IMG_FILE" ]; then | 24 | + file="$TEST_DIR/t.luks" |
33 | @@ -XXX,XX +XXX,XX @@ _make_test_img() | ||
34 | if [ "$use_backing" = "1" -a -z "$backing_file" ]; then | ||
35 | backing_file=$param | ||
36 | continue | ||
37 | + elif $opts_param; then | ||
38 | + optstr=$(_optstr_add "$optstr" "$param") | ||
39 | + opts_param=false | ||
40 | + continue | ||
41 | fi | ||
42 | |||
43 | case "$param" in | ||
44 | @@ -XXX,XX +XXX,XX @@ _make_test_img() | ||
45 | use_backing=1 | ||
46 | ;; | ||
47 | |||
48 | + -o) | ||
49 | + opts_param=true | ||
50 | + ;; | ||
51 | + | 25 | + |
52 | + --no-opts) | 26 | + output=$( |
53 | + optstr="" | 27 | + $QEMU_IMG create -f luks \ |
54 | + ;; | 28 | + --object secret,id=sec0,data=hunter0 \ |
29 | + -o key-secret=sec0 \ | ||
30 | + -o iter-time=10 \ | ||
31 | + "$file" \ | ||
32 | + 1M \ | ||
33 | + 2>&1 | ||
34 | + ) | ||
35 | + status=$? | ||
55 | + | 36 | + |
56 | *) | 37 | + IMGFMT='luks' _rm_test_img "$file" |
57 | misc_params=("${misc_params[@]}" "$param") | 38 | + |
58 | ;; | 39 | + if [ $status != 0 ]; then |
40 | + reason=$(echo "$output" | grep "$file:" | $SED -e "s#.*$file: *##") | ||
41 | + if [ -z "$reason" ]; then | ||
42 | + reason="Failed to create a LUKS image" | ||
43 | + fi | ||
44 | + _notrun "$reason" | ||
45 | + fi | ||
46 | +} | ||
47 | + | ||
48 | # this test requires that a specified command (executable) exists | ||
49 | # | ||
50 | _require_command() | ||
59 | -- | 51 | -- |
60 | 2.24.1 | 52 | 2.26.2 |
61 | 53 | ||
62 | 54 | diff view generated by jsdifflib |
1 | When using an external data file, there are no refcounts for data | 1 | This function will be used by the next patch, which intends to check |
---|---|---|---|
2 | clusters. We thus have to adjust the corruption test in this patch to | 2 | both the exit code and qemu-img's output. |
3 | not be based around a data cluster allocation, but the L2 table | ||
4 | allocation (L2 tables are still refcounted with external data files). | ||
5 | |||
6 | Furthermore, we should not print qcow2.py's list of incompatible | ||
7 | features because it differs depending on whether there is an external | ||
8 | data file or not. | ||
9 | |||
10 | With those two changes, the test will work both with and without | ||
11 | external data files (once that options works with the iotests at all). | ||
12 | 3 | ||
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 4 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
5 | Message-Id: <20200625125548.870061-5-mreitz@redhat.com> | ||
14 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 6 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> |
15 | Message-id: 20191107163708.833192-20-mreitz@redhat.com | 7 | [mreitz: Rebased on 49438972b8c2e] |
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
17 | --- | 9 | --- |
18 | tests/qemu-iotests/137 | 15 +++++++++++---- | 10 | tests/qemu-iotests/iotests.py | 40 +++++++++++++++++------------------ |
19 | tests/qemu-iotests/137.out | 6 ++---- | 11 | 1 file changed, 20 insertions(+), 20 deletions(-) |
20 | 2 files changed, 13 insertions(+), 8 deletions(-) | ||
21 | 12 | ||
22 | diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 | 13 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py |
23 | index XXXXXXX..XXXXXXX 100755 | ||
24 | --- a/tests/qemu-iotests/137 | ||
25 | +++ b/tests/qemu-iotests/137 | ||
26 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO \ | ||
27 | "$TEST_IMG" 2>&1 | _filter_qemu_io | ||
28 | |||
29 | # The dirty bit must not be set | ||
30 | -$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features | ||
31 | +# (Filter the external data file bit) | ||
32 | +if $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features \ | ||
33 | + | grep -q '\<0\>' | ||
34 | +then | ||
35 | + echo 'ERROR: Dirty bit set' | ||
36 | +else | ||
37 | + echo 'OK: Dirty bit not set' | ||
38 | +fi | ||
39 | |||
40 | # Similarly we can test whether corruption detection has been enabled: | ||
41 | -# Create L1/L2, overwrite first entry in refcount block, allocate something. | ||
42 | +# Create L1, overwrite refcounts, force allocation of L2 by writing | ||
43 | +# data. | ||
44 | # Disabling the checks should fail, so the corruption must be detected. | ||
45 | _make_test_img 64M | ||
46 | -$QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io | ||
47 | -poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00" | ||
48 | +poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
49 | $QEMU_IO \ | ||
50 | -c "reopen -o overlap-check=none,lazy-refcounts=42" \ | ||
51 | -c "write 64k 64k" \ | ||
52 | diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out | ||
53 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
54 | --- a/tests/qemu-iotests/137.out | 15 | --- a/tests/qemu-iotests/iotests.py |
55 | +++ b/tests/qemu-iotests/137.out | 16 | +++ b/tests/qemu-iotests/iotests.py |
56 | @@ -XXX,XX +XXX,XX @@ qemu-io: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are | 17 | @@ -XXX,XX +XXX,XX @@ import struct |
57 | wrote 512/512 bytes at offset 0 | 18 | import subprocess |
58 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 19 | import sys |
59 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | 20 | from typing import (Any, Callable, Dict, Iterable, |
60 | -incompatible_features [] | 21 | - List, Optional, Sequence, TypeVar) |
61 | +OK: Dirty bit not set | 22 | + List, Optional, Sequence, Tuple, TypeVar) |
62 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | 23 | import unittest |
63 | -wrote 65536/65536 bytes at offset 0 | 24 | |
64 | -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 25 | # pylint: disable=import-error, wrong-import-position |
65 | qemu-io: Parameter 'lazy-refcounts' expects 'on' or 'off' | 26 | @@ -XXX,XX +XXX,XX @@ luks_default_secret_object = 'secret,id=keysec0,data=' + \ |
66 | -qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with qcow2_header); further corruption events will be suppressed | 27 | luks_default_key_secret_opt = 'key-secret=keysec0' |
67 | +qcow2: Marking image as corrupt: Preventing invalid allocation of L2 table at offset 0; further corruption events will be suppressed | 28 | |
68 | write failed: Input/output error | 29 | |
69 | *** done | 30 | -def qemu_img(*args): |
31 | - '''Run qemu-img and return the exit code''' | ||
32 | - devnull = open('/dev/null', 'r+') | ||
33 | - exitcode = subprocess.call(qemu_img_args + list(args), | ||
34 | - stdin=devnull, stdout=devnull) | ||
35 | - if exitcode < 0: | ||
36 | +def qemu_img_pipe_and_status(*args: str) -> Tuple[str, int]: | ||
37 | + """ | ||
38 | + Run qemu-img and return both its output and its exit code | ||
39 | + """ | ||
40 | + subp = subprocess.Popen(qemu_img_args + list(args), | ||
41 | + stdout=subprocess.PIPE, | ||
42 | + stderr=subprocess.STDOUT, | ||
43 | + universal_newlines=True) | ||
44 | + output = subp.communicate()[0] | ||
45 | + if subp.returncode < 0: | ||
46 | sys.stderr.write('qemu-img received signal %i: %s\n' | ||
47 | - % (-exitcode, ' '.join(qemu_img_args + list(args)))) | ||
48 | - return exitcode | ||
49 | + % (-subp.returncode, | ||
50 | + ' '.join(qemu_img_args + list(args)))) | ||
51 | + return (output, subp.returncode) | ||
52 | + | ||
53 | +def qemu_img(*args: str) -> int: | ||
54 | + '''Run qemu-img and return the exit code''' | ||
55 | + return qemu_img_pipe_and_status(*args)[1] | ||
56 | |||
57 | def ordered_qmp(qmsg, conv_keys=True): | ||
58 | # Dictionaries are not ordered prior to 3.6, therefore: | ||
59 | @@ -XXX,XX +XXX,XX @@ def qemu_img_verbose(*args): | ||
60 | % (-exitcode, ' '.join(qemu_img_args + list(args)))) | ||
61 | return exitcode | ||
62 | |||
63 | -def qemu_img_pipe(*args): | ||
64 | +def qemu_img_pipe(*args: str) -> str: | ||
65 | '''Run qemu-img and return its output''' | ||
66 | - subp = subprocess.Popen(qemu_img_args + list(args), | ||
67 | - stdout=subprocess.PIPE, | ||
68 | - stderr=subprocess.STDOUT, | ||
69 | - universal_newlines=True) | ||
70 | - output = subp.communicate()[0] | ||
71 | - if subp.returncode < 0: | ||
72 | - sys.stderr.write('qemu-img received signal %i: %s\n' | ||
73 | - % (-subp.returncode, | ||
74 | - ' '.join(qemu_img_args + list(args)))) | ||
75 | - return output | ||
76 | + return qemu_img_pipe_and_status(*args)[0] | ||
77 | |||
78 | def qemu_img_log(*args): | ||
79 | result = qemu_img_pipe(*args) | ||
70 | -- | 80 | -- |
71 | 2.24.1 | 81 | 2.26.2 |
72 | 82 | ||
73 | 83 | diff view generated by jsdifflib |
1 | Callers can use this new parameter to expect failure during the | 1 | Similar to _require_working_luks for bash tests, these functions can be |
---|---|---|---|
2 | completion process. | 2 | used to check whether our luks driver can actually create images. |
3 | 3 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 4 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
5 | Reviewed-by: John Snow <jsnow@redhat.com> | 5 | Message-Id: <20200625125548.870061-6-mreitz@redhat.com> |
6 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 6 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> |
7 | Message-id: 20191108123455.39445-5-mreitz@redhat.com | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | --- | 7 | --- |
10 | tests/qemu-iotests/iotests.py | 18 ++++++++++++------ | 8 | tests/qemu-iotests/iotests.py | 39 +++++++++++++++++++++++++++++++++++ |
11 | 1 file changed, 12 insertions(+), 6 deletions(-) | 9 | 1 file changed, 39 insertions(+) |
12 | 10 | ||
13 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | 11 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py |
14 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/tests/qemu-iotests/iotests.py | 13 | --- a/tests/qemu-iotests/iotests.py |
16 | +++ b/tests/qemu-iotests/iotests.py | 14 | +++ b/tests/qemu-iotests/iotests.py |
17 | @@ -XXX,XX +XXX,XX @@ class QMPTestCase(unittest.TestCase): | 15 | @@ -XXX,XX +XXX,XX @@ def verify_quorum(): |
18 | self.assert_no_active_block_jobs() | 16 | if not supports_quorum(): |
19 | return result | 17 | notrun('quorum support missing') |
20 | 18 | ||
21 | - def wait_until_completed(self, drive='drive0', check_offset=True, wait=60.0): | 19 | +def has_working_luks() -> Tuple[bool, str]: |
22 | + def wait_until_completed(self, drive='drive0', check_offset=True, wait=60.0, | 20 | + """ |
23 | + error=None): | 21 | + Check whether our LUKS driver can actually create images |
24 | '''Wait for a block job to finish, returning the event''' | 22 | + (this extends to LUKS encryption for qcow2). |
25 | while True: | 23 | + |
26 | for event in self.vm.get_qmp_events(wait=wait): | 24 | + If not, return the reason why. |
27 | if event['event'] == 'BLOCK_JOB_COMPLETED': | 25 | + """ |
28 | self.assert_qmp(event, 'data/device', drive) | 26 | + |
29 | - self.assert_qmp_absent(event, 'data/error') | 27 | + img_file = f'{test_dir}/luks-test.luks' |
30 | - if check_offset: | 28 | + (output, status) = \ |
31 | - self.assert_qmp(event, 'data/offset', event['data']['len']) | 29 | + qemu_img_pipe_and_status('create', '-f', 'luks', |
32 | + if error is None: | 30 | + '--object', luks_default_secret_object, |
33 | + self.assert_qmp_absent(event, 'data/error') | 31 | + '-o', luks_default_key_secret_opt, |
34 | + if check_offset: | 32 | + '-o', 'iter-time=10', |
35 | + self.assert_qmp(event, 'data/offset', | 33 | + img_file, '1G') |
36 | + event['data']['len']) | 34 | + try: |
37 | + else: | 35 | + os.remove(img_file) |
38 | + self.assert_qmp(event, 'data/error', error) | 36 | + except OSError: |
39 | self.assert_no_active_block_jobs() | 37 | + pass |
40 | return event | 38 | + |
41 | elif event['event'] == 'JOB_STATUS_CHANGE': | 39 | + if status != 0: |
42 | @@ -XXX,XX +XXX,XX @@ class QMPTestCase(unittest.TestCase): | 40 | + reason = output |
43 | self.assert_qmp(event, 'data/type', 'mirror') | 41 | + for line in output.splitlines(): |
44 | self.assert_qmp(event, 'data/offset', event['data']['len']) | 42 | + if img_file + ':' in line: |
45 | 43 | + reason = line.split(img_file + ':', 1)[1].strip() | |
46 | - def complete_and_wait(self, drive='drive0', wait_ready=True): | 44 | + break |
47 | + def complete_and_wait(self, drive='drive0', wait_ready=True, | 45 | + |
48 | + completion_error=None): | 46 | + return (False, reason) |
49 | '''Complete a block job and wait for it to finish''' | 47 | + else: |
50 | if wait_ready: | 48 | + return (True, '') |
51 | self.wait_ready(drive=drive) | 49 | + |
52 | @@ -XXX,XX +XXX,XX @@ class QMPTestCase(unittest.TestCase): | 50 | +def verify_working_luks(): |
53 | result = self.vm.qmp('block-job-complete', device=drive) | 51 | + """ |
54 | self.assert_qmp(result, 'return', {}) | 52 | + Skip test suite if LUKS does not work |
55 | 53 | + """ | |
56 | - event = self.wait_until_completed(drive=drive) | 54 | + (working, reason) = has_working_luks() |
57 | + event = self.wait_until_completed(drive=drive, error=completion_error) | 55 | + if not working: |
58 | self.assert_qmp(event, 'data/type', 'mirror') | 56 | + notrun(reason) |
59 | 57 | + | |
60 | def pause_wait(self, job_id='job0'): | 58 | def qemu_pipe(*args): |
59 | """ | ||
60 | Run qemu with an option to print something and exit (e.g. a help option). | ||
61 | -- | 61 | -- |
62 | 2.24.1 | 62 | 2.26.2 |
63 | 63 | ||
64 | 64 | diff view generated by jsdifflib |
1 | Whenever running an iotest for the luks format, we should check whether | ||
---|---|---|---|
2 | luks actually really works. | ||
3 | |||
4 | Tests that try to create luks-encrypted qcow2 images should do the same. | ||
5 | |||
1 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 6 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
2 | Message-id: 20191107163708.833192-22-mreitz@redhat.com | 7 | Message-Id: <20200625125548.870061-7-mreitz@redhat.com> |
3 | [mreitz: Also disable 273] | 8 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> |
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
5 | --- | 9 | --- |
6 | tests/qemu-iotests/007 | 5 +++-- | 10 | tests/qemu-iotests/087 | 1 + |
7 | tests/qemu-iotests/014 | 2 ++ | 11 | tests/qemu-iotests/178 | 1 + |
8 | tests/qemu-iotests/015 | 5 +++-- | 12 | tests/qemu-iotests/188 | 1 + |
9 | tests/qemu-iotests/026 | 5 ++++- | 13 | tests/qemu-iotests/189 | 1 + |
10 | tests/qemu-iotests/029 | 5 +++-- | 14 | tests/qemu-iotests/198 | 1 + |
11 | tests/qemu-iotests/031 | 6 +++--- | 15 | tests/qemu-iotests/206 | 1 + |
12 | tests/qemu-iotests/036 | 5 +++-- | 16 | tests/qemu-iotests/263 | 1 + |
13 | tests/qemu-iotests/039 | 3 +++ | 17 | tests/qemu-iotests/284 | 1 + |
14 | tests/qemu-iotests/046 | 2 ++ | 18 | tests/qemu-iotests/common.rc | 3 +++ |
15 | tests/qemu-iotests/048 | 2 ++ | 19 | tests/qemu-iotests/iotests.py | 5 +++++ |
16 | tests/qemu-iotests/051 | 5 +++-- | 20 | 10 files changed, 16 insertions(+) |
17 | tests/qemu-iotests/058 | 5 +++-- | ||
18 | tests/qemu-iotests/060 | 6 ++++-- | ||
19 | tests/qemu-iotests/061 | 6 ++++-- | ||
20 | tests/qemu-iotests/062 | 2 +- | ||
21 | tests/qemu-iotests/066 | 4 +++- | ||
22 | tests/qemu-iotests/067 | 6 ++++-- | ||
23 | tests/qemu-iotests/068 | 5 +++-- | ||
24 | tests/qemu-iotests/071 | 3 +++ | ||
25 | tests/qemu-iotests/073 | 4 ++++ | ||
26 | tests/qemu-iotests/074 | 2 ++ | ||
27 | tests/qemu-iotests/080 | 5 +++-- | ||
28 | tests/qemu-iotests/090 | 2 ++ | ||
29 | tests/qemu-iotests/098 | 6 ++++-- | ||
30 | tests/qemu-iotests/099 | 3 ++- | ||
31 | tests/qemu-iotests/103 | 5 +++-- | ||
32 | tests/qemu-iotests/108 | 6 ++++-- | ||
33 | tests/qemu-iotests/112 | 5 +++-- | ||
34 | tests/qemu-iotests/114 | 2 ++ | ||
35 | tests/qemu-iotests/121 | 3 +++ | ||
36 | tests/qemu-iotests/138 | 3 +++ | ||
37 | tests/qemu-iotests/156 | 2 ++ | ||
38 | tests/qemu-iotests/176 | 7 +++++-- | ||
39 | tests/qemu-iotests/191 | 2 ++ | ||
40 | tests/qemu-iotests/201 | 6 +++--- | ||
41 | tests/qemu-iotests/214 | 3 ++- | ||
42 | tests/qemu-iotests/217 | 3 ++- | ||
43 | tests/qemu-iotests/220 | 5 +++-- | ||
44 | tests/qemu-iotests/243 | 6 ++++-- | ||
45 | tests/qemu-iotests/244 | 5 +++-- | ||
46 | tests/qemu-iotests/250 | 2 ++ | ||
47 | tests/qemu-iotests/261 | 3 ++- | ||
48 | tests/qemu-iotests/267 | 5 +++-- | ||
49 | tests/qemu-iotests/273 | 3 +++ | ||
50 | 44 files changed, 127 insertions(+), 53 deletions(-) | ||
51 | 21 | ||
52 | diff --git a/tests/qemu-iotests/007 b/tests/qemu-iotests/007 | 22 | diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087 |
53 | index XXXXXXX..XXXXXXX 100755 | 23 | index XXXXXXX..XXXXXXX 100755 |
54 | --- a/tests/qemu-iotests/007 | 24 | --- a/tests/qemu-iotests/087 |
55 | +++ b/tests/qemu-iotests/007 | 25 | +++ b/tests/qemu-iotests/087 |
56 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
57 | _supported_fmt qcow2 | ||
58 | _supported_proto generic | ||
59 | # refcount_bits must be at least 4 so we can create ten internal snapshots | ||
60 | -# (1 bit supports none, 2 bits support two, 4 bits support 14) | ||
61 | -_unsupported_imgopts 'refcount_bits=\(1\|2\)[^0-9]' | ||
62 | +# (1 bit supports none, 2 bits support two, 4 bits support 14); | ||
63 | +# snapshot are generally impossible with external data files | ||
64 | +_unsupported_imgopts 'refcount_bits=\(1\|2\)[^0-9]' data_file | ||
65 | |||
66 | echo | ||
67 | echo "creating image" | ||
68 | diff --git a/tests/qemu-iotests/014 b/tests/qemu-iotests/014 | ||
69 | index XXXXXXX..XXXXXXX 100755 | ||
70 | --- a/tests/qemu-iotests/014 | ||
71 | +++ b/tests/qemu-iotests/014 | ||
72 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 26 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
73 | _supported_fmt qcow2 | 27 | _supported_fmt qcow2 |
74 | _supported_proto file | 28 | _supported_proto file |
75 | _supported_os Linux | 29 | _supported_os Linux |
76 | +# Compression and snapshots do not work with external data files | 30 | +_require_working_luks |
77 | +_unsupported_imgopts data_file | 31 | |
78 | 32 | do_run_qemu() | |
79 | TEST_OFFSETS="0 4294967296" | 33 | { |
80 | TEST_OPS="writev read write readv" | 34 | diff --git a/tests/qemu-iotests/178 b/tests/qemu-iotests/178 |
81 | diff --git a/tests/qemu-iotests/015 b/tests/qemu-iotests/015 | ||
82 | index XXXXXXX..XXXXXXX 100755 | 35 | index XXXXXXX..XXXXXXX 100755 |
83 | --- a/tests/qemu-iotests/015 | 36 | --- a/tests/qemu-iotests/178 |
84 | +++ b/tests/qemu-iotests/015 | 37 | +++ b/tests/qemu-iotests/178 |
85 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 38 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
86 | # actually any format that supports snapshots | 39 | _supported_fmt raw qcow2 |
87 | _supported_fmt qcow2 | 40 | _supported_proto file |
88 | _supported_proto generic | 41 | _supported_os Linux |
89 | -# Internal snapshots are (currently) impossible with refcount_bits=1 | 42 | +_require_working_luks |
90 | -_unsupported_imgopts 'refcount_bits=1[^0-9]' | 43 | |
91 | +# Internal snapshots are (currently) impossible with refcount_bits=1, | 44 | echo "== Input validation ==" |
92 | +# and generally impossible with external data files | ||
93 | +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file | ||
94 | |||
95 | echo | 45 | echo |
96 | echo "creating image" | 46 | diff --git a/tests/qemu-iotests/188 b/tests/qemu-iotests/188 |
97 | diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 | ||
98 | index XXXXXXX..XXXXXXX 100755 | 47 | index XXXXXXX..XXXXXXX 100755 |
99 | --- a/tests/qemu-iotests/026 | 48 | --- a/tests/qemu-iotests/188 |
100 | +++ b/tests/qemu-iotests/026 | 49 | +++ b/tests/qemu-iotests/188 |
101 | @@ -XXX,XX +XXX,XX @@ _supported_cache_modes writethrough none | ||
102 | # 32 and 64 bits do not work either, however, due to different leaked cluster | ||
103 | # count on error. | ||
104 | # Thus, the only remaining option is refcount_bits=16. | ||
105 | -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
106 | +# | ||
107 | +# As for data_file, none of the refcount tests can work for it. | ||
108 | +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' \ | ||
109 | + data_file | ||
110 | |||
111 | echo "Errors while writing 128 kB" | ||
112 | echo | ||
113 | diff --git a/tests/qemu-iotests/029 b/tests/qemu-iotests/029 | ||
114 | index XXXXXXX..XXXXXXX 100755 | ||
115 | --- a/tests/qemu-iotests/029 | ||
116 | +++ b/tests/qemu-iotests/029 | ||
117 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 50 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
118 | _supported_fmt qcow2 | 51 | _supported_fmt qcow2 |
119 | _supported_proto generic | 52 | _supported_proto generic |
120 | _unsupported_proto vxhs | 53 | _supported_os Linux |
121 | -# Internal snapshots are (currently) impossible with refcount_bits=1 | 54 | +_require_working_luks |
122 | -_unsupported_imgopts 'refcount_bits=1[^0-9]' | 55 | |
123 | +# Internal snapshots are (currently) impossible with refcount_bits=1, | 56 | |
124 | +# and generally impossible with external data files | 57 | size=16M |
125 | +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file | 58 | diff --git a/tests/qemu-iotests/189 b/tests/qemu-iotests/189 |
126 | |||
127 | offset_size=24 | ||
128 | offset_l1_size=36 | ||
129 | diff --git a/tests/qemu-iotests/031 b/tests/qemu-iotests/031 | ||
130 | index XXXXXXX..XXXXXXX 100755 | 59 | index XXXXXXX..XXXXXXX 100755 |
131 | --- a/tests/qemu-iotests/031 | 60 | --- a/tests/qemu-iotests/189 |
132 | +++ b/tests/qemu-iotests/031 | 61 | +++ b/tests/qemu-iotests/189 |
133 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
134 | # This tests qcow2-specific low-level functionality | ||
135 | _supported_fmt qcow2 | ||
136 | _supported_proto file | ||
137 | -# We want to test compat=0.10, which does not support refcount widths | ||
138 | -# other than 16 | ||
139 | -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
140 | +# We want to test compat=0.10, which does not support external data | ||
141 | +# files or refcount widths other than 16 | ||
142 | +_unsupported_imgopts data_file 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
143 | |||
144 | CLUSTER_SIZE=65536 | ||
145 | |||
146 | diff --git a/tests/qemu-iotests/036 b/tests/qemu-iotests/036 | ||
147 | index XXXXXXX..XXXXXXX 100755 | ||
148 | --- a/tests/qemu-iotests/036 | ||
149 | +++ b/tests/qemu-iotests/036 | ||
150 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
151 | # This tests qcow2-specific low-level functionality | ||
152 | _supported_fmt qcow2 | ||
153 | _supported_proto file | ||
154 | -# Only qcow2v3 and later supports feature bits | ||
155 | -_unsupported_imgopts 'compat=0.10' | ||
156 | +# Only qcow2v3 and later supports feature bits; | ||
157 | +# qcow2.py does not support external data files | ||
158 | +_unsupported_imgopts 'compat=0.10' data_file | ||
159 | |||
160 | echo | ||
161 | echo === Image with unknown incompatible feature bit === | ||
162 | diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 | ||
163 | index XXXXXXX..XXXXXXX 100755 | ||
164 | --- a/tests/qemu-iotests/039 | ||
165 | +++ b/tests/qemu-iotests/039 | ||
166 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
167 | _supported_os Linux | ||
168 | _default_cache_mode writethrough | ||
169 | _supported_cache_modes writethrough | ||
170 | +# Some of these test cases expect no external data file so that all | ||
171 | +# clusters are part of the qcow2 image and refcounted | ||
172 | +_unsupported_imgopts data_file | ||
173 | |||
174 | size=128M | ||
175 | |||
176 | diff --git a/tests/qemu-iotests/046 b/tests/qemu-iotests/046 | ||
177 | index XXXXXXX..XXXXXXX 100755 | ||
178 | --- a/tests/qemu-iotests/046 | ||
179 | +++ b/tests/qemu-iotests/046 | ||
180 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
181 | |||
182 | _supported_fmt qcow2 | ||
183 | _supported_proto file | ||
184 | +# data_file does not support compressed clusters | ||
185 | +_unsupported_imgopts data_file | ||
186 | |||
187 | CLUSTER_SIZE=64k | ||
188 | size=128M | ||
189 | diff --git a/tests/qemu-iotests/048 b/tests/qemu-iotests/048 | ||
190 | index XXXXXXX..XXXXXXX 100755 | ||
191 | --- a/tests/qemu-iotests/048 | ||
192 | +++ b/tests/qemu-iotests/048 | ||
193 | @@ -XXX,XX +XXX,XX @@ _compare() | ||
194 | _supported_fmt raw qcow2 qed luks | ||
195 | _supported_proto file | ||
196 | _supported_os Linux | ||
197 | +# Using 'cp' is incompatible with external data files | ||
198 | +_unsupported_imgopts data_file | ||
199 | |||
200 | # Remove once all tests are fixed to use TEST_IMG_FILE | ||
201 | # correctly and common.rc sets it unconditionally | ||
202 | diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 | ||
203 | index XXXXXXX..XXXXXXX 100755 | ||
204 | --- a/tests/qemu-iotests/051 | ||
205 | +++ b/tests/qemu-iotests/051 | ||
206 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
207 | _supported_fmt qcow2 | ||
208 | _supported_proto file | ||
209 | # A compat=0.10 image is created in this test which does not support anything | ||
210 | -# other than refcount_bits=16 | ||
211 | -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
212 | +# other than refcount_bits=16; | ||
213 | +# it also will not support an external data file | ||
214 | +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file | ||
215 | _require_drivers nbd | ||
216 | |||
217 | do_run_qemu() | ||
218 | diff --git a/tests/qemu-iotests/058 b/tests/qemu-iotests/058 | ||
219 | index XXXXXXX..XXXXXXX 100755 | ||
220 | --- a/tests/qemu-iotests/058 | ||
221 | +++ b/tests/qemu-iotests/058 | ||
222 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow2 | ||
223 | _supported_proto file | ||
224 | _supported_os Linux | ||
225 | _require_command QEMU_NBD | ||
226 | -# Internal snapshots are (currently) impossible with refcount_bits=1 | ||
227 | -_unsupported_imgopts 'refcount_bits=1[^0-9]' | ||
228 | +# Internal snapshots are (currently) impossible with refcount_bits=1, | ||
229 | +# and generally impossible with external data files | ||
230 | +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file | ||
231 | |||
232 | nbd_snapshot_img="nbd:unix:$nbd_unix_socket" | ||
233 | |||
234 | diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 | ||
235 | index XXXXXXX..XXXXXXX 100755 | ||
236 | --- a/tests/qemu-iotests/060 | ||
237 | +++ b/tests/qemu-iotests/060 | ||
238 | @@ -XXX,XX +XXX,XX @@ _filter_io_error() | ||
239 | _supported_fmt qcow2 | ||
240 | _supported_proto file | ||
241 | _supported_os Linux | ||
242 | -# These tests only work for compat=1.1 images with refcount_bits=16 | ||
243 | -_unsupported_imgopts 'compat=0.10' 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
244 | +# These tests only work for compat=1.1 images without an external | ||
245 | +# data file with refcount_bits=16 | ||
246 | +_unsupported_imgopts 'compat=0.10' data_file \ | ||
247 | + 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
248 | |||
249 | # The repair process will create a large file - so check for availability first | ||
250 | _require_large_file 64G | ||
251 | diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 | ||
252 | index XXXXXXX..XXXXXXX 100755 | ||
253 | --- a/tests/qemu-iotests/061 | ||
254 | +++ b/tests/qemu-iotests/061 | ||
255 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow2 | ||
256 | _supported_proto file | ||
257 | _supported_os Linux | ||
258 | # Conversion between different compat versions can only really work | ||
259 | -# with refcount_bits=16 | ||
260 | -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
261 | +# with refcount_bits=16; | ||
262 | +# we have explicit tests for data_file here, but the whole test does | ||
263 | +# not work with it | ||
264 | +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file | ||
265 | |||
266 | echo | ||
267 | echo "=== Testing version downgrade with zero expansion ===" | ||
268 | diff --git a/tests/qemu-iotests/062 b/tests/qemu-iotests/062 | ||
269 | index XXXXXXX..XXXXXXX 100755 | ||
270 | --- a/tests/qemu-iotests/062 | ||
271 | +++ b/tests/qemu-iotests/062 | ||
272 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 62 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
273 | _supported_fmt qcow2 | 63 | _supported_fmt qcow2 |
274 | _supported_proto generic | 64 | _supported_proto generic |
275 | # We need zero clusters and snapshots | 65 | _supported_os Linux |
276 | -_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' | 66 | +_require_working_luks |
277 | +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' data_file | 67 | |
278 | 68 | ||
279 | IMG_SIZE=64M | 69 | size=16M |
280 | 70 | diff --git a/tests/qemu-iotests/198 b/tests/qemu-iotests/198 | |
281 | diff --git a/tests/qemu-iotests/066 b/tests/qemu-iotests/066 | ||
282 | index XXXXXXX..XXXXXXX 100755 | 71 | index XXXXXXX..XXXXXXX 100755 |
283 | --- a/tests/qemu-iotests/066 | 72 | --- a/tests/qemu-iotests/198 |
284 | +++ b/tests/qemu-iotests/066 | 73 | +++ b/tests/qemu-iotests/198 |
285 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 74 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
286 | _supported_fmt qcow2 | 75 | _supported_fmt qcow2 |
287 | _supported_proto generic | 76 | _supported_proto generic |
288 | # We need zero clusters and snapshots | 77 | _supported_os Linux |
289 | -_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' | 78 | +_require_working_luks |
290 | +# (TODO: Consider splitting the snapshot part into a separate test | 79 | |
291 | +# file, so this one runs with refcount_bits=1 and data_file) | 80 | |
292 | +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' data_file | 81 | size=16M |
293 | 82 | diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206 | |
294 | # Intentionally create an unaligned image | ||
295 | IMG_SIZE=$((64 * 1024 * 1024 + 512)) | ||
296 | diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067 | ||
297 | index XXXXXXX..XXXXXXX 100755 | 83 | index XXXXXXX..XXXXXXX 100755 |
298 | --- a/tests/qemu-iotests/067 | 84 | --- a/tests/qemu-iotests/206 |
299 | +++ b/tests/qemu-iotests/067 | 85 | +++ b/tests/qemu-iotests/206 |
300 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | 86 | @@ -XXX,XX +XXX,XX @@ import iotests |
301 | 87 | from iotests import imgfmt | |
302 | _supported_fmt qcow2 | 88 | |
303 | _supported_proto file | 89 | iotests.script_initialize(supported_fmts=['qcow2']) |
304 | -# Because anything other than 16 would change the output of query-block | 90 | +iotests.verify_working_luks() |
305 | -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | 91 | |
306 | +# Because anything other than 16 would change the output of query-block, | 92 | with iotests.FilePath('t.qcow2') as disk_path, \ |
307 | +# and external data files would change the output of | 93 | iotests.FilePath('t.qcow2.base') as backing_path, \ |
308 | +# query-named-block-nodes | 94 | diff --git a/tests/qemu-iotests/263 b/tests/qemu-iotests/263 |
309 | +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file | ||
310 | |||
311 | do_run_qemu() | ||
312 | { | ||
313 | diff --git a/tests/qemu-iotests/068 b/tests/qemu-iotests/068 | ||
314 | index XXXXXXX..XXXXXXX 100755 | 95 | index XXXXXXX..XXXXXXX 100755 |
315 | --- a/tests/qemu-iotests/068 | 96 | --- a/tests/qemu-iotests/263 |
316 | +++ b/tests/qemu-iotests/068 | 97 | +++ b/tests/qemu-iotests/263 |
317 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
318 | # This tests qcow2-specific low-level functionality | ||
319 | _supported_fmt qcow2 | ||
320 | _supported_proto generic | ||
321 | -# Internal snapshots are (currently) impossible with refcount_bits=1 | ||
322 | -_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' | ||
323 | +# Internal snapshots are (currently) impossible with refcount_bits=1, | ||
324 | +# and generally impossible with external data files | ||
325 | +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' data_file | ||
326 | |||
327 | IMG_SIZE=128K | ||
328 | |||
329 | diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 | ||
330 | index XXXXXXX..XXXXXXX 100755 | ||
331 | --- a/tests/qemu-iotests/071 | ||
332 | +++ b/tests/qemu-iotests/071 | ||
333 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
334 | _supported_fmt qcow2 | ||
335 | _supported_proto file | ||
336 | _require_drivers blkdebug blkverify | ||
337 | +# blkdebug can only inject errors on bs->file, not on the data_file, | ||
338 | +# so thie test does not work with external data files | ||
339 | +_unsupported_imgopts data_file | ||
340 | |||
341 | do_run_qemu() | ||
342 | { | ||
343 | diff --git a/tests/qemu-iotests/073 b/tests/qemu-iotests/073 | ||
344 | index XXXXXXX..XXXXXXX 100755 | ||
345 | --- a/tests/qemu-iotests/073 | ||
346 | +++ b/tests/qemu-iotests/073 | ||
347 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 98 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
348 | _supported_fmt qcow2 | 99 | _supported_fmt qcow2 |
349 | _supported_proto generic | 100 | _supported_proto generic |
350 | _unsupported_proto vxhs | 101 | _supported_os Linux |
351 | +# External data files do not support compressed clusters | 102 | +_require_working_luks |
352 | +# (TODO: Consider writing a version for external data files that does | 103 | |
353 | +# not test compressed clusters) | 104 | |
354 | +_unsupported_imgopts data_file | 105 | size=1M |
355 | 106 | diff --git a/tests/qemu-iotests/284 b/tests/qemu-iotests/284 | |
356 | CLUSTER_SIZE=64k | ||
357 | size=128M | ||
358 | diff --git a/tests/qemu-iotests/074 b/tests/qemu-iotests/074 | ||
359 | index XXXXXXX..XXXXXXX 100755 | 107 | index XXXXXXX..XXXXXXX 100755 |
360 | --- a/tests/qemu-iotests/074 | 108 | --- a/tests/qemu-iotests/284 |
361 | +++ b/tests/qemu-iotests/074 | 109 | +++ b/tests/qemu-iotests/284 |
362 | @@ -XXX,XX +XXX,XX @@ _compare() | ||
363 | _supported_fmt qcow2 | ||
364 | _supported_proto file | ||
365 | _supported_os Linux | ||
366 | +# blkdebug can only inject errors on bs->file | ||
367 | +_unsupported_imgopts data_file | ||
368 | |||
369 | # Setup test basic parameters | ||
370 | TEST_IMG2=$TEST_IMG.2 | ||
371 | diff --git a/tests/qemu-iotests/080 b/tests/qemu-iotests/080 | ||
372 | index XXXXXXX..XXXXXXX 100755 | ||
373 | --- a/tests/qemu-iotests/080 | ||
374 | +++ b/tests/qemu-iotests/080 | ||
375 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
376 | _supported_fmt qcow2 | ||
377 | _supported_proto file | ||
378 | _supported_os Linux | ||
379 | -# - Internal snapshots are (currently) impossible with refcount_bits=1 | ||
380 | +# - Internal snapshots are (currently) impossible with refcount_bits=1, | ||
381 | +# and generally impossible with external data files | ||
382 | # - This is generally a test for compat=1.1 images | ||
383 | -_unsupported_imgopts 'refcount_bits=1[^0-9]' 'compat=0.10' | ||
384 | +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file 'compat=0.10' | ||
385 | |||
386 | header_size=104 | ||
387 | |||
388 | diff --git a/tests/qemu-iotests/090 b/tests/qemu-iotests/090 | ||
389 | index XXXXXXX..XXXXXXX 100755 | ||
390 | --- a/tests/qemu-iotests/090 | ||
391 | +++ b/tests/qemu-iotests/090 | ||
392 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
393 | |||
394 | _supported_fmt qcow2 | ||
395 | _supported_proto file nfs | ||
396 | +# External data files do not support compressed clusters | ||
397 | +_unsupported_imgopts data_file | ||
398 | |||
399 | IMG_SIZE=128K | ||
400 | |||
401 | diff --git a/tests/qemu-iotests/098 b/tests/qemu-iotests/098 | ||
402 | index XXXXXXX..XXXXXXX 100755 | ||
403 | --- a/tests/qemu-iotests/098 | ||
404 | +++ b/tests/qemu-iotests/098 | ||
405 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
406 | |||
407 | _supported_fmt qcow2 | ||
408 | _supported_proto file | ||
409 | -# The code path we want to test here only works for compat=1.1 images | ||
410 | -_unsupported_imgopts 'compat=0.10' | ||
411 | +# The code path we want to test here only works for compat=1.1 images; | ||
412 | +# blkdebug can only inject errors on bs->file, so external data files | ||
413 | +# do not work with this test | ||
414 | +_unsupported_imgopts 'compat=0.10' data_file | ||
415 | |||
416 | for event in l1_update empty_image_prepare reftable_update refblock_alloc; do | ||
417 | |||
418 | diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099 | ||
419 | index XXXXXXX..XXXXXXX 100755 | ||
420 | --- a/tests/qemu-iotests/099 | ||
421 | +++ b/tests/qemu-iotests/099 | ||
422 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 qed vdi vhdx vmdk vpc | ||
423 | _supported_proto file | ||
424 | _supported_os Linux | ||
425 | _require_drivers blkdebug blkverify | ||
426 | +# data_file would change the json:{} filenames | ||
427 | _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ | ||
428 | - "subformat=twoGbMaxExtentSparse" | ||
429 | + "subformat=twoGbMaxExtentSparse" data_file | ||
430 | |||
431 | do_run_qemu() | ||
432 | { | ||
433 | diff --git a/tests/qemu-iotests/103 b/tests/qemu-iotests/103 | ||
434 | index XXXXXXX..XXXXXXX 100755 | ||
435 | --- a/tests/qemu-iotests/103 | ||
436 | +++ b/tests/qemu-iotests/103 | ||
437 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
438 | |||
439 | _supported_fmt qcow2 | ||
440 | _supported_proto file nfs | ||
441 | -# Internal snapshots are (currently) impossible with refcount_bits=1 | ||
442 | -_unsupported_imgopts 'refcount_bits=1[^0-9]' | ||
443 | +# Internal snapshots are (currently) impossible with refcount_bits=1, | ||
444 | +# and generally impossible with external data files | ||
445 | +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file | ||
446 | |||
447 | IMG_SIZE=64K | ||
448 | |||
449 | diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108 | ||
450 | index XXXXXXX..XXXXXXX 100755 | ||
451 | --- a/tests/qemu-iotests/108 | ||
452 | +++ b/tests/qemu-iotests/108 | ||
453 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
454 | _supported_fmt qcow2 | ||
455 | _supported_proto file | ||
456 | _supported_os Linux | ||
457 | -# This test directly modifies a refblock so it relies on refcount_bits being 16 | ||
458 | -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
459 | +# This test directly modifies a refblock so it relies on refcount_bits being 16; | ||
460 | +# and the low-level modification it performs are not tuned for external data | ||
461 | +# files | ||
462 | +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file | ||
463 | |||
464 | echo | ||
465 | echo '=== Repairing an image without any refcount table ===' | ||
466 | diff --git a/tests/qemu-iotests/112 b/tests/qemu-iotests/112 | ||
467 | index XXXXXXX..XXXXXXX 100755 | ||
468 | --- a/tests/qemu-iotests/112 | ||
469 | +++ b/tests/qemu-iotests/112 | ||
470 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
471 | _supported_fmt qcow2 | ||
472 | _supported_proto file | ||
473 | # This test will set refcount_bits on its own which would conflict with the | ||
474 | -# manual setting; compat will be overridden as well | ||
475 | -_unsupported_imgopts refcount_bits 'compat=0.10' | ||
476 | +# manual setting; compat will be overridden as well; | ||
477 | +# and external data files do not work well with our refcount testing | ||
478 | +_unsupported_imgopts refcount_bits 'compat=0.10' data_file | ||
479 | |||
480 | print_refcount_bits() | ||
481 | { | ||
482 | diff --git a/tests/qemu-iotests/114 b/tests/qemu-iotests/114 | ||
483 | index XXXXXXX..XXXXXXX 100755 | ||
484 | --- a/tests/qemu-iotests/114 | ||
485 | +++ b/tests/qemu-iotests/114 | ||
486 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 110 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
487 | _supported_fmt qcow2 | 111 | _supported_fmt qcow2 |
488 | _supported_proto generic | 112 | _supported_proto generic |
489 | _unsupported_proto vxhs | ||
490 | +# qcow2.py does not work too well with external data files | ||
491 | +_unsupported_imgopts data_file | ||
492 | |||
493 | |||
494 | TEST_IMG="$TEST_IMG.base" _make_test_img 64M | ||
495 | diff --git a/tests/qemu-iotests/121 b/tests/qemu-iotests/121 | ||
496 | index XXXXXXX..XXXXXXX 100755 | ||
497 | --- a/tests/qemu-iotests/121 | ||
498 | +++ b/tests/qemu-iotests/121 | ||
499 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
500 | _supported_fmt qcow2 | ||
501 | _supported_proto file | ||
502 | _supported_os Linux | 113 | _supported_os Linux |
503 | +# Refcount structures are used much differently with external data | 114 | +_require_working_luks |
504 | +# files | 115 | |
505 | +_unsupported_imgopts data_file | 116 | |
506 | 117 | size=1M | |
507 | echo | 118 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc |
508 | echo '=== New refcount structures may not conflict with existing structures ===' | 119 | index XXXXXXX..XXXXXXX 100644 |
509 | diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138 | 120 | --- a/tests/qemu-iotests/common.rc |
510 | index XXXXXXX..XXXXXXX 100755 | 121 | +++ b/tests/qemu-iotests/common.rc |
511 | --- a/tests/qemu-iotests/138 | 122 | @@ -XXX,XX +XXX,XX @@ _supported_fmt() |
512 | +++ b/tests/qemu-iotests/138 | 123 | # setting IMGFMT_GENERIC to false. |
513 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 124 | for f; do |
514 | _supported_fmt qcow2 | 125 | if [ "$f" = "$IMGFMT" -o "$f" = "generic" -a "$IMGFMT_GENERIC" = "true" ]; then |
515 | _supported_proto file | 126 | + if [ "$IMGFMT" = "luks" ]; then |
516 | _supported_os Linux | 127 | + _require_working_luks |
517 | +# With an external data file, data clusters are not refcounted | 128 | + fi |
518 | +# (and so qemu-img check does not check their refcount) | 129 | return |
519 | +_unsupported_imgopts data_file | 130 | fi |
520 | 131 | done | |
521 | echo | 132 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py |
522 | echo '=== Check on an image with a multiple of 2^32 clusters ===' | 133 | index XXXXXXX..XXXXXXX 100644 |
523 | diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156 | 134 | --- a/tests/qemu-iotests/iotests.py |
524 | index XXXXXXX..XXXXXXX 100755 | 135 | +++ b/tests/qemu-iotests/iotests.py |
525 | --- a/tests/qemu-iotests/156 | 136 | @@ -XXX,XX +XXX,XX @@ def _verify_image_format(supported_fmts: Sequence[str] = (), |
526 | +++ b/tests/qemu-iotests/156 | 137 | # similar to |
527 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 138 | # _supported_fmt generic |
528 | _supported_fmt qcow2 qed | 139 | # for bash tests |
529 | _supported_proto generic | 140 | + if imgfmt == 'luks': |
530 | _unsupported_proto vxhs | 141 | + verify_working_luks() |
531 | +# Copying files around with cp does not work with external data files | 142 | return |
532 | +_unsupported_imgopts data_file | 143 | |
533 | 144 | not_sup = supported_fmts and (imgfmt not in supported_fmts) | |
534 | # Create source disk | 145 | if not_sup or (imgfmt in unsupported_fmts): |
535 | TEST_IMG="$TEST_IMG.backing" _make_test_img 1M | 146 | notrun('not suitable for this image format: %s' % imgfmt) |
536 | diff --git a/tests/qemu-iotests/176 b/tests/qemu-iotests/176 | 147 | |
537 | index XXXXXXX..XXXXXXX 100755 | 148 | + if imgfmt == 'luks': |
538 | --- a/tests/qemu-iotests/176 | 149 | + verify_working_luks() |
539 | +++ b/tests/qemu-iotests/176 | 150 | + |
540 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 151 | def _verify_protocol(supported: Sequence[str] = (), |
541 | _supported_fmt qcow2 | 152 | unsupported: Sequence[str] = ()) -> None: |
542 | _supported_proto file | 153 | assert not (supported and unsupported) |
543 | _supported_os Linux | ||
544 | -# Persistent dirty bitmaps require compat=1.1 | ||
545 | -_unsupported_imgopts 'compat=0.10' | ||
546 | +# Persistent dirty bitmaps require compat=1.1; | ||
547 | +# Internal snapshots forbid using an external data file | ||
548 | +# (they work with refcount_bits=1 here, though, because there actually | ||
549 | +# is no data when creating the snapshot) | ||
550 | +_unsupported_imgopts 'compat=0.10' data_file | ||
551 | |||
552 | run_qemu() | ||
553 | { | ||
554 | diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 | ||
555 | index XXXXXXX..XXXXXXX 100755 | ||
556 | --- a/tests/qemu-iotests/191 | ||
557 | +++ b/tests/qemu-iotests/191 | ||
558 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
559 | |||
560 | _supported_fmt qcow2 | ||
561 | _supported_proto file | ||
562 | +# An external data file would change the query-named-block-nodes output | ||
563 | +_unsupported_imgopts data_file | ||
564 | |||
565 | size=64M | ||
566 | |||
567 | diff --git a/tests/qemu-iotests/201 b/tests/qemu-iotests/201 | ||
568 | index XXXXXXX..XXXXXXX 100755 | ||
569 | --- a/tests/qemu-iotests/201 | ||
570 | +++ b/tests/qemu-iotests/201 | ||
571 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow2 | ||
572 | _supported_proto generic | ||
573 | _supported_os Linux | ||
574 | |||
575 | -# Internal snapshots are (currently) impossible with refcount_bits=1 | ||
576 | -# This was taken from test 080 | ||
577 | -_unsupported_imgopts 'refcount_bits=1[^0-9]' | ||
578 | +# Internal snapshots are (currently) impossible with refcount_bits=1, | ||
579 | +# and generally impossible with external data files | ||
580 | +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file | ||
581 | |||
582 | size=64M | ||
583 | _make_test_img $size | ||
584 | diff --git a/tests/qemu-iotests/214 b/tests/qemu-iotests/214 | ||
585 | index XXXXXXX..XXXXXXX 100755 | ||
586 | --- a/tests/qemu-iotests/214 | ||
587 | +++ b/tests/qemu-iotests/214 | ||
588 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
589 | |||
590 | # Repairing the corrupted image requires qemu-img check to store a | ||
591 | # refcount up to 3, which requires at least two refcount bits. | ||
592 | -_unsupported_imgopts 'refcount_bits=1[^0-9]' | ||
593 | +# External data files do not support compressed clusters. | ||
594 | +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file | ||
595 | |||
596 | |||
597 | echo | ||
598 | diff --git a/tests/qemu-iotests/217 b/tests/qemu-iotests/217 | ||
599 | index XXXXXXX..XXXXXXX 100755 | ||
600 | --- a/tests/qemu-iotests/217 | ||
601 | +++ b/tests/qemu-iotests/217 | ||
602 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
603 | |||
604 | # This test needs clusters with at least a refcount of 2 so that | ||
605 | # OFLAG_COPIED is not set. refcount_bits=1 is therefore unsupported. | ||
606 | -_unsupported_imgopts 'refcount_bits=1[^0-9]' | ||
607 | +# (As are external data files.) | ||
608 | +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file | ||
609 | |||
610 | echo | ||
611 | echo '=== Simulating an I/O error during snapshot deletion ===' | ||
612 | diff --git a/tests/qemu-iotests/220 b/tests/qemu-iotests/220 | ||
613 | index XXXXXXX..XXXXXXX 100755 | ||
614 | --- a/tests/qemu-iotests/220 | ||
615 | +++ b/tests/qemu-iotests/220 | ||
616 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
617 | _supported_fmt qcow2 | ||
618 | _supported_proto file | ||
619 | _supported_os Linux | ||
620 | -# To use a different refcount width but 16 bits we need compat=1.1 | ||
621 | -_unsupported_imgopts 'compat=0.10' | ||
622 | +# To use a different refcount width but 16 bits we need compat=1.1, | ||
623 | +# and external data files do not support compressed clusters. | ||
624 | +_unsupported_imgopts 'compat=0.10' data_file | ||
625 | |||
626 | echo "== Creating huge file ==" | ||
627 | |||
628 | diff --git a/tests/qemu-iotests/243 b/tests/qemu-iotests/243 | ||
629 | index XXXXXXX..XXXXXXX 100755 | ||
630 | --- a/tests/qemu-iotests/243 | ||
631 | +++ b/tests/qemu-iotests/243 | ||
632 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
633 | _supported_fmt qcow2 | ||
634 | _supported_proto file | ||
635 | _supported_os Linux | ||
636 | -# External data files do not work with compat=0.10 | ||
637 | -_unsupported_imgopts 'compat=0.10' | ||
638 | +# External data files do not work with compat=0.10, and because there | ||
639 | +# is an explicit case for external data files here, we cannot allow | ||
640 | +# the user to specify whether to use one | ||
641 | +_unsupported_imgopts 'compat=0.10' data_file | ||
642 | |||
643 | for mode in off metadata falloc full; do | ||
644 | |||
645 | diff --git a/tests/qemu-iotests/244 b/tests/qemu-iotests/244 | ||
646 | index XXXXXXX..XXXXXXX 100755 | ||
647 | --- a/tests/qemu-iotests/244 | ||
648 | +++ b/tests/qemu-iotests/244 | ||
649 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
650 | _supported_fmt qcow2 | ||
651 | _supported_proto file | ||
652 | _supported_os Linux | ||
653 | -# External data files do not work with compat=0.10 | ||
654 | -_unsupported_imgopts 'compat=0.10' | ||
655 | +# External data files do not work with compat=0.10, and because we use | ||
656 | +# our own external data file, we cannot let the user specify one | ||
657 | +_unsupported_imgopts 'compat=0.10' data_file | ||
658 | |||
659 | echo | ||
660 | echo "=== Create and open image with external data file ===" | ||
661 | diff --git a/tests/qemu-iotests/250 b/tests/qemu-iotests/250 | ||
662 | index XXXXXXX..XXXXXXX 100755 | ||
663 | --- a/tests/qemu-iotests/250 | ||
664 | +++ b/tests/qemu-iotests/250 | ||
665 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
666 | _supported_fmt qcow2 | ||
667 | _supported_proto file | ||
668 | _supported_os Linux | ||
669 | +# This test does not make much sense with external data files | ||
670 | +_unsupported_imgopts data_file | ||
671 | |||
672 | # This test checks that qcow2_process_discards does not truncate a discard | ||
673 | # request > 2G. | ||
674 | diff --git a/tests/qemu-iotests/261 b/tests/qemu-iotests/261 | ||
675 | index XXXXXXX..XXXXXXX 100755 | ||
676 | --- a/tests/qemu-iotests/261 | ||
677 | +++ b/tests/qemu-iotests/261 | ||
678 | @@ -XXX,XX +XXX,XX @@ _supported_os Linux | ||
679 | # (1) We create a v2 image that supports nothing but refcount_bits=16 | ||
680 | # (2) We do some refcount management on our own which expects | ||
681 | # refcount_bits=16 | ||
682 | -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
683 | +# As for data files, they do not support snapshots at all. | ||
684 | +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file | ||
685 | |||
686 | # Parameters: | ||
687 | # $1: image filename | ||
688 | diff --git a/tests/qemu-iotests/267 b/tests/qemu-iotests/267 | ||
689 | index XXXXXXX..XXXXXXX 100755 | ||
690 | --- a/tests/qemu-iotests/267 | ||
691 | +++ b/tests/qemu-iotests/267 | ||
692 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
693 | _supported_os Linux | ||
694 | _require_drivers copy-on-read | ||
695 | |||
696 | -# Internal snapshots are (currently) impossible with refcount_bits=1 | ||
697 | -_unsupported_imgopts 'refcount_bits=1[^0-9]' | ||
698 | +# Internal snapshots are (currently) impossible with refcount_bits=1, | ||
699 | +# and generally impossible with external data files | ||
700 | +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file | ||
701 | |||
702 | do_run_qemu() | ||
703 | { | ||
704 | diff --git a/tests/qemu-iotests/273 b/tests/qemu-iotests/273 | ||
705 | index XXXXXXX..XXXXXXX 100755 | ||
706 | --- a/tests/qemu-iotests/273 | ||
707 | +++ b/tests/qemu-iotests/273 | ||
708 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
709 | _supported_fmt qcow2 | ||
710 | _supported_proto file | ||
711 | _supported_os Linux | ||
712 | +# External data files would add nodes to the block graph, so it would | ||
713 | +# not match the reference output | ||
714 | +_unsupported_imgopts data_file | ||
715 | |||
716 | do_run_qemu() | ||
717 | { | ||
718 | -- | 154 | -- |
719 | 2.24.1 | 155 | 2.26.2 |
720 | 156 | ||
721 | 157 | diff view generated by jsdifflib |
1 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 2 | |
3 | Message-id: 20191107163708.833192-5-mreitz@redhat.com | 3 | This will be used first to implement luks keyslot management. |
4 | |||
5 | block_crypto_amend_opts_init will be used to convert | ||
6 | qemu-img cmdline to QCryptoBlockAmendOptions | ||
7 | |||
8 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
9 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
10 | Message-Id: <20200608094030.670121-2-mlevitsk@redhat.com> | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 11 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
5 | --- | 12 | --- |
6 | tests/qemu-iotests/common.filter | 24 ++++++++++++++++++++++++ | 13 | qapi/crypto.json | 16 ++++++++++++++++ |
7 | 1 file changed, 24 insertions(+) | 14 | block/crypto.h | 3 +++ |
15 | crypto/blockpriv.h | 8 ++++++++ | ||
16 | include/crypto/block.h | 22 ++++++++++++++++++++++ | ||
17 | block/crypto.c | 17 +++++++++++++++++ | ||
18 | crypto/block.c | 29 +++++++++++++++++++++++++++++ | ||
19 | 6 files changed, 95 insertions(+) | ||
8 | 20 | ||
9 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter | 21 | diff --git a/qapi/crypto.json b/qapi/crypto.json |
10 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/tests/qemu-iotests/common.filter | 23 | --- a/qapi/crypto.json |
12 | +++ b/tests/qemu-iotests/common.filter | 24 | +++ b/qapi/crypto.json |
13 | @@ -XXX,XX +XXX,XX @@ _filter_qmp_empty_return() | 25 | @@ -XXX,XX +XXX,XX @@ |
14 | grep -v '{"return": {}}' | 26 | 'base': 'QCryptoBlockInfoBase', |
27 | 'discriminator': 'format', | ||
28 | 'data': { 'luks': 'QCryptoBlockInfoLUKS' } } | ||
29 | + | ||
30 | + | ||
31 | + | ||
32 | +## | ||
33 | +# @QCryptoBlockAmendOptions: | ||
34 | +# | ||
35 | +# The options that are available for all encryption formats | ||
36 | +# when amending encryption settings | ||
37 | +# | ||
38 | +# Since: 5.1 | ||
39 | +## | ||
40 | +{ 'union': 'QCryptoBlockAmendOptions', | ||
41 | + 'base': 'QCryptoBlockOptionsBase', | ||
42 | + 'discriminator': 'format', | ||
43 | + 'data': { | ||
44 | + } } | ||
45 | diff --git a/block/crypto.h b/block/crypto.h | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/block/crypto.h | ||
48 | +++ b/block/crypto.h | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | QCryptoBlockCreateOptions * | ||
51 | block_crypto_create_opts_init(QDict *opts, Error **errp); | ||
52 | |||
53 | +QCryptoBlockAmendOptions * | ||
54 | +block_crypto_amend_opts_init(QDict *opts, Error **errp); | ||
55 | + | ||
56 | QCryptoBlockOpenOptions * | ||
57 | block_crypto_open_opts_init(QDict *opts, Error **errp); | ||
58 | |||
59 | diff --git a/crypto/blockpriv.h b/crypto/blockpriv.h | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/crypto/blockpriv.h | ||
62 | +++ b/crypto/blockpriv.h | ||
63 | @@ -XXX,XX +XXX,XX @@ struct QCryptoBlockDriver { | ||
64 | void *opaque, | ||
65 | Error **errp); | ||
66 | |||
67 | + int (*amend)(QCryptoBlock *block, | ||
68 | + QCryptoBlockReadFunc readfunc, | ||
69 | + QCryptoBlockWriteFunc writefunc, | ||
70 | + void *opaque, | ||
71 | + QCryptoBlockAmendOptions *options, | ||
72 | + bool force, | ||
73 | + Error **errp); | ||
74 | + | ||
75 | int (*get_info)(QCryptoBlock *block, | ||
76 | QCryptoBlockInfo *info, | ||
77 | Error **errp); | ||
78 | diff --git a/include/crypto/block.h b/include/crypto/block.h | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/include/crypto/block.h | ||
81 | +++ b/include/crypto/block.h | ||
82 | @@ -XXX,XX +XXX,XX @@ QCryptoBlock *qcrypto_block_create(QCryptoBlockCreateOptions *options, | ||
83 | void *opaque, | ||
84 | Error **errp); | ||
85 | |||
86 | +/** | ||
87 | + * qcrypto_block_amend_options: | ||
88 | + * @block: the block encryption object | ||
89 | + * | ||
90 | + * @readfunc: callback for reading data from the volume header | ||
91 | + * @writefunc: callback for writing data to the volume header | ||
92 | + * @opaque: data to pass to @readfunc and @writefunc | ||
93 | + * @options: the new/amended encryption options | ||
94 | + * @force: hint for the driver to allow unsafe operation | ||
95 | + * @errp: error pointer | ||
96 | + * | ||
97 | + * Changes the crypto options of the encryption format | ||
98 | + * | ||
99 | + */ | ||
100 | +int qcrypto_block_amend_options(QCryptoBlock *block, | ||
101 | + QCryptoBlockReadFunc readfunc, | ||
102 | + QCryptoBlockWriteFunc writefunc, | ||
103 | + void *opaque, | ||
104 | + QCryptoBlockAmendOptions *options, | ||
105 | + bool force, | ||
106 | + Error **errp); | ||
107 | + | ||
108 | |||
109 | /** | ||
110 | * qcrypto_block_calculate_payload_offset: | ||
111 | diff --git a/block/crypto.c b/block/crypto.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/block/crypto.c | ||
114 | +++ b/block/crypto.c | ||
115 | @@ -XXX,XX +XXX,XX @@ block_crypto_create_opts_init(QDict *opts, Error **errp) | ||
116 | return ret; | ||
15 | } | 117 | } |
16 | 118 | ||
17 | +_filter_json_filename() | 119 | +QCryptoBlockAmendOptions * |
120 | +block_crypto_amend_opts_init(QDict *opts, Error **errp) | ||
18 | +{ | 121 | +{ |
19 | + $PYTHON -c 'import sys | 122 | + Visitor *v; |
20 | +result, *fnames = sys.stdin.read().split("json:{") | 123 | + QCryptoBlockAmendOptions *ret; |
21 | +depth = 0 | ||
22 | +for fname in fnames: | ||
23 | + depth += 1 # For the opening brace in the split separator | ||
24 | + for chr_i, chr in enumerate(fname): | ||
25 | + if chr == "{": | ||
26 | + depth += 1 | ||
27 | + elif chr == "}": | ||
28 | + depth -= 1 | ||
29 | + if depth == 0: | ||
30 | + break | ||
31 | + | 124 | + |
32 | + # json:{} filenames may be nested; filter out everything from | 125 | + v = qobject_input_visitor_new_flat_confused(opts, errp); |
33 | + # inside the outermost one | 126 | + if (!v) { |
34 | + if depth == 0: | 127 | + return NULL; |
35 | + chr_i += 1 # First character past the filename | 128 | + } |
36 | + result += "json:{ /* filtered */ }" + fname[chr_i:] | ||
37 | + | 129 | + |
38 | +sys.stdout.write(result)' | 130 | + visit_type_QCryptoBlockAmendOptions(v, NULL, &ret, errp); |
131 | + | ||
132 | + visit_free(v); | ||
133 | + return ret; | ||
39 | +} | 134 | +} |
40 | + | 135 | + |
41 | # make sure this script returns success | 136 | |
42 | true | 137 | static int block_crypto_open_generic(QCryptoBlockFormat format, |
138 | QemuOptsList *opts_spec, | ||
139 | diff --git a/crypto/block.c b/crypto/block.c | ||
140 | index XXXXXXX..XXXXXXX 100644 | ||
141 | --- a/crypto/block.c | ||
142 | +++ b/crypto/block.c | ||
143 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_calculate_payload_offset(QCryptoBlockCreateOptions *create_opts, | ||
144 | return crypto != NULL; | ||
145 | } | ||
146 | |||
147 | +int qcrypto_block_amend_options(QCryptoBlock *block, | ||
148 | + QCryptoBlockReadFunc readfunc, | ||
149 | + QCryptoBlockWriteFunc writefunc, | ||
150 | + void *opaque, | ||
151 | + QCryptoBlockAmendOptions *options, | ||
152 | + bool force, | ||
153 | + Error **errp) | ||
154 | +{ | ||
155 | + if (options->format != block->format) { | ||
156 | + error_setg(errp, | ||
157 | + "Cannot amend encryption format"); | ||
158 | + return -1; | ||
159 | + } | ||
160 | + | ||
161 | + if (!block->driver->amend) { | ||
162 | + error_setg(errp, | ||
163 | + "Crypto format %s doesn't support format options amendment", | ||
164 | + QCryptoBlockFormat_str(block->format)); | ||
165 | + return -1; | ||
166 | + } | ||
167 | + | ||
168 | + return block->driver->amend(block, | ||
169 | + readfunc, | ||
170 | + writefunc, | ||
171 | + opaque, | ||
172 | + options, | ||
173 | + force, | ||
174 | + errp); | ||
175 | +} | ||
176 | |||
177 | QCryptoBlockInfo *qcrypto_block_get_info(QCryptoBlock *block, | ||
178 | Error **errp) | ||
43 | -- | 179 | -- |
44 | 2.24.1 | 180 | 2.26.2 |
45 | 181 | ||
46 | 182 | diff view generated by jsdifflib |
1 | Sometimes it is useful to be able to add a node to the block graph that | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | takes or unshare a certain set of permissions for debugging purposes. | ||
3 | This patch adds this capability to blkdebug. | ||
4 | 2 | ||
5 | (Note that you cannot make blkdebug release or share permissions that it | 3 | Next few patches will expose that functionality to the user. |
6 | needs to take or cannot share, because this might result in assertion | ||
7 | failures in the block layer. But if the blkdebug node has no parents, | ||
8 | it will not take any permissions and share everything by default, so you | ||
9 | can then freely choose what permissions to take and share.) | ||
10 | 4 | ||
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 5 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> |
12 | Message-id: 20191108123455.39445-4-mreitz@redhat.com | 6 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> |
13 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 7 | Message-Id: <20200608094030.670121-3-mlevitsk@redhat.com> |
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
15 | --- | 9 | --- |
16 | block/blkdebug.c | 93 +++++++++++++++++++++++++++++++++++++++++++- | 10 | qapi/crypto.json | 59 ++++++- |
17 | qapi/block-core.json | 14 ++++++- | 11 | crypto/block-luks.c | 416 +++++++++++++++++++++++++++++++++++++++++++- |
18 | 2 files changed, 105 insertions(+), 2 deletions(-) | 12 | 2 files changed, 469 insertions(+), 6 deletions(-) |
19 | 13 | ||
20 | diff --git a/block/blkdebug.c b/block/blkdebug.c | 14 | diff --git a/qapi/crypto.json b/qapi/crypto.json |
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/block/blkdebug.c | 16 | --- a/qapi/crypto.json |
23 | +++ b/block/blkdebug.c | 17 | +++ b/qapi/crypto.json |
24 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ |
25 | #include "qemu/cutils.h" | 19 | 'uuid': 'str', |
26 | #include "qemu/config-file.h" | 20 | 'slots': [ 'QCryptoBlockInfoLUKSSlot' ] }} |
27 | #include "block/block_int.h" | 21 | |
28 | +#include "block/qdict.h" | 22 | - |
29 | #include "qemu/module.h" | 23 | ## |
30 | #include "qemu/option.h" | 24 | # @QCryptoBlockInfo: |
31 | +#include "qapi/qapi-visit-block-core.h" | 25 | # |
32 | #include "qapi/qmp/qdict.h" | 26 | @@ -XXX,XX +XXX,XX @@ |
33 | +#include "qapi/qmp/qlist.h" | 27 | 'discriminator': 'format', |
34 | #include "qapi/qmp/qstring.h" | 28 | 'data': { 'luks': 'QCryptoBlockInfoLUKS' } } |
35 | +#include "qapi/qobject-input-visitor.h" | 29 | |
36 | #include "sysemu/qtest.h" | 30 | +## |
37 | 31 | +# @QCryptoBlockLUKSKeyslotState: | |
38 | typedef struct BDRVBlkdebugState { | 32 | +# |
39 | @@ -XXX,XX +XXX,XX @@ typedef struct BDRVBlkdebugState { | 33 | +# Defines state of keyslots that are affected by the update |
40 | uint64_t opt_discard; | 34 | +# |
41 | uint64_t max_discard; | 35 | +# @active: The slots contain the given password and marked as active |
42 | 36 | +# @inactive: The slots are erased (contain garbage) and marked as inactive | |
43 | + uint64_t take_child_perms; | 37 | +# |
44 | + uint64_t unshare_child_perms; | 38 | +# Since: 5.1 |
45 | + | 39 | +## |
46 | /* For blkdebug_refresh_filename() */ | 40 | +{ 'enum': 'QCryptoBlockLUKSKeyslotState', |
47 | char *config_file; | 41 | + 'data': [ 'active', 'inactive' ] } |
48 | 42 | + | |
49 | @@ -XXX,XX +XXX,XX @@ static void blkdebug_parse_filename(const char *filename, QDict *options, | 43 | |
50 | qdict_put_str(options, "x-image", filename); | 44 | +## |
45 | +# @QCryptoBlockAmendOptionsLUKS: | ||
46 | +# | ||
47 | +# This struct defines the update parameters that activate/de-activate set | ||
48 | +# of keyslots | ||
49 | +# | ||
50 | +# @state: the desired state of the keyslots | ||
51 | +# | ||
52 | +# @new-secret: The ID of a QCryptoSecret object providing the password to be | ||
53 | +# written into added active keyslots | ||
54 | +# | ||
55 | +# @old-secret: Optional (for deactivation only) | ||
56 | +# If given will deactive all keyslots that | ||
57 | +# match password located in QCryptoSecret with this ID | ||
58 | +# | ||
59 | +# @iter-time: Optional (for activation only) | ||
60 | +# Number of milliseconds to spend in | ||
61 | +# PBKDF passphrase processing for the newly activated keyslot. | ||
62 | +# Currently defaults to 2000. | ||
63 | +# | ||
64 | +# @keyslot: Optional. ID of the keyslot to activate/deactivate. | ||
65 | +# For keyslot activation, keyslot should not be active already | ||
66 | +# (this is unsafe to update an active keyslot), | ||
67 | +# but possible if 'force' parameter is given. | ||
68 | +# If keyslot is not given, first free keyslot will be written. | ||
69 | +# | ||
70 | +# For keyslot deactivation, this parameter specifies the exact | ||
71 | +# keyslot to deactivate | ||
72 | +# | ||
73 | +# @secret: Optional. The ID of a QCryptoSecret object providing the | ||
74 | +# password to use to retrive current master key. | ||
75 | +# Defaults to the same secret that was used to open the image | ||
76 | +# | ||
77 | +# | ||
78 | +# Since 5.1 | ||
79 | +## | ||
80 | +{ 'struct': 'QCryptoBlockAmendOptionsLUKS', | ||
81 | + 'data': { 'state': 'QCryptoBlockLUKSKeyslotState', | ||
82 | + '*new-secret': 'str', | ||
83 | + '*old-secret': 'str', | ||
84 | + '*keyslot': 'int', | ||
85 | + '*iter-time': 'int', | ||
86 | + '*secret': 'str' } } | ||
87 | |||
88 | ## | ||
89 | # @QCryptoBlockAmendOptions: | ||
90 | @@ -XXX,XX +XXX,XX @@ | ||
91 | 'base': 'QCryptoBlockOptionsBase', | ||
92 | 'discriminator': 'format', | ||
93 | 'data': { | ||
94 | - } } | ||
95 | + 'luks': 'QCryptoBlockAmendOptionsLUKS' } } | ||
96 | diff --git a/crypto/block-luks.c b/crypto/block-luks.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/crypto/block-luks.c | ||
99 | +++ b/crypto/block-luks.c | ||
100 | @@ -XXX,XX +XXX,XX @@ | ||
101 | #include "qemu/uuid.h" | ||
102 | |||
103 | #include "qemu/coroutine.h" | ||
104 | +#include "qemu/bitmap.h" | ||
105 | |||
106 | /* | ||
107 | * Reference for the LUKS format implemented here is | ||
108 | @@ -XXX,XX +XXX,XX @@ typedef struct QCryptoBlockLUKSKeySlot QCryptoBlockLUKSKeySlot; | ||
109 | |||
110 | #define QCRYPTO_BLOCK_LUKS_SECTOR_SIZE 512LL | ||
111 | |||
112 | +#define QCRYPTO_BLOCK_LUKS_DEFAULT_ITER_TIME_MS 2000 | ||
113 | +#define QCRYPTO_BLOCK_LUKS_ERASE_ITERATIONS 40 | ||
114 | + | ||
115 | static const char qcrypto_block_luks_magic[QCRYPTO_BLOCK_LUKS_MAGIC_LEN] = { | ||
116 | 'L', 'U', 'K', 'S', 0xBA, 0xBE | ||
117 | }; | ||
118 | @@ -XXX,XX +XXX,XX @@ struct QCryptoBlockLUKS { | ||
119 | |||
120 | /* Hash algorithm used in pbkdf2 function */ | ||
121 | QCryptoHashAlgorithm hash_alg; | ||
122 | + | ||
123 | + /* Name of the secret that was used to open the image */ | ||
124 | + char *secret; | ||
125 | }; | ||
126 | |||
127 | |||
128 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_luks_store_key(QCryptoBlock *block, | ||
129 | Error **errp) | ||
130 | { | ||
131 | QCryptoBlockLUKS *luks = block->opaque; | ||
132 | - QCryptoBlockLUKSKeySlot *slot = &luks->header.key_slots[slot_idx]; | ||
133 | + QCryptoBlockLUKSKeySlot *slot; | ||
134 | g_autofree uint8_t *splitkey = NULL; | ||
135 | size_t splitkeylen; | ||
136 | g_autofree uint8_t *slotkey = NULL; | ||
137 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_luks_store_key(QCryptoBlock *block, | ||
138 | uint64_t iters; | ||
139 | int ret = -1; | ||
140 | |||
141 | + assert(slot_idx < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS); | ||
142 | + slot = &luks->header.key_slots[slot_idx]; | ||
143 | if (qcrypto_random_bytes(slot->salt, | ||
144 | QCRYPTO_BLOCK_LUKS_SALT_LEN, | ||
145 | errp) < 0) { | ||
146 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_luks_load_key(QCryptoBlock *block, | ||
147 | Error **errp) | ||
148 | { | ||
149 | QCryptoBlockLUKS *luks = block->opaque; | ||
150 | - const QCryptoBlockLUKSKeySlot *slot = &luks->header.key_slots[slot_idx]; | ||
151 | + const QCryptoBlockLUKSKeySlot *slot; | ||
152 | g_autofree uint8_t *splitkey = NULL; | ||
153 | size_t splitkeylen; | ||
154 | g_autofree uint8_t *possiblekey = NULL; | ||
155 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_luks_load_key(QCryptoBlock *block, | ||
156 | g_autoptr(QCryptoIVGen) ivgen = NULL; | ||
157 | size_t niv; | ||
158 | |||
159 | + assert(slot_idx < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS); | ||
160 | + slot = &luks->header.key_slots[slot_idx]; | ||
161 | if (slot->active != QCRYPTO_BLOCK_LUKS_KEY_SLOT_ENABLED) { | ||
162 | return 0; | ||
163 | } | ||
164 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_luks_find_key(QCryptoBlock *block, | ||
165 | return -1; | ||
51 | } | 166 | } |
52 | 167 | ||
53 | +static int blkdebug_parse_perm_list(uint64_t *dest, QDict *options, | 168 | +/* |
54 | + const char *prefix, Error **errp) | 169 | + * Returns true if a slot i is marked as active |
170 | + * (contains encrypted copy of the master key) | ||
171 | + */ | ||
172 | +static bool | ||
173 | +qcrypto_block_luks_slot_active(const QCryptoBlockLUKS *luks, | ||
174 | + unsigned int slot_idx) | ||
55 | +{ | 175 | +{ |
56 | + int ret = 0; | 176 | + uint32_t val; |
57 | + QDict *subqdict = NULL; | 177 | + |
58 | + QObject *crumpled_subqdict = NULL; | 178 | + assert(slot_idx < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS); |
59 | + Visitor *v = NULL; | 179 | + val = luks->header.key_slots[slot_idx].active; |
60 | + BlockPermissionList *perm_list = NULL, *element; | 180 | + return val == QCRYPTO_BLOCK_LUKS_KEY_SLOT_ENABLED; |
61 | + Error *local_err = NULL; | 181 | +} |
62 | + | 182 | + |
63 | + *dest = 0; | 183 | +/* |
64 | + | 184 | + * Returns the number of slots that are marked as active |
65 | + qdict_extract_subqdict(options, &subqdict, prefix); | 185 | + * (slots that contain encrypted copy of the master key) |
66 | + if (!qdict_size(subqdict)) { | 186 | + */ |
67 | + goto out; | 187 | +static unsigned int |
68 | + } | 188 | +qcrypto_block_luks_count_active_slots(const QCryptoBlockLUKS *luks) |
69 | + | 189 | +{ |
70 | + crumpled_subqdict = qdict_crumple(subqdict, errp); | 190 | + size_t i = 0; |
71 | + if (!crumpled_subqdict) { | 191 | + unsigned int ret = 0; |
72 | + ret = -EINVAL; | 192 | + |
73 | + goto out; | 193 | + for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) { |
74 | + } | 194 | + if (qcrypto_block_luks_slot_active(luks, i)) { |
75 | + | 195 | + ret++; |
76 | + v = qobject_input_visitor_new(crumpled_subqdict); | 196 | + } |
77 | + visit_type_BlockPermissionList(v, NULL, &perm_list, &local_err); | 197 | + } |
78 | + if (local_err) { | ||
79 | + error_propagate(errp, local_err); | ||
80 | + ret = -EINVAL; | ||
81 | + goto out; | ||
82 | + } | ||
83 | + | ||
84 | + for (element = perm_list; element; element = element->next) { | ||
85 | + *dest |= bdrv_qapi_perm_to_blk_perm(element->value); | ||
86 | + } | ||
87 | + | ||
88 | +out: | ||
89 | + qapi_free_BlockPermissionList(perm_list); | ||
90 | + visit_free(v); | ||
91 | + qobject_unref(subqdict); | ||
92 | + qobject_unref(crumpled_subqdict); | ||
93 | + return ret; | 198 | + return ret; |
94 | +} | 199 | +} |
95 | + | 200 | + |
96 | +static int blkdebug_parse_perms(BDRVBlkdebugState *s, QDict *options, | 201 | +/* |
97 | + Error **errp) | 202 | + * Finds first key slot which is not active |
203 | + * Returns the key slot index, or -1 if it doesn't exist | ||
204 | + */ | ||
205 | +static int | ||
206 | +qcrypto_block_luks_find_free_keyslot(const QCryptoBlockLUKS *luks) | ||
98 | +{ | 207 | +{ |
208 | + size_t i; | ||
209 | + | ||
210 | + for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) { | ||
211 | + if (!qcrypto_block_luks_slot_active(luks, i)) { | ||
212 | + return i; | ||
213 | + } | ||
214 | + } | ||
215 | + return -1; | ||
216 | +} | ||
217 | + | ||
218 | +/* | ||
219 | + * Erases an keyslot given its index | ||
220 | + * Returns: | ||
221 | + * 0 if the keyslot was erased successfully | ||
222 | + * -1 if a error occurred while erasing the keyslot | ||
223 | + * | ||
224 | + */ | ||
225 | +static int | ||
226 | +qcrypto_block_luks_erase_key(QCryptoBlock *block, | ||
227 | + unsigned int slot_idx, | ||
228 | + QCryptoBlockWriteFunc writefunc, | ||
229 | + void *opaque, | ||
230 | + Error **errp) | ||
231 | +{ | ||
232 | + QCryptoBlockLUKS *luks = block->opaque; | ||
233 | + QCryptoBlockLUKSKeySlot *slot; | ||
234 | + g_autofree uint8_t *garbagesplitkey = NULL; | ||
235 | + size_t splitkeylen; | ||
236 | + size_t i; | ||
237 | + Error *local_err = NULL; | ||
99 | + int ret; | 238 | + int ret; |
100 | + | 239 | + |
101 | + ret = blkdebug_parse_perm_list(&s->take_child_perms, options, | 240 | + assert(slot_idx < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS); |
102 | + "take-child-perms.", errp); | 241 | + slot = &luks->header.key_slots[slot_idx]; |
242 | + | ||
243 | + splitkeylen = luks->header.master_key_len * slot->stripes; | ||
244 | + assert(splitkeylen > 0); | ||
245 | + | ||
246 | + garbagesplitkey = g_new0(uint8_t, splitkeylen); | ||
247 | + | ||
248 | + /* Reset the key slot header */ | ||
249 | + memset(slot->salt, 0, QCRYPTO_BLOCK_LUKS_SALT_LEN); | ||
250 | + slot->iterations = 0; | ||
251 | + slot->active = QCRYPTO_BLOCK_LUKS_KEY_SLOT_DISABLED; | ||
252 | + | ||
253 | + ret = qcrypto_block_luks_store_header(block, writefunc, | ||
254 | + opaque, &local_err); | ||
255 | + | ||
103 | + if (ret < 0) { | 256 | + if (ret < 0) { |
104 | + return ret; | 257 | + error_propagate(errp, local_err); |
105 | + } | 258 | + } |
106 | + | 259 | + /* |
107 | + ret = blkdebug_parse_perm_list(&s->unshare_child_perms, options, | 260 | + * Now try to erase the key material, even if the header |
108 | + "unshare-child-perms.", errp); | 261 | + * update failed |
109 | + if (ret < 0) { | 262 | + */ |
110 | + return ret; | 263 | + for (i = 0; i < QCRYPTO_BLOCK_LUKS_ERASE_ITERATIONS; i++) { |
111 | + } | 264 | + if (qcrypto_random_bytes(garbagesplitkey, |
112 | + | 265 | + splitkeylen, &local_err) < 0) { |
266 | + /* | ||
267 | + * If we failed to get the random data, still write | ||
268 | + * at least zeros to the key slot at least once | ||
269 | + */ | ||
270 | + error_propagate(errp, local_err); | ||
271 | + | ||
272 | + if (i > 0) { | ||
273 | + return -1; | ||
274 | + } | ||
275 | + } | ||
276 | + if (writefunc(block, | ||
277 | + slot->key_offset_sector * QCRYPTO_BLOCK_LUKS_SECTOR_SIZE, | ||
278 | + garbagesplitkey, | ||
279 | + splitkeylen, | ||
280 | + opaque, | ||
281 | + &local_err) != splitkeylen) { | ||
282 | + error_propagate(errp, local_err); | ||
283 | + return -1; | ||
284 | + } | ||
285 | + } | ||
286 | + return ret; | ||
287 | +} | ||
288 | |||
289 | static int | ||
290 | qcrypto_block_luks_open(QCryptoBlock *block, | ||
291 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_luks_open(QCryptoBlock *block, | ||
292 | |||
293 | luks = g_new0(QCryptoBlockLUKS, 1); | ||
294 | block->opaque = luks; | ||
295 | + luks->secret = g_strdup(options->u.luks.key_secret); | ||
296 | |||
297 | if (qcrypto_block_luks_load_header(block, readfunc, opaque, errp) < 0) { | ||
298 | goto fail; | ||
299 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_luks_open(QCryptoBlock *block, | ||
300 | fail: | ||
301 | qcrypto_block_free_cipher(block); | ||
302 | qcrypto_ivgen_free(block->ivgen); | ||
303 | + g_free(luks->secret); | ||
304 | g_free(luks); | ||
305 | return -1; | ||
306 | } | ||
307 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_luks_create(QCryptoBlock *block, | ||
308 | |||
309 | memcpy(&luks_opts, &options->u.luks, sizeof(luks_opts)); | ||
310 | if (!luks_opts.has_iter_time) { | ||
311 | - luks_opts.iter_time = 2000; | ||
312 | + luks_opts.iter_time = QCRYPTO_BLOCK_LUKS_DEFAULT_ITER_TIME_MS; | ||
313 | } | ||
314 | if (!luks_opts.has_cipher_alg) { | ||
315 | luks_opts.cipher_alg = QCRYPTO_CIPHER_ALG_AES_256; | ||
316 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_luks_create(QCryptoBlock *block, | ||
317 | optprefix ? optprefix : ""); | ||
318 | goto error; | ||
319 | } | ||
320 | + luks->secret = g_strdup(options->u.luks.key_secret); | ||
321 | + | ||
322 | password = qcrypto_secret_lookup_as_utf8(luks_opts.key_secret, errp); | ||
323 | if (!password) { | ||
324 | goto error; | ||
325 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_luks_create(QCryptoBlock *block, | ||
326 | qcrypto_block_free_cipher(block); | ||
327 | qcrypto_ivgen_free(block->ivgen); | ||
328 | |||
329 | + g_free(luks->secret); | ||
330 | g_free(luks); | ||
331 | return -1; | ||
332 | } | ||
333 | |||
334 | +static int | ||
335 | +qcrypto_block_luks_amend_add_keyslot(QCryptoBlock *block, | ||
336 | + QCryptoBlockReadFunc readfunc, | ||
337 | + QCryptoBlockWriteFunc writefunc, | ||
338 | + void *opaque, | ||
339 | + QCryptoBlockAmendOptionsLUKS *opts_luks, | ||
340 | + bool force, | ||
341 | + Error **errp) | ||
342 | +{ | ||
343 | + QCryptoBlockLUKS *luks = block->opaque; | ||
344 | + uint64_t iter_time = opts_luks->has_iter_time ? | ||
345 | + opts_luks->iter_time : | ||
346 | + QCRYPTO_BLOCK_LUKS_DEFAULT_ITER_TIME_MS; | ||
347 | + int keyslot; | ||
348 | + g_autofree char *old_password = NULL; | ||
349 | + g_autofree char *new_password = NULL; | ||
350 | + g_autofree uint8_t *master_key = NULL; | ||
351 | + | ||
352 | + char *secret = opts_luks->has_secret ? opts_luks->secret : luks->secret; | ||
353 | + | ||
354 | + if (!opts_luks->has_new_secret) { | ||
355 | + error_setg(errp, "'new-secret' is required to activate a keyslot"); | ||
356 | + return -1; | ||
357 | + } | ||
358 | + if (opts_luks->has_old_secret) { | ||
359 | + error_setg(errp, | ||
360 | + "'old-secret' must not be given when activating keyslots"); | ||
361 | + return -1; | ||
362 | + } | ||
363 | + | ||
364 | + if (opts_luks->has_keyslot) { | ||
365 | + keyslot = opts_luks->keyslot; | ||
366 | + if (keyslot < 0 || keyslot >= QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS) { | ||
367 | + error_setg(errp, | ||
368 | + "Invalid keyslot %u specified, must be between 0 and %u", | ||
369 | + keyslot, QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS - 1); | ||
370 | + return -1; | ||
371 | + } | ||
372 | + } else { | ||
373 | + keyslot = qcrypto_block_luks_find_free_keyslot(luks); | ||
374 | + if (keyslot == -1) { | ||
375 | + error_setg(errp, | ||
376 | + "Can't add a keyslot - all keyslots are in use"); | ||
377 | + return -1; | ||
378 | + } | ||
379 | + } | ||
380 | + | ||
381 | + if (!force && qcrypto_block_luks_slot_active(luks, keyslot)) { | ||
382 | + error_setg(errp, | ||
383 | + "Refusing to overwrite active keyslot %i - " | ||
384 | + "please erase it first", | ||
385 | + keyslot); | ||
386 | + return -1; | ||
387 | + } | ||
388 | + | ||
389 | + /* Locate the password that will be used to retrieve the master key */ | ||
390 | + old_password = qcrypto_secret_lookup_as_utf8(secret, errp); | ||
391 | + if (!old_password) { | ||
392 | + return -1; | ||
393 | + } | ||
394 | + | ||
395 | + /* Retrieve the master key */ | ||
396 | + master_key = g_new0(uint8_t, luks->header.master_key_len); | ||
397 | + | ||
398 | + if (qcrypto_block_luks_find_key(block, old_password, master_key, | ||
399 | + readfunc, opaque, errp) < 0) { | ||
400 | + error_append_hint(errp, "Failed to retrieve the master key"); | ||
401 | + return -1; | ||
402 | + } | ||
403 | + | ||
404 | + /* Locate the new password*/ | ||
405 | + new_password = qcrypto_secret_lookup_as_utf8(opts_luks->new_secret, errp); | ||
406 | + if (!new_password) { | ||
407 | + return -1; | ||
408 | + } | ||
409 | + | ||
410 | + /* Now set the new keyslots */ | ||
411 | + if (qcrypto_block_luks_store_key(block, keyslot, new_password, master_key, | ||
412 | + iter_time, writefunc, opaque, errp)) { | ||
413 | + error_append_hint(errp, "Failed to write to keyslot %i", keyslot); | ||
414 | + return -1; | ||
415 | + } | ||
113 | + return 0; | 416 | + return 0; |
114 | +} | 417 | +} |
115 | + | 418 | + |
116 | static QemuOptsList runtime_opts = { | 419 | +static int |
117 | .name = "blkdebug", | 420 | +qcrypto_block_luks_amend_erase_keyslots(QCryptoBlock *block, |
118 | .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), | 421 | + QCryptoBlockReadFunc readfunc, |
119 | @@ -XXX,XX +XXX,XX @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, | 422 | + QCryptoBlockWriteFunc writefunc, |
120 | /* Set initial state */ | 423 | + void *opaque, |
121 | s->state = 1; | 424 | + QCryptoBlockAmendOptionsLUKS *opts_luks, |
122 | 425 | + bool force, | |
123 | + /* Parse permissions modifiers before opening the image file */ | 426 | + Error **errp) |
124 | + ret = blkdebug_parse_perms(s, options, errp); | 427 | +{ |
125 | + if (ret < 0) { | 428 | + QCryptoBlockLUKS *luks = block->opaque; |
126 | + goto out; | 429 | + g_autofree uint8_t *tmpkey = NULL; |
127 | + } | 430 | + g_autofree char *old_password = NULL; |
128 | + | 431 | + |
129 | /* Open the image file */ | 432 | + if (opts_luks->has_new_secret) { |
130 | bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image", | 433 | + error_setg(errp, |
131 | bs, &child_file, false, &local_err); | 434 | + "'new-secret' must not be given when erasing keyslots"); |
132 | @@ -XXX,XX +XXX,XX @@ static int blkdebug_reopen_prepare(BDRVReopenState *reopen_state, | 435 | + return -1; |
133 | return 0; | 436 | + } |
437 | + if (opts_luks->has_iter_time) { | ||
438 | + error_setg(errp, | ||
439 | + "'iter-time' must not be given when erasing keyslots"); | ||
440 | + return -1; | ||
441 | + } | ||
442 | + if (opts_luks->has_secret) { | ||
443 | + error_setg(errp, | ||
444 | + "'secret' must not be given when erasing keyslots"); | ||
445 | + return -1; | ||
446 | + } | ||
447 | + | ||
448 | + /* Load the old password if given */ | ||
449 | + if (opts_luks->has_old_secret) { | ||
450 | + old_password = qcrypto_secret_lookup_as_utf8(opts_luks->old_secret, | ||
451 | + errp); | ||
452 | + if (!old_password) { | ||
453 | + return -1; | ||
454 | + } | ||
455 | + | ||
456 | + /* | ||
457 | + * Allocate a temporary key buffer that we will need when | ||
458 | + * checking if slot matches the given old password | ||
459 | + */ | ||
460 | + tmpkey = g_new0(uint8_t, luks->header.master_key_len); | ||
461 | + } | ||
462 | + | ||
463 | + /* Erase an explicitly given keyslot */ | ||
464 | + if (opts_luks->has_keyslot) { | ||
465 | + int keyslot = opts_luks->keyslot; | ||
466 | + | ||
467 | + if (keyslot < 0 || keyslot >= QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS) { | ||
468 | + error_setg(errp, | ||
469 | + "Invalid keyslot %i specified, must be between 0 and %i", | ||
470 | + keyslot, QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS - 1); | ||
471 | + return -1; | ||
472 | + } | ||
473 | + | ||
474 | + if (opts_luks->has_old_secret) { | ||
475 | + int rv = qcrypto_block_luks_load_key(block, | ||
476 | + keyslot, | ||
477 | + old_password, | ||
478 | + tmpkey, | ||
479 | + readfunc, | ||
480 | + opaque, | ||
481 | + errp); | ||
482 | + if (rv == -1) { | ||
483 | + return -1; | ||
484 | + } else if (rv == 0) { | ||
485 | + error_setg(errp, | ||
486 | + "Given keyslot %i doesn't contain the given " | ||
487 | + "old password for erase operation", | ||
488 | + keyslot); | ||
489 | + return -1; | ||
490 | + } | ||
491 | + } | ||
492 | + | ||
493 | + if (!force && !qcrypto_block_luks_slot_active(luks, keyslot)) { | ||
494 | + error_setg(errp, | ||
495 | + "Given keyslot %i is already erased (inactive) ", | ||
496 | + keyslot); | ||
497 | + return -1; | ||
498 | + } | ||
499 | + | ||
500 | + if (!force && qcrypto_block_luks_count_active_slots(luks) == 1) { | ||
501 | + error_setg(errp, | ||
502 | + "Attempt to erase the only active keyslot %i " | ||
503 | + "which will erase all the data in the image " | ||
504 | + "irreversibly - refusing operation", | ||
505 | + keyslot); | ||
506 | + return -1; | ||
507 | + } | ||
508 | + | ||
509 | + if (qcrypto_block_luks_erase_key(block, keyslot, | ||
510 | + writefunc, opaque, errp)) { | ||
511 | + error_append_hint(errp, "Failed to erase keyslot %i", keyslot); | ||
512 | + return -1; | ||
513 | + } | ||
514 | + | ||
515 | + /* Erase all keyslots that match the given old password */ | ||
516 | + } else if (opts_luks->has_old_secret) { | ||
517 | + | ||
518 | + unsigned long slots_to_erase_bitmap = 0; | ||
519 | + size_t i; | ||
520 | + int slot_count; | ||
521 | + | ||
522 | + assert(QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS <= | ||
523 | + sizeof(slots_to_erase_bitmap) * 8); | ||
524 | + | ||
525 | + for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) { | ||
526 | + int rv = qcrypto_block_luks_load_key(block, | ||
527 | + i, | ||
528 | + old_password, | ||
529 | + tmpkey, | ||
530 | + readfunc, | ||
531 | + opaque, | ||
532 | + errp); | ||
533 | + if (rv == -1) { | ||
534 | + return -1; | ||
535 | + } else if (rv == 1) { | ||
536 | + bitmap_set(&slots_to_erase_bitmap, i, 1); | ||
537 | + } | ||
538 | + } | ||
539 | + | ||
540 | + slot_count = bitmap_count_one(&slots_to_erase_bitmap, | ||
541 | + QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS); | ||
542 | + if (slot_count == 0) { | ||
543 | + error_setg(errp, | ||
544 | + "No keyslots match given (old) password for erase operation"); | ||
545 | + return -1; | ||
546 | + } | ||
547 | + | ||
548 | + if (!force && | ||
549 | + slot_count == qcrypto_block_luks_count_active_slots(luks)) { | ||
550 | + error_setg(errp, | ||
551 | + "All the active keyslots match the (old) password that " | ||
552 | + "was given and erasing them will erase all the data in " | ||
553 | + "the image irreversibly - refusing operation"); | ||
554 | + return -1; | ||
555 | + } | ||
556 | + | ||
557 | + /* Now apply the update */ | ||
558 | + for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) { | ||
559 | + if (!test_bit(i, &slots_to_erase_bitmap)) { | ||
560 | + continue; | ||
561 | + } | ||
562 | + if (qcrypto_block_luks_erase_key(block, i, writefunc, | ||
563 | + opaque, errp)) { | ||
564 | + error_append_hint(errp, "Failed to erase keyslot %zu", i); | ||
565 | + return -1; | ||
566 | + } | ||
567 | + } | ||
568 | + } else { | ||
569 | + error_setg(errp, | ||
570 | + "To erase keyslot(s), either explicit keyslot index " | ||
571 | + "or the password currently contained in them must be given"); | ||
572 | + return -1; | ||
573 | + } | ||
574 | + return 0; | ||
575 | +} | ||
576 | + | ||
577 | +static int | ||
578 | +qcrypto_block_luks_amend_options(QCryptoBlock *block, | ||
579 | + QCryptoBlockReadFunc readfunc, | ||
580 | + QCryptoBlockWriteFunc writefunc, | ||
581 | + void *opaque, | ||
582 | + QCryptoBlockAmendOptions *options, | ||
583 | + bool force, | ||
584 | + Error **errp) | ||
585 | +{ | ||
586 | + QCryptoBlockAmendOptionsLUKS *opts_luks = &options->u.luks; | ||
587 | + | ||
588 | + switch (opts_luks->state) { | ||
589 | + case Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE_ACTIVE: | ||
590 | + return qcrypto_block_luks_amend_add_keyslot(block, readfunc, | ||
591 | + writefunc, opaque, | ||
592 | + opts_luks, force, errp); | ||
593 | + case Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE_INACTIVE: | ||
594 | + return qcrypto_block_luks_amend_erase_keyslots(block, readfunc, | ||
595 | + writefunc, opaque, | ||
596 | + opts_luks, force, errp); | ||
597 | + default: | ||
598 | + g_assert_not_reached(); | ||
599 | + } | ||
600 | +} | ||
601 | |||
602 | static int qcrypto_block_luks_get_info(QCryptoBlock *block, | ||
603 | QCryptoBlockInfo *info, | ||
604 | @@ -XXX,XX +XXX,XX @@ static int qcrypto_block_luks_get_info(QCryptoBlock *block, | ||
605 | |||
606 | static void qcrypto_block_luks_cleanup(QCryptoBlock *block) | ||
607 | { | ||
608 | - g_free(block->opaque); | ||
609 | + QCryptoBlockLUKS *luks = block->opaque; | ||
610 | + if (luks) { | ||
611 | + g_free(luks->secret); | ||
612 | + g_free(luks); | ||
613 | + } | ||
134 | } | 614 | } |
135 | 615 | ||
136 | +static void blkdebug_child_perm(BlockDriverState *bs, BdrvChild *c, | 616 | |
137 | + const BdrvChildRole *role, | 617 | @@ -XXX,XX +XXX,XX @@ qcrypto_block_luks_encrypt(QCryptoBlock *block, |
138 | + BlockReopenQueue *reopen_queue, | 618 | const QCryptoBlockDriver qcrypto_block_driver_luks = { |
139 | + uint64_t perm, uint64_t shared, | 619 | .open = qcrypto_block_luks_open, |
140 | + uint64_t *nperm, uint64_t *nshared) | 620 | .create = qcrypto_block_luks_create, |
141 | +{ | 621 | + .amend = qcrypto_block_luks_amend_options, |
142 | + BDRVBlkdebugState *s = bs->opaque; | 622 | .get_info = qcrypto_block_luks_get_info, |
143 | + | 623 | .cleanup = qcrypto_block_luks_cleanup, |
144 | + bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared, | 624 | .decrypt = qcrypto_block_luks_decrypt, |
145 | + nperm, nshared); | ||
146 | + | ||
147 | + *nperm |= s->take_child_perms; | ||
148 | + *nshared &= ~s->unshare_child_perms; | ||
149 | +} | ||
150 | + | ||
151 | static const char *const blkdebug_strong_runtime_opts[] = { | ||
152 | "config", | ||
153 | "inject-error.", | ||
154 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_blkdebug = { | ||
155 | .bdrv_file_open = blkdebug_open, | ||
156 | .bdrv_close = blkdebug_close, | ||
157 | .bdrv_reopen_prepare = blkdebug_reopen_prepare, | ||
158 | - .bdrv_child_perm = bdrv_filter_default_perms, | ||
159 | + .bdrv_child_perm = blkdebug_child_perm, | ||
160 | |||
161 | .bdrv_getlength = blkdebug_getlength, | ||
162 | .bdrv_refresh_filename = blkdebug_refresh_filename, | ||
163 | diff --git a/qapi/block-core.json b/qapi/block-core.json | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/qapi/block-core.json | ||
166 | +++ b/qapi/block-core.json | ||
167 | @@ -XXX,XX +XXX,XX @@ | ||
168 | # | ||
169 | # @set-state: array of state-change descriptions | ||
170 | # | ||
171 | +# @take-child-perms: Permissions to take on @image in addition to what | ||
172 | +# is necessary anyway (which depends on how the | ||
173 | +# blkdebug node is used). Defaults to none. | ||
174 | +# (since 5.0) | ||
175 | +# | ||
176 | +# @unshare-child-perms: Permissions not to share on @image in addition | ||
177 | +# to what cannot be shared anyway (which depends | ||
178 | +# on how the blkdebug node is used). Defaults | ||
179 | +# to none. (since 5.0) | ||
180 | +# | ||
181 | # Since: 2.9 | ||
182 | ## | ||
183 | { 'struct': 'BlockdevOptionsBlkdebug', | ||
184 | @@ -XXX,XX +XXX,XX @@ | ||
185 | '*opt-write-zero': 'int32', '*max-write-zero': 'int32', | ||
186 | '*opt-discard': 'int32', '*max-discard': 'int32', | ||
187 | '*inject-error': ['BlkdebugInjectErrorOptions'], | ||
188 | - '*set-state': ['BlkdebugSetStateOptions'] } } | ||
189 | + '*set-state': ['BlkdebugSetStateOptions'], | ||
190 | + '*take-child-perms': ['BlockPermission'], | ||
191 | + '*unshare-child-perms': ['BlockPermission'] } } | ||
192 | |||
193 | ## | ||
194 | # @BlockdevOptionsBlklogwrites: | ||
195 | -- | 625 | -- |
196 | 2.24.1 | 626 | 2.26.2 |
197 | 627 | ||
198 | 628 | diff view generated by jsdifflib |
1 | We need some way to correlate QAPI BlockPermission values with | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | BLK_PERM_* flags. We could: | ||
3 | 2 | ||
4 | (1) have the same order in the QAPI definition as the the BLK_PERM_* | 3 | 'force' option will be used for some unsafe amend operations. |
5 | flags are in LSb-first order. However, then there is no guarantee | ||
6 | that they actually match (e.g. when someone modifies the QAPI schema | ||
7 | without thinking of the BLK_PERM_* definitions). | ||
8 | We could add static assertions, but these would break what’s good | ||
9 | about this solution, namely its simplicity. | ||
10 | 4 | ||
11 | (2) define the BLK_PERM_* flags based on the BlockPermission values. | 5 | This includes things like erasing last keyslot in luks based formats |
12 | But this way whenever someone were to modify the QAPI order | 6 | (which destroys the data, unless the master key is backed up |
13 | (perfectly sensible in theory), the BLK_PERM_* values would change. | 7 | by external means), but that _might_ be desired result. |
14 | Because these values are used for file locking, this might break | ||
15 | file locking between different qemu versions. | ||
16 | 8 | ||
17 | Therefore, go the slightly more cumbersome way: Add a function to | 9 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> |
18 | translate from the QAPI constants to the BLK_PERM_* flags. | 10 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> |
19 | 11 | Reviewed-by: Max Reitz <mreitz@redhat.com> | |
20 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 12 | Message-Id: <20200608094030.670121-4-mlevitsk@redhat.com> |
21 | Message-id: 20191108123455.39445-2-mreitz@redhat.com | ||
22 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
23 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 13 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
24 | --- | 14 | --- |
25 | block.c | 18 ++++++++++++++++++ | 15 | docs/tools/qemu-img.rst | 5 ++++- |
26 | include/block/block.h | 1 + | 16 | include/block/block.h | 1 + |
27 | 2 files changed, 19 insertions(+) | 17 | include/block/block_int.h | 1 + |
18 | block.c | 4 +++- | ||
19 | block/qcow2.c | 1 + | ||
20 | qemu-img.c | 8 +++++++- | ||
21 | qemu-img-cmds.hx | 4 ++-- | ||
22 | 7 files changed, 19 insertions(+), 5 deletions(-) | ||
28 | 23 | ||
24 | diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/docs/tools/qemu-img.rst | ||
27 | +++ b/docs/tools/qemu-img.rst | ||
28 | @@ -XXX,XX +XXX,XX @@ Command description: | ||
29 | |||
30 | .. program:: qemu-img-commands | ||
31 | |||
32 | -.. option:: amend [--object OBJECTDEF] [--image-opts] [-p] [-q] [-f FMT] [-t CACHE] -o OPTIONS FILENAME | ||
33 | +.. option:: amend [--object OBJECTDEF] [--image-opts] [-p] [-q] [-f FMT] [-t CACHE] [--force] -o OPTIONS FILENAME | ||
34 | |||
35 | Amends the image format specific *OPTIONS* for the image file | ||
36 | *FILENAME*. Not all file formats support this operation. | ||
37 | |||
38 | + --force allows some unsafe operations. Currently for -f luks, it allows to | ||
39 | + erase the last encryption key, and to overwrite an active encryption key. | ||
40 | + | ||
41 | .. option:: bench [-c COUNT] [-d DEPTH] [-f FMT] [--flush-interval=FLUSH_INTERVAL] [-i AIO] [-n] [--no-drain] [-o OFFSET] [--pattern=PATTERN] [-q] [-s BUFFER_SIZE] [-S STEP_SIZE] [-t CACHE] [-w] [-U] FILENAME | ||
42 | |||
43 | Run a simple sequential I/O benchmark on the specified image. If ``-w`` is | ||
44 | diff --git a/include/block/block.h b/include/block/block.h | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/include/block/block.h | ||
47 | +++ b/include/block/block.h | ||
48 | @@ -XXX,XX +XXX,XX @@ typedef void BlockDriverAmendStatusCB(BlockDriverState *bs, int64_t offset, | ||
49 | int64_t total_work_size, void *opaque); | ||
50 | int bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts, | ||
51 | BlockDriverAmendStatusCB *status_cb, void *cb_opaque, | ||
52 | + bool force, | ||
53 | Error **errp); | ||
54 | |||
55 | /* check if a named node can be replaced when doing drive-mirror */ | ||
56 | diff --git a/include/block/block_int.h b/include/block/block_int.h | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/include/block/block_int.h | ||
59 | +++ b/include/block/block_int.h | ||
60 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
61 | int (*bdrv_amend_options)(BlockDriverState *bs, QemuOpts *opts, | ||
62 | BlockDriverAmendStatusCB *status_cb, | ||
63 | void *cb_opaque, | ||
64 | + bool force, | ||
65 | Error **errp); | ||
66 | |||
67 | void (*bdrv_debug_event)(BlockDriverState *bs, BlkdebugEvent event); | ||
29 | diff --git a/block.c b/block.c | 68 | diff --git a/block.c b/block.c |
30 | index XXXXXXX..XXXXXXX 100644 | 69 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/block.c | 70 | --- a/block.c |
32 | +++ b/block.c | 71 | +++ b/block.c |
33 | @@ -XXX,XX +XXX,XX @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, | 72 | @@ -XXX,XX +XXX,XX @@ void bdrv_remove_aio_context_notifier(BlockDriverState *bs, |
34 | *nshared = shared; | 73 | |
74 | int bdrv_amend_options(BlockDriverState *bs, QemuOpts *opts, | ||
75 | BlockDriverAmendStatusCB *status_cb, void *cb_opaque, | ||
76 | + bool force, | ||
77 | Error **errp) | ||
78 | { | ||
79 | if (!bs->drv) { | ||
80 | @@ -XXX,XX +XXX,XX @@ int bdrv_amend_options(BlockDriverState *bs, QemuOpts *opts, | ||
81 | bs->drv->format_name); | ||
82 | return -ENOTSUP; | ||
83 | } | ||
84 | - return bs->drv->bdrv_amend_options(bs, opts, status_cb, cb_opaque, errp); | ||
85 | + return bs->drv->bdrv_amend_options(bs, opts, status_cb, | ||
86 | + cb_opaque, force, errp); | ||
35 | } | 87 | } |
36 | 88 | ||
37 | +uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm) | 89 | /* |
38 | +{ | 90 | diff --git a/block/qcow2.c b/block/qcow2.c |
39 | + static const uint64_t permissions[] = { | 91 | index XXXXXXX..XXXXXXX 100644 |
40 | + [BLOCK_PERMISSION_CONSISTENT_READ] = BLK_PERM_CONSISTENT_READ, | 92 | --- a/block/qcow2.c |
41 | + [BLOCK_PERMISSION_WRITE] = BLK_PERM_WRITE, | 93 | +++ b/block/qcow2.c |
42 | + [BLOCK_PERMISSION_WRITE_UNCHANGED] = BLK_PERM_WRITE_UNCHANGED, | 94 | @@ -XXX,XX +XXX,XX @@ static void qcow2_amend_helper_cb(BlockDriverState *bs, |
43 | + [BLOCK_PERMISSION_RESIZE] = BLK_PERM_RESIZE, | 95 | static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, |
44 | + [BLOCK_PERMISSION_GRAPH_MOD] = BLK_PERM_GRAPH_MOD, | 96 | BlockDriverAmendStatusCB *status_cb, |
45 | + }; | 97 | void *cb_opaque, |
46 | + | 98 | + bool force, |
47 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(permissions) != BLOCK_PERMISSION__MAX); | 99 | Error **errp) |
48 | + QEMU_BUILD_BUG_ON(1UL << ARRAY_SIZE(permissions) != BLK_PERM_ALL + 1); | ||
49 | + | ||
50 | + assert(qapi_perm < BLOCK_PERMISSION__MAX); | ||
51 | + | ||
52 | + return permissions[qapi_perm]; | ||
53 | +} | ||
54 | + | ||
55 | static void bdrv_replace_child_noperm(BdrvChild *child, | ||
56 | BlockDriverState *new_bs) | ||
57 | { | 100 | { |
58 | diff --git a/include/block/block.h b/include/block/block.h | 101 | BDRVQcow2State *s = bs->opaque; |
102 | diff --git a/qemu-img.c b/qemu-img.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | 103 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/include/block/block.h | 104 | --- a/qemu-img.c |
61 | +++ b/include/block/block.h | 105 | +++ b/qemu-img.c |
62 | @@ -XXX,XX +XXX,XX @@ enum { | 106 | @@ -XXX,XX +XXX,XX @@ enum { |
107 | OPTION_DISABLE = 273, | ||
108 | OPTION_MERGE = 274, | ||
109 | OPTION_BITMAPS = 275, | ||
110 | + OPTION_FORCE = 276, | ||
63 | }; | 111 | }; |
64 | 112 | ||
65 | char *bdrv_perm_names(uint64_t perm); | 113 | typedef enum OutputFormat { |
66 | +uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm); | 114 | @@ -XXX,XX +XXX,XX @@ static int img_amend(int argc, char **argv) |
67 | 115 | BlockBackend *blk = NULL; | |
68 | /* disk I/O throttling */ | 116 | BlockDriverState *bs = NULL; |
69 | void bdrv_init(void); | 117 | bool image_opts = false; |
118 | + bool force = false; | ||
119 | |||
120 | cache = BDRV_DEFAULT_CACHE; | ||
121 | for (;;) { | ||
122 | @@ -XXX,XX +XXX,XX @@ static int img_amend(int argc, char **argv) | ||
123 | {"help", no_argument, 0, 'h'}, | ||
124 | {"object", required_argument, 0, OPTION_OBJECT}, | ||
125 | {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, | ||
126 | + {"force", no_argument, 0, OPTION_FORCE}, | ||
127 | {0, 0, 0, 0} | ||
128 | }; | ||
129 | c = getopt_long(argc, argv, ":ho:f:t:pq", | ||
130 | @@ -XXX,XX +XXX,XX @@ static int img_amend(int argc, char **argv) | ||
131 | case OPTION_IMAGE_OPTS: | ||
132 | image_opts = true; | ||
133 | break; | ||
134 | + case OPTION_FORCE: | ||
135 | + force = true; | ||
136 | + break; | ||
137 | } | ||
138 | } | ||
139 | |||
140 | @@ -XXX,XX +XXX,XX @@ static int img_amend(int argc, char **argv) | ||
141 | |||
142 | /* In case the driver does not call amend_status_cb() */ | ||
143 | qemu_progress_print(0.f, 0); | ||
144 | - ret = bdrv_amend_options(bs, opts, &amend_status_cb, NULL, &err); | ||
145 | + ret = bdrv_amend_options(bs, opts, &amend_status_cb, NULL, force, &err); | ||
146 | qemu_progress_print(100.f, 0); | ||
147 | if (ret < 0) { | ||
148 | error_report_err(err); | ||
149 | diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx | ||
150 | index XXXXXXX..XXXXXXX 100644 | ||
151 | --- a/qemu-img-cmds.hx | ||
152 | +++ b/qemu-img-cmds.hx | ||
153 | @@ -XXX,XX +XXX,XX @@ HXCOMM When amending the rST sections, please remember to copy the usage | ||
154 | HXCOMM over to the per-command sections in docs/tools/qemu-img.rst. | ||
155 | |||
156 | DEF("amend", img_amend, | ||
157 | - "amend [--object objectdef] [--image-opts] [-p] [-q] [-f fmt] [-t cache] -o options filename") | ||
158 | + "amend [--object objectdef] [--image-opts] [-p] [-q] [-f fmt] [-t cache] [--force] -o options filename") | ||
159 | SRST | ||
160 | -.. option:: amend [--object OBJECTDEF] [--image-opts] [-p] [-q] [-f FMT] [-t CACHE] -o OPTIONS FILENAME | ||
161 | +.. option:: amend [--object OBJECTDEF] [--image-opts] [-p] [-q] [-f FMT] [-t CACHE] [--force] -o OPTIONS FILENAME | ||
162 | ERST | ||
163 | |||
164 | DEF("bench", img_bench, | ||
70 | -- | 165 | -- |
71 | 2.24.1 | 166 | 2.26.2 |
72 | 167 | ||
73 | 168 | diff view generated by jsdifflib |
1 | The only difference is that the json:{} filename of the image looks | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | different. We actually do not care about that filename in this test, we | 2 | |
3 | are only interested in (1) that there is a json:{} filename, and (2) | 3 | Some options are only useful for creation |
4 | whether the backing filename can be constructed. | 4 | (or hard to be amended, like cluster size for qcow2), while some other |
5 | 5 | options are only useful for amend, like upcoming keyslot management | |
6 | So just filter out the json:{} data, thus making this test pass both | 6 | options for luks |
7 | with and without data_file. | 7 | |
8 | 8 | Since currently only qcow2 supports amend, move all its options | |
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 9 | to a common macro and then include it in each action option list. |
10 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 10 | |
11 | Message-id: 20191107163708.833192-19-mreitz@redhat.com | 11 | In future it might be useful to remove some options which are |
12 | not supported anyway from amend list, which currently | ||
13 | cause an error message if amended. | ||
14 | |||
15 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
16 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
17 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
18 | Message-Id: <20200608094030.670121-5-mlevitsk@redhat.com> | ||
12 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 19 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
13 | --- | 20 | --- |
14 | tests/qemu-iotests/110 | 7 +++++-- | 21 | include/block/block_int.h | 4 + |
15 | tests/qemu-iotests/110.out | 4 ++-- | 22 | block/qcow2.c | 173 +++++++++++++++++++++----------------- |
16 | 2 files changed, 7 insertions(+), 4 deletions(-) | 23 | qemu-img.c | 18 ++-- |
17 | 24 | 3 files changed, 107 insertions(+), 88 deletions(-) | |
18 | diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 | 25 | |
19 | index XXXXXXX..XXXXXXX 100755 | 26 | diff --git a/include/block/block_int.h b/include/block/block_int.h |
20 | --- a/tests/qemu-iotests/110 | 27 | index XXXXXXX..XXXXXXX 100644 |
21 | +++ b/tests/qemu-iotests/110 | 28 | --- a/include/block/block_int.h |
22 | @@ -XXX,XX +XXX,XX @@ echo | 29 | +++ b/include/block/block_int.h |
23 | # Across blkdebug without a config file, you cannot reconstruct filenames, so | 30 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { |
24 | # qemu is incapable of knowing the directory of the top image from the filename | 31 | |
25 | # alone. However, using bdrv_dirname(), it should still work. | 32 | /* List of options for creating images, terminated by name == NULL */ |
26 | +# (Filter out the json:{} filename so this test works with external data files) | 33 | QemuOptsList *create_opts; |
27 | TEST_IMG="json:{ | 34 | + |
28 | 'driver': '$IMGFMT', | 35 | + /* List of options for image amend */ |
29 | 'file': { | 36 | + QemuOptsList *amend_opts; |
30 | @@ -XXX,XX +XXX,XX @@ TEST_IMG="json:{ | 37 | + |
31 | } | 38 | /* |
32 | ] | 39 | * If this driver supports reopening images this contains a |
40 | * NULL-terminated list of the runtime options that can be | ||
41 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/block/qcow2.c | ||
44 | +++ b/block/qcow2.c | ||
45 | @@ -XXX,XX +XXX,XX @@ void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset, | ||
46 | s->signaled_corruption = true; | ||
47 | } | ||
48 | |||
49 | +#define QCOW_COMMON_OPTIONS \ | ||
50 | + { \ | ||
51 | + .name = BLOCK_OPT_SIZE, \ | ||
52 | + .type = QEMU_OPT_SIZE, \ | ||
53 | + .help = "Virtual disk size" \ | ||
54 | + }, \ | ||
55 | + { \ | ||
56 | + .name = BLOCK_OPT_COMPAT_LEVEL, \ | ||
57 | + .type = QEMU_OPT_STRING, \ | ||
58 | + .help = "Compatibility level (v2 [0.10] or v3 [1.1])" \ | ||
59 | + }, \ | ||
60 | + { \ | ||
61 | + .name = BLOCK_OPT_BACKING_FILE, \ | ||
62 | + .type = QEMU_OPT_STRING, \ | ||
63 | + .help = "File name of a base image" \ | ||
64 | + }, \ | ||
65 | + { \ | ||
66 | + .name = BLOCK_OPT_BACKING_FMT, \ | ||
67 | + .type = QEMU_OPT_STRING, \ | ||
68 | + .help = "Image format of the base image" \ | ||
69 | + }, \ | ||
70 | + { \ | ||
71 | + .name = BLOCK_OPT_DATA_FILE, \ | ||
72 | + .type = QEMU_OPT_STRING, \ | ||
73 | + .help = "File name of an external data file" \ | ||
74 | + }, \ | ||
75 | + { \ | ||
76 | + .name = BLOCK_OPT_DATA_FILE_RAW, \ | ||
77 | + .type = QEMU_OPT_BOOL, \ | ||
78 | + .help = "The external data file must stay valid " \ | ||
79 | + "as a raw image" \ | ||
80 | + }, \ | ||
81 | + { \ | ||
82 | + .name = BLOCK_OPT_ENCRYPT, \ | ||
83 | + .type = QEMU_OPT_BOOL, \ | ||
84 | + .help = "Encrypt the image with format 'aes'. (Deprecated " \ | ||
85 | + "in favor of " BLOCK_OPT_ENCRYPT_FORMAT "=aes)", \ | ||
86 | + }, \ | ||
87 | + { \ | ||
88 | + .name = BLOCK_OPT_ENCRYPT_FORMAT, \ | ||
89 | + .type = QEMU_OPT_STRING, \ | ||
90 | + .help = "Encrypt the image, format choices: 'aes', 'luks'", \ | ||
91 | + }, \ | ||
92 | + BLOCK_CRYPTO_OPT_DEF_KEY_SECRET("encrypt.", \ | ||
93 | + "ID of secret providing qcow AES key or LUKS passphrase"), \ | ||
94 | + BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_ALG("encrypt."), \ | ||
95 | + BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_MODE("encrypt."), \ | ||
96 | + BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_ALG("encrypt."), \ | ||
97 | + BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_HASH_ALG("encrypt."), \ | ||
98 | + BLOCK_CRYPTO_OPT_DEF_LUKS_HASH_ALG("encrypt."), \ | ||
99 | + BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME("encrypt."), \ | ||
100 | + { \ | ||
101 | + .name = BLOCK_OPT_CLUSTER_SIZE, \ | ||
102 | + .type = QEMU_OPT_SIZE, \ | ||
103 | + .help = "qcow2 cluster size", \ | ||
104 | + .def_value_str = stringify(DEFAULT_CLUSTER_SIZE) \ | ||
105 | + }, \ | ||
106 | + { \ | ||
107 | + .name = BLOCK_OPT_PREALLOC, \ | ||
108 | + .type = QEMU_OPT_STRING, \ | ||
109 | + .help = "Preallocation mode (allowed values: off, " \ | ||
110 | + "metadata, falloc, full)" \ | ||
111 | + }, \ | ||
112 | + { \ | ||
113 | + .name = BLOCK_OPT_LAZY_REFCOUNTS, \ | ||
114 | + .type = QEMU_OPT_BOOL, \ | ||
115 | + .help = "Postpone refcount updates", \ | ||
116 | + .def_value_str = "off" \ | ||
117 | + }, \ | ||
118 | + { \ | ||
119 | + .name = BLOCK_OPT_REFCOUNT_BITS, \ | ||
120 | + .type = QEMU_OPT_NUMBER, \ | ||
121 | + .help = "Width of a reference count entry in bits", \ | ||
122 | + .def_value_str = "16" \ | ||
123 | + }, \ | ||
124 | + { \ | ||
125 | + .name = BLOCK_OPT_COMPRESSION_TYPE, \ | ||
126 | + .type = QEMU_OPT_STRING, \ | ||
127 | + .help = "Compression method used for image cluster " \ | ||
128 | + "compression", \ | ||
129 | + .def_value_str = "zlib" \ | ||
130 | + } | ||
131 | + | ||
132 | static QemuOptsList qcow2_create_opts = { | ||
133 | .name = "qcow2-create-opts", | ||
134 | .head = QTAILQ_HEAD_INITIALIZER(qcow2_create_opts.head), | ||
135 | .desc = { | ||
136 | - { | ||
137 | - .name = BLOCK_OPT_SIZE, | ||
138 | - .type = QEMU_OPT_SIZE, | ||
139 | - .help = "Virtual disk size" | ||
140 | - }, | ||
141 | - { | ||
142 | - .name = BLOCK_OPT_COMPAT_LEVEL, | ||
143 | - .type = QEMU_OPT_STRING, | ||
144 | - .help = "Compatibility level (v2 [0.10] or v3 [1.1])" | ||
145 | - }, | ||
146 | - { | ||
147 | - .name = BLOCK_OPT_BACKING_FILE, | ||
148 | - .type = QEMU_OPT_STRING, | ||
149 | - .help = "File name of a base image" | ||
150 | - }, | ||
151 | - { | ||
152 | - .name = BLOCK_OPT_BACKING_FMT, | ||
153 | - .type = QEMU_OPT_STRING, | ||
154 | - .help = "Image format of the base image" | ||
155 | - }, | ||
156 | - { | ||
157 | - .name = BLOCK_OPT_DATA_FILE, | ||
158 | - .type = QEMU_OPT_STRING, | ||
159 | - .help = "File name of an external data file" | ||
160 | - }, | ||
161 | - { | ||
162 | - .name = BLOCK_OPT_DATA_FILE_RAW, | ||
163 | - .type = QEMU_OPT_BOOL, | ||
164 | - .help = "The external data file must stay valid as a raw image" | ||
165 | - }, | ||
166 | - { | ||
167 | - .name = BLOCK_OPT_ENCRYPT, | ||
168 | - .type = QEMU_OPT_BOOL, | ||
169 | - .help = "Encrypt the image with format 'aes'. (Deprecated " | ||
170 | - "in favor of " BLOCK_OPT_ENCRYPT_FORMAT "=aes)", | ||
171 | - }, | ||
172 | - { | ||
173 | - .name = BLOCK_OPT_ENCRYPT_FORMAT, | ||
174 | - .type = QEMU_OPT_STRING, | ||
175 | - .help = "Encrypt the image, format choices: 'aes', 'luks'", | ||
176 | - }, | ||
177 | - BLOCK_CRYPTO_OPT_DEF_KEY_SECRET("encrypt.", | ||
178 | - "ID of secret providing qcow AES key or LUKS passphrase"), | ||
179 | - BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_ALG("encrypt."), | ||
180 | - BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_MODE("encrypt."), | ||
181 | - BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_ALG("encrypt."), | ||
182 | - BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_HASH_ALG("encrypt."), | ||
183 | - BLOCK_CRYPTO_OPT_DEF_LUKS_HASH_ALG("encrypt."), | ||
184 | - BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME("encrypt."), | ||
185 | - { | ||
186 | - .name = BLOCK_OPT_CLUSTER_SIZE, | ||
187 | - .type = QEMU_OPT_SIZE, | ||
188 | - .help = "qcow2 cluster size", | ||
189 | - .def_value_str = stringify(DEFAULT_CLUSTER_SIZE) | ||
190 | - }, | ||
191 | - { | ||
192 | - .name = BLOCK_OPT_PREALLOC, | ||
193 | - .type = QEMU_OPT_STRING, | ||
194 | - .help = "Preallocation mode (allowed values: off, metadata, " | ||
195 | - "falloc, full)" | ||
196 | - }, | ||
197 | - { | ||
198 | - .name = BLOCK_OPT_LAZY_REFCOUNTS, | ||
199 | - .type = QEMU_OPT_BOOL, | ||
200 | - .help = "Postpone refcount updates", | ||
201 | - .def_value_str = "off" | ||
202 | - }, | ||
203 | - { | ||
204 | - .name = BLOCK_OPT_REFCOUNT_BITS, | ||
205 | - .type = QEMU_OPT_NUMBER, | ||
206 | - .help = "Width of a reference count entry in bits", | ||
207 | - .def_value_str = "16" | ||
208 | - }, | ||
209 | - { | ||
210 | - .name = BLOCK_OPT_COMPRESSION_TYPE, | ||
211 | - .type = QEMU_OPT_STRING, | ||
212 | - .help = "Compression method used for image cluster compression", | ||
213 | - .def_value_str = "zlib" | ||
214 | - }, | ||
215 | + QCOW_COMMON_OPTIONS, | ||
216 | + { /* end of list */ } | ||
217 | + } | ||
218 | +}; | ||
219 | + | ||
220 | +static QemuOptsList qcow2_amend_opts = { | ||
221 | + .name = "qcow2-amend-opts", | ||
222 | + .head = QTAILQ_HEAD_INITIALIZER(qcow2_amend_opts.head), | ||
223 | + .desc = { | ||
224 | + QCOW_COMMON_OPTIONS, | ||
225 | { /* end of list */ } | ||
33 | } | 226 | } |
34 | -}" _img_info | _filter_img_info | grep -v 'backing file format' | 227 | }; |
35 | +}" _img_info | _filter_img_info | grep -v 'backing file format' \ | 228 | @@ -XXX,XX +XXX,XX @@ BlockDriver bdrv_qcow2 = { |
36 | + | _filter_json_filename | 229 | .bdrv_inactivate = qcow2_inactivate, |
37 | 230 | ||
38 | echo | 231 | .create_opts = &qcow2_create_opts, |
39 | echo '=== Backing name is always relative to the backed image ===' | 232 | + .amend_opts = &qcow2_amend_opts, |
40 | @@ -XXX,XX +XXX,XX @@ TEST_IMG="json:{ | 233 | .strong_runtime_opts = qcow2_strong_runtime_opts, |
41 | } | 234 | .mutable_opts = mutable_opts, |
42 | ] | 235 | .bdrv_co_check = qcow2_co_check, |
236 | diff --git a/qemu-img.c b/qemu-img.c | ||
237 | index XXXXXXX..XXXXXXX 100644 | ||
238 | --- a/qemu-img.c | ||
239 | +++ b/qemu-img.c | ||
240 | @@ -XXX,XX +XXX,XX @@ static int print_amend_option_help(const char *format) | ||
241 | return 1; | ||
43 | } | 242 | } |
44 | -}" _img_info | _filter_img_info | grep -v 'backing file format' | 243 | |
45 | +}" _img_info | _filter_img_info | grep -v 'backing file format' \ | 244 | - /* Every driver supporting amendment must have create_opts */ |
46 | + | _filter_json_filename | 245 | - assert(drv->create_opts); |
47 | 246 | + /* Every driver supporting amendment must have amend_opts */ | |
48 | 247 | + assert(drv->amend_opts); | |
49 | # success, all done | 248 | |
50 | diff --git a/tests/qemu-iotests/110.out b/tests/qemu-iotests/110.out | 249 | printf("Creation options for '%s':\n", format); |
51 | index XXXXXXX..XXXXXXX 100644 | 250 | - qemu_opts_print_help(drv->create_opts, false); |
52 | --- a/tests/qemu-iotests/110.out | 251 | + qemu_opts_print_help(drv->amend_opts, false); |
53 | +++ b/tests/qemu-iotests/110.out | 252 | printf("\nNote that not all of these options may be amendable.\n"); |
54 | @@ -XXX,XX +XXX,XX @@ backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base) | 253 | return 0; |
55 | 254 | } | |
56 | === Non-reconstructable filename === | 255 | @@ -XXX,XX +XXX,XX @@ static int img_amend(int argc, char **argv) |
57 | 256 | Error *err = NULL; | |
58 | -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}} | 257 | int c, ret = 0; |
59 | +image: json:{ /* filtered */ } | 258 | char *options = NULL; |
60 | file format: IMGFMT | 259 | - QemuOptsList *create_opts = NULL; |
61 | virtual size: 64 MiB (67108864 bytes) | 260 | + QemuOptsList *amend_opts = NULL; |
62 | backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base) | 261 | QemuOpts *opts = NULL; |
63 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=t.IMGFMT.b | 262 | const char *fmt = NULL, *filename, *cache; |
64 | 263 | int flags; | |
65 | === Nodes without a common directory === | 264 | @@ -XXX,XX +XXX,XX @@ static int img_amend(int argc, char **argv) |
66 | 265 | goto out; | |
67 | -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}} | 266 | } |
68 | +image: json:{ /* filtered */ } | 267 | |
69 | file format: IMGFMT | 268 | - /* Every driver supporting amendment must have create_opts */ |
70 | virtual size: 64 MiB (67108864 bytes) | 269 | - assert(bs->drv->create_opts); |
71 | backing file: t.IMGFMT.base (cannot determine actual path) | 270 | + /* Every driver supporting amendment must have amend_opts */ |
271 | + assert(bs->drv->amend_opts); | ||
272 | |||
273 | - create_opts = qemu_opts_append(create_opts, bs->drv->create_opts); | ||
274 | - opts = qemu_opts_create(create_opts, NULL, 0, &error_abort); | ||
275 | + amend_opts = qemu_opts_append(amend_opts, bs->drv->amend_opts); | ||
276 | + opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort); | ||
277 | qemu_opts_do_parse(opts, options, NULL, &err); | ||
278 | if (err) { | ||
279 | error_report_err(err); | ||
280 | @@ -XXX,XX +XXX,XX @@ out: | ||
281 | out_no_progress: | ||
282 | blk_unref(blk); | ||
283 | qemu_opts_del(opts); | ||
284 | - qemu_opts_free(create_opts); | ||
285 | + qemu_opts_free(amend_opts); | ||
286 | g_free(options); | ||
287 | |||
288 | if (ret) { | ||
72 | -- | 289 | -- |
73 | 2.24.1 | 290 | 2.26.2 |
74 | 291 | ||
75 | 292 | diff view generated by jsdifflib |
1 | Print the feature fields as a set of bits so that filtering is easier. | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Some qcow2 create options can't be used for amend. | ||
4 | Remove them from the qcow2 create options and add generic logic to detect | ||
5 | such options in qemu-img | ||
6 | |||
7 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
8 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
9 | [mreitz: Dropped some iotests reference output hunks that became | ||
10 | unnecessary thanks to | ||
11 | "iotests: Make _filter_img_create more active"] | ||
3 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 12 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
4 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 13 | Message-Id: <20200625125548.870061-12-mreitz@redhat.com> |
5 | Message-id: 20191107163708.833192-4-mreitz@redhat.com | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
7 | --- | 14 | --- |
8 | tests/qemu-iotests/031.out | 36 +++++++++---------- | 15 | block/qcow2.c | 138 +++++++++----------------------- |
9 | tests/qemu-iotests/036.out | 18 +++++----- | 16 | qemu-img.c | 18 ++++- |
10 | tests/qemu-iotests/039.out | 22 ++++++------ | 17 | tests/qemu-iotests/049.out | 102 ++++++++++++------------ |
11 | tests/qemu-iotests/060.out | 20 +++++------ | 18 | tests/qemu-iotests/061.out | 12 ++- |
12 | tests/qemu-iotests/061.out | 72 ++++++++++++++++++------------------- | 19 | tests/qemu-iotests/082.out | 158 ++++--------------------------------- |
13 | tests/qemu-iotests/137.out | 2 +- | 20 | tests/qemu-iotests/085.out | 38 ++++----- |
14 | tests/qemu-iotests/qcow2.py | 18 +++++++--- | 21 | tests/qemu-iotests/144.out | 4 +- |
15 | 7 files changed, 99 insertions(+), 89 deletions(-) | 22 | tests/qemu-iotests/182.out | 2 +- |
23 | tests/qemu-iotests/185.out | 8 +- | ||
24 | tests/qemu-iotests/255.out | 8 +- | ||
25 | tests/qemu-iotests/274.out | 46 +++++------ | ||
26 | tests/qemu-iotests/280.out | 2 +- | ||
27 | 12 files changed, 183 insertions(+), 353 deletions(-) | ||
16 | 28 | ||
17 | diff --git a/tests/qemu-iotests/031.out b/tests/qemu-iotests/031.out | 29 | diff --git a/block/qcow2.c b/block/qcow2.c |
18 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/tests/qemu-iotests/031.out | 31 | --- a/block/qcow2.c |
20 | +++ b/tests/qemu-iotests/031.out | 32 | +++ b/block/qcow2.c |
21 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | 33 | @@ -XXX,XX +XXX,XX @@ static int qcow2_change_backing_file(BlockDriverState *bs, |
22 | refcount_table_clusters 1 | 34 | return qcow2_update_header(bs); |
23 | nb_snapshots 0 | 35 | } |
24 | snapshot_offset 0x0 | 36 | |
25 | -incompatible_features 0x0 | 37 | -static int qcow2_crypt_method_from_format(const char *encryptfmt) |
26 | -compatible_features 0x0 | 38 | -{ |
27 | -autoclear_features 0x0 | 39 | - if (g_str_equal(encryptfmt, "luks")) { |
28 | +incompatible_features [] | 40 | - return QCOW_CRYPT_LUKS; |
29 | +compatible_features [] | 41 | - } else if (g_str_equal(encryptfmt, "aes")) { |
30 | +autoclear_features [] | 42 | - return QCOW_CRYPT_AES; |
31 | refcount_order 4 | 43 | - } else { |
32 | header_length 72 | 44 | - return -EINVAL; |
33 | 45 | - } | |
34 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | 46 | -} |
35 | refcount_table_clusters 1 | 47 | - |
36 | nb_snapshots 0 | 48 | static int qcow2_set_up_encryption(BlockDriverState *bs, |
37 | snapshot_offset 0x0 | 49 | QCryptoBlockCreateOptions *cryptoopts, |
38 | -incompatible_features 0x0 | 50 | Error **errp) |
39 | -compatible_features 0x0 | 51 | @@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, |
40 | -autoclear_features 0x0 | 52 | bool lazy_refcounts = s->use_lazy_refcounts; |
41 | +incompatible_features [] | 53 | bool data_file_raw = data_file_is_raw(bs); |
42 | +compatible_features [] | 54 | const char *compat = NULL; |
43 | +autoclear_features [] | 55 | - uint64_t cluster_size = s->cluster_size; |
44 | refcount_order 4 | 56 | - bool encrypt; |
45 | header_length 72 | 57 | - int encformat; |
46 | 58 | int refcount_bits = s->refcount_bits; | |
47 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | 59 | int ret; |
48 | refcount_table_clusters 1 | 60 | QemuOptDesc *desc = opts->list->desc; |
49 | nb_snapshots 0 | 61 | @@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, |
50 | snapshot_offset 0x0 | 62 | error_setg(errp, "Unknown compatibility level %s", compat); |
51 | -incompatible_features 0x0 | 63 | return -EINVAL; |
52 | -compatible_features 0x0 | 64 | } |
53 | -autoclear_features 0x0 | 65 | - } else if (!strcmp(desc->name, BLOCK_OPT_PREALLOC)) { |
54 | +incompatible_features [] | 66 | - error_setg(errp, "Cannot change preallocation mode"); |
55 | +compatible_features [] | 67 | - return -ENOTSUP; |
56 | +autoclear_features [] | 68 | } else if (!strcmp(desc->name, BLOCK_OPT_SIZE)) { |
57 | refcount_order 4 | 69 | new_size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0); |
58 | header_length 72 | 70 | } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FILE)) { |
59 | 71 | backing_file = qemu_opt_get(opts, BLOCK_OPT_BACKING_FILE); | |
60 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | 72 | } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FMT)) { |
61 | refcount_table_clusters 1 | 73 | backing_format = qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT); |
62 | nb_snapshots 0 | 74 | - } else if (!strcmp(desc->name, BLOCK_OPT_ENCRYPT)) { |
63 | snapshot_offset 0x0 | 75 | - encrypt = qemu_opt_get_bool(opts, BLOCK_OPT_ENCRYPT, |
64 | -incompatible_features 0x0 | 76 | - !!s->crypto); |
65 | -compatible_features 0x0 | 77 | - |
66 | -autoclear_features 0x0 | 78 | - if (encrypt != !!s->crypto) { |
67 | +incompatible_features [] | 79 | - error_setg(errp, |
68 | +compatible_features [] | 80 | - "Changing the encryption flag is not supported"); |
69 | +autoclear_features [] | 81 | - return -ENOTSUP; |
70 | refcount_order 4 | 82 | - } |
71 | header_length 104 | 83 | - } else if (!strcmp(desc->name, BLOCK_OPT_ENCRYPT_FORMAT)) { |
72 | 84 | - encformat = qcow2_crypt_method_from_format( | |
73 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | 85 | - qemu_opt_get(opts, BLOCK_OPT_ENCRYPT_FORMAT)); |
74 | refcount_table_clusters 1 | 86 | - |
75 | nb_snapshots 0 | 87 | - if (encformat != s->crypt_method_header) { |
76 | snapshot_offset 0x0 | 88 | - error_setg(errp, |
77 | -incompatible_features 0x0 | 89 | - "Changing the encryption format is not supported"); |
78 | -compatible_features 0x0 | 90 | - return -ENOTSUP; |
79 | -autoclear_features 0x0 | 91 | - } |
80 | +incompatible_features [] | 92 | - } else if (g_str_has_prefix(desc->name, "encrypt.")) { |
81 | +compatible_features [] | 93 | - error_setg(errp, |
82 | +autoclear_features [] | 94 | - "Changing the encryption parameters is not supported"); |
83 | refcount_order 4 | 95 | - return -ENOTSUP; |
84 | header_length 104 | 96 | - } else if (!strcmp(desc->name, BLOCK_OPT_CLUSTER_SIZE)) { |
85 | 97 | - cluster_size = qemu_opt_get_size(opts, BLOCK_OPT_CLUSTER_SIZE, | |
86 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | 98 | - cluster_size); |
87 | refcount_table_clusters 1 | 99 | - if (cluster_size != s->cluster_size) { |
88 | nb_snapshots 0 | 100 | - error_setg(errp, "Changing the cluster size is not supported"); |
89 | snapshot_offset 0x0 | 101 | - return -ENOTSUP; |
90 | -incompatible_features 0x0 | 102 | - } |
91 | -compatible_features 0x0 | 103 | } else if (!strcmp(desc->name, BLOCK_OPT_LAZY_REFCOUNTS)) { |
92 | -autoclear_features 0x0 | 104 | lazy_refcounts = qemu_opt_get_bool(opts, BLOCK_OPT_LAZY_REFCOUNTS, |
93 | +incompatible_features [] | 105 | lazy_refcounts); |
94 | +compatible_features [] | 106 | @@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, |
95 | +autoclear_features [] | 107 | "images"); |
96 | refcount_order 4 | 108 | return -EINVAL; |
97 | header_length 104 | 109 | } |
98 | 110 | - } else if (!strcmp(desc->name, BLOCK_OPT_COMPRESSION_TYPE)) { | |
99 | diff --git a/tests/qemu-iotests/036.out b/tests/qemu-iotests/036.out | 111 | - const char *ct_name = |
112 | - qemu_opt_get(opts, BLOCK_OPT_COMPRESSION_TYPE); | ||
113 | - int compression_type = | ||
114 | - qapi_enum_parse(&Qcow2CompressionType_lookup, ct_name, -1, | ||
115 | - NULL); | ||
116 | - if (compression_type == -1) { | ||
117 | - error_setg(errp, "Unknown compression type: %s", ct_name); | ||
118 | - return -ENOTSUP; | ||
119 | - } | ||
120 | - | ||
121 | - if (compression_type != s->compression_type) { | ||
122 | - error_setg(errp, "Changing the compression type " | ||
123 | - "is not supported"); | ||
124 | - return -ENOTSUP; | ||
125 | - } | ||
126 | } else { | ||
127 | /* if this point is reached, this probably means a new option was | ||
128 | * added without having it covered here */ | ||
129 | @@ -XXX,XX +XXX,XX @@ void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset, | ||
130 | .help = "The external data file must stay valid " \ | ||
131 | "as a raw image" \ | ||
132 | }, \ | ||
133 | - { \ | ||
134 | - .name = BLOCK_OPT_ENCRYPT, \ | ||
135 | - .type = QEMU_OPT_BOOL, \ | ||
136 | - .help = "Encrypt the image with format 'aes'. (Deprecated " \ | ||
137 | - "in favor of " BLOCK_OPT_ENCRYPT_FORMAT "=aes)", \ | ||
138 | - }, \ | ||
139 | - { \ | ||
140 | - .name = BLOCK_OPT_ENCRYPT_FORMAT, \ | ||
141 | - .type = QEMU_OPT_STRING, \ | ||
142 | - .help = "Encrypt the image, format choices: 'aes', 'luks'", \ | ||
143 | - }, \ | ||
144 | - BLOCK_CRYPTO_OPT_DEF_KEY_SECRET("encrypt.", \ | ||
145 | - "ID of secret providing qcow AES key or LUKS passphrase"), \ | ||
146 | - BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_ALG("encrypt."), \ | ||
147 | - BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_MODE("encrypt."), \ | ||
148 | - BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_ALG("encrypt."), \ | ||
149 | - BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_HASH_ALG("encrypt."), \ | ||
150 | - BLOCK_CRYPTO_OPT_DEF_LUKS_HASH_ALG("encrypt."), \ | ||
151 | - BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME("encrypt."), \ | ||
152 | - { \ | ||
153 | - .name = BLOCK_OPT_CLUSTER_SIZE, \ | ||
154 | - .type = QEMU_OPT_SIZE, \ | ||
155 | - .help = "qcow2 cluster size", \ | ||
156 | - .def_value_str = stringify(DEFAULT_CLUSTER_SIZE) \ | ||
157 | - }, \ | ||
158 | - { \ | ||
159 | - .name = BLOCK_OPT_PREALLOC, \ | ||
160 | - .type = QEMU_OPT_STRING, \ | ||
161 | - .help = "Preallocation mode (allowed values: off, " \ | ||
162 | - "metadata, falloc, full)" \ | ||
163 | - }, \ | ||
164 | { \ | ||
165 | .name = BLOCK_OPT_LAZY_REFCOUNTS, \ | ||
166 | .type = QEMU_OPT_BOOL, \ | ||
167 | @@ -XXX,XX +XXX,XX @@ void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset, | ||
168 | .type = QEMU_OPT_NUMBER, \ | ||
169 | .help = "Width of a reference count entry in bits", \ | ||
170 | .def_value_str = "16" \ | ||
171 | - }, \ | ||
172 | - { \ | ||
173 | - .name = BLOCK_OPT_COMPRESSION_TYPE, \ | ||
174 | - .type = QEMU_OPT_STRING, \ | ||
175 | - .help = "Compression method used for image cluster " \ | ||
176 | - "compression", \ | ||
177 | - .def_value_str = "zlib" \ | ||
178 | } | ||
179 | |||
180 | static QemuOptsList qcow2_create_opts = { | ||
181 | .name = "qcow2-create-opts", | ||
182 | .head = QTAILQ_HEAD_INITIALIZER(qcow2_create_opts.head), | ||
183 | .desc = { | ||
184 | + { \ | ||
185 | + .name = BLOCK_OPT_ENCRYPT, \ | ||
186 | + .type = QEMU_OPT_BOOL, \ | ||
187 | + .help = "Encrypt the image with format 'aes'. (Deprecated " \ | ||
188 | + "in favor of " BLOCK_OPT_ENCRYPT_FORMAT "=aes)", \ | ||
189 | + }, \ | ||
190 | + { \ | ||
191 | + .name = BLOCK_OPT_ENCRYPT_FORMAT, \ | ||
192 | + .type = QEMU_OPT_STRING, \ | ||
193 | + .help = "Encrypt the image, format choices: 'aes', 'luks'", \ | ||
194 | + }, \ | ||
195 | + BLOCK_CRYPTO_OPT_DEF_KEY_SECRET("encrypt.", \ | ||
196 | + "ID of secret providing qcow AES key or LUKS passphrase"), \ | ||
197 | + BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_ALG("encrypt."), \ | ||
198 | + BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_MODE("encrypt."), \ | ||
199 | + BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_ALG("encrypt."), \ | ||
200 | + BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_HASH_ALG("encrypt."), \ | ||
201 | + BLOCK_CRYPTO_OPT_DEF_LUKS_HASH_ALG("encrypt."), \ | ||
202 | + BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME("encrypt."), \ | ||
203 | + { \ | ||
204 | + .name = BLOCK_OPT_CLUSTER_SIZE, \ | ||
205 | + .type = QEMU_OPT_SIZE, \ | ||
206 | + .help = "qcow2 cluster size", \ | ||
207 | + .def_value_str = stringify(DEFAULT_CLUSTER_SIZE) \ | ||
208 | + }, \ | ||
209 | + { \ | ||
210 | + .name = BLOCK_OPT_PREALLOC, \ | ||
211 | + .type = QEMU_OPT_STRING, \ | ||
212 | + .help = "Preallocation mode (allowed values: off, " \ | ||
213 | + "metadata, falloc, full)" \ | ||
214 | + }, \ | ||
215 | + { \ | ||
216 | + .name = BLOCK_OPT_COMPRESSION_TYPE, \ | ||
217 | + .type = QEMU_OPT_STRING, \ | ||
218 | + .help = "Compression method used for image cluster " \ | ||
219 | + "compression", \ | ||
220 | + .def_value_str = "zlib" \ | ||
221 | + }, | ||
222 | QCOW_COMMON_OPTIONS, | ||
223 | { /* end of list */ } | ||
224 | } | ||
225 | diff --git a/qemu-img.c b/qemu-img.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | 226 | index XXXXXXX..XXXXXXX 100644 |
101 | --- a/tests/qemu-iotests/036.out | 227 | --- a/qemu-img.c |
102 | +++ b/tests/qemu-iotests/036.out | 228 | +++ b/qemu-img.c |
103 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | 229 | @@ -XXX,XX +XXX,XX @@ static int print_amend_option_help(const char *format) |
104 | refcount_table_clusters 1 | 230 | /* Every driver supporting amendment must have amend_opts */ |
105 | nb_snapshots 0 | 231 | assert(drv->amend_opts); |
106 | snapshot_offset 0x0 | 232 | |
107 | -incompatible_features 0x8000000000000000 | 233 | - printf("Creation options for '%s':\n", format); |
108 | -compatible_features 0x0 | 234 | + printf("Amend options for '%s':\n", format); |
109 | -autoclear_features 0x0 | 235 | qemu_opts_print_help(drv->amend_opts, false); |
110 | +incompatible_features [63] | 236 | - printf("\nNote that not all of these options may be amendable.\n"); |
111 | +compatible_features [] | 237 | return 0; |
112 | +autoclear_features [] | 238 | } |
113 | refcount_order 4 | 239 | |
114 | header_length 104 | 240 | @@ -XXX,XX +XXX,XX @@ static int img_amend(int argc, char **argv) |
115 | 241 | amend_opts = qemu_opts_append(amend_opts, bs->drv->amend_opts); | |
116 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | 242 | opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort); |
117 | refcount_table_clusters 1 | 243 | qemu_opts_do_parse(opts, options, NULL, &err); |
118 | nb_snapshots 0 | 244 | + |
119 | snapshot_offset 0x0 | 245 | if (err) { |
120 | -incompatible_features 0x0 | 246 | + /* Try to parse options using the create options */ |
121 | -compatible_features 0x0 | 247 | + Error *err1 = NULL; |
122 | -autoclear_features 0x8000000000000000 | 248 | + amend_opts = qemu_opts_append(amend_opts, bs->drv->create_opts); |
123 | +incompatible_features [] | 249 | + qemu_opts_del(opts); |
124 | +compatible_features [] | 250 | + opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort); |
125 | +autoclear_features [63] | 251 | + qemu_opts_do_parse(opts, options, NULL, &err1); |
126 | refcount_order 4 | 252 | + |
127 | header_length 104 | 253 | + if (!err1) { |
128 | 254 | + error_append_hint(&err, | |
129 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | 255 | + "This option is only supported for image creation\n"); |
130 | refcount_table_clusters 1 | 256 | + } else { |
131 | nb_snapshots 0 | 257 | + error_free(err1); |
132 | snapshot_offset 0x0 | 258 | + } |
133 | -incompatible_features 0x0 | 259 | + |
134 | -compatible_features 0x0 | 260 | error_report_err(err); |
135 | -autoclear_features 0x0 | 261 | ret = -1; |
136 | +incompatible_features [] | 262 | goto out; |
137 | +compatible_features [] | 263 | diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out |
138 | +autoclear_features [] | ||
139 | refcount_order 4 | ||
140 | header_length 104 | ||
141 | |||
142 | diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out | ||
143 | index XXXXXXX..XXXXXXX 100644 | 264 | index XXXXXXX..XXXXXXX 100644 |
144 | --- a/tests/qemu-iotests/039.out | 265 | --- a/tests/qemu-iotests/049.out |
145 | +++ b/tests/qemu-iotests/039.out | 266 | +++ b/tests/qemu-iotests/049.out |
146 | @@ -XXX,XX +XXX,XX @@ QA output created by 039 | 267 | @@ -XXX,XX +XXX,XX @@ QA output created by 049 |
147 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | 268 | == 1. Traditional size parameter == |
148 | wrote 512/512 bytes at offset 0 | 269 | |
149 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 270 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024 |
150 | -incompatible_features 0x0 | 271 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
151 | +incompatible_features [] | 272 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16 |
152 | No errors were found on the image. | 273 | |
153 | 274 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024b | |
154 | == Creating a dirty image file == | 275 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
155 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | 276 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16 |
156 | wrote 512/512 bytes at offset 0 | 277 | |
157 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 278 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1k |
158 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | 279 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
159 | -incompatible_features 0x1 | 280 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16 |
160 | +incompatible_features [0] | 281 | |
161 | ERROR cluster 5 refcount=0 reference=1 | 282 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1K |
162 | ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 | 283 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
163 | 284 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16 | |
164 | @@ -XXX,XX +XXX,XX @@ Data may be corrupted, or further writes to the image may corrupt it. | 285 | |
165 | == Read-only access must still work == | 286 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1M |
166 | read 512/512 bytes at offset 0 | 287 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1048576 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
167 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 288 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1048576 lazy_refcounts=off refcount_bits=16 |
168 | -incompatible_features 0x1 | 289 | |
169 | +incompatible_features [0] | 290 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1G |
170 | 291 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1073741824 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | |
171 | == Repairing the image file must succeed == | 292 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1073741824 lazy_refcounts=off refcount_bits=16 |
172 | ERROR cluster 5 refcount=0 reference=1 | 293 | |
173 | @@ -XXX,XX +XXX,XX @@ The following inconsistencies were found and repaired: | 294 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1T |
174 | 295 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1099511627776 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | |
175 | Double checking the fixed image now... | 296 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1099511627776 lazy_refcounts=off refcount_bits=16 |
176 | No errors were found on the image. | 297 | |
177 | -incompatible_features 0x0 | 298 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024.0 |
178 | +incompatible_features [] | 299 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
179 | 300 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16 | |
180 | == Data should still be accessible after repair == | 301 | |
181 | read 512/512 bytes at offset 0 | 302 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024.0b |
182 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | 303 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
183 | wrote 512/512 bytes at offset 0 | 304 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16 |
184 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 305 | |
185 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | 306 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5k |
186 | -incompatible_features 0x1 | 307 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1536 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
187 | +incompatible_features [0] | 308 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1536 lazy_refcounts=off refcount_bits=16 |
188 | ERROR cluster 5 refcount=0 reference=1 | 309 | |
189 | Rebuilding refcount structure | 310 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5K |
190 | Repairing cluster 1 refcount=1 reference=0 | 311 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1536 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
191 | Repairing cluster 2 refcount=1 reference=0 | 312 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1536 lazy_refcounts=off refcount_bits=16 |
192 | wrote 512/512 bytes at offset 0 | 313 | |
193 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 314 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5M |
194 | -incompatible_features 0x0 | 315 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1572864 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
195 | +incompatible_features [] | 316 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1572864 lazy_refcounts=off refcount_bits=16 |
196 | 317 | ||
197 | == Creating an image file with lazy_refcounts=off == | 318 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5G |
198 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | 319 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1610612736 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
199 | wrote 512/512 bytes at offset 0 | 320 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1610612736 lazy_refcounts=off refcount_bits=16 |
200 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 321 | |
201 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | 322 | qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5T |
202 | -incompatible_features 0x0 | 323 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1649267441664 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
203 | +incompatible_features [] | 324 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1649267441664 lazy_refcounts=off refcount_bits=16 |
204 | No errors were found on the image. | 325 | |
205 | 326 | == 2. Specifying size via -o == | |
206 | == Committing to a backing file with lazy_refcounts=on == | 327 | |
207 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/ | 328 | qemu-img create -f qcow2 -o size=1024 TEST_DIR/t.qcow2 |
208 | wrote 512/512 bytes at offset 0 | 329 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
209 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 330 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16 |
210 | Image committed. | 331 | |
211 | -incompatible_features 0x0 | 332 | qemu-img create -f qcow2 -o size=1024b TEST_DIR/t.qcow2 |
212 | -incompatible_features 0x0 | 333 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
213 | +incompatible_features [] | 334 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16 |
214 | +incompatible_features [] | 335 | |
215 | No errors were found on the image. | 336 | qemu-img create -f qcow2 -o size=1k TEST_DIR/t.qcow2 |
216 | No errors were found on the image. | 337 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
217 | 338 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16 | |
218 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | 339 | |
219 | wrote 512/512 bytes at offset 0 | 340 | qemu-img create -f qcow2 -o size=1K TEST_DIR/t.qcow2 |
220 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 341 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
221 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | 342 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16 |
222 | -incompatible_features 0x1 | 343 | |
223 | +incompatible_features [0] | 344 | qemu-img create -f qcow2 -o size=1M TEST_DIR/t.qcow2 |
224 | ERROR cluster 5 refcount=0 reference=1 | 345 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1048576 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
225 | ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 | 346 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1048576 lazy_refcounts=off refcount_bits=16 |
226 | 347 | ||
227 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | 348 | qemu-img create -f qcow2 -o size=1G TEST_DIR/t.qcow2 |
228 | wrote 512/512 bytes at offset 0 | 349 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1073741824 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
229 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 350 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1073741824 lazy_refcounts=off refcount_bits=16 |
230 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | 351 | |
231 | -incompatible_features 0x0 | 352 | qemu-img create -f qcow2 -o size=1T TEST_DIR/t.qcow2 |
232 | +incompatible_features [] | 353 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1099511627776 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
233 | No errors were found on the image. | 354 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1099511627776 lazy_refcounts=off refcount_bits=16 |
355 | |||
356 | qemu-img create -f qcow2 -o size=1024.0 TEST_DIR/t.qcow2 | ||
357 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
358 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16 | ||
359 | |||
360 | qemu-img create -f qcow2 -o size=1024.0b TEST_DIR/t.qcow2 | ||
361 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1024 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
362 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16 | ||
363 | |||
364 | qemu-img create -f qcow2 -o size=1.5k TEST_DIR/t.qcow2 | ||
365 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1536 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
366 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1536 lazy_refcounts=off refcount_bits=16 | ||
367 | |||
368 | qemu-img create -f qcow2 -o size=1.5K TEST_DIR/t.qcow2 | ||
369 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1536 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
370 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1536 lazy_refcounts=off refcount_bits=16 | ||
371 | |||
372 | qemu-img create -f qcow2 -o size=1.5M TEST_DIR/t.qcow2 | ||
373 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1572864 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
374 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1572864 lazy_refcounts=off refcount_bits=16 | ||
375 | |||
376 | qemu-img create -f qcow2 -o size=1.5G TEST_DIR/t.qcow2 | ||
377 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1610612736 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
378 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1610612736 lazy_refcounts=off refcount_bits=16 | ||
379 | |||
380 | qemu-img create -f qcow2 -o size=1.5T TEST_DIR/t.qcow2 | ||
381 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=1649267441664 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
382 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1649267441664 lazy_refcounts=off refcount_bits=16 | ||
383 | |||
384 | == 3. Invalid sizes == | ||
385 | |||
386 | @@ -XXX,XX +XXX,XX @@ qemu-img: TEST_DIR/t.qcow2: The image size must be specified only once | ||
387 | == Check correct interpretation of suffixes for cluster size == | ||
388 | |||
389 | qemu-img create -f qcow2 -o cluster_size=1024 TEST_DIR/t.qcow2 64M | ||
390 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=1024 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
391 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
392 | |||
393 | qemu-img create -f qcow2 -o cluster_size=1024b TEST_DIR/t.qcow2 64M | ||
394 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=1024 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
395 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
396 | |||
397 | qemu-img create -f qcow2 -o cluster_size=1k TEST_DIR/t.qcow2 64M | ||
398 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=1024 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
399 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
400 | |||
401 | qemu-img create -f qcow2 -o cluster_size=1K TEST_DIR/t.qcow2 64M | ||
402 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=1024 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
403 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
404 | |||
405 | qemu-img create -f qcow2 -o cluster_size=1M TEST_DIR/t.qcow2 64M | ||
406 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=1048576 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
407 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1048576 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
408 | |||
409 | qemu-img create -f qcow2 -o cluster_size=1024.0 TEST_DIR/t.qcow2 64M | ||
410 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=1024 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
411 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
412 | |||
413 | qemu-img create -f qcow2 -o cluster_size=1024.0b TEST_DIR/t.qcow2 64M | ||
414 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=1024 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
415 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
416 | |||
417 | qemu-img create -f qcow2 -o cluster_size=0.5k TEST_DIR/t.qcow2 64M | ||
418 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=512 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
419 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=512 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
420 | |||
421 | qemu-img create -f qcow2 -o cluster_size=0.5K TEST_DIR/t.qcow2 64M | ||
422 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=512 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
423 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=512 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
424 | |||
425 | qemu-img create -f qcow2 -o cluster_size=0.5M TEST_DIR/t.qcow2 64M | ||
426 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=524288 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
427 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=524288 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
428 | |||
429 | == Check compat level option == | ||
430 | |||
431 | qemu-img create -f qcow2 -o compat=0.10 TEST_DIR/t.qcow2 64M | ||
432 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=0.10 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
433 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=0.10 lazy_refcounts=off refcount_bits=16 | ||
434 | |||
435 | qemu-img create -f qcow2 -o compat=1.1 TEST_DIR/t.qcow2 64M | ||
436 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=1.1 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
437 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=1.1 lazy_refcounts=off refcount_bits=16 | ||
438 | |||
439 | qemu-img create -f qcow2 -o compat=0.42 TEST_DIR/t.qcow2 64M | ||
440 | qemu-img: TEST_DIR/t.qcow2: Invalid parameter '0.42' | ||
441 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=0.42 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
442 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=0.42 lazy_refcounts=off refcount_bits=16 | ||
443 | |||
444 | qemu-img create -f qcow2 -o compat=foobar TEST_DIR/t.qcow2 64M | ||
445 | qemu-img: TEST_DIR/t.qcow2: Invalid parameter 'foobar' | ||
446 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=foobar cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
447 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=foobar lazy_refcounts=off refcount_bits=16 | ||
448 | |||
449 | == Check preallocation option == | ||
450 | |||
451 | qemu-img create -f qcow2 -o preallocation=off TEST_DIR/t.qcow2 64M | ||
452 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=65536 preallocation=off lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
453 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 preallocation=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
454 | |||
455 | qemu-img create -f qcow2 -o preallocation=metadata TEST_DIR/t.qcow2 64M | ||
456 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=65536 preallocation=metadata lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
457 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 preallocation=metadata compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
458 | |||
459 | qemu-img create -f qcow2 -o preallocation=1234 TEST_DIR/t.qcow2 64M | ||
460 | qemu-img: TEST_DIR/t.qcow2: Invalid parameter '1234' | ||
461 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 cluster_size=65536 preallocation=1234 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
462 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 preallocation=1234 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
463 | |||
464 | == Check encryption option == | ||
465 | |||
466 | qemu-img create -f qcow2 -o encryption=off TEST_DIR/t.qcow2 64M | ||
467 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
468 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 encryption=off cluster_size=65536 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
469 | |||
470 | qemu-img create -f qcow2 --object secret,id=sec0,data=123456 -o encryption=on,encrypt.key-secret=sec0 TEST_DIR/t.qcow2 64M | ||
471 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=on encrypt.key-secret=sec0 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
472 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 encryption=on encrypt.key-secret=sec0 cluster_size=65536 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
473 | |||
474 | == Check lazy_refcounts option (only with v3) == | ||
475 | |||
476 | qemu-img create -f qcow2 -o compat=1.1,lazy_refcounts=off TEST_DIR/t.qcow2 64M | ||
477 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=1.1 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
478 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=1.1 lazy_refcounts=off refcount_bits=16 | ||
479 | |||
480 | qemu-img create -f qcow2 -o compat=1.1,lazy_refcounts=on TEST_DIR/t.qcow2 64M | ||
481 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=1.1 cluster_size=65536 lazy_refcounts=on refcount_bits=16 compression_type=zlib | ||
482 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=1.1 lazy_refcounts=on refcount_bits=16 | ||
483 | |||
484 | qemu-img create -f qcow2 -o compat=0.10,lazy_refcounts=off TEST_DIR/t.qcow2 64M | ||
485 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=0.10 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
486 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=0.10 lazy_refcounts=off refcount_bits=16 | ||
487 | |||
488 | qemu-img create -f qcow2 -o compat=0.10,lazy_refcounts=on TEST_DIR/t.qcow2 64M | ||
489 | qemu-img: TEST_DIR/t.qcow2: Lazy refcounts only supported with compatibility level 1.1 and above (use version=v3 or greater) | ||
490 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 compat=0.10 cluster_size=65536 lazy_refcounts=on refcount_bits=16 compression_type=zlib | ||
491 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=0.10 lazy_refcounts=on refcount_bits=16 | ||
492 | |||
234 | *** done | 493 | *** done |
235 | diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out | ||
236 | index XXXXXXX..XXXXXXX 100644 | ||
237 | --- a/tests/qemu-iotests/060.out | ||
238 | +++ b/tests/qemu-iotests/060.out | ||
239 | @@ -XXX,XX +XXX,XX @@ ERROR cluster 3 refcount=1 reference=3 | ||
240 | |||
241 | 1 errors were found on the image. | ||
242 | Data may be corrupted, or further writes to the image may corrupt it. | ||
243 | -incompatible_features 0x0 | ||
244 | +incompatible_features [] | ||
245 | qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with active L1 table); further corruption events will be suppressed | ||
246 | write failed: Input/output error | ||
247 | -incompatible_features 0x2 | ||
248 | +incompatible_features [1] | ||
249 | image: TEST_DIR/t.IMGFMT | ||
250 | file format: IMGFMT | ||
251 | virtual size: 64 MiB (67108864 bytes) | ||
252 | @@ -XXX,XX +XXX,XX @@ ERROR cluster 2 refcount=1 reference=2 | ||
253 | |||
254 | 2 errors were found on the image. | ||
255 | Data may be corrupted, or further writes to the image may corrupt it. | ||
256 | -incompatible_features 0x0 | ||
257 | +incompatible_features [] | ||
258 | qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with refcount block); further corruption events will be suppressed | ||
259 | write failed: Input/output error | ||
260 | -incompatible_features 0x2 | ||
261 | +incompatible_features [1] | ||
262 | ERROR refcount block 0 refcount=2 | ||
263 | ERROR cluster 2 refcount=1 reference=2 | ||
264 | Rebuilding refcount structure | ||
265 | @@ -XXX,XX +XXX,XX @@ The following inconsistencies were found and repaired: | ||
266 | |||
267 | Double checking the fixed image now... | ||
268 | No errors were found on the image. | ||
269 | -incompatible_features 0x0 | ||
270 | +incompatible_features [] | ||
271 | wrote 512/512 bytes at offset 0 | ||
272 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
273 | -incompatible_features 0x0 | ||
274 | +incompatible_features [] | ||
275 | |||
276 | === Testing cluster data reference into inactive L2 table === | ||
277 | |||
278 | @@ -XXX,XX +XXX,XX @@ Data may be corrupted, or further writes to the image may corrupt it. | ||
279 | |||
280 | 1 leaked clusters were found on the image. | ||
281 | This means waste of disk space, but no harm to data. | ||
282 | -incompatible_features 0x0 | ||
283 | +incompatible_features [] | ||
284 | qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with inactive L2 table); further corruption events will be suppressed | ||
285 | write failed: Input/output error | ||
286 | -incompatible_features 0x2 | ||
287 | +incompatible_features [1] | ||
288 | ERROR cluster 4 refcount=1 reference=2 | ||
289 | Leaked cluster 9 refcount=1 reference=0 | ||
290 | Repairing cluster 4 refcount=1 reference=2 | ||
291 | @@ -XXX,XX +XXX,XX @@ The following inconsistencies were found and repaired: | ||
292 | |||
293 | Double checking the fixed image now... | ||
294 | No errors were found on the image. | ||
295 | -incompatible_features 0x0 | ||
296 | +incompatible_features [] | ||
297 | wrote 512/512 bytes at offset 0 | ||
298 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
299 | -incompatible_features 0x0 | ||
300 | +incompatible_features [] | ||
301 | read 512/512 bytes at offset 0 | ||
302 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
303 | No errors were found on the image. | ||
304 | diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out | 494 | diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out |
305 | index XXXXXXX..XXXXXXX 100644 | 495 | index XXXXXXX..XXXXXXX 100644 |
306 | --- a/tests/qemu-iotests/061.out | 496 | --- a/tests/qemu-iotests/061.out |
307 | +++ b/tests/qemu-iotests/061.out | 497 | +++ b/tests/qemu-iotests/061.out |
308 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | 498 | @@ -XXX,XX +XXX,XX @@ qemu-img: Lazy refcounts only supported with compatibility level 1.1 and above ( |
309 | refcount_table_clusters 1 | 499 | qemu-img: Lazy refcounts only supported with compatibility level 1.1 and above (use compat=1.1 or greater) |
310 | nb_snapshots 0 | 500 | qemu-img: Unknown compatibility level 0.42 |
311 | snapshot_offset 0x0 | 501 | qemu-img: Invalid parameter 'foo' |
312 | -incompatible_features 0x0 | 502 | -qemu-img: Changing the cluster size is not supported |
313 | -compatible_features 0x1 | 503 | -qemu-img: Changing the encryption flag is not supported |
314 | -autoclear_features 0x0 | 504 | -qemu-img: Cannot change preallocation mode |
315 | +incompatible_features [] | 505 | +qemu-img: Invalid parameter 'cluster_size' |
316 | +compatible_features [0] | 506 | +This option is only supported for image creation |
317 | +autoclear_features [] | 507 | +qemu-img: Invalid parameter 'encryption' |
318 | refcount_order 4 | 508 | +This option is only supported for image creation |
319 | header_length 104 | 509 | +qemu-img: Invalid parameter 'preallocation' |
320 | 510 | +This option is only supported for image creation | |
321 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | 511 | |
322 | refcount_table_clusters 1 | 512 | === Testing correct handling of unset value === |
323 | nb_snapshots 0 | 513 | |
324 | snapshot_offset 0x0 | 514 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 |
325 | -incompatible_features 0x0 | 515 | Should work: |
326 | -compatible_features 0x0 | 516 | Should not work: |
327 | -autoclear_features 0x0 | 517 | -qemu-img: Changing the cluster size is not supported |
328 | +incompatible_features [] | 518 | +qemu-img: Invalid parameter 'cluster_size' |
329 | +compatible_features [] | 519 | +This option is only supported for image creation |
330 | +autoclear_features [] | 520 | |
331 | refcount_order 4 | 521 | === Testing zero expansion on inactive clusters === |
332 | header_length 72 | 522 | |
333 | 523 | diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out | |
334 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
335 | refcount_table_clusters 1 | ||
336 | nb_snapshots 0 | ||
337 | snapshot_offset 0x0 | ||
338 | -incompatible_features 0x0 | ||
339 | -compatible_features 0x1 | ||
340 | -autoclear_features 0x0 | ||
341 | +incompatible_features [] | ||
342 | +compatible_features [0] | ||
343 | +autoclear_features [] | ||
344 | refcount_order 4 | ||
345 | header_length 104 | ||
346 | |||
347 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
348 | refcount_table_clusters 1 | ||
349 | nb_snapshots 0 | ||
350 | snapshot_offset 0x0 | ||
351 | -incompatible_features 0x0 | ||
352 | -compatible_features 0x0 | ||
353 | -autoclear_features 0x0 | ||
354 | +incompatible_features [] | ||
355 | +compatible_features [] | ||
356 | +autoclear_features [] | ||
357 | refcount_order 4 | ||
358 | header_length 72 | ||
359 | |||
360 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
361 | refcount_table_clusters 1 | ||
362 | nb_snapshots 0 | ||
363 | snapshot_offset 0x0 | ||
364 | -incompatible_features 0x1 | ||
365 | -compatible_features 0x1 | ||
366 | -autoclear_features 0x0 | ||
367 | +incompatible_features [0] | ||
368 | +compatible_features [0] | ||
369 | +autoclear_features [] | ||
370 | refcount_order 4 | ||
371 | header_length 104 | ||
372 | |||
373 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x80000 | ||
374 | refcount_table_clusters 1 | ||
375 | nb_snapshots 0 | ||
376 | snapshot_offset 0x0 | ||
377 | -incompatible_features 0x0 | ||
378 | -compatible_features 0x0 | ||
379 | -autoclear_features 0x0 | ||
380 | +incompatible_features [] | ||
381 | +compatible_features [] | ||
382 | +autoclear_features [] | ||
383 | refcount_order 4 | ||
384 | header_length 72 | ||
385 | |||
386 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
387 | refcount_table_clusters 1 | ||
388 | nb_snapshots 0 | ||
389 | snapshot_offset 0x0 | ||
390 | -incompatible_features 0x0 | ||
391 | -compatible_features 0x40000000000 | ||
392 | -autoclear_features 0x40000000000 | ||
393 | +incompatible_features [] | ||
394 | +compatible_features [42] | ||
395 | +autoclear_features [42] | ||
396 | refcount_order 4 | ||
397 | header_length 104 | ||
398 | |||
399 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
400 | refcount_table_clusters 1 | ||
401 | nb_snapshots 0 | ||
402 | snapshot_offset 0x0 | ||
403 | -incompatible_features 0x0 | ||
404 | -compatible_features 0x0 | ||
405 | -autoclear_features 0x0 | ||
406 | +incompatible_features [] | ||
407 | +compatible_features [] | ||
408 | +autoclear_features [] | ||
409 | refcount_order 4 | ||
410 | header_length 72 | ||
411 | |||
412 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
413 | refcount_table_clusters 1 | ||
414 | nb_snapshots 0 | ||
415 | snapshot_offset 0x0 | ||
416 | -incompatible_features 0x0 | ||
417 | -compatible_features 0x0 | ||
418 | -autoclear_features 0x0 | ||
419 | +incompatible_features [] | ||
420 | +compatible_features [] | ||
421 | +autoclear_features [] | ||
422 | refcount_order 4 | ||
423 | header_length 72 | ||
424 | |||
425 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
426 | refcount_table_clusters 1 | ||
427 | nb_snapshots 0 | ||
428 | snapshot_offset 0x0 | ||
429 | -incompatible_features 0x0 | ||
430 | -compatible_features 0x1 | ||
431 | -autoclear_features 0x0 | ||
432 | +incompatible_features [] | ||
433 | +compatible_features [0] | ||
434 | +autoclear_features [] | ||
435 | refcount_order 4 | ||
436 | header_length 104 | ||
437 | |||
438 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
439 | refcount_table_clusters 1 | ||
440 | nb_snapshots 0 | ||
441 | snapshot_offset 0x0 | ||
442 | -incompatible_features 0x1 | ||
443 | -compatible_features 0x1 | ||
444 | -autoclear_features 0x0 | ||
445 | +incompatible_features [0] | ||
446 | +compatible_features [0] | ||
447 | +autoclear_features [] | ||
448 | refcount_order 4 | ||
449 | header_length 104 | ||
450 | |||
451 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x80000 | ||
452 | refcount_table_clusters 1 | ||
453 | nb_snapshots 0 | ||
454 | snapshot_offset 0x0 | ||
455 | -incompatible_features 0x0 | ||
456 | -compatible_features 0x0 | ||
457 | -autoclear_features 0x0 | ||
458 | +incompatible_features [] | ||
459 | +compatible_features [] | ||
460 | +autoclear_features [] | ||
461 | refcount_order 4 | ||
462 | header_length 104 | ||
463 | |||
464 | diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out | ||
465 | index XXXXXXX..XXXXXXX 100644 | 524 | index XXXXXXX..XXXXXXX 100644 |
466 | --- a/tests/qemu-iotests/137.out | 525 | --- a/tests/qemu-iotests/082.out |
467 | +++ b/tests/qemu-iotests/137.out | 526 | +++ b/tests/qemu-iotests/082.out |
468 | @@ -XXX,XX +XXX,XX @@ qemu-io: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are | 527 | @@ -XXX,XX +XXX,XX @@ QA output created by 082 |
469 | wrote 512/512 bytes at offset 0 | 528 | === create: Options specified more than once === |
470 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 529 | |
471 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | 530 | Testing: create -f foo -f qcow2 TEST_DIR/t.qcow2 128M |
472 | -incompatible_features 0x0 | 531 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
473 | +incompatible_features [] | 532 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16 |
474 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | 533 | image: TEST_DIR/t.IMGFMT |
475 | wrote 65536/65536 bytes at offset 0 | 534 | file format: IMGFMT |
535 | virtual size: 128 MiB (134217728 bytes) | ||
536 | cluster_size: 65536 | ||
537 | |||
538 | Testing: create -f qcow2 -o cluster_size=4k -o lazy_refcounts=on TEST_DIR/t.qcow2 128M | ||
539 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 cluster_size=4096 lazy_refcounts=on refcount_bits=16 compression_type=zlib | ||
540 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=4096 compression_type=zlib size=134217728 lazy_refcounts=on refcount_bits=16 | ||
541 | image: TEST_DIR/t.IMGFMT | ||
542 | file format: IMGFMT | ||
543 | virtual size: 128 MiB (134217728 bytes) | ||
544 | @@ -XXX,XX +XXX,XX @@ Format specific information: | ||
545 | corrupt: false | ||
546 | |||
547 | Testing: create -f qcow2 -o cluster_size=4k -o lazy_refcounts=on -o cluster_size=8k TEST_DIR/t.qcow2 128M | ||
548 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 cluster_size=8192 lazy_refcounts=on refcount_bits=16 compression_type=zlib | ||
549 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=8192 compression_type=zlib size=134217728 lazy_refcounts=on refcount_bits=16 | ||
550 | image: TEST_DIR/t.IMGFMT | ||
551 | file format: IMGFMT | ||
552 | virtual size: 128 MiB (134217728 bytes) | ||
553 | @@ -XXX,XX +XXX,XX @@ Format specific information: | ||
554 | corrupt: false | ||
555 | |||
556 | Testing: create -f qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2 128M | ||
557 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 cluster_size=8192 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
558 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=8192 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16 | ||
559 | image: TEST_DIR/t.IMGFMT | ||
560 | file format: IMGFMT | ||
561 | virtual size: 128 MiB (134217728 bytes) | ||
562 | @@ -XXX,XX +XXX,XX @@ Supported options: | ||
563 | size=<size> - Virtual disk size | ||
564 | |||
565 | Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 128M | ||
566 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2,,help cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
567 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2,,help lazy_refcounts=off refcount_bits=16 | ||
568 | |||
569 | Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,? TEST_DIR/t.qcow2 128M | ||
570 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2,,? cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
571 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2,,? lazy_refcounts=off refcount_bits=16 | ||
572 | |||
573 | Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2, -o help TEST_DIR/t.qcow2 128M | ||
574 | qemu-img: Invalid option list: backing_file=TEST_DIR/t.qcow2, | ||
575 | @@ -XXX,XX +XXX,XX @@ qemu-img: Format driver 'bochs' does not support image creation | ||
576 | === convert: Options specified more than once === | ||
577 | |||
578 | Testing: create -f qcow2 TEST_DIR/t.qcow2 128M | ||
579 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
580 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16 | ||
581 | |||
582 | Testing: convert -f foo -f qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base | ||
583 | image: TEST_DIR/t.IMGFMT.base | ||
584 | @@ -XXX,XX +XXX,XX @@ cluster_size: 65536 | ||
585 | === amend: help for -o === | ||
586 | |||
587 | Testing: amend -f qcow2 -o help TEST_DIR/t.qcow2 | ||
588 | -Creation options for 'qcow2': | ||
589 | +Amend options for 'qcow2': | ||
590 | backing_file=<str> - File name of a base image | ||
591 | backing_fmt=<str> - Image format of the base image | ||
592 | - cluster_size=<size> - qcow2 cluster size | ||
593 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
594 | - compression_type=<str> - Compression method used for image cluster compression | ||
595 | data_file=<str> - File name of an external data file | ||
596 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
597 | - encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
598 | - encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
599 | - encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
600 | - encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
601 | - encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
602 | - encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
603 | - encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
604 | - encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
605 | - encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
606 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
607 | - preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
608 | refcount_bits=<num> - Width of a reference count entry in bits | ||
609 | size=<size> - Virtual disk size | ||
610 | |||
611 | -Note that not all of these options may be amendable. | ||
612 | - | ||
613 | Testing: amend -f qcow2 -o ? TEST_DIR/t.qcow2 | ||
614 | -Creation options for 'qcow2': | ||
615 | +Amend options for 'qcow2': | ||
616 | backing_file=<str> - File name of a base image | ||
617 | backing_fmt=<str> - Image format of the base image | ||
618 | - cluster_size=<size> - qcow2 cluster size | ||
619 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
620 | - compression_type=<str> - Compression method used for image cluster compression | ||
621 | data_file=<str> - File name of an external data file | ||
622 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
623 | - encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
624 | - encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
625 | - encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
626 | - encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
627 | - encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
628 | - encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
629 | - encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
630 | - encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
631 | - encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
632 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
633 | - preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
634 | refcount_bits=<num> - Width of a reference count entry in bits | ||
635 | size=<size> - Virtual disk size | ||
636 | |||
637 | -Note that not all of these options may be amendable. | ||
638 | - | ||
639 | Testing: amend -f qcow2 -o cluster_size=4k,help TEST_DIR/t.qcow2 | ||
640 | -Creation options for 'qcow2': | ||
641 | +Amend options for 'qcow2': | ||
642 | backing_file=<str> - File name of a base image | ||
643 | backing_fmt=<str> - Image format of the base image | ||
644 | - cluster_size=<size> - qcow2 cluster size | ||
645 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
646 | - compression_type=<str> - Compression method used for image cluster compression | ||
647 | data_file=<str> - File name of an external data file | ||
648 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
649 | - encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
650 | - encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
651 | - encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
652 | - encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
653 | - encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
654 | - encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
655 | - encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
656 | - encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
657 | - encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
658 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
659 | - preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
660 | refcount_bits=<num> - Width of a reference count entry in bits | ||
661 | size=<size> - Virtual disk size | ||
662 | |||
663 | -Note that not all of these options may be amendable. | ||
664 | - | ||
665 | Testing: amend -f qcow2 -o cluster_size=4k,? TEST_DIR/t.qcow2 | ||
666 | -Creation options for 'qcow2': | ||
667 | +Amend options for 'qcow2': | ||
668 | backing_file=<str> - File name of a base image | ||
669 | backing_fmt=<str> - Image format of the base image | ||
670 | - cluster_size=<size> - qcow2 cluster size | ||
671 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
672 | - compression_type=<str> - Compression method used for image cluster compression | ||
673 | data_file=<str> - File name of an external data file | ||
674 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
675 | - encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
676 | - encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
677 | - encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
678 | - encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
679 | - encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
680 | - encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
681 | - encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
682 | - encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
683 | - encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
684 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
685 | - preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
686 | refcount_bits=<num> - Width of a reference count entry in bits | ||
687 | size=<size> - Virtual disk size | ||
688 | |||
689 | -Note that not all of these options may be amendable. | ||
690 | - | ||
691 | Testing: amend -f qcow2 -o help,cluster_size=4k TEST_DIR/t.qcow2 | ||
692 | -Creation options for 'qcow2': | ||
693 | +Amend options for 'qcow2': | ||
694 | backing_file=<str> - File name of a base image | ||
695 | backing_fmt=<str> - Image format of the base image | ||
696 | - cluster_size=<size> - qcow2 cluster size | ||
697 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
698 | - compression_type=<str> - Compression method used for image cluster compression | ||
699 | data_file=<str> - File name of an external data file | ||
700 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
701 | - encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
702 | - encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
703 | - encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
704 | - encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
705 | - encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
706 | - encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
707 | - encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
708 | - encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
709 | - encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
710 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
711 | - preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
712 | refcount_bits=<num> - Width of a reference count entry in bits | ||
713 | size=<size> - Virtual disk size | ||
714 | |||
715 | -Note that not all of these options may be amendable. | ||
716 | - | ||
717 | Testing: amend -f qcow2 -o ?,cluster_size=4k TEST_DIR/t.qcow2 | ||
718 | -Creation options for 'qcow2': | ||
719 | +Amend options for 'qcow2': | ||
720 | backing_file=<str> - File name of a base image | ||
721 | backing_fmt=<str> - Image format of the base image | ||
722 | - cluster_size=<size> - qcow2 cluster size | ||
723 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
724 | - compression_type=<str> - Compression method used for image cluster compression | ||
725 | data_file=<str> - File name of an external data file | ||
726 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
727 | - encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
728 | - encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
729 | - encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
730 | - encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
731 | - encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
732 | - encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
733 | - encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
734 | - encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
735 | - encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
736 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
737 | - preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
738 | refcount_bits=<num> - Width of a reference count entry in bits | ||
739 | size=<size> - Virtual disk size | ||
740 | |||
741 | -Note that not all of these options may be amendable. | ||
742 | - | ||
743 | Testing: amend -f qcow2 -o cluster_size=4k -o help TEST_DIR/t.qcow2 | ||
744 | -Creation options for 'qcow2': | ||
745 | +Amend options for 'qcow2': | ||
746 | backing_file=<str> - File name of a base image | ||
747 | backing_fmt=<str> - Image format of the base image | ||
748 | - cluster_size=<size> - qcow2 cluster size | ||
749 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
750 | - compression_type=<str> - Compression method used for image cluster compression | ||
751 | data_file=<str> - File name of an external data file | ||
752 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
753 | - encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
754 | - encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
755 | - encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
756 | - encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
757 | - encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
758 | - encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
759 | - encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
760 | - encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
761 | - encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
762 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
763 | - preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
764 | refcount_bits=<num> - Width of a reference count entry in bits | ||
765 | size=<size> - Virtual disk size | ||
766 | |||
767 | -Note that not all of these options may be amendable. | ||
768 | - | ||
769 | Testing: amend -f qcow2 -o cluster_size=4k -o ? TEST_DIR/t.qcow2 | ||
770 | -Creation options for 'qcow2': | ||
771 | +Amend options for 'qcow2': | ||
772 | backing_file=<str> - File name of a base image | ||
773 | backing_fmt=<str> - Image format of the base image | ||
774 | - cluster_size=<size> - qcow2 cluster size | ||
775 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
776 | - compression_type=<str> - Compression method used for image cluster compression | ||
777 | data_file=<str> - File name of an external data file | ||
778 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
779 | - encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
780 | - encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
781 | - encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
782 | - encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
783 | - encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
784 | - encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
785 | - encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
786 | - encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
787 | - encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
788 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
789 | - preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
790 | refcount_bits=<num> - Width of a reference count entry in bits | ||
791 | size=<size> - Virtual disk size | ||
792 | |||
793 | -Note that not all of these options may be amendable. | ||
794 | - | ||
795 | Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 | ||
796 | |||
797 | Testing: rebase -u -b -f qcow2 TEST_DIR/t.qcow2 | ||
798 | @@ -XXX,XX +XXX,XX @@ Testing: amend -f qcow2 -o backing_file=TEST_DIR/t.qcow2 -o ,, -o help TEST_DIR/ | ||
799 | qemu-img: Invalid option list: ,, | ||
800 | |||
801 | Testing: amend -f qcow2 -o help | ||
802 | -Creation options for 'qcow2': | ||
803 | +Amend options for 'qcow2': | ||
804 | backing_file=<str> - File name of a base image | ||
805 | backing_fmt=<str> - Image format of the base image | ||
806 | - cluster_size=<size> - qcow2 cluster size | ||
807 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
808 | - compression_type=<str> - Compression method used for image cluster compression | ||
809 | data_file=<str> - File name of an external data file | ||
810 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
811 | - encrypt.cipher-alg=<str> - Name of encryption cipher algorithm | ||
812 | - encrypt.cipher-mode=<str> - Name of encryption cipher mode | ||
813 | - encrypt.format=<str> - Encrypt the image, format choices: 'aes', 'luks' | ||
814 | - encrypt.hash-alg=<str> - Name of encryption hash algorithm | ||
815 | - encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
816 | - encrypt.ivgen-alg=<str> - Name of IV generator algorithm | ||
817 | - encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm | ||
818 | - encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase | ||
819 | - encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes) | ||
820 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
821 | - preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full) | ||
822 | refcount_bits=<num> - Width of a reference count entry in bits | ||
823 | size=<size> - Virtual disk size | ||
824 | |||
825 | -Note that not all of these options may be amendable. | ||
826 | - | ||
827 | Testing: amend -o help | ||
828 | qemu-img: Expecting one image file name | ||
829 | |||
830 | diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out | ||
831 | index XXXXXXX..XXXXXXX 100644 | ||
832 | --- a/tests/qemu-iotests/085.out | ||
833 | +++ b/tests/qemu-iotests/085.out | ||
834 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=134217728 | ||
835 | === Create a single snapshot on virtio0 === | ||
836 | |||
837 | { 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0', 'snapshot-file':'TEST_DIR/1-snapshot-v0.IMGFMT', 'format': 'IMGFMT' } } | ||
838 | -Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2.1 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
839 | +Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2.1 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
840 | {"return": {}} | ||
841 | |||
842 | === Invalid command - missing device and nodename === | ||
843 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file | ||
844 | === Create several transactional group snapshots === | ||
845 | |||
846 | { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/2-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/2-snapshot-v1.IMGFMT' } } ] } } | ||
847 | -Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/1-snapshot-v0.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
848 | -Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2.2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
849 | +Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/1-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
850 | +Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2.2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
851 | {"return": {}} | ||
852 | { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/3-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/3-snapshot-v1.IMGFMT' } } ] } } | ||
853 | -Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/2-snapshot-v0.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
854 | -Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/2-snapshot-v1.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
855 | +Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/2-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
856 | +Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/2-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
857 | {"return": {}} | ||
858 | { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/4-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/4-snapshot-v1.IMGFMT' } } ] } } | ||
859 | -Formatting 'TEST_DIR/4-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/3-snapshot-v0.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
860 | -Formatting 'TEST_DIR/4-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/3-snapshot-v1.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
861 | +Formatting 'TEST_DIR/4-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/3-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
862 | +Formatting 'TEST_DIR/4-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/3-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
863 | {"return": {}} | ||
864 | { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/5-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/5-snapshot-v1.IMGFMT' } } ] } } | ||
865 | -Formatting 'TEST_DIR/5-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/4-snapshot-v0.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
866 | -Formatting 'TEST_DIR/5-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/4-snapshot-v1.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
867 | +Formatting 'TEST_DIR/5-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/4-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
868 | +Formatting 'TEST_DIR/5-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/4-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
869 | {"return": {}} | ||
870 | { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/6-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/6-snapshot-v1.IMGFMT' } } ] } } | ||
871 | -Formatting 'TEST_DIR/6-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/5-snapshot-v0.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
872 | -Formatting 'TEST_DIR/6-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/5-snapshot-v1.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
873 | +Formatting 'TEST_DIR/6-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/5-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
874 | +Formatting 'TEST_DIR/6-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/5-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
875 | {"return": {}} | ||
876 | { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/7-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/7-snapshot-v1.IMGFMT' } } ] } } | ||
877 | -Formatting 'TEST_DIR/7-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/6-snapshot-v0.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
878 | -Formatting 'TEST_DIR/7-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/6-snapshot-v1.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
879 | +Formatting 'TEST_DIR/7-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/6-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
880 | +Formatting 'TEST_DIR/7-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/6-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
881 | {"return": {}} | ||
882 | { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/8-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/8-snapshot-v1.IMGFMT' } } ] } } | ||
883 | -Formatting 'TEST_DIR/8-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/7-snapshot-v0.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
884 | -Formatting 'TEST_DIR/8-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/7-snapshot-v1.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
885 | +Formatting 'TEST_DIR/8-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/7-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
886 | +Formatting 'TEST_DIR/8-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/7-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
887 | {"return": {}} | ||
888 | { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/9-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/9-snapshot-v1.IMGFMT' } } ] } } | ||
889 | -Formatting 'TEST_DIR/9-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/8-snapshot-v0.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
890 | -Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/8-snapshot-v1.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
891 | +Formatting 'TEST_DIR/9-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/8-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
892 | +Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/8-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
893 | {"return": {}} | ||
894 | { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/10-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/10-snapshot-v1.IMGFMT' } } ] } } | ||
895 | -Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/9-snapshot-v0.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
896 | -Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/9-snapshot-v1.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
897 | +Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/9-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
898 | +Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/9-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
899 | {"return": {}} | ||
900 | |||
901 | === Create a couple of snapshots using blockdev-snapshot === | ||
902 | diff --git a/tests/qemu-iotests/144.out b/tests/qemu-iotests/144.out | ||
903 | index XXXXXXX..XXXXXXX 100644 | ||
904 | --- a/tests/qemu-iotests/144.out | ||
905 | +++ b/tests/qemu-iotests/144.out | ||
906 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=536870912 | ||
907 | { 'execute': 'qmp_capabilities' } | ||
908 | {"return": {}} | ||
909 | { 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0', 'snapshot-file':'TEST_DIR/tmp.IMGFMT', 'format': 'IMGFMT' } } | ||
910 | -Formatting 'TEST_DIR/tmp.qcow2', fmt=qcow2 size=536870912 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
911 | +Formatting 'TEST_DIR/tmp.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=536870912 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
912 | {"return": {}} | ||
913 | |||
914 | === Performing block-commit on active layer === | ||
915 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/tmp.qcow2', fmt=qcow2 size=536870912 backing_file=TEST_DIR/ | ||
916 | === Performing Live Snapshot 2 === | ||
917 | |||
918 | { 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0', 'snapshot-file':'TEST_DIR/tmp2.IMGFMT', 'format': 'IMGFMT' } } | ||
919 | -Formatting 'TEST_DIR/tmp2.qcow2', fmt=qcow2 size=536870912 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
920 | +Formatting 'TEST_DIR/tmp2.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=536870912 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
921 | {"return": {}} | ||
922 | *** done | ||
923 | diff --git a/tests/qemu-iotests/182.out b/tests/qemu-iotests/182.out | ||
924 | index XXXXXXX..XXXXXXX 100644 | ||
925 | --- a/tests/qemu-iotests/182.out | ||
926 | +++ b/tests/qemu-iotests/182.out | ||
927 | @@ -XXX,XX +XXX,XX @@ Is another process using the image [TEST_DIR/t.qcow2]? | ||
928 | {'execute': 'blockdev-add', 'arguments': { 'node-name': 'node0', 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT', 'locking': 'on' } } | ||
929 | {"return": {}} | ||
930 | {'execute': 'blockdev-snapshot-sync', 'arguments': { 'node-name': 'node0', 'snapshot-file': 'TEST_DIR/t.IMGFMT.overlay', 'snapshot-node-name': 'node1' } } | ||
931 | -Formatting 'TEST_DIR/t.qcow2.overlay', fmt=qcow2 size=197120 backing_file=TEST_DIR/t.qcow2 backing_fmt=file cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
932 | +Formatting 'TEST_DIR/t.qcow2.overlay', fmt=qcow2 cluster_size=65536 compression_type=zlib size=197120 backing_file=TEST_DIR/t.qcow2 backing_fmt=file lazy_refcounts=off refcount_bits=16 | ||
933 | {"return": {}} | ||
934 | {'execute': 'blockdev-add', 'arguments': { 'node-name': 'node1', 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT', 'locking': 'on' } } | ||
935 | {"return": {}} | ||
936 | diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out | ||
937 | index XXXXXXX..XXXXXXX 100644 | ||
938 | --- a/tests/qemu-iotests/185.out | ||
939 | +++ b/tests/qemu-iotests/185.out | ||
940 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864 | ||
941 | === Creating backing chain === | ||
942 | |||
943 | { 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'disk', 'snapshot-file': 'TEST_DIR/t.IMGFMT.mid', 'format': 'IMGFMT', 'mode': 'absolute-paths' } } | ||
944 | -Formatting 'TEST_DIR/t.qcow2.mid', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.qcow2.base backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
945 | +Formatting 'TEST_DIR/t.qcow2.mid', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 backing_file=TEST_DIR/t.qcow2.base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
946 | {"return": {}} | ||
947 | { 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io disk "write 0 4M"' } } | ||
948 | wrote 4194304/4194304 bytes at offset 0 | ||
949 | 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
950 | {"return": ""} | ||
951 | { 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'disk', 'snapshot-file': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'absolute-paths' } } | ||
952 | -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.qcow2.mid backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
953 | +Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 backing_file=TEST_DIR/t.qcow2.mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 | ||
954 | {"return": {}} | ||
955 | |||
956 | === Start commit job and exit qemu === | ||
957 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q | ||
958 | { 'execute': 'qmp_capabilities' } | ||
959 | {"return": {}} | ||
960 | { 'execute': 'drive-mirror', 'arguments': { 'device': 'disk', 'target': 'TEST_DIR/t.IMGFMT.copy', 'format': 'IMGFMT', 'sync': 'full', 'speed': 65536 } } | ||
961 | -Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
962 | +Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
963 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} | ||
964 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} | ||
965 | {"return": {}} | ||
966 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 l | ||
967 | { 'execute': 'qmp_capabilities' } | ||
968 | {"return": {}} | ||
969 | { 'execute': 'drive-backup', 'arguments': { 'device': 'disk', 'target': 'TEST_DIR/t.IMGFMT.copy', 'format': 'IMGFMT', 'sync': 'full', 'speed': 65536 } } | ||
970 | -Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
971 | +Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
972 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} | ||
973 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} | ||
974 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "paused", "id": "disk"}} | ||
975 | diff --git a/tests/qemu-iotests/255.out b/tests/qemu-iotests/255.out | ||
976 | index XXXXXXX..XXXXXXX 100644 | ||
977 | --- a/tests/qemu-iotests/255.out | ||
978 | +++ b/tests/qemu-iotests/255.out | ||
979 | @@ -XXX,XX +XXX,XX @@ Finishing a commit job with background reads | ||
980 | |||
981 | === Create backing chain and start VM === | ||
982 | |||
983 | -Formatting 'TEST_DIR/PID-t.qcow2.mid', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
984 | +Formatting 'TEST_DIR/PID-t.qcow2.mid', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16 | ||
985 | |||
986 | -Formatting 'TEST_DIR/PID-t.qcow2', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
987 | +Formatting 'TEST_DIR/PID-t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16 | ||
988 | |||
989 | === Start background read requests === | ||
990 | |||
991 | @@ -XXX,XX +XXX,XX @@ Closing the VM while a job is being cancelled | ||
992 | |||
993 | === Create images and start VM === | ||
994 | |||
995 | -Formatting 'TEST_DIR/PID-src.qcow2', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
996 | +Formatting 'TEST_DIR/PID-src.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16 | ||
997 | |||
998 | -Formatting 'TEST_DIR/PID-dst.qcow2', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
999 | +Formatting 'TEST_DIR/PID-dst.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16 | ||
1000 | |||
1001 | wrote 1048576/1048576 bytes at offset 0 | ||
1002 | 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
1003 | diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out | ||
1004 | index XXXXXXX..XXXXXXX 100644 | ||
1005 | --- a/tests/qemu-iotests/274.out | ||
1006 | +++ b/tests/qemu-iotests/274.out | ||
1007 | @@ -XXX,XX +XXX,XX @@ | ||
1008 | == Commit tests == | ||
1009 | -Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=2097152 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1010 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16 | ||
1011 | |||
1012 | -Formatting 'TEST_DIR/PID-mid', fmt=qcow2 size=1048576 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1013 | +Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base lazy_refcounts=off refcount_bits=16 | ||
1014 | |||
1015 | -Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=2097152 backing_file=TEST_DIR/PID-mid cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1016 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid lazy_refcounts=off refcount_bits=16 | ||
1017 | |||
1018 | wrote 2097152/2097152 bytes at offset 0 | ||
1019 | 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
1020 | @@ -XXX,XX +XXX,XX @@ read 1048576/1048576 bytes at offset 1048576 | ||
1021 | 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
1022 | |||
1023 | === Testing HMP commit (top -> mid) === | ||
1024 | -Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=2097152 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1025 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16 | ||
1026 | |||
1027 | -Formatting 'TEST_DIR/PID-mid', fmt=qcow2 size=1048576 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1028 | +Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base lazy_refcounts=off refcount_bits=16 | ||
1029 | |||
1030 | -Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=2097152 backing_file=TEST_DIR/PID-mid cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1031 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid lazy_refcounts=off refcount_bits=16 | ||
1032 | |||
1033 | wrote 2097152/2097152 bytes at offset 0 | ||
1034 | 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
1035 | @@ -XXX,XX +XXX,XX @@ read 1048576/1048576 bytes at offset 1048576 | ||
1036 | 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
1037 | |||
1038 | === Testing QMP active commit (top -> mid) === | ||
1039 | -Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=2097152 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1040 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16 | ||
1041 | |||
1042 | -Formatting 'TEST_DIR/PID-mid', fmt=qcow2 size=1048576 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1043 | +Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base lazy_refcounts=off refcount_bits=16 | ||
1044 | |||
1045 | -Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=2097152 backing_file=TEST_DIR/PID-mid cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1046 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid lazy_refcounts=off refcount_bits=16 | ||
1047 | |||
1048 | wrote 2097152/2097152 bytes at offset 0 | ||
1049 | 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
1050 | @@ -XXX,XX +XXX,XX @@ read 1048576/1048576 bytes at offset 1048576 | ||
1051 | |||
1052 | == Resize tests == | ||
1053 | === preallocation=off === | ||
1054 | -Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=6442450944 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1055 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=6442450944 lazy_refcounts=off refcount_bits=16 | ||
1056 | |||
1057 | -Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=1073741824 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1058 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1073741824 backing_file=TEST_DIR/PID-base lazy_refcounts=off refcount_bits=16 | ||
1059 | |||
1060 | wrote 65536/65536 bytes at offset 5368709120 | ||
476 | 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 1061 | 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
477 | diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py | 1062 | @@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 5368709120 |
478 | index XXXXXXX..XXXXXXX 100755 | 1063 | { "start": 1073741824, "length": 7516192768, "depth": 0, "zero": true, "data": false}] |
479 | --- a/tests/qemu-iotests/qcow2.py | 1064 | |
480 | +++ b/tests/qemu-iotests/qcow2.py | 1065 | === preallocation=metadata === |
481 | @@ -XXX,XX +XXX,XX @@ class QcowHeader: | 1066 | -Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=34359738368 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
482 | [ uint64_t, '%#x', 'snapshot_offset' ], | 1067 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=34359738368 lazy_refcounts=off refcount_bits=16 |
483 | 1068 | ||
484 | # Version 3 header fields | 1069 | -Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=32212254720 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
485 | - [ uint64_t, '%#x', 'incompatible_features' ], | 1070 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=32212254720 backing_file=TEST_DIR/PID-base lazy_refcounts=off refcount_bits=16 |
486 | - [ uint64_t, '%#x', 'compatible_features' ], | 1071 | |
487 | - [ uint64_t, '%#x', 'autoclear_features' ], | 1072 | wrote 65536/65536 bytes at offset 33285996544 |
488 | + [ uint64_t, 'mask', 'incompatible_features' ], | 1073 | 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
489 | + [ uint64_t, 'mask', 'compatible_features' ], | 1074 | @@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 33285996544 |
490 | + [ uint64_t, 'mask', 'autoclear_features' ], | 1075 | { "start": 34896609280, "length": 536870912, "depth": 0, "zero": true, "data": false, "offset": 2685075456}] |
491 | [ uint32_t, '%d', 'refcount_order' ], | 1076 | |
492 | [ uint32_t, '%d', 'header_length' ], | 1077 | === preallocation=falloc === |
493 | ]; | 1078 | -Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=10485760 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
494 | @@ -XXX,XX +XXX,XX @@ class QcowHeader: | 1079 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=10485760 lazy_refcounts=off refcount_bits=16 |
495 | 1080 | ||
496 | def dump(self): | 1081 | -Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=5242880 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
497 | for f in QcowHeader.fields: | 1082 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=5242880 backing_file=TEST_DIR/PID-base lazy_refcounts=off refcount_bits=16 |
498 | - print("%-25s" % f[2], f[1] % self.__dict__[f[2]]) | 1083 | |
499 | + value = self.__dict__[f[2]] | 1084 | wrote 65536/65536 bytes at offset 9437184 |
500 | + if f[1] == 'mask': | 1085 | 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
501 | + bits = [] | 1086 | @@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 9437184 |
502 | + for bit in range(64): | 1087 | { "start": 5242880, "length": 10485760, "depth": 0, "zero": false, "data": true, "offset": 327680}] |
503 | + if value & (1 << bit): | 1088 | |
504 | + bits.append(bit) | 1089 | === preallocation=full === |
505 | + value_str = str(bits) | 1090 | -Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=16777216 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
506 | + else: | 1091 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=16777216 lazy_refcounts=off refcount_bits=16 |
507 | + value_str = f[1] % value | 1092 | |
508 | + | 1093 | -Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=8388608 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib |
509 | + print("%-25s" % f[2], value_str) | 1094 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=8388608 backing_file=TEST_DIR/PID-base lazy_refcounts=off refcount_bits=16 |
510 | print("") | 1095 | |
511 | 1096 | wrote 65536/65536 bytes at offset 11534336 | |
512 | def dump_extensions(self): | 1097 | 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
1098 | @@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 11534336 | ||
1099 | { "start": 8388608, "length": 4194304, "depth": 0, "zero": false, "data": true, "offset": 327680}] | ||
1100 | |||
1101 | === preallocation=off === | ||
1102 | -Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=393216 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1103 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=393216 lazy_refcounts=off refcount_bits=16 | ||
1104 | |||
1105 | -Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=259072 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1106 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=259072 backing_file=TEST_DIR/PID-base lazy_refcounts=off refcount_bits=16 | ||
1107 | |||
1108 | wrote 65536/65536 bytes at offset 259072 | ||
1109 | 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
1110 | @@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 259072 | ||
1111 | { "start": 262144, "length": 262144, "depth": 0, "zero": true, "data": false}] | ||
1112 | |||
1113 | === preallocation=off === | ||
1114 | -Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=409600 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1115 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=409600 lazy_refcounts=off refcount_bits=16 | ||
1116 | |||
1117 | -Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=262144 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1118 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=262144 backing_file=TEST_DIR/PID-base lazy_refcounts=off refcount_bits=16 | ||
1119 | |||
1120 | wrote 65536/65536 bytes at offset 344064 | ||
1121 | 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
1122 | @@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 344064 | ||
1123 | { "start": 262144, "length": 262144, "depth": 0, "zero": true, "data": false}] | ||
1124 | |||
1125 | === preallocation=off === | ||
1126 | -Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=524288 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1127 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=524288 lazy_refcounts=off refcount_bits=16 | ||
1128 | |||
1129 | -Formatting 'TEST_DIR/PID-top', fmt=qcow2 size=262144 backing_file=TEST_DIR/PID-base cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1130 | +Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=262144 backing_file=TEST_DIR/PID-base lazy_refcounts=off refcount_bits=16 | ||
1131 | |||
1132 | wrote 65536/65536 bytes at offset 446464 | ||
1133 | 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
1134 | diff --git a/tests/qemu-iotests/280.out b/tests/qemu-iotests/280.out | ||
1135 | index XXXXXXX..XXXXXXX 100644 | ||
1136 | --- a/tests/qemu-iotests/280.out | ||
1137 | +++ b/tests/qemu-iotests/280.out | ||
1138 | @@ -XXX,XX +XXX,XX @@ | ||
1139 | -Formatting 'TEST_DIR/PID-base', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib | ||
1140 | +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16 | ||
1141 | |||
1142 | === Launch VM === | ||
1143 | Enabling migration QMP events on VM... | ||
513 | -- | 1144 | -- |
514 | 2.24.1 | 1145 | 2.26.2 |
515 | 1146 | ||
516 | 1147 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Commit 6f6e1698a6 desugarized "-machine accel=" to a list | 3 | rename the write_func to create_write_func, and init_func to create_init_func. |
4 | of "-accel" options. Since now "-machine accel" and "-accel" | 4 | This is preparation for other write_func that will be used to update the encryption keys. |
5 | became incompatible, update the iotests to the new format. | ||
6 | 5 | ||
7 | Error reported here: | 6 | No functional changes |
8 | https://gitlab.com/qemu-project/qemu/-/jobs/385801004#L3400 | ||
9 | 7 | ||
10 | Reported-by: GitLab CI | 8 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> |
11 | Fixes: 6f6e1698a6 (vl: configure accelerators from -accel options) | 9 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> |
12 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 10 | Message-Id: <20200608094030.670121-7-mlevitsk@redhat.com> |
13 | Message-id: 20200106130951.29873-1-philmd@redhat.com | ||
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 11 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
15 | --- | 12 | --- |
16 | tests/qemu-iotests/235 | 2 +- | 13 | block/crypto.c | 25 ++++++++++++------------- |
17 | tests/qemu-iotests/check | 6 +++--- | 14 | 1 file changed, 12 insertions(+), 13 deletions(-) |
18 | 2 files changed, 4 insertions(+), 4 deletions(-) | ||
19 | 15 | ||
20 | diff --git a/tests/qemu-iotests/235 b/tests/qemu-iotests/235 | 16 | diff --git a/block/crypto.c b/block/crypto.c |
21 | index XXXXXXX..XXXXXXX 100755 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/tests/qemu-iotests/235 | 18 | --- a/block/crypto.c |
23 | +++ b/tests/qemu-iotests/235 | 19 | +++ b/block/crypto.c |
24 | @@ -XXX,XX +XXX,XX @@ qemu_img_create('-f', iotests.imgfmt, '-o', 'preallocation=metadata', disk, | 20 | @@ -XXX,XX +XXX,XX @@ struct BlockCryptoCreateData { |
25 | str(size)) | 21 | }; |
26 | 22 | ||
27 | vm = QEMUMachine(iotests.qemu_prog) | 23 | |
28 | -vm.add_args('-machine', 'accel=kvm:tcg') | 24 | -static ssize_t block_crypto_write_func(QCryptoBlock *block, |
29 | +vm.add_args('-accel', 'kvm', '-accel', 'tcg') | 25 | - size_t offset, |
30 | if iotests.qemu_default_machine == 's390-ccw-virtio': | 26 | - const uint8_t *buf, |
31 | vm.add_args('-no-shutdown') | 27 | - size_t buflen, |
32 | vm.add_args('-drive', 'id=src,file=' + disk) | 28 | - void *opaque, |
33 | diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check | 29 | - Error **errp) |
34 | index XXXXXXX..XXXXXXX 100755 | 30 | +static ssize_t block_crypto_create_write_func(QCryptoBlock *block, |
35 | --- a/tests/qemu-iotests/check | 31 | + size_t offset, |
36 | +++ b/tests/qemu-iotests/check | 32 | + const uint8_t *buf, |
37 | @@ -XXX,XX +XXX,XX @@ export QEMU_PROG="$(type -p "$QEMU_PROG")" | 33 | + size_t buflen, |
38 | 34 | + void *opaque, | |
39 | case "$QEMU_PROG" in | 35 | + Error **errp) |
40 | *qemu-system-arm|*qemu-system-aarch64) | 36 | { |
41 | - export QEMU_OPTIONS="-nodefaults -display none -machine virt,accel=qtest" | 37 | struct BlockCryptoCreateData *data = opaque; |
42 | + export QEMU_OPTIONS="-nodefaults -display none -machine virt -accel qtest" | 38 | ssize_t ret; |
43 | ;; | 39 | @@ -XXX,XX +XXX,XX @@ static ssize_t block_crypto_write_func(QCryptoBlock *block, |
44 | *qemu-system-tricore) | 40 | return ret; |
45 | - export QEMU_OPTIONS="-nodefaults -display none -machine tricore_testboard,accel=qtest" | 41 | } |
46 | + export QEMU_OPTIONS="-nodefaults -display none -machine tricore_testboard -accel qtest" | 42 | |
47 | ;; | 43 | - |
48 | *) | 44 | -static ssize_t block_crypto_init_func(QCryptoBlock *block, |
49 | - export QEMU_OPTIONS="-nodefaults -display none -machine accel=qtest" | 45 | - size_t headerlen, |
50 | + export QEMU_OPTIONS="-nodefaults -display none -accel qtest" | 46 | - void *opaque, |
51 | ;; | 47 | - Error **errp) |
52 | esac | 48 | +static ssize_t block_crypto_create_init_func(QCryptoBlock *block, |
49 | + size_t headerlen, | ||
50 | + void *opaque, | ||
51 | + Error **errp) | ||
52 | { | ||
53 | struct BlockCryptoCreateData *data = opaque; | ||
54 | Error *local_error = NULL; | ||
55 | @@ -XXX,XX +XXX,XX @@ static int block_crypto_co_create_generic(BlockDriverState *bs, | ||
56 | }; | ||
57 | |||
58 | crypto = qcrypto_block_create(opts, NULL, | ||
59 | - block_crypto_init_func, | ||
60 | - block_crypto_write_func, | ||
61 | + block_crypto_create_init_func, | ||
62 | + block_crypto_create_write_func, | ||
63 | &data, | ||
64 | errp); | ||
53 | 65 | ||
54 | -- | 66 | -- |
55 | 2.24.1 | 67 | 2.26.2 |
56 | 68 | ||
57 | 69 | diff view generated by jsdifflib |
1 | Just rm will not delete external data files. Use _rm_test_img every | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | time we delete a test image. | 2 | |
3 | 3 | This implements the encryption key management using the generic code in | |
4 | (In the process, clean up the indentation of every _cleanup() this patch | 4 | qcrypto layer and exposes it to the user via qemu-img |
5 | touches.) | 5 | |
6 | 6 | This code adds another 'write_func' because the initialization | |
7 | ((Also, use quotes consistently. I am happy to see unquoted instances | 7 | write_func works directly on the underlying file, and amend |
8 | like "rm -rf $TEST_DIR/..." go.)) | 8 | works on instance of luks device. |
9 | 9 | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | This commit also adds a 'hack/workaround' I and Kevin Wolf (thanks) |
11 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 11 | made to make the driver both support write sharing (to avoid breaking the users), |
12 | Message-id: 20191107163708.833192-16-mreitz@redhat.com | 12 | and be safe against concurrent metadata update (the keyslots) |
13 | |||
14 | Eventually the write sharing for luks driver will be deprecated | ||
15 | and removed together with this hack. | ||
16 | |||
17 | The hack is that we ask (as a format driver) for BLK_PERM_CONSISTENT_READ | ||
18 | and then when we want to update the keys, we unshare that permission. | ||
19 | So if someone else has the image open, even readonly, encryption | ||
20 | key update will fail gracefully. | ||
21 | |||
22 | Also thanks to Daniel Berrange for the idea of | ||
23 | unsharing read, rather that write permission which allows | ||
24 | to avoid cases when the other user had opened the image read-only. | ||
25 | |||
26 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
27 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
28 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
29 | Message-Id: <20200608094030.670121-8-mlevitsk@redhat.com> | ||
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 30 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
14 | --- | 31 | --- |
15 | tests/qemu-iotests/019 | 6 +++--- | 32 | block/crypto.h | 34 +++++++++++++ |
16 | tests/qemu-iotests/020 | 6 +++--- | 33 | block/crypto.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++-- |
17 | tests/qemu-iotests/024 | 10 +++++----- | 34 | 2 files changed, 161 insertions(+), 3 deletions(-) |
18 | tests/qemu-iotests/028 | 2 +- | 35 | |
19 | tests/qemu-iotests/029 | 2 +- | 36 | diff --git a/block/crypto.h b/block/crypto.h |
20 | tests/qemu-iotests/043 | 4 +++- | 37 | index XXXXXXX..XXXXXXX 100644 |
21 | tests/qemu-iotests/048 | 2 +- | 38 | --- a/block/crypto.h |
22 | tests/qemu-iotests/050 | 4 ++-- | 39 | +++ b/block/crypto.h |
23 | tests/qemu-iotests/053 | 4 ++-- | 40 | @@ -XXX,XX +XXX,XX @@ |
24 | tests/qemu-iotests/058 | 2 +- | 41 | #define BLOCK_CRYPTO_OPT_LUKS_IVGEN_HASH_ALG "ivgen-hash-alg" |
25 | tests/qemu-iotests/059 | 2 +- | 42 | #define BLOCK_CRYPTO_OPT_LUKS_HASH_ALG "hash-alg" |
26 | tests/qemu-iotests/061 | 2 +- | 43 | #define BLOCK_CRYPTO_OPT_LUKS_ITER_TIME "iter-time" |
27 | tests/qemu-iotests/063 | 6 ++++-- | 44 | +#define BLOCK_CRYPTO_OPT_LUKS_KEYSLOT "keyslot" |
28 | tests/qemu-iotests/069 | 2 +- | 45 | +#define BLOCK_CRYPTO_OPT_LUKS_STATE "state" |
29 | tests/qemu-iotests/074 | 2 +- | 46 | +#define BLOCK_CRYPTO_OPT_LUKS_OLD_SECRET "old-secret" |
30 | tests/qemu-iotests/080 | 2 +- | 47 | +#define BLOCK_CRYPTO_OPT_LUKS_NEW_SECRET "new-secret" |
31 | tests/qemu-iotests/081 | 6 +++--- | 48 | + |
32 | tests/qemu-iotests/085 | 9 ++++++--- | 49 | |
33 | tests/qemu-iotests/088 | 2 +- | 50 | #define BLOCK_CRYPTO_OPT_DEF_LUKS_KEY_SECRET(prefix) \ |
34 | tests/qemu-iotests/092 | 2 +- | 51 | BLOCK_CRYPTO_OPT_DEF_KEY_SECRET(prefix, \ |
35 | tests/qemu-iotests/094 | 2 +- | 52 | @@ -XXX,XX +XXX,XX @@ |
36 | tests/qemu-iotests/095 | 5 +++-- | 53 | .help = "Time to spend in PBKDF in milliseconds", \ |
37 | tests/qemu-iotests/099 | 7 ++++--- | 54 | } |
38 | tests/qemu-iotests/109 | 4 ++-- | 55 | |
39 | tests/qemu-iotests/110 | 4 ++-- | 56 | +#define BLOCK_CRYPTO_OPT_DEF_LUKS_STATE(prefix) \ |
40 | tests/qemu-iotests/122 | 6 ++++-- | 57 | + { \ |
41 | tests/qemu-iotests/123 | 2 +- | 58 | + .name = prefix BLOCK_CRYPTO_OPT_LUKS_STATE, \ |
42 | tests/qemu-iotests/141 | 4 +++- | 59 | + .type = QEMU_OPT_STRING, \ |
43 | tests/qemu-iotests/142 | 2 +- | 60 | + .help = "Select new state of affected keyslots (active/inactive)",\ |
44 | tests/qemu-iotests/144 | 4 +++- | 61 | + } |
45 | tests/qemu-iotests/153 | 10 +++------- | 62 | + |
46 | tests/qemu-iotests/156 | 8 ++++++-- | 63 | +#define BLOCK_CRYPTO_OPT_DEF_LUKS_KEYSLOT(prefix) \ |
47 | tests/qemu-iotests/159 | 2 +- | 64 | + { \ |
48 | tests/qemu-iotests/160 | 3 ++- | 65 | + .name = prefix BLOCK_CRYPTO_OPT_LUKS_KEYSLOT, \ |
49 | tests/qemu-iotests/161 | 4 ++-- | 66 | + .type = QEMU_OPT_NUMBER, \ |
50 | tests/qemu-iotests/170 | 2 +- | 67 | + .help = "Select a single keyslot to modify explicitly",\ |
51 | tests/qemu-iotests/172 | 6 +++--- | 68 | + } |
52 | tests/qemu-iotests/173 | 3 ++- | 69 | + |
53 | tests/qemu-iotests/178 | 2 +- | 70 | +#define BLOCK_CRYPTO_OPT_DEF_LUKS_OLD_SECRET(prefix) \ |
54 | tests/qemu-iotests/182 | 2 +- | 71 | + { \ |
55 | tests/qemu-iotests/183 | 2 +- | 72 | + .name = prefix BLOCK_CRYPTO_OPT_LUKS_OLD_SECRET, \ |
56 | tests/qemu-iotests/185 | 4 ++-- | 73 | + .type = QEMU_OPT_STRING, \ |
57 | tests/qemu-iotests/187 | 6 +++--- | 74 | + .help = "Select all keyslots that match this password", \ |
58 | tests/qemu-iotests/190 | 2 +- | 75 | + } |
59 | tests/qemu-iotests/191 | 6 +++--- | 76 | + |
60 | tests/qemu-iotests/195 | 2 +- | 77 | +#define BLOCK_CRYPTO_OPT_DEF_LUKS_NEW_SECRET(prefix) \ |
61 | tests/qemu-iotests/197 | 2 +- | 78 | + { \ |
62 | tests/qemu-iotests/200 | 3 ++- | 79 | + .name = prefix BLOCK_CRYPTO_OPT_LUKS_NEW_SECRET, \ |
63 | tests/qemu-iotests/215 | 2 +- | 80 | + .type = QEMU_OPT_STRING, \ |
64 | tests/qemu-iotests/225 | 2 +- | 81 | + .help = "New secret to set in the matching keyslots. " \ |
65 | tests/qemu-iotests/229 | 3 ++- | 82 | + "Empty string to erase", \ |
66 | tests/qemu-iotests/232 | 4 +++- | 83 | + } |
67 | tests/qemu-iotests/243 | 2 +- | 84 | + |
68 | tests/qemu-iotests/244 | 4 ++-- | 85 | QCryptoBlockCreateOptions * |
69 | tests/qemu-iotests/247 | 4 +++- | 86 | block_crypto_create_opts_init(QDict *opts, Error **errp); |
70 | tests/qemu-iotests/249 | 4 ++-- | 87 | |
71 | tests/qemu-iotests/252 | 2 +- | 88 | diff --git a/block/crypto.c b/block/crypto.c |
72 | 57 files changed, 118 insertions(+), 95 deletions(-) | 89 | index XXXXXXX..XXXXXXX 100644 |
73 | 90 | --- a/block/crypto.c | |
74 | diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019 | 91 | +++ b/block/crypto.c |
75 | index XXXXXXX..XXXXXXX 100755 | 92 | @@ -XXX,XX +XXX,XX @@ typedef struct BlockCrypto BlockCrypto; |
76 | --- a/tests/qemu-iotests/019 | 93 | |
77 | +++ b/tests/qemu-iotests/019 | 94 | struct BlockCrypto { |
78 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | 95 | QCryptoBlock *block; |
79 | 96 | + bool updating_keys; | |
80 | _cleanup() | 97 | }; |
98 | |||
99 | |||
100 | @@ -XXX,XX +XXX,XX @@ static ssize_t block_crypto_read_func(QCryptoBlock *block, | ||
101 | return ret; | ||
102 | } | ||
103 | |||
104 | +static ssize_t block_crypto_write_func(QCryptoBlock *block, | ||
105 | + size_t offset, | ||
106 | + const uint8_t *buf, | ||
107 | + size_t buflen, | ||
108 | + void *opaque, | ||
109 | + Error **errp) | ||
110 | +{ | ||
111 | + BlockDriverState *bs = opaque; | ||
112 | + ssize_t ret; | ||
113 | + | ||
114 | + ret = bdrv_pwrite(bs->file, offset, buf, buflen); | ||
115 | + if (ret < 0) { | ||
116 | + error_setg_errno(errp, -ret, "Could not write encryption header"); | ||
117 | + return ret; | ||
118 | + } | ||
119 | + return ret; | ||
120 | +} | ||
121 | + | ||
122 | |||
123 | struct BlockCryptoCreateData { | ||
124 | BlockBackend *blk; | ||
125 | @@ -XXX,XX +XXX,XX @@ static QemuOptsList block_crypto_create_opts_luks = { | ||
126 | }; | ||
127 | |||
128 | |||
129 | +static QemuOptsList block_crypto_amend_opts_luks = { | ||
130 | + .name = "crypto", | ||
131 | + .head = QTAILQ_HEAD_INITIALIZER(block_crypto_create_opts_luks.head), | ||
132 | + .desc = { | ||
133 | + BLOCK_CRYPTO_OPT_DEF_LUKS_STATE(""), | ||
134 | + BLOCK_CRYPTO_OPT_DEF_LUKS_KEYSLOT(""), | ||
135 | + BLOCK_CRYPTO_OPT_DEF_LUKS_OLD_SECRET(""), | ||
136 | + BLOCK_CRYPTO_OPT_DEF_LUKS_NEW_SECRET(""), | ||
137 | + BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME(""), | ||
138 | + { /* end of list */ } | ||
139 | + }, | ||
140 | +}; | ||
141 | + | ||
142 | QCryptoBlockOpenOptions * | ||
143 | block_crypto_open_opts_init(QDict *opts, Error **errp) | ||
81 | { | 144 | { |
82 | - _cleanup_test_img | 145 | @@ -XXX,XX +XXX,XX @@ block_crypto_get_specific_info_luks(BlockDriverState *bs, Error **errp) |
83 | - rm -f "$TEST_IMG.base" | 146 | return spec_info; |
84 | - rm -f "$TEST_IMG.orig" | ||
85 | + _cleanup_test_img | ||
86 | + _rm_test_img "$TEST_IMG.base" | ||
87 | + _rm_test_img "$TEST_IMG.orig" | ||
88 | } | 147 | } |
89 | trap "_cleanup; exit \$status" 0 1 2 3 15 | 148 | |
90 | 149 | +static int | |
91 | diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020 | 150 | +block_crypto_amend_options_luks(BlockDriverState *bs, |
92 | index XXXXXXX..XXXXXXX 100755 | 151 | + QemuOpts *opts, |
93 | --- a/tests/qemu-iotests/020 | 152 | + BlockDriverAmendStatusCB *status_cb, |
94 | +++ b/tests/qemu-iotests/020 | 153 | + void *cb_opaque, |
95 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | 154 | + bool force, |
96 | 155 | + Error **errp) | |
97 | _cleanup() | 156 | +{ |
98 | { | 157 | + BlockCrypto *crypto = bs->opaque; |
99 | - _cleanup_test_img | 158 | + QDict *cryptoopts = NULL; |
100 | - rm -f "$TEST_IMG.base" | 159 | + QCryptoBlockAmendOptions *amend_options = NULL; |
101 | - rm -f "$TEST_IMG.orig" | 160 | + int ret; |
102 | + _cleanup_test_img | 161 | + |
103 | + _rm_test_img "$TEST_IMG.base" | 162 | + assert(crypto); |
104 | + _rm_test_img "$TEST_IMG.orig" | 163 | + assert(crypto->block); |
105 | } | 164 | + crypto->updating_keys = true; |
106 | trap "_cleanup; exit \$status" 0 1 2 3 15 | 165 | + |
107 | 166 | + ret = bdrv_child_refresh_perms(bs, bs->file, errp); | |
108 | diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024 | 167 | + if (ret < 0) { |
109 | index XXXXXXX..XXXXXXX 100755 | 168 | + goto cleanup; |
110 | --- a/tests/qemu-iotests/024 | 169 | + } |
111 | +++ b/tests/qemu-iotests/024 | 170 | + |
112 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | 171 | + cryptoopts = qemu_opts_to_qdict(opts, NULL); |
113 | _cleanup() | 172 | + qdict_put_str(cryptoopts, "format", "luks"); |
114 | { | 173 | + amend_options = block_crypto_amend_opts_init(cryptoopts, errp); |
115 | _cleanup_test_img | 174 | + if (!amend_options) { |
116 | - rm -f "$TEST_DIR/t.$IMGFMT.base_old" | 175 | + ret = -EINVAL; |
117 | - rm -f "$TEST_DIR/t.$IMGFMT.base_new" | 176 | + goto cleanup; |
118 | + _rm_test_img "$TEST_DIR/t.$IMGFMT.base_old" | 177 | + } |
119 | + _rm_test_img "$TEST_DIR/t.$IMGFMT.base_new" | 178 | + |
120 | 179 | + ret = qcrypto_block_amend_options(crypto->block, | |
121 | - rm -f "$TEST_DIR/subdir/t.$IMGFMT" | 180 | + block_crypto_read_func, |
122 | - rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_old" | 181 | + block_crypto_write_func, |
123 | - rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_new" | 182 | + bs, |
124 | + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT" | 183 | + amend_options, |
125 | + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_old" | 184 | + force, |
126 | + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_new" | 185 | + errp); |
127 | rmdir "$TEST_DIR/subdir" 2> /dev/null | 186 | +cleanup: |
128 | } | 187 | + crypto->updating_keys = false; |
129 | trap "_cleanup; exit \$status" 0 1 2 3 15 | 188 | + bdrv_child_refresh_perms(bs, bs->file, errp); |
130 | diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028 | 189 | + qapi_free_QCryptoBlockAmendOptions(amend_options); |
131 | index XXXXXXX..XXXXXXX 100755 | 190 | + qobject_unref(cryptoopts); |
132 | --- a/tests/qemu-iotests/028 | 191 | + return ret; |
133 | +++ b/tests/qemu-iotests/028 | 192 | +} |
134 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | 193 | + |
135 | _cleanup() | 194 | + |
136 | { | 195 | +static void |
137 | _cleanup_qemu | 196 | +block_crypto_child_perms(BlockDriverState *bs, BdrvChild *c, |
138 | - rm -f "${TEST_IMG}.copy" | 197 | + const BdrvChildRole role, |
139 | + _rm_test_img "${TEST_IMG}.copy" | 198 | + BlockReopenQueue *reopen_queue, |
140 | _cleanup_test_img | 199 | + uint64_t perm, uint64_t shared, |
141 | } | 200 | + uint64_t *nperm, uint64_t *nshared) |
142 | trap "_cleanup; exit \$status" 0 1 2 3 15 | 201 | +{ |
143 | diff --git a/tests/qemu-iotests/029 b/tests/qemu-iotests/029 | 202 | + |
144 | index XXXXXXX..XXXXXXX 100755 | 203 | + BlockCrypto *crypto = bs->opaque; |
145 | --- a/tests/qemu-iotests/029 | 204 | + |
146 | +++ b/tests/qemu-iotests/029 | 205 | + bdrv_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nshared); |
147 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | 206 | + |
148 | 207 | + /* | |
149 | _cleanup() | 208 | + * For backward compatibility, manually share the write |
150 | { | 209 | + * and resize permission |
151 | - rm -f $TEST_IMG.snap | 210 | + */ |
152 | + _rm_test_img "$TEST_IMG.snap" | 211 | + *nshared |= (BLK_PERM_WRITE | BLK_PERM_RESIZE); |
153 | _cleanup_test_img | 212 | + /* |
154 | } | 213 | + * Since we are not fully a format driver, don't always request |
155 | trap "_cleanup; exit \$status" 0 1 2 3 15 | 214 | + * the read/resize permission but only when explicitly |
156 | diff --git a/tests/qemu-iotests/043 b/tests/qemu-iotests/043 | 215 | + * requested |
157 | index XXXXXXX..XXXXXXX 100755 | 216 | + */ |
158 | --- a/tests/qemu-iotests/043 | 217 | + *nperm &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); |
159 | +++ b/tests/qemu-iotests/043 | 218 | + *nperm |= perm & (BLK_PERM_WRITE | BLK_PERM_RESIZE); |
160 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | 219 | + |
161 | _cleanup() | 220 | + /* |
162 | { | 221 | + * This driver doesn't modify LUKS metadata except |
163 | _cleanup_test_img | 222 | + * when updating the encryption slots. |
164 | - rm -f "$TEST_IMG".[123].base | 223 | + * Thus unlike a proper format driver we don't ask for |
165 | + for img in "$TEST_IMG".[123].base; do | 224 | + * shared write/read permission. However we need it |
166 | + _rm_test_img "$img" | 225 | + * when we are updating the keys, to ensure that only we |
167 | + done | 226 | + * have access to the device. |
168 | } | 227 | + * |
169 | trap "_cleanup; exit \$status" 0 1 2 3 15 | 228 | + * Encryption update will set the crypto->updating_keys |
170 | 229 | + * during that period and refresh permissions | |
171 | diff --git a/tests/qemu-iotests/048 b/tests/qemu-iotests/048 | 230 | + * |
172 | index XXXXXXX..XXXXXXX 100755 | 231 | + */ |
173 | --- a/tests/qemu-iotests/048 | 232 | + if (crypto->updating_keys) { |
174 | +++ b/tests/qemu-iotests/048 | 233 | + /* need exclusive write access for header update */ |
175 | @@ -XXX,XX +XXX,XX @@ _cleanup() | 234 | + *nperm |= BLK_PERM_WRITE; |
176 | { | 235 | + /* unshare read and write permission */ |
177 | echo "Cleanup" | 236 | + *nshared &= ~(BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE); |
178 | _cleanup_test_img | 237 | + } |
179 | - rm "${TEST_IMG_FILE2}" | 238 | +} |
180 | + _rm_test_img "${TEST_IMG_FILE2}" | 239 | + |
181 | } | 240 | + |
182 | trap "_cleanup; exit \$status" 0 1 2 3 15 | 241 | static const char *const block_crypto_strong_runtime_opts[] = { |
183 | 242 | BLOCK_CRYPTO_OPT_LUKS_KEY_SECRET, | |
184 | diff --git a/tests/qemu-iotests/050 b/tests/qemu-iotests/050 | 243 | |
185 | index XXXXXXX..XXXXXXX 100755 | 244 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_crypto_luks = { |
186 | --- a/tests/qemu-iotests/050 | 245 | .bdrv_probe = block_crypto_probe_luks, |
187 | +++ b/tests/qemu-iotests/050 | 246 | .bdrv_open = block_crypto_open_luks, |
188 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | 247 | .bdrv_close = block_crypto_close, |
189 | _cleanup() | 248 | - /* This driver doesn't modify LUKS metadata except when creating image. |
190 | { | 249 | - * Allow share-rw=on as a special case. */ |
191 | _cleanup_test_img | 250 | - .bdrv_child_perm = bdrv_default_perms, |
192 | - rm -f "$TEST_IMG.old" | 251 | + .bdrv_child_perm = block_crypto_child_perms, |
193 | - rm -f "$TEST_IMG.new" | 252 | .bdrv_co_create = block_crypto_co_create_luks, |
194 | + _rm_test_img "$TEST_IMG.old" | 253 | .bdrv_co_create_opts = block_crypto_co_create_opts_luks, |
195 | + _rm_test_img "$TEST_IMG.new" | 254 | .bdrv_co_truncate = block_crypto_co_truncate, |
196 | } | 255 | .create_opts = &block_crypto_create_opts_luks, |
197 | trap "_cleanup; exit \$status" 0 1 2 3 15 | 256 | + .amend_opts = &block_crypto_amend_opts_luks, |
198 | 257 | ||
199 | diff --git a/tests/qemu-iotests/053 b/tests/qemu-iotests/053 | 258 | .bdrv_reopen_prepare = block_crypto_reopen_prepare, |
200 | index XXXXXXX..XXXXXXX 100755 | 259 | .bdrv_refresh_limits = block_crypto_refresh_limits, |
201 | --- a/tests/qemu-iotests/053 | 260 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_crypto_luks = { |
202 | +++ b/tests/qemu-iotests/053 | 261 | .bdrv_measure = block_crypto_measure, |
203 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | 262 | .bdrv_get_info = block_crypto_get_info_luks, |
204 | 263 | .bdrv_get_specific_info = block_crypto_get_specific_info_luks, | |
205 | _cleanup() | 264 | + .bdrv_amend_options = block_crypto_amend_options_luks, |
206 | { | 265 | |
207 | - rm -f "$TEST_IMG.orig" | 266 | .is_format = true, |
208 | - _cleanup_test_img | ||
209 | + _rm_test_img "$TEST_IMG.orig" | ||
210 | + _cleanup_test_img | ||
211 | } | ||
212 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
213 | |||
214 | diff --git a/tests/qemu-iotests/058 b/tests/qemu-iotests/058 | ||
215 | index XXXXXXX..XXXXXXX 100755 | ||
216 | --- a/tests/qemu-iotests/058 | ||
217 | +++ b/tests/qemu-iotests/058 | ||
218 | @@ -XXX,XX +XXX,XX @@ _cleanup() | ||
219 | { | ||
220 | nbd_server_stop | ||
221 | _cleanup_test_img | ||
222 | - rm -f "$converted_image" | ||
223 | + _rm_test_img "$converted_image" | ||
224 | } | ||
225 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
226 | |||
227 | diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 | ||
228 | index XXXXXXX..XXXXXXX 100755 | ||
229 | --- a/tests/qemu-iotests/059 | ||
230 | +++ b/tests/qemu-iotests/059 | ||
231 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
232 | _cleanup() | ||
233 | { | ||
234 | _cleanup_test_img | ||
235 | - rm -f "$TEST_IMG.qcow2" | ||
236 | + IMGFMT=qcow2 _rm_test_img "$TEST_IMG.qcow2" | ||
237 | } | ||
238 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
239 | |||
240 | diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 | ||
241 | index XXXXXXX..XXXXXXX 100755 | ||
242 | --- a/tests/qemu-iotests/061 | ||
243 | +++ b/tests/qemu-iotests/061 | ||
244 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
245 | _cleanup() | ||
246 | { | ||
247 | _cleanup_test_img | ||
248 | - rm -f $TEST_IMG.data | ||
249 | + _rm_test_img "$TEST_IMG.data" | ||
250 | } | ||
251 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
252 | |||
253 | diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063 | ||
254 | index XXXXXXX..XXXXXXX 100755 | ||
255 | --- a/tests/qemu-iotests/063 | ||
256 | +++ b/tests/qemu-iotests/063 | ||
257 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
258 | |||
259 | _cleanup() | ||
260 | { | ||
261 | - _cleanup_test_img | ||
262 | - rm -f "$TEST_IMG.orig" "$TEST_IMG.raw1" "$TEST_IMG.raw2" | ||
263 | + _cleanup_test_img | ||
264 | + for img in "$TEST_IMG".{orig,raw1,raw2,target}; do | ||
265 | + _rm_test_img "$img" | ||
266 | + done | ||
267 | } | ||
268 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
269 | |||
270 | diff --git a/tests/qemu-iotests/069 b/tests/qemu-iotests/069 | ||
271 | index XXXXXXX..XXXXXXX 100755 | ||
272 | --- a/tests/qemu-iotests/069 | ||
273 | +++ b/tests/qemu-iotests/069 | ||
274 | @@ -XXX,XX +XXX,XX @@ echo "=== Creating an image with a backing file and deleting that file ===" | ||
275 | echo | ||
276 | TEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE | ||
277 | _make_test_img -b "$TEST_IMG.base" $IMG_SIZE | ||
278 | -rm -f "$TEST_IMG.base" | ||
279 | +_rm_test_img "$TEST_IMG.base" | ||
280 | # Just open the image and close it right again (this should print an error message) | ||
281 | $QEMU_IO -c quit "$TEST_IMG" 2>&1 | _filter_testdir | _filter_imgfmt | ||
282 | |||
283 | diff --git a/tests/qemu-iotests/074 b/tests/qemu-iotests/074 | ||
284 | index XXXXXXX..XXXXXXX 100755 | ||
285 | --- a/tests/qemu-iotests/074 | ||
286 | +++ b/tests/qemu-iotests/074 | ||
287 | @@ -XXX,XX +XXX,XX @@ _cleanup() | ||
288 | { | ||
289 | echo "Cleanup" | ||
290 | _cleanup_test_img | ||
291 | - rm "${TEST_IMG2}" | ||
292 | + _rm_test_img "${TEST_IMG2}" | ||
293 | rm -f "$TEST_DIR/blkdebug.conf" | ||
294 | } | ||
295 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
296 | diff --git a/tests/qemu-iotests/080 b/tests/qemu-iotests/080 | ||
297 | index XXXXXXX..XXXXXXX 100755 | ||
298 | --- a/tests/qemu-iotests/080 | ||
299 | +++ b/tests/qemu-iotests/080 | ||
300 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
301 | |||
302 | _cleanup() | ||
303 | { | ||
304 | - rm -f $TEST_IMG.snap | ||
305 | + _rm_test_img "$TEST_IMG.snap" | ||
306 | _cleanup_test_img | ||
307 | } | ||
308 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
309 | diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 | ||
310 | index XXXXXXX..XXXXXXX 100755 | ||
311 | --- a/tests/qemu-iotests/081 | ||
312 | +++ b/tests/qemu-iotests/081 | ||
313 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
314 | |||
315 | _cleanup() | ||
316 | { | ||
317 | - rm -rf $TEST_DIR/1.raw | ||
318 | - rm -rf $TEST_DIR/2.raw | ||
319 | - rm -rf $TEST_DIR/3.raw | ||
320 | + _rm_test_img "$TEST_DIR/1.raw" | ||
321 | + _rm_test_img "$TEST_DIR/2.raw" | ||
322 | + _rm_test_img "$TEST_DIR/3.raw" | ||
323 | } | ||
324 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
325 | |||
326 | diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085 | ||
327 | index XXXXXXX..XXXXXXX 100755 | ||
328 | --- a/tests/qemu-iotests/085 | ||
329 | +++ b/tests/qemu-iotests/085 | ||
330 | @@ -XXX,XX +XXX,XX @@ _cleanup() | ||
331 | _cleanup_qemu | ||
332 | for i in $(seq 1 ${SNAPSHOTS}) | ||
333 | do | ||
334 | - rm -f "${TEST_DIR}/${i}-${snapshot_virt0}" | ||
335 | - rm -f "${TEST_DIR}/${i}-${snapshot_virt1}" | ||
336 | + _rm_test_img "${TEST_DIR}/${i}-${snapshot_virt0}" | ||
337 | + _rm_test_img "${TEST_DIR}/${i}-${snapshot_virt1}" | ||
338 | + done | ||
339 | + for img in "${TEST_IMG}".{1,2,base} | ||
340 | + do | ||
341 | + _rm_test_img "$img" | ||
342 | done | ||
343 | - rm -f "${TEST_IMG}" "${TEST_IMG}.1" "${TEST_IMG}.2" "${TEST_IMG}.base" | ||
344 | |||
345 | } | ||
346 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
347 | diff --git a/tests/qemu-iotests/088 b/tests/qemu-iotests/088 | ||
348 | index XXXXXXX..XXXXXXX 100755 | ||
349 | --- a/tests/qemu-iotests/088 | ||
350 | +++ b/tests/qemu-iotests/088 | ||
351 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
352 | |||
353 | _cleanup() | ||
354 | { | ||
355 | - rm -f $TEST_IMG.snap | ||
356 | + _rm_test_img "$TEST_IMG.snap" | ||
357 | _cleanup_test_img | ||
358 | } | ||
359 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
360 | diff --git a/tests/qemu-iotests/092 b/tests/qemu-iotests/092 | ||
361 | index XXXXXXX..XXXXXXX 100755 | ||
362 | --- a/tests/qemu-iotests/092 | ||
363 | +++ b/tests/qemu-iotests/092 | ||
364 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
365 | |||
366 | _cleanup() | ||
367 | { | ||
368 | - rm -f $TEST_IMG.snap | ||
369 | + _rm_test_img "$TEST_IMG.snap" | ||
370 | _cleanup_test_img | ||
371 | } | ||
372 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
373 | diff --git a/tests/qemu-iotests/094 b/tests/qemu-iotests/094 | ||
374 | index XXXXXXX..XXXXXXX 100755 | ||
375 | --- a/tests/qemu-iotests/094 | ||
376 | +++ b/tests/qemu-iotests/094 | ||
377 | @@ -XXX,XX +XXX,XX @@ _cleanup() | ||
378 | { | ||
379 | _cleanup_qemu | ||
380 | _cleanup_test_img | ||
381 | - rm -f "$TEST_DIR/source.$IMGFMT" | ||
382 | + _rm_test_img "$TEST_DIR/source.$IMGFMT" | ||
383 | } | ||
384 | |||
385 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
386 | diff --git a/tests/qemu-iotests/095 b/tests/qemu-iotests/095 | ||
387 | index XXXXXXX..XXXXXXX 100755 | ||
388 | --- a/tests/qemu-iotests/095 | ||
389 | +++ b/tests/qemu-iotests/095 | ||
390 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
391 | _cleanup() | ||
392 | { | ||
393 | _cleanup_qemu | ||
394 | - rm -f "${TEST_IMG}.base" "${TEST_IMG}.snp1" | ||
395 | - _cleanup_test_img | ||
396 | + _rm_test_img "${TEST_IMG}.base" | ||
397 | + _rm_test_img "${TEST_IMG}.snp1" | ||
398 | + _cleanup_test_img | ||
399 | } | ||
400 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
401 | |||
402 | diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099 | ||
403 | index XXXXXXX..XXXXXXX 100755 | ||
404 | --- a/tests/qemu-iotests/099 | ||
405 | +++ b/tests/qemu-iotests/099 | ||
406 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
407 | |||
408 | _cleanup() | ||
409 | { | ||
410 | - _cleanup_test_img | ||
411 | + _cleanup_test_img | ||
412 | + _rm_test_img "$TEST_IMG.compare" | ||
413 | + rm -f "$TEST_DIR/blkdebug.conf" | ||
414 | + | ||
415 | } | ||
416 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
417 | |||
418 | @@ -XXX,XX +XXX,XX @@ echo | ||
419 | test_qemu "file.driver=blkdebug,file.image.filename=$TEST_IMG" | ||
420 | |||
421 | |||
422 | -rm -f "$TEST_IMG.compare" "$TEST_DIR/blkdebug.conf" | ||
423 | - | ||
424 | # success, all done | ||
425 | echo "*** done" | ||
426 | rm -f $seq.full | ||
427 | diff --git a/tests/qemu-iotests/109 b/tests/qemu-iotests/109 | ||
428 | index XXXXXXX..XXXXXXX 100755 | ||
429 | --- a/tests/qemu-iotests/109 | ||
430 | +++ b/tests/qemu-iotests/109 | ||
431 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
432 | _cleanup() | ||
433 | { | ||
434 | _cleanup_qemu | ||
435 | - rm -f $TEST_IMG.src | ||
436 | - _cleanup_test_img | ||
437 | + _rm_test_img "$TEST_IMG.src" | ||
438 | + _cleanup_test_img | ||
439 | } | ||
440 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
441 | |||
442 | diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 | ||
443 | index XXXXXXX..XXXXXXX 100755 | ||
444 | --- a/tests/qemu-iotests/110 | ||
445 | +++ b/tests/qemu-iotests/110 | ||
446 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
447 | |||
448 | _cleanup() | ||
449 | { | ||
450 | - _cleanup_test_img | ||
451 | - rm -f "$TEST_IMG.copy" | ||
452 | + _cleanup_test_img | ||
453 | + _rm_test_img "$TEST_IMG.copy" | ||
454 | } | ||
455 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
456 | |||
457 | diff --git a/tests/qemu-iotests/122 b/tests/qemu-iotests/122 | ||
458 | index XXXXXXX..XXXXXXX 100755 | ||
459 | --- a/tests/qemu-iotests/122 | ||
460 | +++ b/tests/qemu-iotests/122 | ||
461 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
462 | |||
463 | _cleanup() | ||
464 | { | ||
465 | - rm -f "$TEST_IMG".[123] | ||
466 | - _cleanup_test_img | ||
467 | + for img in "$TEST_IMG".[123]; do | ||
468 | + _rm_test_img "$img" | ||
469 | + done | ||
470 | + _cleanup_test_img | ||
471 | } | ||
472 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
473 | |||
474 | diff --git a/tests/qemu-iotests/123 b/tests/qemu-iotests/123 | ||
475 | index XXXXXXX..XXXXXXX 100755 | ||
476 | --- a/tests/qemu-iotests/123 | ||
477 | +++ b/tests/qemu-iotests/123 | ||
478 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
479 | _cleanup() | ||
480 | { | ||
481 | _cleanup_test_img | ||
482 | - rm -f "$SRC_IMG" | ||
483 | + _rm_test_img "$SRC_IMG" | ||
484 | } | ||
485 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
486 | |||
487 | diff --git a/tests/qemu-iotests/141 b/tests/qemu-iotests/141 | ||
488 | index XXXXXXX..XXXXXXX 100755 | ||
489 | --- a/tests/qemu-iotests/141 | ||
490 | +++ b/tests/qemu-iotests/141 | ||
491 | @@ -XXX,XX +XXX,XX @@ _cleanup() | ||
492 | { | ||
493 | _cleanup_qemu | ||
494 | _cleanup_test_img | ||
495 | - rm -f "$TEST_DIR"/{b,m,o}.$IMGFMT | ||
496 | + for img in "$TEST_DIR"/{b,m,o}.$IMGFMT; do | ||
497 | + _rm_test_img "$img" | ||
498 | + done | ||
499 | } | ||
500 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
501 | |||
502 | diff --git a/tests/qemu-iotests/142 b/tests/qemu-iotests/142 | ||
503 | index XXXXXXX..XXXXXXX 100755 | ||
504 | --- a/tests/qemu-iotests/142 | ||
505 | +++ b/tests/qemu-iotests/142 | ||
506 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
507 | _cleanup() | ||
508 | { | ||
509 | _cleanup_test_img | ||
510 | - rm -f $TEST_IMG.snap | ||
511 | + _rm_test_img "$TEST_IMG.snap" | ||
512 | } | ||
513 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
514 | |||
515 | diff --git a/tests/qemu-iotests/144 b/tests/qemu-iotests/144 | ||
516 | index XXXXXXX..XXXXXXX 100755 | ||
517 | --- a/tests/qemu-iotests/144 | ||
518 | +++ b/tests/qemu-iotests/144 | ||
519 | @@ -XXX,XX +XXX,XX @@ TMP_SNAP2=${TEST_DIR}/tmp2.qcow2 | ||
520 | _cleanup() | ||
521 | { | ||
522 | _cleanup_qemu | ||
523 | - rm -f "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}" | ||
524 | + for img in "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}"; do | ||
525 | + _rm_test_img "$img" | ||
526 | + done | ||
527 | } | ||
528 | |||
529 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
530 | diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153 | ||
531 | index XXXXXXX..XXXXXXX 100755 | ||
532 | --- a/tests/qemu-iotests/153 | ||
533 | +++ b/tests/qemu-iotests/153 | ||
534 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
535 | _cleanup() | ||
536 | { | ||
537 | _cleanup_test_img | ||
538 | - rm -f "${TEST_IMG}.base" | ||
539 | - rm -f "${TEST_IMG}.overlay" | ||
540 | - rm -f "${TEST_IMG}.convert" | ||
541 | - rm -f "${TEST_IMG}.a" | ||
542 | - rm -f "${TEST_IMG}.b" | ||
543 | - rm -f "${TEST_IMG}.c" | ||
544 | - rm -f "${TEST_IMG}.lnk" | ||
545 | + for img in "${TEST_IMG}".{base,overlay,convert,a,b,c,lnk}; do | ||
546 | + _rm_test_img "$img" | ||
547 | + done | ||
548 | } | ||
549 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
550 | |||
551 | diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156 | ||
552 | index XXXXXXX..XXXXXXX 100755 | ||
553 | --- a/tests/qemu-iotests/156 | ||
554 | +++ b/tests/qemu-iotests/156 | ||
555 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
556 | _cleanup() | ||
557 | { | ||
558 | _cleanup_qemu | ||
559 | - rm -f "$TEST_IMG"{,.target}{,.backing,.overlay} | ||
560 | + for img in "$TEST_IMG"{,.target}{,.backing,.overlay}; do | ||
561 | + _rm_test_img "$img" | ||
562 | + done | ||
563 | } | ||
564 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
565 | |||
566 | @@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $QEMU_HANDLE \ | ||
567 | '"status": "null"' | ||
568 | |||
569 | # Remove the source images | ||
570 | -rm -f "$TEST_IMG{,.backing,.overlay}" | ||
571 | +for img in "$TEST_IMG{,.backing,.overlay}"; do | ||
572 | + _rm_test_img "$img" | ||
573 | +done | ||
574 | |||
575 | echo | ||
576 | |||
577 | diff --git a/tests/qemu-iotests/159 b/tests/qemu-iotests/159 | ||
578 | index XXXXXXX..XXXXXXX 100755 | ||
579 | --- a/tests/qemu-iotests/159 | ||
580 | +++ b/tests/qemu-iotests/159 | ||
581 | @@ -XXX,XX +XXX,XX @@ status=1 | ||
582 | _cleanup() | ||
583 | { | ||
584 | _cleanup_test_img | ||
585 | - rm -f "$TEST_IMG.out" | ||
586 | + _rm_test_img "$TEST_IMG.out" | ||
587 | } | ||
588 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
589 | |||
590 | diff --git a/tests/qemu-iotests/160 b/tests/qemu-iotests/160 | ||
591 | index XXXXXXX..XXXXXXX 100755 | ||
592 | --- a/tests/qemu-iotests/160 | ||
593 | +++ b/tests/qemu-iotests/160 | ||
594 | @@ -XXX,XX +XXX,XX @@ status=1 | ||
595 | _cleanup() | ||
596 | { | ||
597 | _cleanup_test_img | ||
598 | - rm -f "$TEST_IMG.out" "$TEST_IMG.out.dd" | ||
599 | + _rm_test_img "$TEST_IMG.out" | ||
600 | + _rm_test_img "$TEST_IMG.out.dd" | ||
601 | } | ||
602 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
603 | |||
604 | diff --git a/tests/qemu-iotests/161 b/tests/qemu-iotests/161 | ||
605 | index XXXXXXX..XXXXXXX 100755 | ||
606 | --- a/tests/qemu-iotests/161 | ||
607 | +++ b/tests/qemu-iotests/161 | ||
608 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
609 | _cleanup() | ||
610 | { | ||
611 | _cleanup_test_img | ||
612 | - rm -f "$TEST_IMG.base" | ||
613 | - rm -f "$TEST_IMG.int" | ||
614 | + _rm_test_img "$TEST_IMG.base" | ||
615 | + _rm_test_img "$TEST_IMG.int" | ||
616 | } | ||
617 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
618 | |||
619 | diff --git a/tests/qemu-iotests/170 b/tests/qemu-iotests/170 | ||
620 | index XXXXXXX..XXXXXXX 100755 | ||
621 | --- a/tests/qemu-iotests/170 | ||
622 | +++ b/tests/qemu-iotests/170 | ||
623 | @@ -XXX,XX +XXX,XX @@ status=1 | ||
624 | _cleanup() | ||
625 | { | ||
626 | _cleanup_test_img | ||
627 | - rm -f "$TEST_IMG.out" | ||
628 | + _rm_test_img "$TEST_IMG.out" | ||
629 | } | ||
630 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
631 | |||
632 | diff --git a/tests/qemu-iotests/172 b/tests/qemu-iotests/172 | ||
633 | index XXXXXXX..XXXXXXX 100755 | ||
634 | --- a/tests/qemu-iotests/172 | ||
635 | +++ b/tests/qemu-iotests/172 | ||
636 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
637 | |||
638 | _cleanup() | ||
639 | { | ||
640 | - _cleanup_test_img | ||
641 | - rm -f "$TEST_IMG.2" | ||
642 | - rm -f "$TEST_IMG.3" | ||
643 | + _cleanup_test_img | ||
644 | + _rm_test_img "$TEST_IMG.2" | ||
645 | + _rm_test_img "$TEST_IMG.3" | ||
646 | } | ||
647 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
648 | |||
649 | diff --git a/tests/qemu-iotests/173 b/tests/qemu-iotests/173 | ||
650 | index XXXXXXX..XXXXXXX 100755 | ||
651 | --- a/tests/qemu-iotests/173 | ||
652 | +++ b/tests/qemu-iotests/173 | ||
653 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
654 | _cleanup() | ||
655 | { | ||
656 | _cleanup_qemu | ||
657 | - rm -f "${QEMU_TEST_DIR}/image.base" "${QEMU_TEST_DIR}/image.snp1" | ||
658 | + _rm_test_img "${TEST_DIR}/image.base" | ||
659 | + _rm_test_img "${TEST_DIR}/image.snp1" | ||
660 | _cleanup_test_img | ||
661 | } | ||
662 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
663 | diff --git a/tests/qemu-iotests/178 b/tests/qemu-iotests/178 | ||
664 | index XXXXXXX..XXXXXXX 100755 | ||
665 | --- a/tests/qemu-iotests/178 | ||
666 | +++ b/tests/qemu-iotests/178 | ||
667 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
668 | _cleanup() | ||
669 | { | ||
670 | _cleanup_test_img | ||
671 | - rm -f "$TEST_IMG.converted" | ||
672 | + _rm_test_img "$TEST_IMG.converted" | ||
673 | } | ||
674 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
675 | |||
676 | diff --git a/tests/qemu-iotests/182 b/tests/qemu-iotests/182 | ||
677 | index XXXXXXX..XXXXXXX 100755 | ||
678 | --- a/tests/qemu-iotests/182 | ||
679 | +++ b/tests/qemu-iotests/182 | ||
680 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
681 | _cleanup() | ||
682 | { | ||
683 | _cleanup_test_img | ||
684 | - rm -f "$TEST_IMG.overlay" | ||
685 | + _rm_test_img "$TEST_IMG.overlay" | ||
686 | rm -f "$SOCK_DIR/nbd.socket" | ||
687 | } | ||
688 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
689 | diff --git a/tests/qemu-iotests/183 b/tests/qemu-iotests/183 | ||
690 | index XXXXXXX..XXXXXXX 100755 | ||
691 | --- a/tests/qemu-iotests/183 | ||
692 | +++ b/tests/qemu-iotests/183 | ||
693 | @@ -XXX,XX +XXX,XX @@ MIG_SOCKET="${SOCK_DIR}/migrate" | ||
694 | _cleanup() | ||
695 | { | ||
696 | rm -f "${MIG_SOCKET}" | ||
697 | - rm -f "${TEST_IMG}.dest" | ||
698 | + _rm_test_img "${TEST_IMG}.dest" | ||
699 | _cleanup_test_img | ||
700 | _cleanup_qemu | ||
701 | } | ||
702 | diff --git a/tests/qemu-iotests/185 b/tests/qemu-iotests/185 | ||
703 | index XXXXXXX..XXXXXXX 100755 | ||
704 | --- a/tests/qemu-iotests/185 | ||
705 | +++ b/tests/qemu-iotests/185 | ||
706 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
707 | |||
708 | _cleanup() | ||
709 | { | ||
710 | - rm -f "${TEST_IMG}.mid" | ||
711 | - rm -f "${TEST_IMG}.copy" | ||
712 | + _rm_test_img "${TEST_IMG}.mid" | ||
713 | + _rm_test_img "${TEST_IMG}.copy" | ||
714 | _cleanup_test_img | ||
715 | _cleanup_qemu | ||
716 | } | ||
717 | diff --git a/tests/qemu-iotests/187 b/tests/qemu-iotests/187 | ||
718 | index XXXXXXX..XXXXXXX 100755 | ||
719 | --- a/tests/qemu-iotests/187 | ||
720 | +++ b/tests/qemu-iotests/187 | ||
721 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
722 | |||
723 | _cleanup() | ||
724 | { | ||
725 | - _cleanup_test_img | ||
726 | - rm -f "$TEST_IMG.2" | ||
727 | - rm -f "$TEST_IMG.3" | ||
728 | + _cleanup_test_img | ||
729 | + _rm_test_img "$TEST_IMG.2" | ||
730 | + _rm_test_img "$TEST_IMG.3" | ||
731 | } | ||
732 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
733 | |||
734 | diff --git a/tests/qemu-iotests/190 b/tests/qemu-iotests/190 | ||
735 | index XXXXXXX..XXXXXXX 100755 | ||
736 | --- a/tests/qemu-iotests/190 | ||
737 | +++ b/tests/qemu-iotests/190 | ||
738 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
739 | _cleanup() | ||
740 | { | ||
741 | _cleanup_test_img | ||
742 | - rm -f "$TEST_IMG.converted" | ||
743 | + _rm_test_img "$TEST_IMG.converted" | ||
744 | } | ||
745 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
746 | |||
747 | diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 | ||
748 | index XXXXXXX..XXXXXXX 100755 | ||
749 | --- a/tests/qemu-iotests/191 | ||
750 | +++ b/tests/qemu-iotests/191 | ||
751 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
752 | |||
753 | _cleanup() | ||
754 | { | ||
755 | - rm -f "${TEST_IMG}.mid" | ||
756 | - rm -f "${TEST_IMG}.ovl2" | ||
757 | - rm -f "${TEST_IMG}.ovl3" | ||
758 | + _rm_test_img "${TEST_IMG}.mid" | ||
759 | + _rm_test_img "${TEST_IMG}.ovl2" | ||
760 | + _rm_test_img "${TEST_IMG}.ovl3" | ||
761 | _cleanup_test_img | ||
762 | _cleanup_qemu | ||
763 | } | ||
764 | diff --git a/tests/qemu-iotests/195 b/tests/qemu-iotests/195 | ||
765 | index XXXXXXX..XXXXXXX 100755 | ||
766 | --- a/tests/qemu-iotests/195 | ||
767 | +++ b/tests/qemu-iotests/195 | ||
768 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
769 | _cleanup() | ||
770 | { | ||
771 | _cleanup_test_img | ||
772 | - rm -f "$TEST_IMG.mid" | ||
773 | + _rm_test_img "$TEST_IMG.mid" | ||
774 | } | ||
775 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
776 | |||
777 | diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197 | ||
778 | index XXXXXXX..XXXXXXX 100755 | ||
779 | --- a/tests/qemu-iotests/197 | ||
780 | +++ b/tests/qemu-iotests/197 | ||
781 | @@ -XXX,XX +XXX,XX @@ esac | ||
782 | _cleanup() | ||
783 | { | ||
784 | _cleanup_test_img | ||
785 | - rm -f "$TEST_WRAP" | ||
786 | + _rm_test_img "$TEST_WRAP" | ||
787 | rm -f "$BLKDBG_CONF" | ||
788 | } | ||
789 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
790 | diff --git a/tests/qemu-iotests/200 b/tests/qemu-iotests/200 | ||
791 | index XXXXXXX..XXXXXXX 100755 | ||
792 | --- a/tests/qemu-iotests/200 | ||
793 | +++ b/tests/qemu-iotests/200 | ||
794 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
795 | _cleanup() | ||
796 | { | ||
797 | _cleanup_qemu | ||
798 | - rm -f "${TEST_IMG}" "${BACKING_IMG}" | ||
799 | + _rm_test_img "${TEST_IMG}" | ||
800 | + _rm_test_img "${BACKING_IMG}" | ||
801 | } | ||
802 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
803 | |||
804 | diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215 | ||
805 | index XXXXXXX..XXXXXXX 100755 | ||
806 | --- a/tests/qemu-iotests/215 | ||
807 | +++ b/tests/qemu-iotests/215 | ||
808 | @@ -XXX,XX +XXX,XX @@ esac | ||
809 | _cleanup() | ||
810 | { | ||
811 | _cleanup_test_img | ||
812 | - rm -f "$TEST_WRAP" | ||
813 | + _rm_test_img "$TEST_WRAP" | ||
814 | rm -f "$BLKDBG_CONF" | ||
815 | } | ||
816 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
817 | diff --git a/tests/qemu-iotests/225 b/tests/qemu-iotests/225 | ||
818 | index XXXXXXX..XXXXXXX 100755 | ||
819 | --- a/tests/qemu-iotests/225 | ||
820 | +++ b/tests/qemu-iotests/225 | ||
821 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
822 | _cleanup() | ||
823 | { | ||
824 | _cleanup_test_img | ||
825 | - rm -f "$TEST_IMG.not_base" | ||
826 | + _rm_test_img "$TEST_IMG.not_base" | ||
827 | } | ||
828 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
829 | |||
830 | diff --git a/tests/qemu-iotests/229 b/tests/qemu-iotests/229 | ||
831 | index XXXXXXX..XXXXXXX 100755 | ||
832 | --- a/tests/qemu-iotests/229 | ||
833 | +++ b/tests/qemu-iotests/229 | ||
834 | @@ -XXX,XX +XXX,XX @@ _cleanup() | ||
835 | { | ||
836 | _cleanup_qemu | ||
837 | _cleanup_test_img | ||
838 | - rm -f "$TEST_IMG" "$DEST_IMG" | ||
839 | + _rm_test_img "$TEST_IMG" | ||
840 | + _rm_test_img "$DEST_IMG" | ||
841 | } | ||
842 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
843 | |||
844 | diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232 | ||
845 | index XXXXXXX..XXXXXXX 100755 | ||
846 | --- a/tests/qemu-iotests/232 | ||
847 | +++ b/tests/qemu-iotests/232 | ||
848 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
849 | _cleanup() | ||
850 | { | ||
851 | _cleanup_test_img | ||
852 | - rm -f $TEST_IMG.[01234] | ||
853 | + for img in "$TEST_IMG".[01234]; do | ||
854 | + _rm_test_img "$img" | ||
855 | + done | ||
856 | } | ||
857 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
858 | |||
859 | diff --git a/tests/qemu-iotests/243 b/tests/qemu-iotests/243 | ||
860 | index XXXXXXX..XXXXXXX 100755 | ||
861 | --- a/tests/qemu-iotests/243 | ||
862 | +++ b/tests/qemu-iotests/243 | ||
863 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
864 | _cleanup() | ||
865 | { | ||
866 | _cleanup_test_img | ||
867 | - rm -f $TEST_IMG.data | ||
868 | + _rm_test_img "$TEST_IMG.data" | ||
869 | } | ||
870 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
871 | |||
872 | diff --git a/tests/qemu-iotests/244 b/tests/qemu-iotests/244 | ||
873 | index XXXXXXX..XXXXXXX 100755 | ||
874 | --- a/tests/qemu-iotests/244 | ||
875 | +++ b/tests/qemu-iotests/244 | ||
876 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
877 | _cleanup() | ||
878 | { | ||
879 | _cleanup_test_img | ||
880 | - rm -f $TEST_IMG.data | ||
881 | - rm -f $TEST_IMG.src | ||
882 | + _rm_test_img "$TEST_IMG.data" | ||
883 | + _rm_test_img "$TEST_IMG.src" | ||
884 | } | ||
885 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
886 | |||
887 | diff --git a/tests/qemu-iotests/247 b/tests/qemu-iotests/247 | ||
888 | index XXXXXXX..XXXXXXX 100755 | ||
889 | --- a/tests/qemu-iotests/247 | ||
890 | +++ b/tests/qemu-iotests/247 | ||
891 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
892 | _cleanup() | ||
893 | { | ||
894 | _cleanup_test_img | ||
895 | - rm -f $TEST_IMG.[01234] | ||
896 | + for img in "$TEST_IMG".[01234]; do | ||
897 | + _rm_test_img "$img" | ||
898 | + done | ||
899 | } | ||
900 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
901 | |||
902 | diff --git a/tests/qemu-iotests/249 b/tests/qemu-iotests/249 | ||
903 | index XXXXXXX..XXXXXXX 100755 | ||
904 | --- a/tests/qemu-iotests/249 | ||
905 | +++ b/tests/qemu-iotests/249 | ||
906 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
907 | _cleanup() | ||
908 | { | ||
909 | _cleanup_test_img | ||
910 | - rm -f "$TEST_IMG.base" | ||
911 | - rm -f "$TEST_IMG.int" | ||
912 | + _rm_test_img "$TEST_IMG.base" | ||
913 | + _rm_test_img "$TEST_IMG.int" | ||
914 | } | ||
915 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
916 | |||
917 | diff --git a/tests/qemu-iotests/252 b/tests/qemu-iotests/252 | ||
918 | index XXXXXXX..XXXXXXX 100755 | ||
919 | --- a/tests/qemu-iotests/252 | ||
920 | +++ b/tests/qemu-iotests/252 | ||
921 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
922 | _cleanup() | ||
923 | { | ||
924 | _cleanup_test_img | ||
925 | - rm -f "$TEST_IMG.base_new" | ||
926 | + _rm_test_img "$TEST_IMG.base_new" | ||
927 | } | ||
928 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
929 | 267 | ||
930 | -- | 268 | -- |
931 | 2.24.1 | 269 | 2.26.2 |
932 | 270 | ||
933 | 271 | diff view generated by jsdifflib |
1 | This will not work with external data files, so try to get tests working | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | without it as far as possible. | 2 | |
3 | 3 | Now that we have all the infrastructure in place, | |
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 4 | wire it in the qcow2 driver and expose this to the user. |
5 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 5 | |
6 | Message-id: 20191107163708.833192-17-mreitz@redhat.com | 6 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> |
7 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
8 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
9 | Message-Id: <20200608094030.670121-9-mlevitsk@redhat.com> | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
8 | --- | 11 | --- |
9 | tests/qemu-iotests/063 | 12 ++++-------- | 12 | block/qcow2.c | 71 +++++++++++++++++++++++++++++++++----- |
10 | tests/qemu-iotests/063.out | 3 ++- | 13 | tests/qemu-iotests/082.out | 45 ++++++++++++++++++++++++ |
11 | tests/qemu-iotests/085 | 9 +++------ | 14 | 2 files changed, 107 insertions(+), 9 deletions(-) |
12 | tests/qemu-iotests/085.out | 8 ++++---- | 15 | |
13 | 4 files changed, 13 insertions(+), 19 deletions(-) | 16 | diff --git a/block/qcow2.c b/block/qcow2.c |
14 | |||
15 | diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063 | ||
16 | index XXXXXXX..XXXXXXX 100755 | ||
17 | --- a/tests/qemu-iotests/063 | ||
18 | +++ b/tests/qemu-iotests/063 | ||
19 | @@ -XXX,XX +XXX,XX @@ _unsupported_imgopts "subformat=monolithicFlat" \ | ||
20 | _make_test_img 4M | ||
21 | |||
22 | echo "== Testing conversion with -n fails with no target file ==" | ||
23 | -# check .orig file does not exist | ||
24 | -rm -f "$TEST_IMG.orig" | ||
25 | if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" >/dev/null 2>&1; then | ||
26 | exit 1 | ||
27 | fi | ||
28 | |||
29 | echo "== Testing conversion with -n succeeds with a target file ==" | ||
30 | -rm -f "$TEST_IMG.orig" | ||
31 | -cp "$TEST_IMG" "$TEST_IMG.orig" | ||
32 | +_rm_test_img "$TEST_IMG.orig" | ||
33 | +TEST_IMG="$TEST_IMG.orig" _make_test_img 4M | ||
34 | if ! $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" ; then | ||
35 | exit 1 | ||
36 | fi | ||
37 | @@ -XXX,XX +XXX,XX @@ fi | ||
38 | _check_test_img | ||
39 | |||
40 | echo "== Testing conversion to a smaller file fails ==" | ||
41 | -rm -f "$TEST_IMG.orig" | ||
42 | -mv "$TEST_IMG" "$TEST_IMG.orig" | ||
43 | -_make_test_img 2M | ||
44 | -if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG.orig" "$TEST_IMG" >/dev/null 2>&1; then | ||
45 | +TEST_IMG="$TEST_IMG.target" _make_test_img 2M | ||
46 | +if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.target" >/dev/null 2>&1; then | ||
47 | exit 1 | ||
48 | fi | ||
49 | |||
50 | diff --git a/tests/qemu-iotests/063.out b/tests/qemu-iotests/063.out | ||
51 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
52 | --- a/tests/qemu-iotests/063.out | 18 | --- a/block/qcow2.c |
53 | +++ b/tests/qemu-iotests/063.out | 19 | +++ b/block/qcow2.c |
54 | @@ -XXX,XX +XXX,XX @@ QA output created by 063 | 20 | @@ -XXX,XX +XXX,XX @@ static ssize_t qcow2_crypto_hdr_write_func(QCryptoBlock *block, size_t offset, |
55 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304 | 21 | return ret; |
56 | == Testing conversion with -n fails with no target file == | ||
57 | == Testing conversion with -n succeeds with a target file == | ||
58 | +Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=IMGFMT size=4194304 | ||
59 | == Testing conversion to raw is the same after conversion with -n == | ||
60 | == Testing conversion back to original format == | ||
61 | No errors were found on the image. | ||
62 | == Testing conversion to a smaller file fails == | ||
63 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152 | ||
64 | +Formatting 'TEST_DIR/t.IMGFMT.target', fmt=IMGFMT size=2097152 | ||
65 | == Regression testing for copy offloading bug == | ||
66 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 | ||
67 | Formatting 'TEST_DIR/t.IMGFMT.target', fmt=IMGFMT size=1048576 | ||
68 | diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085 | ||
69 | index XXXXXXX..XXXXXXX 100755 | ||
70 | --- a/tests/qemu-iotests/085 | ||
71 | +++ b/tests/qemu-iotests/085 | ||
72 | @@ -XXX,XX +XXX,XX @@ add_snapshot_image() | ||
73 | { | ||
74 | base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}" | ||
75 | snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}" | ||
76 | - _make_test_img -u -b "${base_image}" "$size" | ||
77 | - mv "${TEST_IMG}" "${snapshot_file}" | ||
78 | + TEST_IMG=$snapshot_file _make_test_img -u -b "${base_image}" "$size" | ||
79 | do_blockdev_add "$1" "'backing': null, " "${snapshot_file}" | ||
80 | } | 22 | } |
81 | 23 | ||
82 | @@ -XXX,XX +XXX,XX @@ blockdev_snapshot() | 24 | +static QDict* |
83 | 25 | +qcow2_extract_crypto_opts(QemuOpts *opts, const char *fmt, Error **errp) | |
84 | size=128M | 26 | +{ |
85 | 27 | + QDict *cryptoopts_qdict; | |
86 | -_make_test_img $size | 28 | + QDict *opts_qdict; |
87 | -mv "${TEST_IMG}" "${TEST_IMG}.1" | 29 | + |
88 | -_make_test_img $size | 30 | + /* Extract "encrypt." options into a qdict */ |
89 | -mv "${TEST_IMG}" "${TEST_IMG}.2" | 31 | + opts_qdict = qemu_opts_to_qdict(opts, NULL); |
90 | +TEST_IMG="$TEST_IMG.1" _make_test_img $size | 32 | + qdict_extract_subqdict(opts_qdict, &cryptoopts_qdict, "encrypt."); |
91 | +TEST_IMG="$TEST_IMG.2" _make_test_img $size | 33 | + qobject_unref(opts_qdict); |
92 | 34 | + qdict_put_str(cryptoopts_qdict, "format", fmt); | |
93 | echo | 35 | + return cryptoopts_qdict; |
94 | echo === Running QEMU === | 36 | +} |
95 | diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out | 37 | |
38 | /* | ||
39 | * read qcow2 extension and fill bs | ||
40 | @@ -XXX,XX +XXX,XX @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs, | ||
41 | |||
42 | if (has_luks) { | ||
43 | g_autoptr(QCryptoBlockCreateOptions) create_opts = NULL; | ||
44 | - QDict *opts_qdict; | ||
45 | - QDict *cryptoopts; | ||
46 | + QDict *cryptoopts = qcow2_extract_crypto_opts(opts, "luks", errp); | ||
47 | size_t headerlen; | ||
48 | |||
49 | - opts_qdict = qemu_opts_to_qdict(opts, NULL); | ||
50 | - qdict_extract_subqdict(opts_qdict, &cryptoopts, "encrypt."); | ||
51 | - qobject_unref(opts_qdict); | ||
52 | - | ||
53 | - qdict_put_str(cryptoopts, "format", "luks"); | ||
54 | - | ||
55 | create_opts = block_crypto_create_opts_init(cryptoopts, errp); | ||
56 | qobject_unref(cryptoopts); | ||
57 | if (!create_opts) { | ||
58 | @@ -XXX,XX +XXX,XX @@ typedef enum Qcow2AmendOperation { | ||
59 | QCOW2_NO_OPERATION = 0, | ||
60 | |||
61 | QCOW2_UPGRADING, | ||
62 | + QCOW2_UPDATING_ENCRYPTION, | ||
63 | QCOW2_CHANGING_REFCOUNT_ORDER, | ||
64 | QCOW2_DOWNGRADING, | ||
65 | } Qcow2AmendOperation; | ||
66 | @@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, | ||
67 | int ret; | ||
68 | QemuOptDesc *desc = opts->list->desc; | ||
69 | Qcow2AmendHelperCBInfo helper_cb_info; | ||
70 | + bool encryption_update = false; | ||
71 | |||
72 | while (desc && desc->name) { | ||
73 | if (!qemu_opt_find(opts, desc->name)) { | ||
74 | @@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, | ||
75 | backing_file = qemu_opt_get(opts, BLOCK_OPT_BACKING_FILE); | ||
76 | } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FMT)) { | ||
77 | backing_format = qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT); | ||
78 | + } else if (g_str_has_prefix(desc->name, "encrypt.")) { | ||
79 | + if (!s->crypto) { | ||
80 | + error_setg(errp, | ||
81 | + "Can't amend encryption options - encryption not present"); | ||
82 | + return -EINVAL; | ||
83 | + } | ||
84 | + if (s->crypt_method_header != QCOW_CRYPT_LUKS) { | ||
85 | + error_setg(errp, | ||
86 | + "Only LUKS encryption options can be amended"); | ||
87 | + return -ENOTSUP; | ||
88 | + } | ||
89 | + encryption_update = true; | ||
90 | } else if (!strcmp(desc->name, BLOCK_OPT_LAZY_REFCOUNTS)) { | ||
91 | lazy_refcounts = qemu_opt_get_bool(opts, BLOCK_OPT_LAZY_REFCOUNTS, | ||
92 | lazy_refcounts); | ||
93 | @@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, | ||
94 | .original_status_cb = status_cb, | ||
95 | .original_cb_opaque = cb_opaque, | ||
96 | .total_operations = (new_version != old_version) | ||
97 | - + (s->refcount_bits != refcount_bits) | ||
98 | + + (s->refcount_bits != refcount_bits) + | ||
99 | + (encryption_update == true) | ||
100 | }; | ||
101 | |||
102 | /* Upgrade first (some features may require compat=1.1) */ | ||
103 | @@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, | ||
104 | } | ||
105 | } | ||
106 | |||
107 | + if (encryption_update) { | ||
108 | + QDict *amend_opts_dict; | ||
109 | + QCryptoBlockAmendOptions *amend_opts; | ||
110 | + | ||
111 | + helper_cb_info.current_operation = QCOW2_UPDATING_ENCRYPTION; | ||
112 | + amend_opts_dict = qcow2_extract_crypto_opts(opts, "luks", errp); | ||
113 | + if (!amend_opts_dict) { | ||
114 | + return -EINVAL; | ||
115 | + } | ||
116 | + amend_opts = block_crypto_amend_opts_init(amend_opts_dict, errp); | ||
117 | + qobject_unref(amend_opts_dict); | ||
118 | + if (!amend_opts) { | ||
119 | + return -EINVAL; | ||
120 | + } | ||
121 | + ret = qcrypto_block_amend_options(s->crypto, | ||
122 | + qcow2_crypto_hdr_read_func, | ||
123 | + qcow2_crypto_hdr_write_func, | ||
124 | + bs, | ||
125 | + amend_opts, | ||
126 | + force, | ||
127 | + errp); | ||
128 | + qapi_free_QCryptoBlockAmendOptions(amend_opts); | ||
129 | + if (ret < 0) { | ||
130 | + return ret; | ||
131 | + } | ||
132 | + } | ||
133 | + | ||
134 | if (s->refcount_bits != refcount_bits) { | ||
135 | int refcount_order = ctz32(refcount_bits); | ||
136 | |||
137 | @@ -XXX,XX +XXX,XX @@ static QemuOptsList qcow2_amend_opts = { | ||
138 | .name = "qcow2-amend-opts", | ||
139 | .head = QTAILQ_HEAD_INITIALIZER(qcow2_amend_opts.head), | ||
140 | .desc = { | ||
141 | + BLOCK_CRYPTO_OPT_DEF_LUKS_STATE("encrypt."), | ||
142 | + BLOCK_CRYPTO_OPT_DEF_LUKS_KEYSLOT("encrypt."), | ||
143 | + BLOCK_CRYPTO_OPT_DEF_LUKS_OLD_SECRET("encrypt."), | ||
144 | + BLOCK_CRYPTO_OPT_DEF_LUKS_NEW_SECRET("encrypt."), | ||
145 | + BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME("encrypt."), | ||
146 | QCOW_COMMON_OPTIONS, | ||
147 | { /* end of list */ } | ||
148 | } | ||
149 | diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out | ||
96 | index XXXXXXX..XXXXXXX 100644 | 150 | index XXXXXXX..XXXXXXX 100644 |
97 | --- a/tests/qemu-iotests/085.out | 151 | --- a/tests/qemu-iotests/082.out |
98 | +++ b/tests/qemu-iotests/085.out | 152 | +++ b/tests/qemu-iotests/082.out |
99 | @@ -XXX,XX +XXX,XX @@ | 153 | @@ -XXX,XX +XXX,XX @@ Amend options for 'qcow2': |
100 | QA output created by 085 | 154 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) |
101 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | 155 | data_file=<str> - File name of an external data file |
102 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | 156 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image |
103 | +Formatting 'TEST_DIR/t.IMGFMT.1', fmt=IMGFMT size=134217728 | 157 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds |
104 | +Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=134217728 | 158 | + encrypt.keyslot=<num> - Select a single keyslot to modify explicitly |
105 | 159 | + encrypt.new-secret=<str> - New secret to set in the matching keyslots. Empty string to erase | |
106 | === Running QEMU === | 160 | + encrypt.old-secret=<str> - Select all keyslots that match this password |
107 | 161 | + encrypt.state=<str> - Select new state of affected keyslots (active/inactive) | |
108 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_fil | 162 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates |
109 | 163 | refcount_bits=<num> - Width of a reference count entry in bits | |
110 | === Create a couple of snapshots using blockdev-snapshot === | 164 | size=<size> - Virtual disk size |
111 | 165 | @@ -XXX,XX +XXX,XX @@ Amend options for 'qcow2': | |
112 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT | 166 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) |
113 | +Formatting 'TEST_DIR/11-snapshot-v0.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT | 167 | data_file=<str> - File name of an external data file |
114 | { 'execute': 'blockdev-add', 'arguments': { 'driver': 'IMGFMT', 'node-name': 'snap_11', 'backing': null, 'file': { 'driver': 'file', 'filename': 'TEST_DIR/11-snapshot-v0.IMGFMT', 'node-name': 'file_11' } } } | 168 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image |
115 | {"return": {}} | 169 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds |
116 | { 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay':'snap_11' } } | 170 | + encrypt.keyslot=<num> - Select a single keyslot to modify explicitly |
117 | {"return": {}} | 171 | + encrypt.new-secret=<str> - New secret to set in the matching keyslots. Empty string to erase |
118 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT | 172 | + encrypt.old-secret=<str> - Select all keyslots that match this password |
119 | +Formatting 'TEST_DIR/12-snapshot-v0.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT | 173 | + encrypt.state=<str> - Select new state of affected keyslots (active/inactive) |
120 | { 'execute': 'blockdev-add', 'arguments': { 'driver': 'IMGFMT', 'node-name': 'snap_12', 'backing': null, 'file': { 'driver': 'file', 'filename': 'TEST_DIR/12-snapshot-v0.IMGFMT', 'node-name': 'file_12' } } } | 174 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates |
121 | {"return": {}} | 175 | refcount_bits=<num> - Width of a reference count entry in bits |
122 | { 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay':'snap_12' } } | 176 | size=<size> - Virtual disk size |
177 | @@ -XXX,XX +XXX,XX @@ Amend options for 'qcow2': | ||
178 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
179 | data_file=<str> - File name of an external data file | ||
180 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
181 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
182 | + encrypt.keyslot=<num> - Select a single keyslot to modify explicitly | ||
183 | + encrypt.new-secret=<str> - New secret to set in the matching keyslots. Empty string to erase | ||
184 | + encrypt.old-secret=<str> - Select all keyslots that match this password | ||
185 | + encrypt.state=<str> - Select new state of affected keyslots (active/inactive) | ||
186 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
187 | refcount_bits=<num> - Width of a reference count entry in bits | ||
188 | size=<size> - Virtual disk size | ||
189 | @@ -XXX,XX +XXX,XX @@ Amend options for 'qcow2': | ||
190 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
191 | data_file=<str> - File name of an external data file | ||
192 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
193 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
194 | + encrypt.keyslot=<num> - Select a single keyslot to modify explicitly | ||
195 | + encrypt.new-secret=<str> - New secret to set in the matching keyslots. Empty string to erase | ||
196 | + encrypt.old-secret=<str> - Select all keyslots that match this password | ||
197 | + encrypt.state=<str> - Select new state of affected keyslots (active/inactive) | ||
198 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
199 | refcount_bits=<num> - Width of a reference count entry in bits | ||
200 | size=<size> - Virtual disk size | ||
201 | @@ -XXX,XX +XXX,XX @@ Amend options for 'qcow2': | ||
202 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
203 | data_file=<str> - File name of an external data file | ||
204 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
205 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
206 | + encrypt.keyslot=<num> - Select a single keyslot to modify explicitly | ||
207 | + encrypt.new-secret=<str> - New secret to set in the matching keyslots. Empty string to erase | ||
208 | + encrypt.old-secret=<str> - Select all keyslots that match this password | ||
209 | + encrypt.state=<str> - Select new state of affected keyslots (active/inactive) | ||
210 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
211 | refcount_bits=<num> - Width of a reference count entry in bits | ||
212 | size=<size> - Virtual disk size | ||
213 | @@ -XXX,XX +XXX,XX @@ Amend options for 'qcow2': | ||
214 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
215 | data_file=<str> - File name of an external data file | ||
216 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
217 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
218 | + encrypt.keyslot=<num> - Select a single keyslot to modify explicitly | ||
219 | + encrypt.new-secret=<str> - New secret to set in the matching keyslots. Empty string to erase | ||
220 | + encrypt.old-secret=<str> - Select all keyslots that match this password | ||
221 | + encrypt.state=<str> - Select new state of affected keyslots (active/inactive) | ||
222 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
223 | refcount_bits=<num> - Width of a reference count entry in bits | ||
224 | size=<size> - Virtual disk size | ||
225 | @@ -XXX,XX +XXX,XX @@ Amend options for 'qcow2': | ||
226 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
227 | data_file=<str> - File name of an external data file | ||
228 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
229 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
230 | + encrypt.keyslot=<num> - Select a single keyslot to modify explicitly | ||
231 | + encrypt.new-secret=<str> - New secret to set in the matching keyslots. Empty string to erase | ||
232 | + encrypt.old-secret=<str> - Select all keyslots that match this password | ||
233 | + encrypt.state=<str> - Select new state of affected keyslots (active/inactive) | ||
234 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
235 | refcount_bits=<num> - Width of a reference count entry in bits | ||
236 | size=<size> - Virtual disk size | ||
237 | @@ -XXX,XX +XXX,XX @@ Amend options for 'qcow2': | ||
238 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
239 | data_file=<str> - File name of an external data file | ||
240 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
241 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
242 | + encrypt.keyslot=<num> - Select a single keyslot to modify explicitly | ||
243 | + encrypt.new-secret=<str> - New secret to set in the matching keyslots. Empty string to erase | ||
244 | + encrypt.old-secret=<str> - Select all keyslots that match this password | ||
245 | + encrypt.state=<str> - Select new state of affected keyslots (active/inactive) | ||
246 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
247 | refcount_bits=<num> - Width of a reference count entry in bits | ||
248 | size=<size> - Virtual disk size | ||
249 | @@ -XXX,XX +XXX,XX @@ Amend options for 'qcow2': | ||
250 | compat=<str> - Compatibility level (v2 [0.10] or v3 [1.1]) | ||
251 | data_file=<str> - File name of an external data file | ||
252 | data_file_raw=<bool (on/off)> - The external data file must stay valid as a raw image | ||
253 | + encrypt.iter-time=<num> - Time to spend in PBKDF in milliseconds | ||
254 | + encrypt.keyslot=<num> - Select a single keyslot to modify explicitly | ||
255 | + encrypt.new-secret=<str> - New secret to set in the matching keyslots. Empty string to erase | ||
256 | + encrypt.old-secret=<str> - Select all keyslots that match this password | ||
257 | + encrypt.state=<str> - Select new state of affected keyslots (active/inactive) | ||
258 | lazy_refcounts=<bool (on/off)> - Postpone refcount updates | ||
259 | refcount_bits=<num> - Width of a reference count entry in bits | ||
260 | size=<size> - Virtual disk size | ||
123 | -- | 261 | -- |
124 | 2.24.1 | 262 | 2.26.2 |
125 | 263 | ||
126 | 264 | diff view generated by jsdifflib |
1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Add the case to the iotest #214 that checks possibility of writing | 3 | This commit adds two tests, which test the new amend interface |
4 | compressed data of more than one cluster size. The test case involves | 4 | of both luks raw images and qcow2 luks encrypted images. |
5 | the compress filter driver showing a sample usage of that. | ||
6 | 5 | ||
7 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | 6 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> |
8 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 7 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> |
9 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 8 | [mreitz: Let 293 verify that LUKS works; drop $(seq) usage from 293; |
10 | Message-id: 1575288906-551879-4-git-send-email-andrey.shinkevich@virtuozzo.com | 9 | drop 293 and 294 from the auto group] |
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
11 | Message-Id: <20200625125548.870061-16-mreitz@redhat.com> | ||
12 | --- | 12 | --- |
13 | tests/qemu-iotests/214 | 43 ++++++++++++++++++++++++++++++++++++++ | 13 | tests/qemu-iotests/293 | 208 +++++++++++++++++++++++++++++++++++++ |
14 | tests/qemu-iotests/214.out | 14 +++++++++++++ | 14 | tests/qemu-iotests/293.out | 99 ++++++++++++++++++ |
15 | 2 files changed, 57 insertions(+) | 15 | tests/qemu-iotests/294 | 90 ++++++++++++++++ |
16 | tests/qemu-iotests/294.out | 30 ++++++ | ||
17 | tests/qemu-iotests/group | 2 + | ||
18 | 5 files changed, 429 insertions(+) | ||
19 | create mode 100755 tests/qemu-iotests/293 | ||
20 | create mode 100644 tests/qemu-iotests/293.out | ||
21 | create mode 100755 tests/qemu-iotests/294 | ||
22 | create mode 100644 tests/qemu-iotests/294.out | ||
16 | 23 | ||
17 | diff --git a/tests/qemu-iotests/214 b/tests/qemu-iotests/214 | 24 | diff --git a/tests/qemu-iotests/293 b/tests/qemu-iotests/293 |
18 | index XXXXXXX..XXXXXXX 100755 | 25 | new file mode 100755 |
19 | --- a/tests/qemu-iotests/214 | 26 | index XXXXXXX..XXXXXXX |
20 | +++ b/tests/qemu-iotests/214 | 27 | --- /dev/null |
21 | @@ -XXX,XX +XXX,XX @@ _check_test_img -r all | 28 | +++ b/tests/qemu-iotests/293 |
22 | $QEMU_IO -c "read -P 0x11 0 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir | 29 | @@ -XXX,XX +XXX,XX @@ |
23 | $QEMU_IO -c "read -P 0x22 4M 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir | 30 | +#!/usr/bin/env bash |
24 | 31 | +# | |
25 | +echo | 32 | +# Test encryption key management with luks |
26 | +echo "=== Write compressed data of multiple clusters ===" | 33 | +# Based on 134 |
27 | +echo | 34 | +# |
28 | +cluster_size=0x10000 | 35 | +# Copyright (C) 2019 Red Hat, Inc. |
29 | +_make_test_img 2M -o cluster_size=$cluster_size | 36 | +# |
30 | + | 37 | +# This program is free software; you can redistribute it and/or modify |
31 | +echo "Write uncompressed data:" | 38 | +# it under the terms of the GNU General Public License as published by |
32 | +let data_size="8 * $cluster_size" | 39 | +# the Free Software Foundation; either version 2 of the License, or |
33 | +$QEMU_IO -c "write -P 0xaa 0 $data_size" "$TEST_IMG" \ | 40 | +# (at your option) any later version. |
34 | + 2>&1 | _filter_qemu_io | _filter_testdir | 41 | +# |
35 | +sizeA=$($QEMU_IMG info --output=json "$TEST_IMG" | | 42 | +# This program is distributed in the hope that it will be useful, |
36 | + sed -n '/"actual-size":/ s/[^0-9]//gp') | 43 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
37 | + | 44 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
38 | +_make_test_img 2M -o cluster_size=$cluster_size | 45 | +# GNU General Public License for more details. |
39 | +echo "Write compressed data:" | 46 | +# |
40 | +let data_size="3 * $cluster_size + $cluster_size / 2" | 47 | +# You should have received a copy of the GNU General Public License |
41 | +# Set compress on. That will align the written data | 48 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
42 | +# by the cluster size and will write them compressed. | 49 | +# |
43 | +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT \ | 50 | + |
44 | +$QEMU_IO -c "write -P 0xbb 0 $data_size" --image-opts \ | 51 | +# creator |
45 | + "driver=compress,file.driver=$IMGFMT,file.file.driver=file,file.file.filename=$TEST_IMG" \ | 52 | +owner=mlevitsk@redhat.com |
46 | + 2>&1 | _filter_qemu_io | _filter_testdir | 53 | + |
47 | + | 54 | +seq=`basename $0` |
48 | +let offset="4 * $cluster_size + $cluster_size / 4" | 55 | +echo "QA output created by $seq" |
49 | +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT \ | 56 | + |
50 | +$QEMU_IO -c "write -P 0xcc $offset $data_size" "json:{\ | 57 | +status=1 # failure is the default! |
51 | + 'driver': 'compress', | 58 | + |
52 | + 'file': {'driver': '$IMGFMT', | 59 | +_cleanup() |
53 | + 'file': {'driver': 'file', | 60 | +{ |
54 | + 'filename': '$TEST_IMG'}}}" | \ | 61 | + _cleanup_test_img |
55 | + _filter_qemu_io | _filter_testdir | 62 | +} |
56 | + | 63 | +trap "_cleanup; exit \$status" 0 1 2 3 15 |
57 | +sizeB=$($QEMU_IMG info --output=json "$TEST_IMG" | | 64 | + |
58 | + sed -n '/"actual-size":/ s/[^0-9]//gp') | 65 | +# get standard environment, filters and checks |
59 | + | 66 | +. ./common.rc |
60 | +if [ $sizeA -le $sizeB ] | 67 | +. ./common.filter |
61 | +then | 68 | + |
62 | + echo "Compression ERROR" | 69 | +_supported_fmt qcow2 luks |
70 | +_supported_proto file #TODO | ||
71 | +_require_working_luks | ||
72 | + | ||
73 | +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT | ||
74 | + | ||
75 | +if [ "$IMGFMT" = "qcow2" ] ; then | ||
76 | + PR="encrypt." | ||
77 | + EXTRA_IMG_ARGS="-o encrypt.format=luks" | ||
63 | +fi | 78 | +fi |
64 | + | 79 | + |
65 | +$QEMU_IMG check --output=json "$TEST_IMG" | | 80 | + |
66 | + sed -n 's/,$//; /"compressed-clusters":/ s/^ *//p' | 81 | +# secrets: you are supposed to see the password as *******, see :-) |
67 | + | 82 | +S0="--object secret,id=sec0,data=hunter0" |
68 | # success, all done | 83 | +S1="--object secret,id=sec1,data=hunter1" |
69 | echo '*** done' | 84 | +S2="--object secret,id=sec2,data=hunter2" |
70 | rm -f $seq.full | 85 | +S3="--object secret,id=sec3,data=hunter3" |
71 | diff --git a/tests/qemu-iotests/214.out b/tests/qemu-iotests/214.out | 86 | +S4="--object secret,id=sec4,data=hunter4" |
87 | +SECRETS="$S0 $S1 $S2 $S3 $S4" | ||
88 | + | ||
89 | +# image with given secret | ||
90 | +IMGS0="--image-opts driver=$IMGFMT,file.filename=$TEST_IMG,${PR}key-secret=sec0" | ||
91 | +IMGS1="--image-opts driver=$IMGFMT,file.filename=$TEST_IMG,${PR}key-secret=sec1" | ||
92 | +IMGS2="--image-opts driver=$IMGFMT,file.filename=$TEST_IMG,${PR}key-secret=sec2" | ||
93 | +IMGS3="--image-opts driver=$IMGFMT,file.filename=$TEST_IMG,${PR}key-secret=sec3" | ||
94 | +IMGS4="--image-opts driver=$IMGFMT,file.filename=$TEST_IMG,${PR}key-secret=sec4" | ||
95 | + | ||
96 | + | ||
97 | +echo "== creating a test image ==" | ||
98 | +_make_test_img $S0 $EXTRA_IMG_ARGS -o ${PR}key-secret=sec0,${PR}iter-time=10 32M | ||
99 | + | ||
100 | +echo | ||
101 | +echo "== test that key 0 opens the image ==" | ||
102 | +$QEMU_IO $S0 -c "read 0 4096" $IMGS0 | _filter_qemu_io | _filter_testdir | ||
103 | + | ||
104 | +echo | ||
105 | +echo "== adding a password to slot 4 ==" | ||
106 | +$QEMU_IMG amend $SECRETS $IMGS0 -o ${PR}state=active,${PR}new-secret=sec4,${PR}iter-time=10,${PR}keyslot=4 | ||
107 | +echo "== adding a password to slot 1 ==" | ||
108 | +$QEMU_IMG amend $SECRETS $IMGS0 -o ${PR}state=active,${PR}new-secret=sec1,${PR}iter-time=10 | ||
109 | +echo "== adding a password to slot 3 ==" | ||
110 | +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=active,${PR}new-secret=sec3,${PR}iter-time=10,${PR}keyslot=3 | ||
111 | + | ||
112 | +echo "== adding a password to slot 2 ==" | ||
113 | +$QEMU_IMG amend $SECRETS $IMGS3 -o ${PR}state=active,${PR}new-secret=sec2,${PR}iter-time=10 | ||
114 | + | ||
115 | + | ||
116 | +echo "== erase slot 4 ==" | ||
117 | +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=inactive,${PR}keyslot=4 | _filter_img_create | ||
118 | + | ||
119 | + | ||
120 | +echo | ||
121 | +echo "== all secrets should work ==" | ||
122 | +for IMG in "$IMGS0" "$IMGS1" "$IMGS2" "$IMGS3"; do | ||
123 | + $QEMU_IO $SECRETS -c "read 0 4096" $IMG | _filter_qemu_io | _filter_testdir | ||
124 | +done | ||
125 | + | ||
126 | +echo | ||
127 | +echo "== erase slot 0 and try it ==" | ||
128 | +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=inactive,${PR}old-secret=sec0 | _filter_img_create | ||
129 | +$QEMU_IO $SECRETS -c "read 0 4096" $IMGS0 | _filter_qemu_io | _filter_testdir | ||
130 | + | ||
131 | +echo | ||
132 | +echo "== erase slot 2 and try it ==" | ||
133 | +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=inactive,${PR}keyslot=2 | _filter_img_create | ||
134 | +$QEMU_IO $SECRETS -c "read 0 4096" $IMGS2 | _filter_qemu_io | _filter_testdir | ||
135 | + | ||
136 | + | ||
137 | +# at this point slots 1 and 3 should be active | ||
138 | + | ||
139 | +echo | ||
140 | +echo "== filling 4 slots with secret 2 ==" | ||
141 | +for ((i = 0; i < 4; i++)); do | ||
142 | + $QEMU_IMG amend $SECRETS $IMGS3 -o ${PR}state=active,${PR}new-secret=sec2,${PR}iter-time=10 | ||
143 | +done | ||
144 | + | ||
145 | +echo | ||
146 | +echo "== adding secret 0 ==" | ||
147 | + $QEMU_IMG amend $SECRETS $IMGS3 -o ${PR}state=active,${PR}new-secret=sec0,${PR}iter-time=10 | ||
148 | + | ||
149 | +echo | ||
150 | +echo "== adding secret 3 (last slot) ==" | ||
151 | + $QEMU_IMG amend $SECRETS $IMGS3 -o ${PR}state=active,${PR}new-secret=sec3,${PR}iter-time=10 | ||
152 | + | ||
153 | +echo | ||
154 | +echo "== trying to add another slot (should fail) ==" | ||
155 | +$QEMU_IMG amend $SECRETS $IMGS2 -o ${PR}state=active,${PR}new-secret=sec3,${PR}iter-time=10 | ||
156 | + | ||
157 | +echo | ||
158 | +echo "== all secrets should work again ==" | ||
159 | +for IMG in "$IMGS0" "$IMGS1" "$IMGS2" "$IMGS3"; do | ||
160 | + $QEMU_IO $SECRETS -c "read 0 4096" $IMG | _filter_qemu_io | _filter_testdir | ||
161 | +done | ||
162 | + | ||
163 | + | ||
164 | +echo | ||
165 | + | ||
166 | +echo "== erase all keys of secret 2==" | ||
167 | +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=inactive,${PR}old-secret=sec2 | ||
168 | + | ||
169 | +echo "== erase all keys of secret 1==" | ||
170 | +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=inactive,${PR}old-secret=sec1 | ||
171 | + | ||
172 | +echo "== erase all keys of secret 0==" | ||
173 | +$QEMU_IMG amend $SECRETS $IMGS0 -o ${PR}state=inactive,${PR}old-secret=sec0 | ||
174 | + | ||
175 | +echo "== erasing secret3 will fail now since it is the only secret (in 3 slots) ==" | ||
176 | +$QEMU_IMG amend $SECRETS $IMGS3 -o ${PR}state=inactive,${PR}old-secret=sec3 | ||
177 | + | ||
178 | +echo | ||
179 | +echo "== only secret3 should work now ==" | ||
180 | +for IMG in "$IMGS0" "$IMGS1" "$IMGS2" "$IMGS3"; do | ||
181 | + $QEMU_IO $SECRETS -c "read 0 4096" $IMG | _filter_qemu_io | _filter_testdir | ||
182 | +done | ||
183 | + | ||
184 | +echo | ||
185 | +echo "== add secret0 ==" | ||
186 | +$QEMU_IMG amend $SECRETS $IMGS3 -o ${PR}state=active,${PR}new-secret=sec0,${PR}iter-time=10 | ||
187 | + | ||
188 | +echo "== erase secret3 ==" | ||
189 | +$QEMU_IMG amend $SECRETS $IMGS0 -o ${PR}state=inactive,${PR}old-secret=sec3 | ||
190 | + | ||
191 | +echo | ||
192 | +echo "== only secret0 should work now ==" | ||
193 | +for IMG in "$IMGS0" "$IMGS1" "$IMGS2" "$IMGS3"; do | ||
194 | + $QEMU_IO $SECRETS -c "read 0 4096" $IMG | _filter_qemu_io | _filter_testdir | ||
195 | +done | ||
196 | + | ||
197 | +echo | ||
198 | +echo "== replace secret0 with secret1 (should fail) ==" | ||
199 | +$QEMU_IMG amend $SECRETS $IMGS0 -o ${PR}state=active,${PR}new-secret=sec1,${PR}keyslot=0 | ||
200 | + | ||
201 | +echo | ||
202 | +echo "== replace secret0 with secret1 with force (should work) ==" | ||
203 | +$QEMU_IMG amend $SECRETS $IMGS0 -o ${PR}state=active,${PR}new-secret=sec1,${PR}iter-time=10,${PR}keyslot=0 --force | ||
204 | + | ||
205 | +echo | ||
206 | +echo "== only secret1 should work now ==" | ||
207 | +for IMG in "$IMGS0" "$IMGS1" "$IMGS2" "$IMGS3"; do | ||
208 | + $QEMU_IO $SECRETS -c "read 0 4096" $IMG | _filter_qemu_io | _filter_testdir | ||
209 | +done | ||
210 | + | ||
211 | + | ||
212 | +echo | ||
213 | +echo "== erase last secret (should fail) ==" | ||
214 | +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=inactive,${PR}keyslot=0 | ||
215 | +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=inactive,${PR}old-secret=sec1 | ||
216 | + | ||
217 | + | ||
218 | +echo "== erase non existing secrets (should fail) ==" | ||
219 | +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=inactive,${PR}old-secret=sec5 --force | ||
220 | +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=inactive,${PR}old-secret=sec0 --force | ||
221 | +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=inactive,${PR}keyslot=1 --force | ||
222 | + | ||
223 | +echo | ||
224 | +echo "== erase last secret with force by slot (should work) ==" | ||
225 | +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=inactive,${PR}keyslot=0 --force | ||
226 | + | ||
227 | +echo | ||
228 | +echo "== we have no secrets now, data is lost forever ==" | ||
229 | +for IMG in "$IMGS0" "$IMGS1" "$IMGS2" "$IMGS3"; do | ||
230 | + $QEMU_IO $SECRETS -c "read 0 4096" $IMG | _filter_qemu_io | _filter_testdir | ||
231 | +done | ||
232 | + | ||
233 | +# success, all done | ||
234 | +echo "*** done" | ||
235 | +rm -f $seq.full | ||
236 | +status=0 | ||
237 | + | ||
238 | diff --git a/tests/qemu-iotests/293.out b/tests/qemu-iotests/293.out | ||
239 | new file mode 100644 | ||
240 | index XXXXXXX..XXXXXXX | ||
241 | --- /dev/null | ||
242 | +++ b/tests/qemu-iotests/293.out | ||
243 | @@ -XXX,XX +XXX,XX @@ | ||
244 | +QA output created by 293 | ||
245 | +== creating a test image == | ||
246 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 | ||
247 | + | ||
248 | +== test that key 0 opens the image == | ||
249 | +read 4096/4096 bytes at offset 0 | ||
250 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
251 | + | ||
252 | +== adding a password to slot 4 == | ||
253 | +== adding a password to slot 1 == | ||
254 | +== adding a password to slot 3 == | ||
255 | +== adding a password to slot 2 == | ||
256 | +== erase slot 4 == | ||
257 | + | ||
258 | +== all secrets should work == | ||
259 | +read 4096/4096 bytes at offset 0 | ||
260 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
261 | +read 4096/4096 bytes at offset 0 | ||
262 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
263 | +read 4096/4096 bytes at offset 0 | ||
264 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
265 | +read 4096/4096 bytes at offset 0 | ||
266 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
267 | + | ||
268 | +== erase slot 0 and try it == | ||
269 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
270 | + | ||
271 | +== erase slot 2 and try it == | ||
272 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
273 | + | ||
274 | +== filling 4 slots with secret 2 == | ||
275 | + | ||
276 | +== adding secret 0 == | ||
277 | + | ||
278 | +== adding secret 3 (last slot) == | ||
279 | + | ||
280 | +== trying to add another slot (should fail) == | ||
281 | +qemu-img: Can't add a keyslot - all keyslots are in use | ||
282 | + | ||
283 | +== all secrets should work again == | ||
284 | +read 4096/4096 bytes at offset 0 | ||
285 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
286 | +read 4096/4096 bytes at offset 0 | ||
287 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
288 | +read 4096/4096 bytes at offset 0 | ||
289 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
290 | +read 4096/4096 bytes at offset 0 | ||
291 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
292 | + | ||
293 | +== erase all keys of secret 2== | ||
294 | +== erase all keys of secret 1== | ||
295 | +== erase all keys of secret 0== | ||
296 | +== erasing secret3 will fail now since it is the only secret (in 3 slots) == | ||
297 | +qemu-img: All the active keyslots match the (old) password that was given and erasing them will erase all the data in the image irreversibly - refusing operation | ||
298 | + | ||
299 | +== only secret3 should work now == | ||
300 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
301 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
302 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
303 | +read 4096/4096 bytes at offset 0 | ||
304 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
305 | + | ||
306 | +== add secret0 == | ||
307 | +== erase secret3 == | ||
308 | + | ||
309 | +== only secret0 should work now == | ||
310 | +read 4096/4096 bytes at offset 0 | ||
311 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
312 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
313 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
314 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
315 | + | ||
316 | +== replace secret0 with secret1 (should fail) == | ||
317 | +qemu-img: Refusing to overwrite active keyslot 0 - please erase it first | ||
318 | + | ||
319 | +== replace secret0 with secret1 with force (should work) == | ||
320 | + | ||
321 | +== only secret1 should work now == | ||
322 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
323 | +read 4096/4096 bytes at offset 0 | ||
324 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
325 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
326 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
327 | + | ||
328 | +== erase last secret (should fail) == | ||
329 | +qemu-img: Attempt to erase the only active keyslot 0 which will erase all the data in the image irreversibly - refusing operation | ||
330 | +qemu-img: All the active keyslots match the (old) password that was given and erasing them will erase all the data in the image irreversibly - refusing operation | ||
331 | +== erase non existing secrets (should fail) == | ||
332 | +qemu-img: No secret with id 'sec5' | ||
333 | +qemu-img: No keyslots match given (old) password for erase operation | ||
334 | + | ||
335 | +== erase last secret with force by slot (should work) == | ||
336 | + | ||
337 | +== we have no secrets now, data is lost forever == | ||
338 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
339 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
340 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
341 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
342 | +*** done | ||
343 | diff --git a/tests/qemu-iotests/294 b/tests/qemu-iotests/294 | ||
344 | new file mode 100755 | ||
345 | index XXXXXXX..XXXXXXX | ||
346 | --- /dev/null | ||
347 | +++ b/tests/qemu-iotests/294 | ||
348 | @@ -XXX,XX +XXX,XX @@ | ||
349 | +# | ||
350 | +# Copyright (C) 2019 Red Hat, Inc. | ||
351 | +# | ||
352 | +# This program is free software; you can redistribute it and/or modify | ||
353 | +# it under the terms of the GNU General Public License as published by | ||
354 | +# the Free Software Foundation; either version 2 of the License, or | ||
355 | +# (at your option) any later version. | ||
356 | +# | ||
357 | +# This program is distributed in the hope that it will be useful, | ||
358 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
359 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
360 | +# GNU General Public License for more details. | ||
361 | +# | ||
362 | +# You should have received a copy of the GNU General Public License | ||
363 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
364 | +# | ||
365 | + | ||
366 | +# creator | ||
367 | +owner=mlevitsk@redhat.com | ||
368 | + | ||
369 | +seq=`basename $0` | ||
370 | +echo "QA output created by $seq" | ||
371 | + | ||
372 | +status=1 # failure is the default! | ||
373 | + | ||
374 | +_cleanup() | ||
375 | +{ | ||
376 | + _cleanup_test_img | ||
377 | +} | ||
378 | +trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
379 | + | ||
380 | +# get standard environment, filters and checks | ||
381 | +. ./common.rc | ||
382 | +. ./common.filter | ||
383 | + | ||
384 | +_supported_fmt luks | ||
385 | +_supported_proto file #TODO | ||
386 | + | ||
387 | +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT | ||
388 | + | ||
389 | +# you are supposed to see the password as *******, see :-) | ||
390 | +S0="--object secret,id=sec0,data=hunter0" | ||
391 | +S1="--object secret,id=sec1,data=hunter1" | ||
392 | +SECRETS="$S0 $S1" | ||
393 | + | ||
394 | + | ||
395 | +IMGS0="--image-opts driver=$IMGFMT,file.filename=$TEST_IMG,key-secret=sec0" | ||
396 | +IMGS1="--image-opts driver=$IMGFMT,file.filename=$TEST_IMG,key-secret=sec1" | ||
397 | + | ||
398 | +echo "== creating a test image ==" | ||
399 | +_make_test_img $S0 -o "key-secret=sec0,iter-time=10" 32M | ||
400 | + | ||
401 | +echo | ||
402 | +echo "== test that key 0 opens the image ==" | ||
403 | +$QEMU_IO $S0 -c "read 0 4096" $IMGS0 | _filter_qemu_io | _filter_testdir | ||
404 | + | ||
405 | +echo | ||
406 | +echo "== adding a password to slot 1 ==" | ||
407 | +$QEMU_IMG amend $SECRETS $IMGS0 -o state=active,new-secret=sec1,keyslot=1,iter-time=10 | ||
408 | + | ||
409 | +echo | ||
410 | +echo "== 'backup' the image header ==" | ||
411 | +dd if=$TEST_IMG_FILE of=${TEST_IMG_FILE}.bk bs=4K skip=0 count=1 | ||
412 | + | ||
413 | +echo | ||
414 | +echo "== erase slot 0 ==" | ||
415 | +$QEMU_IMG amend $SECRETS $IMGS1 -o state=inactive,keyslot=0 | _filter_img_create | ||
416 | + | ||
417 | +echo | ||
418 | +echo "== test that key 0 doesn't open the image ==" | ||
419 | +$QEMU_IO $S0 -c "read 0 4096" $IMGS0 | _filter_qemu_io | _filter_testdir | ||
420 | + | ||
421 | +echo | ||
422 | +echo "== 'restore' the image header ==" | ||
423 | +dd if=${TEST_IMG_FILE}.bk of=${TEST_IMG_FILE} bs=4K skip=0 count=1 conv=notrunc | ||
424 | + | ||
425 | +echo | ||
426 | +echo "== test that key 0 still doesn't open the image (key material is erased) ==" | ||
427 | +$QEMU_IO $SECRETS -c "read 0 4096" $IMGS0 | _filter_qemu_io | _filter_testdir | ||
428 | + | ||
429 | +echo | ||
430 | +echo "== test that key 1 still works ==" | ||
431 | +$QEMU_IO $SECRETS -c "read 0 4096" $IMGS1 | _filter_qemu_io | _filter_testdir | ||
432 | + | ||
433 | +echo "*** done" | ||
434 | +rm -f $seq.full | ||
435 | +status=0 | ||
436 | + | ||
437 | + | ||
438 | +exit 0 | ||
439 | diff --git a/tests/qemu-iotests/294.out b/tests/qemu-iotests/294.out | ||
440 | new file mode 100644 | ||
441 | index XXXXXXX..XXXXXXX | ||
442 | --- /dev/null | ||
443 | +++ b/tests/qemu-iotests/294.out | ||
444 | @@ -XXX,XX +XXX,XX @@ | ||
445 | +QA output created by 294 | ||
446 | +== creating a test image == | ||
447 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 | ||
448 | + | ||
449 | +== test that key 0 opens the image == | ||
450 | +read 4096/4096 bytes at offset 0 | ||
451 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
452 | + | ||
453 | +== adding a password to slot 1 == | ||
454 | + | ||
455 | +== 'backup' the image header == | ||
456 | +1+0 records in | ||
457 | +1+0 records out | ||
458 | + | ||
459 | +== erase slot 0 == | ||
460 | + | ||
461 | +== test that key 0 doesn't open the image == | ||
462 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
463 | + | ||
464 | +== 'restore' the image header == | ||
465 | +1+0 records in | ||
466 | +1+0 records out | ||
467 | + | ||
468 | +== test that key 0 still doesn't open the image (key material is erased) == | ||
469 | +qemu-io: can't open: Invalid password, cannot unlock any keyslot | ||
470 | + | ||
471 | +== test that key 1 still works == | ||
472 | +read 4096/4096 bytes at offset 0 | ||
473 | +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
474 | +*** done | ||
475 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | ||
72 | index XXXXXXX..XXXXXXX 100644 | 476 | index XXXXXXX..XXXXXXX 100644 |
73 | --- a/tests/qemu-iotests/214.out | 477 | --- a/tests/qemu-iotests/group |
74 | +++ b/tests/qemu-iotests/214.out | 478 | +++ b/tests/qemu-iotests/group |
75 | @@ -XXX,XX +XXX,XX @@ read 4194304/4194304 bytes at offset 0 | 479 | @@ -XXX,XX +XXX,XX @@ |
76 | 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 480 | 290 rw auto quick |
77 | read 4194304/4194304 bytes at offset 4194304 | 481 | 291 rw quick |
78 | 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 482 | 292 rw auto quick |
79 | + | 483 | +293 rw |
80 | +=== Write compressed data of multiple clusters === | 484 | +294 rw quick |
81 | + | 485 | 297 meta |
82 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152 | ||
83 | +Write uncompressed data: | ||
84 | +wrote 524288/524288 bytes at offset 0 | ||
85 | +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
86 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152 | ||
87 | +Write compressed data: | ||
88 | +wrote 229376/229376 bytes at offset 0 | ||
89 | +224 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
90 | +wrote 229376/229376 bytes at offset 278528 | ||
91 | +224 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
92 | +"compressed-clusters": 8 | ||
93 | *** done | ||
94 | -- | 486 | -- |
95 | 2.24.1 | 487 | 2.26.2 |
96 | 488 | ||
97 | 489 | diff view generated by jsdifflib |
1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Allow writing all the data compressed through the filter driver. | 3 | blockdev-amend will be used similiar to blockdev-create |
4 | The written data will be aligned by the cluster size. | 4 | to allow on the fly changes of the structure of the format based block devices. |
5 | Based on the QEMU current implementation, that data can be written to | 5 | |
6 | unallocated clusters only. May be used for a backup job. | 6 | Current plan is to first support encryption keyslot management for luks |
7 | 7 | based formats (raw and embedded in qcow2) | |
8 | Suggested-by: Max Reitz <mreitz@redhat.com> | 8 | |
9 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | 9 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> |
10 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 10 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> |
11 | Message-id: 1575288906-551879-2-git-send-email-andrey.shinkevich@virtuozzo.com | 11 | Message-Id: <20200608094030.670121-12-mlevitsk@redhat.com> |
12 | [mreitz: Replace NULL bdrv_get_format_name() by "(no format)"] | ||
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 12 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
14 | --- | 13 | --- |
15 | block/Makefile.objs | 1 + | 14 | qapi/block-core.json | 42 ++++++++++++++ |
16 | block/filter-compress.c | 168 ++++++++++++++++++++++++++++++++++++++++ | 15 | qapi/job.json | 4 +- |
17 | qapi/block-core.json | 10 ++- | 16 | include/block/block_int.h | 21 +++++-- |
18 | 3 files changed, 175 insertions(+), 4 deletions(-) | 17 | block/amend.c | 113 ++++++++++++++++++++++++++++++++++++++ |
19 | create mode 100644 block/filter-compress.c | 18 | block/Makefile.objs | 2 +- |
20 | 19 | 5 files changed, 174 insertions(+), 8 deletions(-) | |
21 | diff --git a/block/Makefile.objs b/block/Makefile.objs | 20 | create mode 100644 block/amend.c |
22 | index XXXXXXX..XXXXXXX 100644 | 21 | |
23 | --- a/block/Makefile.objs | 22 | diff --git a/qapi/block-core.json b/qapi/block-core.json |
24 | +++ b/block/Makefile.objs | 23 | index XXXXXXX..XXXXXXX 100644 |
25 | @@ -XXX,XX +XXX,XX @@ block-obj-y += crypto.o | 24 | --- a/qapi/block-core.json |
26 | 25 | +++ b/qapi/block-core.json | |
27 | block-obj-y += aio_task.o | 26 | @@ -XXX,XX +XXX,XX @@ |
28 | block-obj-y += backup-top.o | 27 | 'data': { 'job-id': 'str', |
29 | +block-obj-y += filter-compress.o | 28 | 'options': 'BlockdevCreateOptions' } } |
30 | 29 | ||
31 | common-obj-y += stream.o | 30 | +## |
32 | 31 | +# @BlockdevAmendOptions: | |
33 | diff --git a/block/filter-compress.c b/block/filter-compress.c | 32 | +# |
33 | +# Options for amending an image format | ||
34 | +# | ||
35 | +# @driver: Block driver of the node to amend. | ||
36 | +# | ||
37 | +# Since: 5.1 | ||
38 | +## | ||
39 | +{ 'union': 'BlockdevAmendOptions', | ||
40 | + 'base': { | ||
41 | + 'driver': 'BlockdevDriver' }, | ||
42 | + 'discriminator': 'driver', | ||
43 | + 'data': { | ||
44 | + } } | ||
45 | + | ||
46 | +## | ||
47 | +# @x-blockdev-amend: | ||
48 | +# | ||
49 | +# Starts a job to amend format specific options of an existing open block device | ||
50 | +# The job is automatically finalized, but a manual job-dismiss is required. | ||
51 | +# | ||
52 | +# @job-id: Identifier for the newly created job. | ||
53 | +# | ||
54 | +# @node-name: Name of the block node to work on | ||
55 | +# | ||
56 | +# @options: Options (driver specific) | ||
57 | +# | ||
58 | +# @force: Allow unsafe operations, format specific | ||
59 | +# For luks that allows erase of the last active keyslot | ||
60 | +# (permanent loss of data), | ||
61 | +# and replacement of an active keyslot | ||
62 | +# (possible loss of data if IO error happens) | ||
63 | +# | ||
64 | +# Since: 5.1 | ||
65 | +## | ||
66 | +{ 'command': 'x-blockdev-amend', | ||
67 | + 'data': { 'job-id': 'str', | ||
68 | + 'node-name': 'str', | ||
69 | + 'options': 'BlockdevAmendOptions', | ||
70 | + '*force': 'bool' } } | ||
71 | + | ||
72 | ## | ||
73 | # @BlockErrorAction: | ||
74 | # | ||
75 | diff --git a/qapi/job.json b/qapi/job.json | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/qapi/job.json | ||
78 | +++ b/qapi/job.json | ||
79 | @@ -XXX,XX +XXX,XX @@ | ||
80 | # | ||
81 | # @create: image creation job type, see "blockdev-create" (since 3.0) | ||
82 | # | ||
83 | +# @amend: image options amend job type, see "x-blockdev-amend" (since 5.1) | ||
84 | +# | ||
85 | # Since: 1.7 | ||
86 | ## | ||
87 | { 'enum': 'JobType', | ||
88 | - 'data': ['commit', 'stream', 'mirror', 'backup', 'create'] } | ||
89 | + 'data': ['commit', 'stream', 'mirror', 'backup', 'create', 'amend'] } | ||
90 | |||
91 | ## | ||
92 | # @JobStatus: | ||
93 | diff --git a/include/block/block_int.h b/include/block/block_int.h | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/include/block/block_int.h | ||
96 | +++ b/include/block/block_int.h | ||
97 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
98 | int (*bdrv_file_open)(BlockDriverState *bs, QDict *options, int flags, | ||
99 | Error **errp); | ||
100 | void (*bdrv_close)(BlockDriverState *bs); | ||
101 | + | ||
102 | + | ||
103 | int coroutine_fn (*bdrv_co_create)(BlockdevCreateOptions *opts, | ||
104 | Error **errp); | ||
105 | int coroutine_fn (*bdrv_co_create_opts)(BlockDriver *drv, | ||
106 | const char *filename, | ||
107 | QemuOpts *opts, | ||
108 | Error **errp); | ||
109 | + | ||
110 | + int coroutine_fn (*bdrv_co_amend)(BlockDriverState *bs, | ||
111 | + BlockdevAmendOptions *opts, | ||
112 | + bool force, | ||
113 | + Error **errp); | ||
114 | + | ||
115 | + int (*bdrv_amend_options)(BlockDriverState *bs, | ||
116 | + QemuOpts *opts, | ||
117 | + BlockDriverAmendStatusCB *status_cb, | ||
118 | + void *cb_opaque, | ||
119 | + bool force, | ||
120 | + Error **errp); | ||
121 | + | ||
122 | int (*bdrv_make_empty)(BlockDriverState *bs); | ||
123 | |||
124 | /* | ||
125 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
126 | BdrvCheckResult *result, | ||
127 | BdrvCheckMode fix); | ||
128 | |||
129 | - int (*bdrv_amend_options)(BlockDriverState *bs, QemuOpts *opts, | ||
130 | - BlockDriverAmendStatusCB *status_cb, | ||
131 | - void *cb_opaque, | ||
132 | - bool force, | ||
133 | - Error **errp); | ||
134 | - | ||
135 | void (*bdrv_debug_event)(BlockDriverState *bs, BlkdebugEvent event); | ||
136 | |||
137 | /* TODO Better pass a option string/QDict/QemuOpts to add any rule? */ | ||
138 | diff --git a/block/amend.c b/block/amend.c | ||
34 | new file mode 100644 | 139 | new file mode 100644 |
35 | index XXXXXXX..XXXXXXX | 140 | index XXXXXXX..XXXXXXX |
36 | --- /dev/null | 141 | --- /dev/null |
37 | +++ b/block/filter-compress.c | 142 | +++ b/block/amend.c |
38 | @@ -XXX,XX +XXX,XX @@ | 143 | @@ -XXX,XX +XXX,XX @@ |
39 | +/* | 144 | +/* |
40 | + * Compress filter block driver | 145 | + * Block layer code related to image options amend |
41 | + * | 146 | + * |
42 | + * Copyright (c) 2019 Virtuozzo International GmbH | 147 | + * Copyright (c) 2018 Kevin Wolf <kwolf@redhat.com> |
43 | + * | 148 | + * Copyright (c) 2020 Red Hat. Inc |
44 | + * Author: | 149 | + * |
45 | + * Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | 150 | + * Heavily based on create.c |
46 | + * (based on block/copy-on-read.c by Max Reitz) | 151 | + * |
47 | + * | 152 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
48 | + * This program is free software; you can redistribute it and/or | 153 | + * of this software and associated documentation files (the "Software"), to deal |
49 | + * modify it under the terms of the GNU General Public License as | 154 | + * in the Software without restriction, including without limitation the rights |
50 | + * published by the Free Software Foundation; either version 2 or | 155 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
51 | + * (at your option) any later version of the License. | 156 | + * copies of the Software, and to permit persons to whom the Software is |
52 | + * | 157 | + * furnished to do so, subject to the following conditions: |
53 | + * This program is distributed in the hope that it will be useful, | 158 | + * |
54 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | 159 | + * The above copyright notice and this permission notice shall be included in |
55 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 160 | + * all copies or substantial portions of the Software. |
56 | + * GNU General Public License for more details. | 161 | + * |
57 | + * | 162 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
58 | + * You should have received a copy of the GNU General Public License | 163 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
59 | + * along with this program; if not, see <http://www.gnu.org/licenses/>. | 164 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
165 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
166 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
167 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
168 | + * THE SOFTWARE. | ||
60 | + */ | 169 | + */ |
61 | + | 170 | + |
62 | +#include "qemu/osdep.h" | 171 | +#include "qemu/osdep.h" |
63 | +#include "block/block_int.h" | 172 | +#include "block/block_int.h" |
64 | +#include "qemu/module.h" | 173 | +#include "qemu/job.h" |
174 | +#include "qemu/main-loop.h" | ||
175 | +#include "qapi/qapi-commands-block-core.h" | ||
176 | +#include "qapi/qapi-visit-block-core.h" | ||
177 | +#include "qapi/clone-visitor.h" | ||
65 | +#include "qapi/error.h" | 178 | +#include "qapi/error.h" |
66 | + | 179 | + |
67 | + | 180 | +typedef struct BlockdevAmendJob { |
68 | +static int compress_open(BlockDriverState *bs, QDict *options, int flags, | 181 | + Job common; |
69 | + Error **errp) | 182 | + BlockdevAmendOptions *opts; |
183 | + BlockDriverState *bs; | ||
184 | + bool force; | ||
185 | +} BlockdevAmendJob; | ||
186 | + | ||
187 | +static int coroutine_fn blockdev_amend_run(Job *job, Error **errp) | ||
70 | +{ | 188 | +{ |
71 | + bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, | 189 | + BlockdevAmendJob *s = container_of(job, BlockdevAmendJob, common); |
72 | + errp); | 190 | + int ret; |
73 | + if (!bs->file) { | 191 | + |
74 | + return -EINVAL; | 192 | + job_progress_set_remaining(&s->common, 1); |
75 | + } | 193 | + ret = s->bs->drv->bdrv_co_amend(s->bs, s->opts, s->force, errp); |
76 | + | 194 | + job_progress_update(&s->common, 1); |
77 | + if (!bs->file->bs->drv || !block_driver_can_compress(bs->file->bs->drv)) { | 195 | + qapi_free_BlockdevAmendOptions(s->opts); |
196 | + return ret; | ||
197 | +} | ||
198 | + | ||
199 | +static const JobDriver blockdev_amend_job_driver = { | ||
200 | + .instance_size = sizeof(BlockdevAmendJob), | ||
201 | + .job_type = JOB_TYPE_AMEND, | ||
202 | + .run = blockdev_amend_run, | ||
203 | +}; | ||
204 | + | ||
205 | +void qmp_x_blockdev_amend(const char *job_id, | ||
206 | + const char *node_name, | ||
207 | + BlockdevAmendOptions *options, | ||
208 | + bool has_force, | ||
209 | + bool force, | ||
210 | + Error **errp) | ||
211 | +{ | ||
212 | + BlockdevAmendJob *s; | ||
213 | + const char *fmt = BlockdevDriver_str(options->driver); | ||
214 | + BlockDriver *drv = bdrv_find_format(fmt); | ||
215 | + BlockDriverState *bs = bdrv_find_node(node_name); | ||
216 | + | ||
217 | + | ||
218 | + if (!drv) { | ||
219 | + error_setg(errp, "Block driver '%s' not found or not supported", fmt); | ||
220 | + return; | ||
221 | + } | ||
222 | + | ||
223 | + /* | ||
224 | + * If the driver is in the schema, we know that it exists. But it may not | ||
225 | + * be whitelisted. | ||
226 | + */ | ||
227 | + if (bdrv_uses_whitelist() && !bdrv_is_whitelisted(drv, false)) { | ||
228 | + error_setg(errp, "Driver is not whitelisted"); | ||
229 | + return; | ||
230 | + } | ||
231 | + | ||
232 | + if (bs->drv != drv) { | ||
78 | + error_setg(errp, | 233 | + error_setg(errp, |
79 | + "Compression is not supported for underlying format: %s", | 234 | + "x-blockdev-amend doesn't support changing the block driver"); |
80 | + bdrv_get_format_name(bs->file->bs) ?: "(no format)"); | 235 | + return; |
81 | + | 236 | + } |
82 | + return -ENOTSUP; | 237 | + |
83 | + } | 238 | + /* Error out if the driver doesn't support .bdrv_co_amend */ |
84 | + | 239 | + if (!drv->bdrv_co_amend) { |
85 | + bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED | | 240 | + error_setg(errp, "Driver does not support x-blockdev-amend"); |
86 | + (BDRV_REQ_FUA & bs->file->bs->supported_write_flags); | 241 | + return; |
87 | + | 242 | + } |
88 | + bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED | | 243 | + |
89 | + ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & | 244 | + /* Create the block job */ |
90 | + bs->file->bs->supported_zero_flags); | 245 | + s = job_create(job_id, &blockdev_amend_job_driver, NULL, |
91 | + | 246 | + bdrv_get_aio_context(bs), JOB_DEFAULT | JOB_MANUAL_DISMISS, |
92 | + return 0; | 247 | + NULL, NULL, errp); |
248 | + if (!s) { | ||
249 | + return; | ||
250 | + } | ||
251 | + | ||
252 | + s->bs = bs, | ||
253 | + s->opts = QAPI_CLONE(BlockdevAmendOptions, options), | ||
254 | + s->force = has_force ? force : false; | ||
255 | + job_start(&s->common); | ||
93 | +} | 256 | +} |
94 | + | 257 | diff --git a/block/Makefile.objs b/block/Makefile.objs |
95 | + | 258 | index XXXXXXX..XXXXXXX 100644 |
96 | +static int64_t compress_getlength(BlockDriverState *bs) | 259 | --- a/block/Makefile.objs |
97 | +{ | 260 | +++ b/block/Makefile.objs |
98 | + return bdrv_getlength(bs->file->bs); | 261 | @@ -XXX,XX +XXX,XX @@ block-obj-$(CONFIG_WIN32) += file-win32.o win32-aio.o |
99 | +} | 262 | block-obj-$(CONFIG_POSIX) += file-posix.o |
100 | + | 263 | block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o |
101 | + | 264 | block-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o |
102 | +static int coroutine_fn compress_co_preadv_part(BlockDriverState *bs, | 265 | -block-obj-y += null.o mirror.o commit.o io.o create.o |
103 | + uint64_t offset, uint64_t bytes, | 266 | +block-obj-y += null.o mirror.o commit.o io.o create.o amend.o |
104 | + QEMUIOVector *qiov, | 267 | block-obj-y += throttle-groups.o |
105 | + size_t qiov_offset, | 268 | block-obj-$(CONFIG_LINUX) += nvme.o |
106 | + int flags) | 269 | |
107 | +{ | ||
108 | + return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, | ||
109 | + flags); | ||
110 | +} | ||
111 | + | ||
112 | + | ||
113 | +static int coroutine_fn compress_co_pwritev_part(BlockDriverState *bs, | ||
114 | + uint64_t offset, | ||
115 | + uint64_t bytes, | ||
116 | + QEMUIOVector *qiov, | ||
117 | + size_t qiov_offset, int flags) | ||
118 | +{ | ||
119 | + return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, | ||
120 | + flags | BDRV_REQ_WRITE_COMPRESSED); | ||
121 | +} | ||
122 | + | ||
123 | + | ||
124 | +static int coroutine_fn compress_co_pwrite_zeroes(BlockDriverState *bs, | ||
125 | + int64_t offset, int bytes, | ||
126 | + BdrvRequestFlags flags) | ||
127 | +{ | ||
128 | + return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); | ||
129 | +} | ||
130 | + | ||
131 | + | ||
132 | +static int coroutine_fn compress_co_pdiscard(BlockDriverState *bs, | ||
133 | + int64_t offset, int bytes) | ||
134 | +{ | ||
135 | + return bdrv_co_pdiscard(bs->file, offset, bytes); | ||
136 | +} | ||
137 | + | ||
138 | + | ||
139 | +static void compress_refresh_limits(BlockDriverState *bs, Error **errp) | ||
140 | +{ | ||
141 | + BlockDriverInfo bdi; | ||
142 | + int ret; | ||
143 | + | ||
144 | + if (!bs->file) { | ||
145 | + return; | ||
146 | + } | ||
147 | + | ||
148 | + ret = bdrv_get_info(bs->file->bs, &bdi); | ||
149 | + if (ret < 0 || bdi.cluster_size == 0) { | ||
150 | + return; | ||
151 | + } | ||
152 | + | ||
153 | + bs->bl.request_alignment = bdi.cluster_size; | ||
154 | +} | ||
155 | + | ||
156 | + | ||
157 | +static void compress_eject(BlockDriverState *bs, bool eject_flag) | ||
158 | +{ | ||
159 | + bdrv_eject(bs->file->bs, eject_flag); | ||
160 | +} | ||
161 | + | ||
162 | + | ||
163 | +static void compress_lock_medium(BlockDriverState *bs, bool locked) | ||
164 | +{ | ||
165 | + bdrv_lock_medium(bs->file->bs, locked); | ||
166 | +} | ||
167 | + | ||
168 | + | ||
169 | +static bool compress_recurse_is_first_non_filter(BlockDriverState *bs, | ||
170 | + BlockDriverState *candidate) | ||
171 | +{ | ||
172 | + return bdrv_recurse_is_first_non_filter(bs->file->bs, candidate); | ||
173 | +} | ||
174 | + | ||
175 | + | ||
176 | +static BlockDriver bdrv_compress = { | ||
177 | + .format_name = "compress", | ||
178 | + | ||
179 | + .bdrv_open = compress_open, | ||
180 | + .bdrv_child_perm = bdrv_filter_default_perms, | ||
181 | + | ||
182 | + .bdrv_getlength = compress_getlength, | ||
183 | + | ||
184 | + .bdrv_co_preadv_part = compress_co_preadv_part, | ||
185 | + .bdrv_co_pwritev_part = compress_co_pwritev_part, | ||
186 | + .bdrv_co_pwrite_zeroes = compress_co_pwrite_zeroes, | ||
187 | + .bdrv_co_pdiscard = compress_co_pdiscard, | ||
188 | + .bdrv_refresh_limits = compress_refresh_limits, | ||
189 | + | ||
190 | + .bdrv_eject = compress_eject, | ||
191 | + .bdrv_lock_medium = compress_lock_medium, | ||
192 | + | ||
193 | + .bdrv_co_block_status = bdrv_co_block_status_from_file, | ||
194 | + | ||
195 | + .bdrv_recurse_is_first_non_filter = compress_recurse_is_first_non_filter, | ||
196 | + | ||
197 | + .has_variable_length = true, | ||
198 | + .is_filter = true, | ||
199 | +}; | ||
200 | + | ||
201 | +static void bdrv_compress_init(void) | ||
202 | +{ | ||
203 | + bdrv_register(&bdrv_compress); | ||
204 | +} | ||
205 | + | ||
206 | +block_init(bdrv_compress_init); | ||
207 | diff --git a/qapi/block-core.json b/qapi/block-core.json | ||
208 | index XXXXXXX..XXXXXXX 100644 | ||
209 | --- a/qapi/block-core.json | ||
210 | +++ b/qapi/block-core.json | ||
211 | @@ -XXX,XX +XXX,XX @@ | ||
212 | # @copy-on-read: Since 3.0 | ||
213 | # @blklogwrites: Since 3.0 | ||
214 | # @blkreplay: Since 4.2 | ||
215 | +# @compress: Since 5.0 | ||
216 | # | ||
217 | # Since: 2.9 | ||
218 | ## | ||
219 | { 'enum': 'BlockdevDriver', | ||
220 | 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs', | ||
221 | - 'cloop', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'gluster', | ||
222 | - 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 'luks', | ||
223 | - 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', 'qcow', | ||
224 | - 'qcow2', 'qed', 'quorum', 'raw', 'rbd', | ||
225 | + 'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', | ||
226 | + 'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', | ||
227 | + 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', | ||
228 | + 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', | ||
229 | { 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' }, | ||
230 | 'sheepdog', | ||
231 | 'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] } | ||
232 | @@ -XXX,XX +XXX,XX @@ | ||
233 | 'blkreplay': 'BlockdevOptionsBlkreplay', | ||
234 | 'bochs': 'BlockdevOptionsGenericFormat', | ||
235 | 'cloop': 'BlockdevOptionsGenericFormat', | ||
236 | + 'compress': 'BlockdevOptionsGenericFormat', | ||
237 | 'copy-on-read':'BlockdevOptionsGenericFormat', | ||
238 | 'dmg': 'BlockdevOptionsGenericFormat', | ||
239 | 'file': 'BlockdevOptionsFile', | ||
240 | -- | 270 | -- |
241 | 2.24.1 | 271 | 2.26.2 |
242 | 272 | ||
243 | 273 | diff view generated by jsdifflib |
1 | Use _make_test_img whenever possible. This way, we will not ignore | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | user-specified image options. | ||
3 | 2 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> |
5 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 4 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> |
6 | Message-id: 20191107163708.833192-15-mreitz@redhat.com | 5 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
6 | Message-Id: <20200608094030.670121-13-mlevitsk@redhat.com> | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
8 | --- | 8 | --- |
9 | tests/qemu-iotests/094 | 2 +- | 9 | qapi/block-core.json | 14 ++++++++- |
10 | tests/qemu-iotests/111 | 3 +-- | 10 | block/crypto.c | 72 ++++++++++++++++++++++++++++++++------------ |
11 | tests/qemu-iotests/123 | 2 +- | 11 | 2 files changed, 66 insertions(+), 20 deletions(-) |
12 | tests/qemu-iotests/153 | 2 +- | ||
13 | tests/qemu-iotests/200 | 4 ++-- | ||
14 | 5 files changed, 6 insertions(+), 7 deletions(-) | ||
15 | 12 | ||
16 | diff --git a/tests/qemu-iotests/094 b/tests/qemu-iotests/094 | 13 | diff --git a/qapi/block-core.json b/qapi/block-core.json |
17 | index XXXXXXX..XXXXXXX 100755 | 14 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/tests/qemu-iotests/094 | 15 | --- a/qapi/block-core.json |
19 | +++ b/tests/qemu-iotests/094 | 16 | +++ b/qapi/block-core.json |
20 | @@ -XXX,XX +XXX,XX @@ _supported_proto nbd | 17 | @@ -XXX,XX +XXX,XX @@ |
21 | _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" | 18 | 'data': { 'job-id': 'str', |
22 | 19 | 'options': 'BlockdevCreateOptions' } } | |
23 | _make_test_img 64M | 20 | |
24 | -$QEMU_IMG create -f $IMGFMT "$TEST_DIR/source.$IMGFMT" 64M | _filter_img_create | 21 | +## |
25 | +TEST_IMG_FILE="$TEST_DIR/source.$IMGFMT" IMGPROTO=file _make_test_img 64M | 22 | +# @BlockdevAmendOptionsLUKS: |
26 | 23 | +# | |
27 | _launch_qemu -drive if=none,id=src,file="$TEST_DIR/source.$IMGFMT",format=raw \ | 24 | +# Driver specific image amend options for LUKS. |
28 | -nodefaults | 25 | +# |
29 | diff --git a/tests/qemu-iotests/111 b/tests/qemu-iotests/111 | 26 | +# Since: 5.1 |
30 | index XXXXXXX..XXXXXXX 100755 | 27 | +## |
31 | --- a/tests/qemu-iotests/111 | 28 | +{ 'struct': 'BlockdevAmendOptionsLUKS', |
32 | +++ b/tests/qemu-iotests/111 | 29 | + 'base': 'QCryptoBlockAmendOptionsLUKS', |
33 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qed qcow qcow2 vmdk | 30 | + 'data': { } |
34 | _supported_proto file | 31 | +} |
35 | _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" | 32 | + |
36 | 33 | ## | |
37 | -$QEMU_IMG create -f $IMGFMT -b "$TEST_IMG.inexistent" "$TEST_IMG" 2>&1 \ | 34 | # @BlockdevAmendOptions: |
38 | - | _filter_testdir | _filter_imgfmt | 35 | # |
39 | +_make_test_img -b "$TEST_IMG.inexistent" | 36 | @@ -XXX,XX +XXX,XX @@ |
40 | 37 | 'driver': 'BlockdevDriver' }, | |
41 | # success, all done | 38 | 'discriminator': 'driver', |
42 | echo '*** done' | 39 | 'data': { |
43 | diff --git a/tests/qemu-iotests/123 b/tests/qemu-iotests/123 | 40 | - } } |
44 | index XXXXXXX..XXXXXXX 100755 | 41 | + 'luks': 'BlockdevAmendOptionsLUKS' } } |
45 | --- a/tests/qemu-iotests/123 | 42 | |
46 | +++ b/tests/qemu-iotests/123 | 43 | ## |
47 | @@ -XXX,XX +XXX,XX @@ _supported_os Linux | 44 | # @x-blockdev-amend: |
48 | SRC_IMG="$TEST_DIR/source.$IMGFMT" | 45 | diff --git a/block/crypto.c b/block/crypto.c |
49 | 46 | index XXXXXXX..XXXXXXX 100644 | |
50 | _make_test_img 1M | 47 | --- a/block/crypto.c |
51 | -$QEMU_IMG create -f $IMGFMT "$SRC_IMG" 1M | _filter_img_create | 48 | +++ b/block/crypto.c |
52 | +TEST_IMG_FILE=$SRC_IMG IMGPROTO=file _make_test_img 1M | 49 | @@ -XXX,XX +XXX,XX @@ block_crypto_get_specific_info_luks(BlockDriverState *bs, Error **errp) |
53 | 50 | } | |
54 | $QEMU_IO -c 'write -P 42 0 1M' "$SRC_IMG" | _filter_qemu_io | 51 | |
55 | 52 | static int | |
56 | diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153 | 53 | -block_crypto_amend_options_luks(BlockDriverState *bs, |
57 | index XXXXXXX..XXXXXXX 100755 | 54 | - QemuOpts *opts, |
58 | --- a/tests/qemu-iotests/153 | 55 | - BlockDriverAmendStatusCB *status_cb, |
59 | +++ b/tests/qemu-iotests/153 | 56 | - void *cb_opaque, |
60 | @@ -XXX,XX +XXX,XX @@ for opts1 in "" "read-only=on" "read-only=on,force-share=on"; do | 57 | - bool force, |
61 | 58 | - Error **errp) | |
62 | echo | 59 | +block_crypto_amend_options_generic_luks(BlockDriverState *bs, |
63 | echo "== Creating test image ==" | 60 | + QCryptoBlockAmendOptions *amend_options, |
64 | - $QEMU_IMG create -f $IMGFMT "${TEST_IMG}" -b ${TEST_IMG}.base | _filter_img_create | 61 | + bool force, |
65 | + _make_test_img -b "${TEST_IMG}.base" | 62 | + Error **errp) |
66 | 63 | { | |
67 | echo | 64 | BlockCrypto *crypto = bs->opaque; |
68 | echo "== Launching QEMU, opts: '$opts1' ==" | 65 | - QDict *cryptoopts = NULL; |
69 | diff --git a/tests/qemu-iotests/200 b/tests/qemu-iotests/200 | 66 | - QCryptoBlockAmendOptions *amend_options = NULL; |
70 | index XXXXXXX..XXXXXXX 100755 | 67 | int ret; |
71 | --- a/tests/qemu-iotests/200 | 68 | |
72 | +++ b/tests/qemu-iotests/200 | 69 | assert(crypto); |
73 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | 70 | assert(crypto->block); |
74 | BACKING_IMG="${TEST_DIR}/backing.img" | 71 | - crypto->updating_keys = true; |
75 | TEST_IMG="${TEST_DIR}/test.img" | 72 | |
76 | 73 | + /* apply for exclusive read/write permissions to the underlying file*/ | |
77 | -${QEMU_IMG} create -f $IMGFMT "${BACKING_IMG}" 512M | _filter_img_create | 74 | + crypto->updating_keys = true; |
78 | -${QEMU_IMG} create -f $IMGFMT -F $IMGFMT "${TEST_IMG}" -b "${BACKING_IMG}" 512M | _filter_img_create | 75 | ret = bdrv_child_refresh_perms(bs, bs->file, errp); |
79 | +TEST_IMG="$BACKING_IMG" _make_test_img 512M | 76 | - if (ret < 0) { |
80 | +_make_test_img -F $IMGFMT -b "$BACKING_IMG" 512M | 77 | - goto cleanup; |
81 | 78 | - } | |
82 | ${QEMU_IO} -c "write -P 0xa5 512 300M" "${BACKING_IMG}" | _filter_qemu_io | 79 | - |
80 | - cryptoopts = qemu_opts_to_qdict(opts, NULL); | ||
81 | - qdict_put_str(cryptoopts, "format", "luks"); | ||
82 | - amend_options = block_crypto_amend_opts_init(cryptoopts, errp); | ||
83 | - if (!amend_options) { | ||
84 | - ret = -EINVAL; | ||
85 | + if (ret) { | ||
86 | goto cleanup; | ||
87 | } | ||
88 | |||
89 | @@ -XXX,XX +XXX,XX @@ block_crypto_amend_options_luks(BlockDriverState *bs, | ||
90 | force, | ||
91 | errp); | ||
92 | cleanup: | ||
93 | + /* release exclusive read/write permissions to the underlying file*/ | ||
94 | crypto->updating_keys = false; | ||
95 | bdrv_child_refresh_perms(bs, bs->file, errp); | ||
96 | - qapi_free_QCryptoBlockAmendOptions(amend_options); | ||
97 | + return ret; | ||
98 | +} | ||
99 | + | ||
100 | +static int | ||
101 | +block_crypto_amend_options_luks(BlockDriverState *bs, | ||
102 | + QemuOpts *opts, | ||
103 | + BlockDriverAmendStatusCB *status_cb, | ||
104 | + void *cb_opaque, | ||
105 | + bool force, | ||
106 | + Error **errp) | ||
107 | +{ | ||
108 | + BlockCrypto *crypto = bs->opaque; | ||
109 | + QDict *cryptoopts = NULL; | ||
110 | + QCryptoBlockAmendOptions *amend_options = NULL; | ||
111 | + int ret = -EINVAL; | ||
112 | + | ||
113 | + assert(crypto); | ||
114 | + assert(crypto->block); | ||
115 | + | ||
116 | + cryptoopts = qemu_opts_to_qdict(opts, NULL); | ||
117 | + qdict_put_str(cryptoopts, "format", "luks"); | ||
118 | + amend_options = block_crypto_amend_opts_init(cryptoopts, errp); | ||
119 | qobject_unref(cryptoopts); | ||
120 | + if (!amend_options) { | ||
121 | + goto cleanup; | ||
122 | + } | ||
123 | + ret = block_crypto_amend_options_generic_luks(bs, amend_options, | ||
124 | + force, errp); | ||
125 | +cleanup: | ||
126 | + qapi_free_QCryptoBlockAmendOptions(amend_options); | ||
127 | return ret; | ||
128 | } | ||
129 | |||
130 | +static int | ||
131 | +coroutine_fn block_crypto_co_amend_luks(BlockDriverState *bs, | ||
132 | + BlockdevAmendOptions *opts, | ||
133 | + bool force, | ||
134 | + Error **errp) | ||
135 | +{ | ||
136 | + QCryptoBlockAmendOptions amend_opts; | ||
137 | + | ||
138 | + amend_opts = (QCryptoBlockAmendOptions) { | ||
139 | + .format = Q_CRYPTO_BLOCK_FORMAT_LUKS, | ||
140 | + .u.luks = *qapi_BlockdevAmendOptionsLUKS_base(&opts->u.luks), | ||
141 | + }; | ||
142 | + return block_crypto_amend_options_generic_luks(bs, &amend_opts, | ||
143 | + force, errp); | ||
144 | +} | ||
145 | |||
146 | static void | ||
147 | block_crypto_child_perms(BlockDriverState *bs, BdrvChild *c, | ||
148 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_crypto_luks = { | ||
149 | .bdrv_get_info = block_crypto_get_info_luks, | ||
150 | .bdrv_get_specific_info = block_crypto_get_specific_info_luks, | ||
151 | .bdrv_amend_options = block_crypto_amend_options_luks, | ||
152 | + .bdrv_co_amend = block_crypto_co_amend_luks, | ||
153 | |||
154 | .is_format = true, | ||
83 | 155 | ||
84 | -- | 156 | -- |
85 | 2.24.1 | 157 | 2.26.2 |
86 | 158 | ||
87 | 159 | diff view generated by jsdifflib |
1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | 1 | From: Maxim Levitsky <mlevitsk@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | QEMU currently supports writing compressed data of the size equal to | 3 | Currently the implementation only supports amending the encryption |
4 | one cluster. This patch allows writing QCOW2 compressed data that | 4 | options, unlike the qemu-img version |
5 | exceed one cluster. Now, we split buffered data into separate clusters | ||
6 | and write them compressed using the block/aio_task API. | ||
7 | 5 | ||
8 | Suggested-by: Pavel Butsykin <pbutsykin@virtuozzo.com> | 6 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> |
9 | Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 7 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> |
10 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | ||
11 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
12 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 8 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
13 | Message-id: 1575288906-551879-3-git-send-email-andrey.shinkevich@virtuozzo.com | 9 | Message-Id: <20200608094030.670121-14-mlevitsk@redhat.com> |
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
15 | --- | 11 | --- |
16 | block/qcow2.c | 102 +++++++++++++++++++++++++++++++++++++------------- | 12 | qapi/block-core.json | 16 +++++++++++++++- |
17 | 1 file changed, 75 insertions(+), 27 deletions(-) | 13 | block/qcow2.c | 39 +++++++++++++++++++++++++++++++++++++++ |
14 | 2 files changed, 54 insertions(+), 1 deletion(-) | ||
18 | 15 | ||
16 | diff --git a/qapi/block-core.json b/qapi/block-core.json | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/qapi/block-core.json | ||
19 | +++ b/qapi/block-core.json | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | 'data': { } | ||
22 | } | ||
23 | |||
24 | +## | ||
25 | +# @BlockdevAmendOptionsQcow2: | ||
26 | +# | ||
27 | +# Driver specific image amend options for qcow2. | ||
28 | +# For now, only encryption options can be amended | ||
29 | +# | ||
30 | +# @encrypt Encryption options to be amended | ||
31 | +# | ||
32 | +# Since: 5.1 | ||
33 | +## | ||
34 | +{ 'struct': 'BlockdevAmendOptionsQcow2', | ||
35 | + 'data': { '*encrypt': 'QCryptoBlockAmendOptions' } } | ||
36 | + | ||
37 | ## | ||
38 | # @BlockdevAmendOptions: | ||
39 | # | ||
40 | @@ -XXX,XX +XXX,XX @@ | ||
41 | 'driver': 'BlockdevDriver' }, | ||
42 | 'discriminator': 'driver', | ||
43 | 'data': { | ||
44 | - 'luks': 'BlockdevAmendOptionsLUKS' } } | ||
45 | + 'luks': 'BlockdevAmendOptionsLUKS', | ||
46 | + 'qcow2': 'BlockdevAmendOptionsQcow2' } } | ||
47 | |||
48 | ## | ||
49 | # @x-blockdev-amend: | ||
19 | diff --git a/block/qcow2.c b/block/qcow2.c | 50 | diff --git a/block/qcow2.c b/block/qcow2.c |
20 | index XXXXXXX..XXXXXXX 100644 | 51 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/block/qcow2.c | 52 | --- a/block/qcow2.c |
22 | +++ b/block/qcow2.c | 53 | +++ b/block/qcow2.c |
23 | @@ -XXX,XX +XXX,XX @@ fail: | 54 | @@ -XXX,XX +XXX,XX @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, |
24 | return ret; | 55 | return 0; |
25 | } | 56 | } |
26 | 57 | ||
27 | -/* XXX: put compressed sectors first, then all the cluster aligned | 58 | +static int coroutine_fn qcow2_co_amend(BlockDriverState *bs, |
28 | - tables to avoid losing bytes in alignment */ | 59 | + BlockdevAmendOptions *opts, |
29 | static coroutine_fn int | 60 | + bool force, |
30 | -qcow2_co_pwritev_compressed_part(BlockDriverState *bs, | 61 | + Error **errp) |
31 | +qcow2_co_pwritev_compressed_task(BlockDriverState *bs, | ||
32 | uint64_t offset, uint64_t bytes, | ||
33 | QEMUIOVector *qiov, size_t qiov_offset) | ||
34 | { | ||
35 | @@ -XXX,XX +XXX,XX @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs, | ||
36 | uint8_t *buf, *out_buf; | ||
37 | uint64_t cluster_offset; | ||
38 | |||
39 | - if (has_data_file(bs)) { | ||
40 | - return -ENOTSUP; | ||
41 | - } | ||
42 | - | ||
43 | - if (bytes == 0) { | ||
44 | - /* align end of file to a sector boundary to ease reading with | ||
45 | - sector based I/Os */ | ||
46 | - int64_t len = bdrv_getlength(bs->file->bs); | ||
47 | - if (len < 0) { | ||
48 | - return len; | ||
49 | - } | ||
50 | - return bdrv_co_truncate(bs->file, len, false, PREALLOC_MODE_OFF, NULL); | ||
51 | - } | ||
52 | - | ||
53 | - if (offset_into_cluster(s, offset)) { | ||
54 | - return -EINVAL; | ||
55 | - } | ||
56 | + assert(bytes == s->cluster_size || (bytes < s->cluster_size && | ||
57 | + (offset + bytes == bs->total_sectors << BDRV_SECTOR_BITS))); | ||
58 | |||
59 | buf = qemu_blockalign(bs, s->cluster_size); | ||
60 | - if (bytes != s->cluster_size) { | ||
61 | - if (bytes > s->cluster_size || | ||
62 | - offset + bytes != bs->total_sectors << BDRV_SECTOR_BITS) | ||
63 | - { | ||
64 | - qemu_vfree(buf); | ||
65 | - return -EINVAL; | ||
66 | - } | ||
67 | + if (bytes < s->cluster_size) { | ||
68 | /* Zero-pad last write if image size is not cluster aligned */ | ||
69 | memset(buf + bytes, 0, s->cluster_size - bytes); | ||
70 | } | ||
71 | @@ -XXX,XX +XXX,XX @@ fail: | ||
72 | return ret; | ||
73 | } | ||
74 | |||
75 | +static coroutine_fn int qcow2_co_pwritev_compressed_task_entry(AioTask *task) | ||
76 | +{ | 62 | +{ |
77 | + Qcow2AioTask *t = container_of(task, Qcow2AioTask, task); | 63 | + BlockdevAmendOptionsQcow2 *qopts = &opts->u.qcow2; |
78 | + | ||
79 | + assert(!t->cluster_type && !t->l2meta); | ||
80 | + | ||
81 | + return qcow2_co_pwritev_compressed_task(t->bs, t->offset, t->bytes, t->qiov, | ||
82 | + t->qiov_offset); | ||
83 | +} | ||
84 | + | ||
85 | +/* | ||
86 | + * XXX: put compressed sectors first, then all the cluster aligned | ||
87 | + * tables to avoid losing bytes in alignment | ||
88 | + */ | ||
89 | +static coroutine_fn int | ||
90 | +qcow2_co_pwritev_compressed_part(BlockDriverState *bs, | ||
91 | + uint64_t offset, uint64_t bytes, | ||
92 | + QEMUIOVector *qiov, size_t qiov_offset) | ||
93 | +{ | ||
94 | + BDRVQcow2State *s = bs->opaque; | 64 | + BDRVQcow2State *s = bs->opaque; |
95 | + AioTaskPool *aio = NULL; | ||
96 | + int ret = 0; | 65 | + int ret = 0; |
97 | + | 66 | + |
98 | + if (has_data_file(bs)) { | 67 | + if (qopts->has_encrypt) { |
99 | + return -ENOTSUP; | 68 | + if (!s->crypto) { |
100 | + } | 69 | + error_setg(errp, "image is not encrypted, can't amend"); |
101 | + | 70 | + return -EOPNOTSUPP; |
102 | + if (bytes == 0) { | ||
103 | + /* | ||
104 | + * align end of file to a sector boundary to ease reading with | ||
105 | + * sector based I/Os | ||
106 | + */ | ||
107 | + int64_t len = bdrv_getlength(bs->file->bs); | ||
108 | + if (len < 0) { | ||
109 | + return len; | ||
110 | + } | ||
111 | + return bdrv_co_truncate(bs->file, len, false, PREALLOC_MODE_OFF, NULL); | ||
112 | + } | ||
113 | + | ||
114 | + if (offset_into_cluster(s, offset)) { | ||
115 | + return -EINVAL; | ||
116 | + } | ||
117 | + | ||
118 | + while (bytes && aio_task_pool_status(aio) == 0) { | ||
119 | + uint64_t chunk_size = MIN(bytes, s->cluster_size); | ||
120 | + | ||
121 | + if (!aio && chunk_size != bytes) { | ||
122 | + aio = aio_task_pool_new(QCOW2_MAX_WORKERS); | ||
123 | + } | 71 | + } |
124 | + | 72 | + |
125 | + ret = qcow2_add_task(bs, aio, qcow2_co_pwritev_compressed_task_entry, | 73 | + if (qopts->encrypt->format != Q_CRYPTO_BLOCK_FORMAT_LUKS) { |
126 | + 0, 0, offset, chunk_size, qiov, qiov_offset, NULL); | 74 | + error_setg(errp, |
127 | + if (ret < 0) { | 75 | + "Amend can't be used to change the qcow2 encryption format"); |
128 | + break; | 76 | + return -EOPNOTSUPP; |
129 | + } | 77 | + } |
130 | + qiov_offset += chunk_size; | 78 | + |
131 | + offset += chunk_size; | 79 | + if (s->crypt_method_header != QCOW_CRYPT_LUKS) { |
132 | + bytes -= chunk_size; | 80 | + error_setg(errp, |
81 | + "Only LUKS encryption options can be amended for qcow2 with blockdev-amend"); | ||
82 | + return -EOPNOTSUPP; | ||
83 | + } | ||
84 | + | ||
85 | + ret = qcrypto_block_amend_options(s->crypto, | ||
86 | + qcow2_crypto_hdr_read_func, | ||
87 | + qcow2_crypto_hdr_write_func, | ||
88 | + bs, | ||
89 | + qopts->encrypt, | ||
90 | + force, | ||
91 | + errp); | ||
133 | + } | 92 | + } |
134 | + | ||
135 | + if (aio) { | ||
136 | + aio_task_pool_wait_all(aio); | ||
137 | + if (ret == 0) { | ||
138 | + ret = aio_task_pool_status(aio); | ||
139 | + } | ||
140 | + g_free(aio); | ||
141 | + } | ||
142 | + | ||
143 | + return ret; | 93 | + return ret; |
144 | +} | 94 | +} |
145 | + | 95 | + |
146 | static int coroutine_fn | 96 | /* |
147 | qcow2_co_preadv_compressed(BlockDriverState *bs, | 97 | * If offset or size are negative, respectively, they will not be included in |
148 | uint64_t file_cluster_offset, | 98 | * the BLOCK_IMAGE_CORRUPTED event emitted. |
99 | @@ -XXX,XX +XXX,XX @@ BlockDriver bdrv_qcow2 = { | ||
100 | .mutable_opts = mutable_opts, | ||
101 | .bdrv_co_check = qcow2_co_check, | ||
102 | .bdrv_amend_options = qcow2_amend_options, | ||
103 | + .bdrv_co_amend = qcow2_co_amend, | ||
104 | |||
105 | .bdrv_detach_aio_context = qcow2_detach_aio_context, | ||
106 | .bdrv_attach_aio_context = qcow2_attach_aio_context, | ||
149 | -- | 107 | -- |
150 | 2.24.1 | 108 | 2.26.2 |
151 | 109 | ||
152 | 110 | diff view generated by jsdifflib |
1 | From: Maxim Levitsky <mlevitsk@redhat.com> | ||
---|---|---|---|
2 | |||
3 | This commit adds two tests that cover the | ||
4 | new blockdev-amend functionality of luks and qcow2 driver | ||
5 | |||
6 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
7 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
8 | [mreitz: Let 295 verify that LUKS works; drop 295 and 296 from the auto | ||
9 | group] | ||
1 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
2 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 11 | Message-Id: <20200625125548.870061-20-mreitz@redhat.com> |
3 | Tested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
4 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
5 | Message-id: 20191108123455.39445-6-mreitz@redhat.com | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
7 | --- | 12 | --- |
8 | tests/qemu-iotests/041 | 44 ++++++++++++++++++++++++++++++++++++++ | 13 | tests/qemu-iotests/295 | 280 +++++++++++++++++++++++++++++++++++++ |
9 | tests/qemu-iotests/041.out | 4 ++-- | 14 | tests/qemu-iotests/295.out | 40 ++++++ |
10 | 2 files changed, 46 insertions(+), 2 deletions(-) | 15 | tests/qemu-iotests/296 | 234 +++++++++++++++++++++++++++++++ |
16 | tests/qemu-iotests/296.out | 33 +++++ | ||
17 | tests/qemu-iotests/group | 2 + | ||
18 | 5 files changed, 589 insertions(+) | ||
19 | create mode 100755 tests/qemu-iotests/295 | ||
20 | create mode 100644 tests/qemu-iotests/295.out | ||
21 | create mode 100755 tests/qemu-iotests/296 | ||
22 | create mode 100644 tests/qemu-iotests/296.out | ||
11 | 23 | ||
12 | diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 | 24 | diff --git a/tests/qemu-iotests/295 b/tests/qemu-iotests/295 |
13 | index XXXXXXX..XXXXXXX 100755 | 25 | new file mode 100755 |
14 | --- a/tests/qemu-iotests/041 | 26 | index XXXXXXX..XXXXXXX |
15 | +++ b/tests/qemu-iotests/041 | 27 | --- /dev/null |
16 | @@ -XXX,XX +XXX,XX @@ class TestOrphanedSource(iotests.QMPTestCase): | 28 | +++ b/tests/qemu-iotests/295 |
17 | target='dest-ro') | 29 | @@ -XXX,XX +XXX,XX @@ |
18 | self.assert_qmp(result, 'error/class', 'GenericError') | 30 | +#!/usr/bin/env python3 |
19 | 31 | +# | |
20 | + def test_failing_permission_in_complete(self): | 32 | +# Test case QMP's encrypted key management |
21 | + self.assert_no_active_block_jobs() | 33 | +# |
22 | + | 34 | +# Copyright (C) 2019 Red Hat, Inc. |
23 | + # Unshare consistent-read on the target | 35 | +# |
24 | + # (The mirror job does not care) | 36 | +# This program is free software; you can redistribute it and/or modify |
25 | + result = self.vm.qmp('blockdev-add', | 37 | +# it under the terms of the GNU General Public License as published by |
26 | + driver='blkdebug', | 38 | +# the Free Software Foundation; either version 2 of the License, or |
27 | + node_name='dest-perm', | 39 | +# (at your option) any later version. |
28 | + image='dest', | 40 | +# |
29 | + unshare_child_perms=['consistent-read']) | 41 | +# This program is distributed in the hope that it will be useful, |
42 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
43 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
44 | +# GNU General Public License for more details. | ||
45 | +# | ||
46 | +# You should have received a copy of the GNU General Public License | ||
47 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
48 | +# | ||
49 | + | ||
50 | +import iotests | ||
51 | +import os | ||
52 | +import time | ||
53 | +import json | ||
54 | + | ||
55 | +test_img = os.path.join(iotests.test_dir, 'test.img') | ||
56 | + | ||
57 | +class Secret: | ||
58 | + def __init__(self, index): | ||
59 | + self._id = "keysec" + str(index) | ||
60 | + # you are not supposed to see the password... | ||
61 | + self._secret = "hunter" + str(index) | ||
62 | + | ||
63 | + def id(self): | ||
64 | + return self._id | ||
65 | + | ||
66 | + def secret(self): | ||
67 | + return self._secret | ||
68 | + | ||
69 | + def to_cmdline_object(self): | ||
70 | + return [ "secret,id=" + self._id + ",data=" + self._secret] | ||
71 | + | ||
72 | + def to_qmp_object(self): | ||
73 | + return { "qom_type" : "secret", "id": self.id(), | ||
74 | + "props": { "data": self.secret() } } | ||
75 | + | ||
76 | +################################################################################ | ||
77 | +class EncryptionSetupTestCase(iotests.QMPTestCase): | ||
78 | + | ||
79 | + # test case startup | ||
80 | + def setUp(self): | ||
81 | + # start the VM | ||
82 | + self.vm = iotests.VM() | ||
83 | + self.vm.launch() | ||
84 | + | ||
85 | + # create the secrets and load 'em into the VM | ||
86 | + self.secrets = [ Secret(i) for i in range(0, 6) ] | ||
87 | + for secret in self.secrets: | ||
88 | + result = self.vm.qmp("object-add", **secret.to_qmp_object()) | ||
89 | + self.assert_qmp(result, 'return', {}) | ||
90 | + | ||
91 | + if iotests.imgfmt == "qcow2": | ||
92 | + self.pfx = "encrypt." | ||
93 | + self.img_opts = [ '-o', "encrypt.format=luks" ] | ||
94 | + else: | ||
95 | + self.pfx = "" | ||
96 | + self.img_opts = [] | ||
97 | + | ||
98 | + # test case shutdown | ||
99 | + def tearDown(self): | ||
100 | + # stop the VM | ||
101 | + self.vm.shutdown() | ||
102 | + | ||
103 | + ########################################################################### | ||
104 | + # create the encrypted block device | ||
105 | + def createImg(self, file, secret): | ||
106 | + | ||
107 | + iotests.qemu_img( | ||
108 | + 'create', | ||
109 | + '--object', *secret.to_cmdline_object(), | ||
110 | + '-f', iotests.imgfmt, | ||
111 | + '-o', self.pfx + 'key-secret=' + secret.id(), | ||
112 | + '-o', self.pfx + 'iter-time=10', | ||
113 | + *self.img_opts, | ||
114 | + file, | ||
115 | + '1M') | ||
116 | + | ||
117 | + ########################################################################### | ||
118 | + # open an encrypted block device | ||
119 | + def openImageQmp(self, id, file, secret, read_only = False): | ||
120 | + | ||
121 | + encrypt_options = { | ||
122 | + 'key-secret' : secret.id() | ||
123 | + } | ||
124 | + | ||
125 | + if iotests.imgfmt == "qcow2": | ||
126 | + encrypt_options = { | ||
127 | + 'encrypt': { | ||
128 | + 'format':'luks', | ||
129 | + **encrypt_options | ||
130 | + } | ||
131 | + } | ||
132 | + | ||
133 | + result = self.vm.qmp('blockdev-add', ** | ||
134 | + { | ||
135 | + 'driver': iotests.imgfmt, | ||
136 | + 'node-name': id, | ||
137 | + 'read-only': read_only, | ||
138 | + | ||
139 | + **encrypt_options, | ||
140 | + | ||
141 | + 'file': { | ||
142 | + 'driver': 'file', | ||
143 | + 'filename': test_img, | ||
144 | + } | ||
145 | + } | ||
146 | + ) | ||
30 | + self.assert_qmp(result, 'return', {}) | 147 | + self.assert_qmp(result, 'return', {}) |
31 | + | 148 | + |
32 | + result = self.vm.qmp('blockdev-mirror', job_id='job', device='src', | 149 | + # close the encrypted block device |
33 | + sync='full', target='dest', | 150 | + def closeImageQmp(self, id): |
34 | + filter_node_name='mirror-filter') | 151 | + result = self.vm.qmp('blockdev-del', **{ 'node-name': id }) |
35 | + self.assert_qmp(result, 'return', {}) | 152 | + self.assert_qmp(result, 'return', {}) |
36 | + | 153 | + |
37 | + # Require consistent-read on the source | 154 | + ########################################################################### |
38 | + # (We can only add this node once the job has started, or it | 155 | + # add a key to an encrypted block device |
39 | + # will complain that it does not want to run on non-root nodes) | 156 | + def addKeyQmp(self, id, new_secret, secret = None, |
40 | + result = self.vm.qmp('blockdev-add', | 157 | + slot = None, force = False): |
41 | + driver='blkdebug', | 158 | + |
42 | + node_name='src-perm', | 159 | + crypt_options = { |
43 | + image='src', | 160 | + 'state' : 'active', |
44 | + take_child_perms=['consistent-read']) | 161 | + 'new-secret' : new_secret.id(), |
162 | + 'iter-time' : 10 | ||
163 | + } | ||
164 | + | ||
165 | + if slot != None: | ||
166 | + crypt_options['keyslot'] = slot | ||
167 | + | ||
168 | + | ||
169 | + if secret != None: | ||
170 | + crypt_options['secret'] = secret.id() | ||
171 | + | ||
172 | + if iotests.imgfmt == "qcow2": | ||
173 | + crypt_options['format'] = 'luks' | ||
174 | + crypt_options = { | ||
175 | + 'encrypt': crypt_options | ||
176 | + } | ||
177 | + | ||
178 | + args = { | ||
179 | + 'node-name': id, | ||
180 | + 'job-id' : 'job_add_key', | ||
181 | + 'options' : { | ||
182 | + 'driver' : iotests.imgfmt, | ||
183 | + **crypt_options | ||
184 | + }, | ||
185 | + } | ||
186 | + | ||
187 | + if force == True: | ||
188 | + args['force'] = True | ||
189 | + | ||
190 | + #TODO: check what jobs return | ||
191 | + result = self.vm.qmp('x-blockdev-amend', **args) | ||
192 | + assert result['return'] == {} | ||
193 | + self.vm.run_job('job_add_key') | ||
194 | + | ||
195 | + # erase a key from an encrypted block device | ||
196 | + def eraseKeyQmp(self, id, old_secret = None, slot = None, force = False): | ||
197 | + | ||
198 | + crypt_options = { | ||
199 | + 'state' : 'inactive', | ||
200 | + } | ||
201 | + | ||
202 | + if slot != None: | ||
203 | + crypt_options['keyslot'] = slot | ||
204 | + if old_secret != None: | ||
205 | + crypt_options['old-secret'] = old_secret.id() | ||
206 | + | ||
207 | + if iotests.imgfmt == "qcow2": | ||
208 | + crypt_options['format'] = 'luks' | ||
209 | + crypt_options = { | ||
210 | + 'encrypt': crypt_options | ||
211 | + } | ||
212 | + | ||
213 | + args = { | ||
214 | + 'node-name': id, | ||
215 | + 'job-id' : 'job_erase_key', | ||
216 | + 'options' : { | ||
217 | + 'driver' : iotests.imgfmt, | ||
218 | + **crypt_options | ||
219 | + }, | ||
220 | + } | ||
221 | + | ||
222 | + if force == True: | ||
223 | + args['force'] = True | ||
224 | + | ||
225 | + result = self.vm.qmp('x-blockdev-amend', **args) | ||
226 | + assert result['return'] == {} | ||
227 | + self.vm.run_job('job_erase_key') | ||
228 | + | ||
229 | + ########################################################################### | ||
230 | + # create image, and change its key | ||
231 | + def testChangeKey(self): | ||
232 | + | ||
233 | + # create the image with secret0 and open it | ||
234 | + self.createImg(test_img, self.secrets[0]); | ||
235 | + self.openImageQmp("testdev", test_img, self.secrets[0]) | ||
236 | + | ||
237 | + # add key to slot 1 | ||
238 | + self.addKeyQmp("testdev", new_secret = self.secrets[1]) | ||
239 | + | ||
240 | + # add key to slot 5 | ||
241 | + self.addKeyQmp("testdev", new_secret = self.secrets[2], slot=5) | ||
242 | + | ||
243 | + # erase key from slot 0 | ||
244 | + self.eraseKeyQmp("testdev", old_secret = self.secrets[0]) | ||
245 | + | ||
246 | + #reopen the image with secret1 | ||
247 | + self.closeImageQmp("testdev") | ||
248 | + self.openImageQmp("testdev", test_img, self.secrets[1]) | ||
249 | + | ||
250 | + # close and erase the image for good | ||
251 | + self.closeImageQmp("testdev") | ||
252 | + os.remove(test_img) | ||
253 | + | ||
254 | + # test that if we erase the old password, | ||
255 | + # we can still change the encryption keys using 'old-secret' | ||
256 | + def testOldPassword(self): | ||
257 | + | ||
258 | + # create the image with secret0 and open it | ||
259 | + self.createImg(test_img, self.secrets[0]); | ||
260 | + self.openImageQmp("testdev", test_img, self.secrets[0]) | ||
261 | + | ||
262 | + # add key to slot 1 | ||
263 | + self.addKeyQmp("testdev", new_secret = self.secrets[1]) | ||
264 | + | ||
265 | + # erase key from slot 0 | ||
266 | + self.eraseKeyQmp("testdev", old_secret = self.secrets[0]) | ||
267 | + | ||
268 | + # this will fail as the old password is no longer valid | ||
269 | + self.addKeyQmp("testdev", new_secret = self.secrets[2]) | ||
270 | + | ||
271 | + # this will work | ||
272 | + self.addKeyQmp("testdev", new_secret = self.secrets[2], secret = self.secrets[1]) | ||
273 | + | ||
274 | + # close and erase the image for good | ||
275 | + self.closeImageQmp("testdev") | ||
276 | + os.remove(test_img) | ||
277 | + | ||
278 | + def testUseForceLuke(self): | ||
279 | + | ||
280 | + self.createImg(test_img, self.secrets[0]); | ||
281 | + self.openImageQmp("testdev", test_img, self.secrets[0]) | ||
282 | + | ||
283 | + # Add bunch of secrets | ||
284 | + self.addKeyQmp("testdev", new_secret = self.secrets[1], slot=4) | ||
285 | + self.addKeyQmp("testdev", new_secret = self.secrets[4], slot=2) | ||
286 | + | ||
287 | + # overwrite an active secret | ||
288 | + self.addKeyQmp("testdev", new_secret = self.secrets[5], slot=2) | ||
289 | + self.addKeyQmp("testdev", new_secret = self.secrets[5], slot=2, force=True) | ||
290 | + | ||
291 | + self.addKeyQmp("testdev", new_secret = self.secrets[0]) | ||
292 | + | ||
293 | + # Now erase all the secrets | ||
294 | + self.eraseKeyQmp("testdev", old_secret = self.secrets[5]) | ||
295 | + self.eraseKeyQmp("testdev", slot=4) | ||
296 | + | ||
297 | + # erase last keyslot | ||
298 | + self.eraseKeyQmp("testdev", old_secret = self.secrets[0]) | ||
299 | + self.eraseKeyQmp("testdev", old_secret = self.secrets[0], force=True) | ||
300 | + | ||
301 | + self.closeImageQmp("testdev") | ||
302 | + os.remove(test_img) | ||
303 | + | ||
304 | + | ||
305 | +if __name__ == '__main__': | ||
306 | + iotests.verify_working_luks() | ||
307 | + # Encrypted formats support | ||
308 | + iotests.activate_logging() | ||
309 | + iotests.main(supported_fmts = ['qcow2', 'luks']) | ||
310 | diff --git a/tests/qemu-iotests/295.out b/tests/qemu-iotests/295.out | ||
311 | new file mode 100644 | ||
312 | index XXXXXXX..XXXXXXX | ||
313 | --- /dev/null | ||
314 | +++ b/tests/qemu-iotests/295.out | ||
315 | @@ -XXX,XX +XXX,XX @@ | ||
316 | +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
317 | +{"return": {}} | ||
318 | +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
319 | +{"return": {}} | ||
320 | +{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} | ||
321 | +{"return": {}} | ||
322 | +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
323 | +{"return": {}} | ||
324 | +{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} | ||
325 | +{"return": {}} | ||
326 | +Job failed: Invalid password, cannot unlock any keyslot | ||
327 | +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
328 | +{"return": {}} | ||
329 | +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
330 | +{"return": {}} | ||
331 | +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
332 | +{"return": {}} | ||
333 | +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
334 | +{"return": {}} | ||
335 | +Job failed: Refusing to overwrite active keyslot 2 - please erase it first | ||
336 | +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
337 | +{"return": {}} | ||
338 | +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
339 | +{"return": {}} | ||
340 | +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
341 | +{"return": {}} | ||
342 | +{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} | ||
343 | +{"return": {}} | ||
344 | +{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} | ||
345 | +{"return": {}} | ||
346 | +Job failed: All the active keyslots match the (old) password that was given and erasing them will erase all the data in the image irreversibly - refusing operation | ||
347 | +{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} | ||
348 | +{"return": {}} | ||
349 | +{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} | ||
350 | +{"return": {}} | ||
351 | +... | ||
352 | +---------------------------------------------------------------------- | ||
353 | +Ran 3 tests | ||
354 | + | ||
355 | +OK | ||
356 | diff --git a/tests/qemu-iotests/296 b/tests/qemu-iotests/296 | ||
357 | new file mode 100755 | ||
358 | index XXXXXXX..XXXXXXX | ||
359 | --- /dev/null | ||
360 | +++ b/tests/qemu-iotests/296 | ||
361 | @@ -XXX,XX +XXX,XX @@ | ||
362 | +#!/usr/bin/env python3 | ||
363 | +# | ||
364 | +# Test case for encryption key management versus image sharing | ||
365 | +# | ||
366 | +# Copyright (C) 2019 Red Hat, Inc. | ||
367 | +# | ||
368 | +# This program is free software; you can redistribute it and/or modify | ||
369 | +# it under the terms of the GNU General Public License as published by | ||
370 | +# the Free Software Foundation; either version 2 of the License, or | ||
371 | +# (at your option) any later version. | ||
372 | +# | ||
373 | +# This program is distributed in the hope that it will be useful, | ||
374 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
375 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
376 | +# GNU General Public License for more details. | ||
377 | +# | ||
378 | +# You should have received a copy of the GNU General Public License | ||
379 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
380 | +# | ||
381 | + | ||
382 | +import iotests | ||
383 | +import os | ||
384 | +import time | ||
385 | +import json | ||
386 | + | ||
387 | +test_img = os.path.join(iotests.test_dir, 'test.img') | ||
388 | + | ||
389 | +class Secret: | ||
390 | + def __init__(self, index): | ||
391 | + self._id = "keysec" + str(index) | ||
392 | + # you are not supposed to see the password... | ||
393 | + self._secret = "hunter" + str(index) | ||
394 | + | ||
395 | + def id(self): | ||
396 | + return self._id | ||
397 | + | ||
398 | + def secret(self): | ||
399 | + return self._secret | ||
400 | + | ||
401 | + def to_cmdline_object(self): | ||
402 | + return [ "secret,id=" + self._id + ",data=" + self._secret] | ||
403 | + | ||
404 | + def to_qmp_object(self): | ||
405 | + return { "qom_type" : "secret", "id": self.id(), | ||
406 | + "props": { "data": self.secret() } } | ||
407 | + | ||
408 | +################################################################################ | ||
409 | + | ||
410 | +class EncryptionSetupTestCase(iotests.QMPTestCase): | ||
411 | + | ||
412 | + # test case startup | ||
413 | + def setUp(self): | ||
414 | + | ||
415 | + # start the VMs | ||
416 | + self.vm1 = iotests.VM(path_suffix = 'VM1') | ||
417 | + self.vm2 = iotests.VM(path_suffix = 'VM2') | ||
418 | + self.vm1.launch() | ||
419 | + self.vm2.launch() | ||
420 | + | ||
421 | + # create the secrets and load 'em into the VMs | ||
422 | + self.secrets = [ Secret(i) for i in range(0, 4) ] | ||
423 | + for secret in self.secrets: | ||
424 | + result = self.vm1.qmp("object-add", **secret.to_qmp_object()) | ||
425 | + self.assert_qmp(result, 'return', {}) | ||
426 | + result = self.vm2.qmp("object-add", **secret.to_qmp_object()) | ||
427 | + self.assert_qmp(result, 'return', {}) | ||
428 | + | ||
429 | + # test case shutdown | ||
430 | + def tearDown(self): | ||
431 | + # stop the VM | ||
432 | + self.vm1.shutdown() | ||
433 | + self.vm2.shutdown() | ||
434 | + | ||
435 | + ########################################################################### | ||
436 | + # create the encrypted block device using qemu-img | ||
437 | + def createImg(self, file, secret): | ||
438 | + | ||
439 | + output = iotests.qemu_img_pipe( | ||
440 | + 'create', | ||
441 | + '--object', *secret.to_cmdline_object(), | ||
442 | + '-f', iotests.imgfmt, | ||
443 | + '-o', 'key-secret=' + secret.id(), | ||
444 | + '-o', 'iter-time=10', | ||
445 | + file, | ||
446 | + '1M') | ||
447 | + | ||
448 | + iotests.log(output, filters=[iotests.filter_test_dir]) | ||
449 | + | ||
450 | + # attempts to add a key using qemu-img | ||
451 | + def addKey(self, file, secret, new_secret): | ||
452 | + | ||
453 | + image_options = { | ||
454 | + 'key-secret' : secret.id(), | ||
455 | + 'driver' : iotests.imgfmt, | ||
456 | + 'file' : { | ||
457 | + 'driver':'file', | ||
458 | + 'filename': file, | ||
459 | + } | ||
460 | + } | ||
461 | + | ||
462 | + output = iotests.qemu_img_pipe( | ||
463 | + 'amend', | ||
464 | + '--object', *secret.to_cmdline_object(), | ||
465 | + '--object', *new_secret.to_cmdline_object(), | ||
466 | + | ||
467 | + '-o', 'state=active', | ||
468 | + '-o', 'new-secret=' + new_secret.id(), | ||
469 | + '-o', 'iter-time=10', | ||
470 | + | ||
471 | + "json:" + json.dumps(image_options) | ||
472 | + ) | ||
473 | + | ||
474 | + iotests.log(output, filters=[iotests.filter_test_dir]) | ||
475 | + | ||
476 | + ########################################################################### | ||
477 | + # open an encrypted block device | ||
478 | + def openImageQmp(self, vm, id, file, secret, | ||
479 | + readOnly = False, reOpen = False): | ||
480 | + | ||
481 | + command = 'x-blockdev-reopen' if reOpen else 'blockdev-add' | ||
482 | + | ||
483 | + result = vm.qmp(command, ** | ||
484 | + { | ||
485 | + 'driver': iotests.imgfmt, | ||
486 | + 'node-name': id, | ||
487 | + 'read-only': readOnly, | ||
488 | + 'key-secret' : secret.id(), | ||
489 | + 'file': { | ||
490 | + 'driver': 'file', | ||
491 | + 'filename': test_img, | ||
492 | + } | ||
493 | + } | ||
494 | + ) | ||
45 | + self.assert_qmp(result, 'return', {}) | 495 | + self.assert_qmp(result, 'return', {}) |
46 | + | 496 | + |
47 | + # While completing, mirror will attempt to replace src by | 497 | + # close the encrypted block device |
48 | + # dest, which must fail because src-perm requires | 498 | + def closeImageQmp(self, vm, id): |
49 | + # consistent-read but dest-perm does not share it; thus | 499 | + result = vm.qmp('blockdev-del', **{ 'node-name': id }) |
50 | + # aborting the job when it is supposed to complete | 500 | + self.assert_qmp(result, 'return', {}) |
51 | + self.complete_and_wait('job', | 501 | + |
52 | + completion_error='Operation not permitted') | 502 | + ########################################################################### |
53 | + | 503 | + |
54 | + # Assert that all of our nodes are still there (except for the | 504 | + # add a key to an encrypted block device |
55 | + # mirror filter, which should be gone despite the failure) | 505 | + def addKeyQmp(self, vm, id, new_secret): |
56 | + nodes = self.vm.qmp('query-named-block-nodes')['return'] | 506 | + |
57 | + nodes = [node['node-name'] for node in nodes] | 507 | + args = { |
58 | + | 508 | + 'node-name': id, |
59 | + for expect in ('src', 'src-perm', 'dest', 'dest-perm'): | 509 | + 'job-id' : 'job0', |
60 | + self.assertTrue(expect in nodes, '%s disappeared' % expect) | 510 | + 'options' : { |
61 | + self.assertFalse('mirror-filter' in nodes, | 511 | + 'state' : 'active', |
62 | + 'Mirror filter node did not disappear') | 512 | + 'driver' : iotests.imgfmt, |
63 | + | 513 | + 'new-secret': new_secret.id(), |
64 | if __name__ == '__main__': | 514 | + 'iter-time' : 10 |
65 | iotests.main(supported_fmts=['qcow2', 'qed'], | 515 | + }, |
66 | supported_protocols=['file']) | 516 | + } |
67 | diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out | 517 | + |
518 | + result = vm.qmp('x-blockdev-amend', **args) | ||
519 | + assert result['return'] == {} | ||
520 | + vm.run_job('job0') | ||
521 | + | ||
522 | + # test that when the image opened by two qemu processes, | ||
523 | + # neither of them can update the image | ||
524 | + def test1(self): | ||
525 | + self.createImg(test_img, self.secrets[0]); | ||
526 | + | ||
527 | + # VM1 opens the image and adds a key | ||
528 | + self.openImageQmp(self.vm1, "testdev", test_img, self.secrets[0]) | ||
529 | + self.addKeyQmp(self.vm1, "testdev", new_secret = self.secrets[1]) | ||
530 | + | ||
531 | + | ||
532 | + # VM2 opens the image | ||
533 | + self.openImageQmp(self.vm2, "testdev", test_img, self.secrets[0]) | ||
534 | + | ||
535 | + | ||
536 | + # neither VMs now should be able to add a key | ||
537 | + self.addKeyQmp(self.vm1, "testdev", new_secret = self.secrets[2]) | ||
538 | + self.addKeyQmp(self.vm2, "testdev", new_secret = self.secrets[2]) | ||
539 | + | ||
540 | + | ||
541 | + # VM 1 closes the image | ||
542 | + self.closeImageQmp(self.vm1, "testdev") | ||
543 | + | ||
544 | + | ||
545 | + # now VM2 can add the key | ||
546 | + self.addKeyQmp(self.vm2, "testdev", new_secret = self.secrets[2]) | ||
547 | + | ||
548 | + | ||
549 | + # qemu-img should also not be able to add a key | ||
550 | + self.addKey(test_img, self.secrets[0], self.secrets[2]) | ||
551 | + | ||
552 | + # cleanup | ||
553 | + self.closeImageQmp(self.vm2, "testdev") | ||
554 | + os.remove(test_img) | ||
555 | + | ||
556 | + | ||
557 | + def test2(self): | ||
558 | + self.createImg(test_img, self.secrets[0]); | ||
559 | + | ||
560 | + # VM1 opens the image readonly | ||
561 | + self.openImageQmp(self.vm1, "testdev", test_img, self.secrets[0], | ||
562 | + readOnly = True) | ||
563 | + | ||
564 | + # VM2 opens the image | ||
565 | + self.openImageQmp(self.vm2, "testdev", test_img, self.secrets[0]) | ||
566 | + | ||
567 | + # VM1 can't add a key since image is readonly | ||
568 | + self.addKeyQmp(self.vm1, "testdev", new_secret = self.secrets[2]) | ||
569 | + | ||
570 | + # VM2 can't add a key since VM is has the image opened | ||
571 | + self.addKeyQmp(self.vm2, "testdev", new_secret = self.secrets[2]) | ||
572 | + | ||
573 | + | ||
574 | + #VM1 reopens the image read-write | ||
575 | + self.openImageQmp(self.vm1, "testdev", test_img, self.secrets[0], | ||
576 | + reOpen = True, readOnly = False) | ||
577 | + | ||
578 | + # VM1 still can't add the key | ||
579 | + self.addKeyQmp(self.vm1, "testdev", new_secret = self.secrets[2]) | ||
580 | + | ||
581 | + # VM2 gets away | ||
582 | + self.closeImageQmp(self.vm2, "testdev") | ||
583 | + | ||
584 | + # VM1 now can add the key | ||
585 | + self.addKeyQmp(self.vm1, "testdev", new_secret = self.secrets[2]) | ||
586 | + | ||
587 | + self.closeImageQmp(self.vm1, "testdev") | ||
588 | + os.remove(test_img) | ||
589 | + | ||
590 | + | ||
591 | +if __name__ == '__main__': | ||
592 | + # support only raw luks since luks encrypted qcow2 is a proper | ||
593 | + # format driver which doesn't allow any sharing | ||
594 | + iotests.activate_logging() | ||
595 | + iotests.main(supported_fmts = ['luks']) | ||
596 | diff --git a/tests/qemu-iotests/296.out b/tests/qemu-iotests/296.out | ||
597 | new file mode 100644 | ||
598 | index XXXXXXX..XXXXXXX | ||
599 | --- /dev/null | ||
600 | +++ b/tests/qemu-iotests/296.out | ||
601 | @@ -XXX,XX +XXX,XX @@ | ||
602 | +Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10 | ||
603 | + | ||
604 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
605 | +{"return": {}} | ||
606 | +Job failed: Failed to get shared "consistent read" lock | ||
607 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
608 | +{"return": {}} | ||
609 | +Job failed: Failed to get shared "consistent read" lock | ||
610 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
611 | +{"return": {}} | ||
612 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
613 | +{"return": {}} | ||
614 | +qemu-img: Failed to get shared "consistent read" lock | ||
615 | +Is another process using the image [TEST_DIR/test.img]? | ||
616 | + | ||
617 | +Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10 | ||
618 | + | ||
619 | +Job failed: Block node is read-only | ||
620 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
621 | +{"return": {}} | ||
622 | +Job failed: Failed to get shared "consistent read" lock | ||
623 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
624 | +{"return": {}} | ||
625 | +Job failed: Failed to get shared "consistent read" lock | ||
626 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
627 | +{"return": {}} | ||
628 | +{"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
629 | +{"return": {}} | ||
630 | +.. | ||
631 | +---------------------------------------------------------------------- | ||
632 | +Ran 2 tests | ||
633 | + | ||
634 | +OK | ||
635 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | ||
68 | index XXXXXXX..XXXXXXX 100644 | 636 | index XXXXXXX..XXXXXXX 100644 |
69 | --- a/tests/qemu-iotests/041.out | 637 | --- a/tests/qemu-iotests/group |
70 | +++ b/tests/qemu-iotests/041.out | 638 | +++ b/tests/qemu-iotests/group |
71 | @@ -XXX,XX +XXX,XX @@ | 639 | @@ -XXX,XX +XXX,XX @@ |
72 | -.......................................................................................... | 640 | 292 rw auto quick |
73 | +........................................................................................... | 641 | 293 rw |
74 | ---------------------------------------------------------------------- | 642 | 294 rw quick |
75 | -Ran 90 tests | 643 | +295 rw |
76 | +Ran 91 tests | 644 | +296 rw |
77 | 645 | 297 meta | |
78 | OK | ||
79 | -- | 646 | -- |
80 | 2.24.1 | 647 | 2.26.2 |
81 | 648 | ||
82 | 649 | diff view generated by jsdifflib |
1 | It did not matter before, but now that _make_test_img understands -o, we | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | should use it properly here. | ||
3 | 2 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | qemu-img convert wants to distinguish ZERO which comes from short |
5 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 4 | backing files. unallocated_blocks_are_zero field of bdi is unrelated: |
6 | Message-id: 20191107163708.833192-11-mreitz@redhat.com | 5 | space after EOF is always considered to be zero anyway. So, just make |
6 | post_backing_zero true in case of short backing file. | ||
7 | |||
8 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
9 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
10 | Message-Id: <20200528094405.145708-2-vsementsov@virtuozzo.com> | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 11 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
8 | --- | 12 | --- |
9 | tests/qemu-iotests/051 | 2 +- | 13 | qemu-img.c | 4 +--- |
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 3 deletions(-) |
11 | 15 | ||
12 | diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 | 16 | diff --git a/qemu-img.c b/qemu-img.c |
13 | index XXXXXXX..XXXXXXX 100755 | 17 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/tests/qemu-iotests/051 | 18 | --- a/qemu-img.c |
15 | +++ b/tests/qemu-iotests/051 | 19 | +++ b/qemu-img.c |
16 | @@ -XXX,XX +XXX,XX @@ echo | 20 | @@ -XXX,XX +XXX,XX @@ typedef struct ImgConvertState { |
17 | echo === With version 2 images enabling lazy refcounts must fail === | 21 | BlockBackend *target; |
18 | echo | 22 | bool has_zero_init; |
19 | 23 | bool compressed; | |
20 | -_make_test_img -ocompat=0.10 $size | 24 | - bool unallocated_blocks_are_zero; |
21 | +_make_test_img -o compat=0.10 $size | 25 | bool target_is_new; |
22 | 26 | bool target_has_backing; | |
23 | run_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=on | 27 | int64_t target_backing_sectors; /* negative if unknown */ |
24 | run_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=off | 28 | @@ -XXX,XX +XXX,XX @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num) |
29 | |||
30 | if (s->target_backing_sectors >= 0) { | ||
31 | if (sector_num >= s->target_backing_sectors) { | ||
32 | - post_backing_zero = s->unallocated_blocks_are_zero; | ||
33 | + post_backing_zero = true; | ||
34 | } else if (sector_num + n > s->target_backing_sectors) { | ||
35 | /* Split requests around target_backing_sectors (because | ||
36 | * starting from there, zeros are handled differently) */ | ||
37 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) | ||
38 | } else { | ||
39 | s.compressed = s.compressed || bdi.needs_compressed_writes; | ||
40 | s.cluster_sectors = bdi.cluster_size / BDRV_SECTOR_SIZE; | ||
41 | - s.unallocated_blocks_are_zero = bdi.unallocated_blocks_are_zero; | ||
42 | } | ||
43 | |||
44 | ret = convert_do_copy(&s); | ||
25 | -- | 45 | -- |
26 | 2.24.1 | 46 | 2.26.2 |
27 | 47 | ||
28 | 48 | diff view generated by jsdifflib |
1 | We can save some LoC in xdbg_graph_add_edge() by using | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | bdrv_qapi_perm_to_blk_perm(). | ||
3 | 2 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | The function has only one user: bdrv_co_block_status(). Inline it to |
5 | Message-id: 20191108123455.39445-3-mreitz@redhat.com | 4 | simplify reviewing of the following patches, which will finally drop |
6 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 5 | unallocated_blocks_are_zero field too. |
6 | |||
7 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
8 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
9 | Message-Id: <20200528094405.145708-3-vsementsov@virtuozzo.com> | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
8 | --- | 11 | --- |
9 | block.c | 29 ++++++++--------------------- | 12 | include/block/block.h | 1 - |
10 | 1 file changed, 8 insertions(+), 21 deletions(-) | 13 | block.c | 15 --------------- |
14 | block/io.c | 11 ++++++++--- | ||
15 | 3 files changed, 8 insertions(+), 19 deletions(-) | ||
11 | 16 | ||
17 | diff --git a/include/block/block.h b/include/block/block.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/block/block.h | ||
20 | +++ b/include/block/block.h | ||
21 | @@ -XXX,XX +XXX,XX @@ int bdrv_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes); | ||
22 | int bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes); | ||
23 | int bdrv_has_zero_init_1(BlockDriverState *bs); | ||
24 | int bdrv_has_zero_init(BlockDriverState *bs); | ||
25 | -bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs); | ||
26 | bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs); | ||
27 | int bdrv_block_status(BlockDriverState *bs, int64_t offset, | ||
28 | int64_t bytes, int64_t *pnum, int64_t *map, | ||
12 | diff --git a/block.c b/block.c | 29 | diff --git a/block.c b/block.c |
13 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/block.c | 31 | --- a/block.c |
15 | +++ b/block.c | 32 | +++ b/block.c |
16 | @@ -XXX,XX +XXX,XX @@ static void xdbg_graph_add_node(XDbgBlockGraphConstructor *gr, void *node, | 33 | @@ -XXX,XX +XXX,XX @@ int bdrv_has_zero_init(BlockDriverState *bs) |
17 | static void xdbg_graph_add_edge(XDbgBlockGraphConstructor *gr, void *parent, | 34 | return 0; |
18 | const BdrvChild *child) | 35 | } |
36 | |||
37 | -bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs) | ||
38 | -{ | ||
39 | - BlockDriverInfo bdi; | ||
40 | - | ||
41 | - if (bs->backing) { | ||
42 | - return false; | ||
43 | - } | ||
44 | - | ||
45 | - if (bdrv_get_info(bs, &bdi) == 0) { | ||
46 | - return bdi.unallocated_blocks_are_zero; | ||
47 | - } | ||
48 | - | ||
49 | - return false; | ||
50 | -} | ||
51 | - | ||
52 | bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs) | ||
19 | { | 53 | { |
20 | - typedef struct { | 54 | if (!(bs->open_flags & BDRV_O_UNMAP)) { |
21 | - unsigned int flag; | 55 | diff --git a/block/io.c b/block/io.c |
22 | - BlockPermission num; | 56 | index XXXXXXX..XXXXXXX 100644 |
23 | - } PermissionMap; | 57 | --- a/block/io.c |
24 | - | 58 | +++ b/block/io.c |
25 | - static const PermissionMap permissions[] = { | 59 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs, |
26 | - { BLK_PERM_CONSISTENT_READ, BLOCK_PERMISSION_CONSISTENT_READ }, | 60 | if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) { |
27 | - { BLK_PERM_WRITE, BLOCK_PERMISSION_WRITE }, | 61 | ret |= BDRV_BLOCK_ALLOCATED; |
28 | - { BLK_PERM_WRITE_UNCHANGED, BLOCK_PERMISSION_WRITE_UNCHANGED }, | 62 | } else if (want_zero) { |
29 | - { BLK_PERM_RESIZE, BLOCK_PERMISSION_RESIZE }, | 63 | - if (bdrv_unallocated_blocks_are_zero(bs)) { |
30 | - { BLK_PERM_GRAPH_MOD, BLOCK_PERMISSION_GRAPH_MOD }, | 64 | - ret |= BDRV_BLOCK_ZERO; |
31 | - { 0, 0 } | 65 | - } else if (bs->backing) { |
32 | - }; | 66 | + if (bs->backing) { |
33 | - const PermissionMap *p; | 67 | BlockDriverState *bs2 = bs->backing->bs; |
34 | + BlockPermission qapi_perm; | 68 | int64_t size2 = bdrv_getlength(bs2); |
35 | XDbgBlockGraphEdge *edge; | 69 | |
36 | 70 | if (size2 >= 0 && offset >= size2) { | |
37 | - QEMU_BUILD_BUG_ON(1UL << (ARRAY_SIZE(permissions) - 1) != BLK_PERM_ALL + 1); | 71 | ret |= BDRV_BLOCK_ZERO; |
38 | - | 72 | } |
39 | edge = g_new0(XDbgBlockGraphEdge, 1); | 73 | + } else { |
40 | 74 | + BlockDriverInfo bdi; | |
41 | edge->parent = xdbg_graph_node_num(gr, parent); | 75 | + int ret2 = bdrv_get_info(bs, &bdi); |
42 | edge->child = xdbg_graph_node_num(gr, child->bs); | ||
43 | edge->name = g_strdup(child->name); | ||
44 | |||
45 | - for (p = permissions; p->flag; p++) { | ||
46 | - if (p->flag & child->perm) { | ||
47 | - QAPI_LIST_ADD(edge->perm, p->num); | ||
48 | + for (qapi_perm = 0; qapi_perm < BLOCK_PERMISSION__MAX; qapi_perm++) { | ||
49 | + uint64_t flag = bdrv_qapi_perm_to_blk_perm(qapi_perm); | ||
50 | + | 76 | + |
51 | + if (flag & child->perm) { | 77 | + if (ret2 == 0 && bdi.unallocated_blocks_are_zero) { |
52 | + QAPI_LIST_ADD(edge->perm, qapi_perm); | 78 | + ret |= BDRV_BLOCK_ZERO; |
53 | } | 79 | + } |
54 | - if (p->flag & child->shared_perm) { | ||
55 | - QAPI_LIST_ADD(edge->shared_perm, p->num); | ||
56 | + if (flag & child->shared_perm) { | ||
57 | + QAPI_LIST_ADD(edge->shared_perm, qapi_perm); | ||
58 | } | 80 | } |
59 | } | 81 | } |
60 | 82 | ||
61 | -- | 83 | -- |
62 | 2.24.1 | 84 | 2.26.2 |
63 | 85 | ||
64 | 86 | diff view generated by jsdifflib |
1 | Overwriting IMGOPTS means ignoring all user-supplied options, which is | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | not what we want. Replace the current IMGOPTS use by a new BACKING_FILE | ||
3 | variable. | ||
4 | 2 | ||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | In case of !VDI_IS_ALLOCATED[], we do zero out the corresponding chunk |
6 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 4 | of qiov. So, this should be reported as ZERO. |
7 | Message-id: 20191107163708.833192-14-mreitz@redhat.com | 5 | |
6 | Note that this changes visible output of "qemu-img map --output=json" | ||
7 | and "qemu-io -c map" commands. For qemu-img map, the change is obvious: | ||
8 | we just mark as zero what is really zero. For qemu-io it's less | ||
9 | obvious: what was unallocated now is allocated. | ||
10 | |||
11 | There is an inconsistency in understanding of unallocated regions in | ||
12 | Qemu: backing-supporting format-drivers return 0 block-status to report | ||
13 | go-to-backing logic for this area. Some protocol-drivers (iscsi) return | ||
14 | 0 to report fs-unallocated-non-zero status (i.e., don't occupy space on | ||
15 | disk, read result is undefined). | ||
16 | |||
17 | BDRV_BLOCK_ALLOCATED is defined as something more close to | ||
18 | go-to-backing logic. Still it is calculated as ZERO | DATA, so 0 from | ||
19 | iscsi is treated as unallocated. It doesn't influence backing-chain | ||
20 | behavior, as iscsi can't have backing file. But it does influence | ||
21 | "qemu-io -c map". | ||
22 | |||
23 | We should solve this inconsistency at some future point. Now, let's | ||
24 | just make backing-not-supporting format drivers (vdi at this patch and | ||
25 | vpc with the following) to behave more like backing-supporting drivers | ||
26 | and not report 0 block-status. More over, returning ZERO status is | ||
27 | absolutely valid thing, and again, corresponds to how the other | ||
28 | format-drivers (backing-supporting) work. | ||
29 | |||
30 | After block-status update, it never reports 0, so setting | ||
31 | unallocated_blocks_are_zero doesn't make sense (as the only user of it | ||
32 | is bdrv_co_block_status and it checks unallocated_blocks_are_zero only | ||
33 | for unallocated areas). Drop it. | ||
34 | |||
35 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
36 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
37 | Message-Id: <20200528094405.145708-4-vsementsov@virtuozzo.com> | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 38 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
9 | --- | 39 | --- |
10 | tests/qemu-iotests/267 | 12 ++++++++---- | 40 | block/vdi.c | 3 +-- |
11 | 1 file changed, 8 insertions(+), 4 deletions(-) | 41 | 1 file changed, 1 insertion(+), 2 deletions(-) |
12 | 42 | ||
13 | diff --git a/tests/qemu-iotests/267 b/tests/qemu-iotests/267 | 43 | diff --git a/block/vdi.c b/block/vdi.c |
14 | index XXXXXXX..XXXXXXX 100755 | 44 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/tests/qemu-iotests/267 | 45 | --- a/block/vdi.c |
16 | +++ b/tests/qemu-iotests/267 | 46 | +++ b/block/vdi.c |
17 | @@ -XXX,XX +XXX,XX @@ size=128M | 47 | @@ -XXX,XX +XXX,XX @@ static int vdi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) |
18 | 48 | logout("\n"); | |
19 | run_test() | 49 | bdi->cluster_size = s->block_size; |
20 | { | 50 | bdi->vm_state_offset = 0; |
21 | - _make_test_img $size | 51 | - bdi->unallocated_blocks_are_zero = true; |
22 | + if [ -n "$BACKING_FILE" ]; then | 52 | return 0; |
23 | + _make_test_img -b "$BACKING_FILE" $size | ||
24 | + else | ||
25 | + _make_test_img $size | ||
26 | + fi | ||
27 | printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu "$@" | _filter_date | ||
28 | } | 53 | } |
29 | 54 | ||
30 | @@ -XXX,XX +XXX,XX @@ echo | 55 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn vdi_co_block_status(BlockDriverState *bs, |
31 | 56 | *pnum = MIN(s->block_size - index_in_block, bytes); | |
32 | TEST_IMG="$TEST_IMG.base" _make_test_img $size | 57 | result = VDI_IS_ALLOCATED(bmap_entry); |
33 | 58 | if (!result) { | |
34 | -IMGOPTS="backing_file=$TEST_IMG.base" \ | 59 | - return 0; |
35 | +BACKING_FILE="$TEST_IMG.base" \ | 60 | + return BDRV_BLOCK_ZERO; |
36 | run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ | 61 | } |
37 | -blockdev driver=file,filename="$TEST_IMG",node-name=file \ | 62 | |
38 | -blockdev driver=$IMGFMT,file=file,backing=backing-file,node-name=fmt | 63 | *map = s->header.offset_data + (uint64_t)bmap_entry * s->block_size + |
39 | |||
40 | -IMGOPTS="backing_file=$TEST_IMG.base" \ | ||
41 | +BACKING_FILE="$TEST_IMG.base" \ | ||
42 | run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ | ||
43 | -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \ | ||
44 | -blockdev driver=file,filename="$TEST_IMG",node-name=file \ | ||
45 | @@ -XXX,XX +XXX,XX @@ echo | ||
46 | echo "=== -blockdev with NBD server on the backing file ===" | ||
47 | echo | ||
48 | |||
49 | -IMGOPTS="backing_file=$TEST_IMG.base" _make_test_img $size | ||
50 | +_make_test_img -b "$TEST_IMG.base" $size | ||
51 | cat <<EOF | | ||
52 | nbd_server_start unix:$SOCK_DIR/nbd | ||
53 | nbd_server_add -w backing-fmt | ||
54 | -- | 64 | -- |
55 | 2.24.1 | 65 | 2.26.2 |
56 | 66 | ||
57 | 67 | diff view generated by jsdifflib |
1 | The image end offset as reported by qemu-img check is different when | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | using an external data file; we do not care about its value here, so we | 2 | |
3 | can just filter it. Incidentally, common.rc already has _check_test_img | 3 | In case when get_image_offset() returns -1, we do zero out the |
4 | for us which does exactly that. | 4 | corresponding chunk of qiov. So, this should be reported as ZERO. |
5 | 5 | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 6 | Note that this changes visible output of "qemu-img map --output=json" |
7 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 7 | and "qemu-io -c map" commands. For qemu-img map, the change is obvious: |
8 | Message-id: 20191107163708.833192-18-mreitz@redhat.com | 8 | we just mark as zero what is really zero. For qemu-io it's less |
9 | obvious: what was unallocated now is allocated. | ||
10 | |||
11 | There is an inconsistency in understanding of unallocated regions in | ||
12 | Qemu: backing-supporting format-drivers return 0 block-status to report | ||
13 | go-to-backing logic for this area. Some protocol-drivers (iscsi) return | ||
14 | 0 to report fs-unallocated-non-zero status (i.e., don't occupy space on | ||
15 | disk, read result is undefined). | ||
16 | |||
17 | BDRV_BLOCK_ALLOCATED is defined as something more close to | ||
18 | go-to-backing logic. Still it is calculated as ZERO | DATA, so 0 from | ||
19 | iscsi is treated as unallocated. It doesn't influence backing-chain | ||
20 | behavior, as iscsi can't have backing file. But it does influence | ||
21 | "qemu-io -c map". | ||
22 | |||
23 | We should solve this inconsistency at some future point. Now, let's | ||
24 | just make backing-not-supporting format drivers (vdi in the previous | ||
25 | patch and vpc now) to behave more like backing-supporting drivers | ||
26 | and not report 0 block-status. More over, returning ZERO status is | ||
27 | absolutely valid thing, and again, corresponds to how the other | ||
28 | format-drivers (backing-supporting) work. | ||
29 | |||
30 | After block-status update, it never reports 0, so setting | ||
31 | unallocated_blocks_are_zero doesn't make sense (as the only user of it | ||
32 | is bdrv_co_block_status and it checks unallocated_blocks_are_zero only | ||
33 | for unallocated areas). Drop it. | ||
34 | |||
35 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
36 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
37 | Message-Id: <20200528094405.145708-5-vsementsov@virtuozzo.com> | ||
38 | [mreitz: qemu-io -c map as used by iotest 146 now reports everything as | ||
39 | allocated; in order to make the test do something useful, we | ||
40 | use qemu-img map --output=json now] | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 41 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
10 | --- | 42 | --- |
11 | tests/qemu-iotests/091 | 2 +- | 43 | block/vpc.c | 3 +- |
12 | tests/qemu-iotests/091.out | 2 -- | 44 | tests/qemu-iotests/146 | 60 ++++-- |
13 | 2 files changed, 1 insertion(+), 3 deletions(-) | 45 | tests/qemu-iotests/146.out | 405 +++++++++++++++++++++++++++++++++++-- |
14 | 46 | 3 files changed, 436 insertions(+), 32 deletions(-) | |
15 | diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091 | 47 | |
48 | diff --git a/block/vpc.c b/block/vpc.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/block/vpc.c | ||
51 | +++ b/block/vpc.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static int vpc_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) | ||
53 | bdi->cluster_size = s->block_size; | ||
54 | } | ||
55 | |||
56 | - bdi->unallocated_blocks_are_zero = true; | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn vpc_co_block_status(BlockDriverState *bs, | ||
61 | image_offset = get_image_offset(bs, offset, false, NULL); | ||
62 | allocated = (image_offset != -1); | ||
63 | *pnum = 0; | ||
64 | - ret = 0; | ||
65 | + ret = BDRV_BLOCK_ZERO; | ||
66 | |||
67 | do { | ||
68 | /* All sectors in a block are contiguous (without using the bitmap) */ | ||
69 | diff --git a/tests/qemu-iotests/146 b/tests/qemu-iotests/146 | ||
16 | index XXXXXXX..XXXXXXX 100755 | 70 | index XXXXXXX..XXXXXXX 100755 |
17 | --- a/tests/qemu-iotests/091 | 71 | --- a/tests/qemu-iotests/146 |
18 | +++ b/tests/qemu-iotests/091 | 72 | +++ b/tests/qemu-iotests/146 |
19 | @@ -XXX,XX +XXX,XX @@ echo "Check image pattern" | 73 | @@ -XXX,XX +XXX,XX @@ echo === Testing VPC Autodetect === |
20 | ${QEMU_IO} -c "read -P 0x22 0 4M" "${TEST_IMG}" | _filter_testdir | _filter_qemu_io | 74 | echo |
21 | 75 | _use_sample_img virtualpc-dynamic.vhd.bz2 | |
22 | echo "Running 'qemu-img check -r all \$TEST_IMG'" | 76 | |
23 | -"${QEMU_IMG}" check -r all "${TEST_IMG}" 2>&1 | _filter_testdir | _filter_qemu | 77 | -${QEMU_IO} -c "open -o driver=vpc ${TEST_IMG}" -c 'map' |
24 | +_check_test_img -r all | 78 | +$QEMU_IMG map --output=json --image-opts \ |
79 | + "driver=vpc,file.filename=$TEST_IMG" \ | ||
80 | + | _filter_qemu_img_map | ||
81 | |||
82 | echo | ||
83 | echo === Testing VPC with current_size force === | ||
84 | echo | ||
85 | |||
86 | -${QEMU_IO} -c "open -o driver=vpc,force_size_calc=current_size ${TEST_IMG}" -c 'map' | ||
87 | +$QEMU_IMG map --output=json --image-opts \ | ||
88 | + "driver=vpc,force_size_calc=current_size,file.filename=$TEST_IMG" \ | ||
89 | + | _filter_qemu_img_map | ||
90 | |||
91 | echo | ||
92 | echo === Testing VPC with chs force === | ||
93 | echo | ||
94 | |||
95 | -${QEMU_IO} -c "open -o driver=vpc,force_size_calc=chs ${TEST_IMG}" -c 'map' | ||
96 | +$QEMU_IMG map --output=json --image-opts \ | ||
97 | + "driver=vpc,force_size_calc=chs,file.filename=$TEST_IMG" \ | ||
98 | + | _filter_qemu_img_map | ||
99 | |||
100 | _cleanup_test_img | ||
101 | |||
102 | @@ -XXX,XX +XXX,XX @@ echo === Testing Hyper-V Autodetect === | ||
103 | echo | ||
104 | _use_sample_img hyperv2012r2-dynamic.vhd.bz2 | ||
105 | |||
106 | -${QEMU_IO} -c "open -o driver=vpc ${TEST_IMG}" -c 'map' | ||
107 | +$QEMU_IMG map --output=json --image-opts \ | ||
108 | + "driver=vpc,file.filename=$TEST_IMG" \ | ||
109 | + | _filter_qemu_img_map | ||
110 | |||
111 | echo | ||
112 | echo === Testing Hyper-V with current_size force === | ||
113 | echo | ||
114 | |||
115 | -${QEMU_IO} -c "open -o driver=vpc,force_size_calc=current_size ${TEST_IMG}" -c 'map' | ||
116 | +$QEMU_IMG map --output=json --image-opts \ | ||
117 | + "driver=vpc,force_size_calc=current_size,file.filename=$TEST_IMG" \ | ||
118 | + | _filter_qemu_img_map | ||
119 | |||
120 | echo | ||
121 | echo === Testing Hyper-V with chs force === | ||
122 | echo | ||
123 | |||
124 | -${QEMU_IO} -c "open -o driver=vpc,force_size_calc=chs ${TEST_IMG}" -c 'map' | ||
125 | +$QEMU_IMG map --output=json --image-opts \ | ||
126 | + "driver=vpc,force_size_calc=chs,file.filename=$TEST_IMG" \ | ||
127 | + | _filter_qemu_img_map | ||
128 | |||
129 | _cleanup_test_img | ||
130 | |||
131 | @@ -XXX,XX +XXX,XX @@ echo === Testing d2v Autodetect === | ||
132 | echo | ||
133 | _use_sample_img d2v-zerofilled.vhd.bz2 | ||
134 | |||
135 | -${QEMU_IO} -c "open -o driver=vpc ${TEST_IMG}" -c 'map' | ||
136 | +$QEMU_IMG map --output=json --image-opts \ | ||
137 | + "driver=vpc,file.filename=$TEST_IMG" \ | ||
138 | + | _filter_qemu_img_map | ||
139 | |||
140 | echo | ||
141 | echo === Testing d2v with current_size force === | ||
142 | echo | ||
143 | |||
144 | -${QEMU_IO} -c "open -o driver=vpc,force_size_calc=current_size ${TEST_IMG}" -c 'map' | ||
145 | +$QEMU_IMG map --output=json --image-opts \ | ||
146 | + "driver=vpc,force_size_calc=current_size,file.filename=$TEST_IMG" \ | ||
147 | + | _filter_qemu_img_map | ||
148 | |||
149 | echo | ||
150 | echo === Testing d2v with chs force === | ||
151 | echo | ||
152 | |||
153 | -${QEMU_IO} -c "open -o driver=vpc,force_size_calc=chs ${TEST_IMG}" -c 'map' | ||
154 | +$QEMU_IMG map --output=json --image-opts \ | ||
155 | + "driver=vpc,force_size_calc=chs,file.filename=$TEST_IMG" \ | ||
156 | + | _filter_qemu_img_map | ||
157 | |||
158 | _cleanup_test_img | ||
159 | |||
160 | @@ -XXX,XX +XXX,XX @@ echo | ||
161 | echo === Read created image, default opts ==== | ||
162 | echo | ||
163 | |||
164 | -${QEMU_IO} -c "open -o driver=vpc ${TEST_IMG}" -c 'map' | ||
165 | +$QEMU_IMG map --output=json --image-opts \ | ||
166 | + "driver=vpc,file.filename=$TEST_IMG" \ | ||
167 | + | _filter_qemu_img_map | ||
168 | |||
169 | echo | ||
170 | echo === Read created image, force_size_calc=chs ==== | ||
171 | echo | ||
172 | |||
173 | -${QEMU_IO} -c "open -o driver=vpc,force_size_calc=chs ${TEST_IMG}" -c 'map' | ||
174 | +$QEMU_IMG map --output=json --image-opts \ | ||
175 | + "driver=vpc,force_size_calc=chs,file.filename=$TEST_IMG" \ | ||
176 | + | _filter_qemu_img_map | ||
177 | |||
178 | echo | ||
179 | echo === Read created image, force_size_calc=current_size ==== | ||
180 | echo | ||
181 | |||
182 | -${QEMU_IO} -c "open -o driver=vpc,force_size_calc=current_size ${TEST_IMG}" -c 'map' | ||
183 | +$QEMU_IMG map --output=json --image-opts \ | ||
184 | + "driver=vpc,force_size_calc=current_size,file.filename=$TEST_IMG" \ | ||
185 | + | _filter_qemu_img_map | ||
186 | |||
187 | echo | ||
188 | echo === Testing Image create, force_size === | ||
189 | @@ -XXX,XX +XXX,XX @@ echo | ||
190 | echo === Read created image, default opts ==== | ||
191 | echo | ||
192 | |||
193 | -${QEMU_IO} -c "open -o driver=vpc ${TEST_IMG}" -c 'map' | ||
194 | +$QEMU_IMG map --output=json --image-opts \ | ||
195 | + "driver=vpc,file.filename=$TEST_IMG" \ | ||
196 | + | _filter_qemu_img_map | ||
197 | |||
198 | echo | ||
199 | echo === Read created image, force_size_calc=chs ==== | ||
200 | echo | ||
201 | |||
202 | -${QEMU_IO} -c "open -o driver=vpc,force_size_calc=chs ${TEST_IMG}" -c 'map' | ||
203 | +$QEMU_IMG map --output=json --image-opts \ | ||
204 | + "driver=vpc,force_size_calc=chs,file.filename=$TEST_IMG" \ | ||
205 | + | _filter_qemu_img_map | ||
206 | |||
207 | echo | ||
208 | echo === Read created image, force_size_calc=current_size ==== | ||
209 | echo | ||
210 | |||
211 | -${QEMU_IO} -c "open -o driver=vpc,force_size_calc=current_size ${TEST_IMG}" -c 'map' | ||
212 | +$QEMU_IMG map --output=json --image-opts \ | ||
213 | + "driver=vpc,force_size_calc=current_size,file.filename=$TEST_IMG" \ | ||
214 | + | _filter_qemu_img_map | ||
25 | 215 | ||
26 | echo "*** done" | 216 | echo "*** done" |
27 | rm -f $seq.full | 217 | rm -f $seq.full |
28 | diff --git a/tests/qemu-iotests/091.out b/tests/qemu-iotests/091.out | 218 | diff --git a/tests/qemu-iotests/146.out b/tests/qemu-iotests/146.out |
29 | index XXXXXXX..XXXXXXX 100644 | 219 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/tests/qemu-iotests/091.out | 220 | --- a/tests/qemu-iotests/146.out |
31 | +++ b/tests/qemu-iotests/091.out | 221 | +++ b/tests/qemu-iotests/146.out |
32 | @@ -XXX,XX +XXX,XX @@ read 4194304/4194304 bytes at offset 0 | 222 | @@ -XXX,XX +XXX,XX @@ QA output created by 146 |
33 | 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 223 | |
34 | Running 'qemu-img check -r all $TEST_IMG' | 224 | === Testing VPC Autodetect === |
35 | No errors were found on the image. | 225 | |
36 | -80/16384 = 0.49% allocated, 0.00% fragmented, 0.00% compressed clusters | 226 | -126.998 GiB (0x1fbfe04000) bytes not allocated at offset 0 bytes (0x0) |
37 | -Image end offset: 5570560 | 227 | +[{ "start": 0, "length": 136363130880, "depth": 0, "zero": true, "data": false }] |
228 | |||
229 | === Testing VPC with current_size force === | ||
230 | |||
231 | -127 GiB (0x1fc0000000) bytes not allocated at offset 0 bytes (0x0) | ||
232 | +[{ "start": 0, "length": 136365211648, "depth": 0, "zero": true, "data": false }] | ||
233 | |||
234 | === Testing VPC with chs force === | ||
235 | |||
236 | -126.998 GiB (0x1fbfe04000) bytes not allocated at offset 0 bytes (0x0) | ||
237 | +[{ "start": 0, "length": 136363130880, "depth": 0, "zero": true, "data": false }] | ||
238 | |||
239 | === Testing Hyper-V Autodetect === | ||
240 | |||
241 | -127 GiB (0x1fc0000000) bytes not allocated at offset 0 bytes (0x0) | ||
242 | +[{ "start": 0, "length": 136365211648, "depth": 0, "zero": true, "data": false }] | ||
243 | |||
244 | === Testing Hyper-V with current_size force === | ||
245 | |||
246 | -127 GiB (0x1fc0000000) bytes not allocated at offset 0 bytes (0x0) | ||
247 | +[{ "start": 0, "length": 136365211648, "depth": 0, "zero": true, "data": false }] | ||
248 | |||
249 | === Testing Hyper-V with chs force === | ||
250 | |||
251 | -126.998 GiB (0x1fbfe04000) bytes not allocated at offset 0 bytes (0x0) | ||
252 | +[{ "start": 0, "length": 136363130880, "depth": 0, "zero": true, "data": false }] | ||
253 | |||
254 | === Testing d2v Autodetect === | ||
255 | |||
256 | -251.250 MiB (0xfb40000) bytes allocated at offset 0 bytes (0x0) | ||
257 | +[{ "start": 0, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
258 | +{ "start": 2097152, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
259 | +{ "start": 4194304, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
260 | +{ "start": 6291456, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
261 | +{ "start": 8388608, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
262 | +{ "start": 10485760, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
263 | +{ "start": 12582912, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
264 | +{ "start": 14680064, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
265 | +{ "start": 16777216, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
266 | +{ "start": 18874368, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
267 | +{ "start": 20971520, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
268 | +{ "start": 23068672, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
269 | +{ "start": 25165824, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
270 | +{ "start": 27262976, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
271 | +{ "start": 29360128, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
272 | +{ "start": 31457280, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
273 | +{ "start": 33554432, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
274 | +{ "start": 35651584, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
275 | +{ "start": 37748736, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
276 | +{ "start": 39845888, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
277 | +{ "start": 41943040, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
278 | +{ "start": 44040192, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
279 | +{ "start": 46137344, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
280 | +{ "start": 48234496, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
281 | +{ "start": 50331648, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
282 | +{ "start": 52428800, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
283 | +{ "start": 54525952, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
284 | +{ "start": 56623104, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
285 | +{ "start": 58720256, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
286 | +{ "start": 60817408, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
287 | +{ "start": 62914560, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
288 | +{ "start": 65011712, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
289 | +{ "start": 67108864, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
290 | +{ "start": 69206016, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
291 | +{ "start": 71303168, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
292 | +{ "start": 73400320, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
293 | +{ "start": 75497472, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
294 | +{ "start": 77594624, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
295 | +{ "start": 79691776, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
296 | +{ "start": 81788928, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
297 | +{ "start": 83886080, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
298 | +{ "start": 85983232, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
299 | +{ "start": 88080384, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
300 | +{ "start": 90177536, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
301 | +{ "start": 92274688, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
302 | +{ "start": 94371840, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
303 | +{ "start": 96468992, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
304 | +{ "start": 98566144, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
305 | +{ "start": 100663296, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
306 | +{ "start": 102760448, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
307 | +{ "start": 104857600, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
308 | +{ "start": 106954752, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
309 | +{ "start": 109051904, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
310 | +{ "start": 111149056, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
311 | +{ "start": 113246208, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
312 | +{ "start": 115343360, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
313 | +{ "start": 117440512, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
314 | +{ "start": 119537664, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
315 | +{ "start": 121634816, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
316 | +{ "start": 123731968, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
317 | +{ "start": 125829120, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
318 | +{ "start": 127926272, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
319 | +{ "start": 130023424, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
320 | +{ "start": 132120576, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
321 | +{ "start": 134217728, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
322 | +{ "start": 136314880, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
323 | +{ "start": 138412032, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
324 | +{ "start": 140509184, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
325 | +{ "start": 142606336, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
326 | +{ "start": 144703488, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
327 | +{ "start": 146800640, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
328 | +{ "start": 148897792, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
329 | +{ "start": 150994944, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
330 | +{ "start": 153092096, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
331 | +{ "start": 155189248, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
332 | +{ "start": 157286400, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
333 | +{ "start": 159383552, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
334 | +{ "start": 161480704, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
335 | +{ "start": 163577856, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
336 | +{ "start": 165675008, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
337 | +{ "start": 167772160, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
338 | +{ "start": 169869312, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
339 | +{ "start": 171966464, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
340 | +{ "start": 174063616, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
341 | +{ "start": 176160768, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
342 | +{ "start": 178257920, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
343 | +{ "start": 180355072, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
344 | +{ "start": 182452224, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
345 | +{ "start": 184549376, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
346 | +{ "start": 186646528, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
347 | +{ "start": 188743680, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
348 | +{ "start": 190840832, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
349 | +{ "start": 192937984, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
350 | +{ "start": 195035136, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
351 | +{ "start": 197132288, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
352 | +{ "start": 199229440, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
353 | +{ "start": 201326592, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
354 | +{ "start": 203423744, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
355 | +{ "start": 205520896, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
356 | +{ "start": 207618048, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
357 | +{ "start": 209715200, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
358 | +{ "start": 211812352, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
359 | +{ "start": 213909504, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
360 | +{ "start": 216006656, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
361 | +{ "start": 218103808, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
362 | +{ "start": 220200960, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
363 | +{ "start": 222298112, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
364 | +{ "start": 224395264, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
365 | +{ "start": 226492416, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
366 | +{ "start": 228589568, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
367 | +{ "start": 230686720, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
368 | +{ "start": 232783872, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
369 | +{ "start": 234881024, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
370 | +{ "start": 236978176, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
371 | +{ "start": 239075328, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
372 | +{ "start": 241172480, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
373 | +{ "start": 243269632, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
374 | +{ "start": 245366784, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
375 | +{ "start": 247463936, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
376 | +{ "start": 249561088, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
377 | +{ "start": 251658240, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
378 | +{ "start": 253755392, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
379 | +{ "start": 255852544, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
380 | +{ "start": 257949696, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
381 | +{ "start": 260046848, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
382 | +{ "start": 262144000, "length": 1310720, "depth": 0, "zero": false, "data": true, "offset": OFFSET }] | ||
383 | |||
384 | === Testing d2v with current_size force === | ||
385 | |||
386 | -251.250 MiB (0xfb40000) bytes allocated at offset 0 bytes (0x0) | ||
387 | +[{ "start": 0, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
388 | +{ "start": 2097152, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
389 | +{ "start": 4194304, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
390 | +{ "start": 6291456, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
391 | +{ "start": 8388608, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
392 | +{ "start": 10485760, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
393 | +{ "start": 12582912, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
394 | +{ "start": 14680064, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
395 | +{ "start": 16777216, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
396 | +{ "start": 18874368, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
397 | +{ "start": 20971520, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
398 | +{ "start": 23068672, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
399 | +{ "start": 25165824, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
400 | +{ "start": 27262976, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
401 | +{ "start": 29360128, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
402 | +{ "start": 31457280, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
403 | +{ "start": 33554432, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
404 | +{ "start": 35651584, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
405 | +{ "start": 37748736, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
406 | +{ "start": 39845888, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
407 | +{ "start": 41943040, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
408 | +{ "start": 44040192, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
409 | +{ "start": 46137344, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
410 | +{ "start": 48234496, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
411 | +{ "start": 50331648, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
412 | +{ "start": 52428800, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
413 | +{ "start": 54525952, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
414 | +{ "start": 56623104, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
415 | +{ "start": 58720256, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
416 | +{ "start": 60817408, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
417 | +{ "start": 62914560, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
418 | +{ "start": 65011712, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
419 | +{ "start": 67108864, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
420 | +{ "start": 69206016, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
421 | +{ "start": 71303168, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
422 | +{ "start": 73400320, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
423 | +{ "start": 75497472, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
424 | +{ "start": 77594624, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
425 | +{ "start": 79691776, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
426 | +{ "start": 81788928, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
427 | +{ "start": 83886080, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
428 | +{ "start": 85983232, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
429 | +{ "start": 88080384, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
430 | +{ "start": 90177536, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
431 | +{ "start": 92274688, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
432 | +{ "start": 94371840, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
433 | +{ "start": 96468992, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
434 | +{ "start": 98566144, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
435 | +{ "start": 100663296, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
436 | +{ "start": 102760448, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
437 | +{ "start": 104857600, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
438 | +{ "start": 106954752, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
439 | +{ "start": 109051904, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
440 | +{ "start": 111149056, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
441 | +{ "start": 113246208, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
442 | +{ "start": 115343360, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
443 | +{ "start": 117440512, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
444 | +{ "start": 119537664, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
445 | +{ "start": 121634816, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
446 | +{ "start": 123731968, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
447 | +{ "start": 125829120, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
448 | +{ "start": 127926272, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
449 | +{ "start": 130023424, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
450 | +{ "start": 132120576, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
451 | +{ "start": 134217728, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
452 | +{ "start": 136314880, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
453 | +{ "start": 138412032, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
454 | +{ "start": 140509184, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
455 | +{ "start": 142606336, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
456 | +{ "start": 144703488, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
457 | +{ "start": 146800640, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
458 | +{ "start": 148897792, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
459 | +{ "start": 150994944, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
460 | +{ "start": 153092096, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
461 | +{ "start": 155189248, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
462 | +{ "start": 157286400, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
463 | +{ "start": 159383552, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
464 | +{ "start": 161480704, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
465 | +{ "start": 163577856, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
466 | +{ "start": 165675008, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
467 | +{ "start": 167772160, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
468 | +{ "start": 169869312, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
469 | +{ "start": 171966464, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
470 | +{ "start": 174063616, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
471 | +{ "start": 176160768, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
472 | +{ "start": 178257920, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
473 | +{ "start": 180355072, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
474 | +{ "start": 182452224, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
475 | +{ "start": 184549376, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
476 | +{ "start": 186646528, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
477 | +{ "start": 188743680, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
478 | +{ "start": 190840832, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
479 | +{ "start": 192937984, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
480 | +{ "start": 195035136, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
481 | +{ "start": 197132288, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
482 | +{ "start": 199229440, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
483 | +{ "start": 201326592, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
484 | +{ "start": 203423744, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
485 | +{ "start": 205520896, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
486 | +{ "start": 207618048, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
487 | +{ "start": 209715200, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
488 | +{ "start": 211812352, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
489 | +{ "start": 213909504, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
490 | +{ "start": 216006656, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
491 | +{ "start": 218103808, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
492 | +{ "start": 220200960, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
493 | +{ "start": 222298112, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
494 | +{ "start": 224395264, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
495 | +{ "start": 226492416, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
496 | +{ "start": 228589568, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
497 | +{ "start": 230686720, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
498 | +{ "start": 232783872, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
499 | +{ "start": 234881024, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
500 | +{ "start": 236978176, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
501 | +{ "start": 239075328, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
502 | +{ "start": 241172480, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
503 | +{ "start": 243269632, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
504 | +{ "start": 245366784, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
505 | +{ "start": 247463936, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
506 | +{ "start": 249561088, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
507 | +{ "start": 251658240, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
508 | +{ "start": 253755392, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
509 | +{ "start": 255852544, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
510 | +{ "start": 257949696, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
511 | +{ "start": 260046848, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
512 | +{ "start": 262144000, "length": 1310720, "depth": 0, "zero": false, "data": true, "offset": OFFSET }] | ||
513 | |||
514 | === Testing d2v with chs force === | ||
515 | |||
516 | -251.250 MiB (0xfb40000) bytes allocated at offset 0 bytes (0x0) | ||
517 | +[{ "start": 0, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
518 | +{ "start": 2097152, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
519 | +{ "start": 4194304, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
520 | +{ "start": 6291456, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
521 | +{ "start": 8388608, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
522 | +{ "start": 10485760, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
523 | +{ "start": 12582912, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
524 | +{ "start": 14680064, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
525 | +{ "start": 16777216, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
526 | +{ "start": 18874368, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
527 | +{ "start": 20971520, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
528 | +{ "start": 23068672, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
529 | +{ "start": 25165824, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
530 | +{ "start": 27262976, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
531 | +{ "start": 29360128, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
532 | +{ "start": 31457280, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
533 | +{ "start": 33554432, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
534 | +{ "start": 35651584, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
535 | +{ "start": 37748736, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
536 | +{ "start": 39845888, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
537 | +{ "start": 41943040, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
538 | +{ "start": 44040192, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
539 | +{ "start": 46137344, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
540 | +{ "start": 48234496, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
541 | +{ "start": 50331648, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
542 | +{ "start": 52428800, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
543 | +{ "start": 54525952, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
544 | +{ "start": 56623104, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
545 | +{ "start": 58720256, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
546 | +{ "start": 60817408, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
547 | +{ "start": 62914560, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
548 | +{ "start": 65011712, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
549 | +{ "start": 67108864, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
550 | +{ "start": 69206016, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
551 | +{ "start": 71303168, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
552 | +{ "start": 73400320, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
553 | +{ "start": 75497472, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
554 | +{ "start": 77594624, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
555 | +{ "start": 79691776, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
556 | +{ "start": 81788928, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
557 | +{ "start": 83886080, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
558 | +{ "start": 85983232, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
559 | +{ "start": 88080384, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
560 | +{ "start": 90177536, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
561 | +{ "start": 92274688, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
562 | +{ "start": 94371840, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
563 | +{ "start": 96468992, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
564 | +{ "start": 98566144, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
565 | +{ "start": 100663296, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
566 | +{ "start": 102760448, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
567 | +{ "start": 104857600, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
568 | +{ "start": 106954752, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
569 | +{ "start": 109051904, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
570 | +{ "start": 111149056, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
571 | +{ "start": 113246208, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
572 | +{ "start": 115343360, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
573 | +{ "start": 117440512, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
574 | +{ "start": 119537664, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
575 | +{ "start": 121634816, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
576 | +{ "start": 123731968, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
577 | +{ "start": 125829120, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
578 | +{ "start": 127926272, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
579 | +{ "start": 130023424, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
580 | +{ "start": 132120576, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
581 | +{ "start": 134217728, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
582 | +{ "start": 136314880, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
583 | +{ "start": 138412032, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
584 | +{ "start": 140509184, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
585 | +{ "start": 142606336, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
586 | +{ "start": 144703488, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
587 | +{ "start": 146800640, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
588 | +{ "start": 148897792, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
589 | +{ "start": 150994944, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
590 | +{ "start": 153092096, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
591 | +{ "start": 155189248, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
592 | +{ "start": 157286400, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
593 | +{ "start": 159383552, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
594 | +{ "start": 161480704, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
595 | +{ "start": 163577856, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
596 | +{ "start": 165675008, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
597 | +{ "start": 167772160, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
598 | +{ "start": 169869312, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
599 | +{ "start": 171966464, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
600 | +{ "start": 174063616, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
601 | +{ "start": 176160768, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
602 | +{ "start": 178257920, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
603 | +{ "start": 180355072, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
604 | +{ "start": 182452224, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
605 | +{ "start": 184549376, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
606 | +{ "start": 186646528, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
607 | +{ "start": 188743680, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
608 | +{ "start": 190840832, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
609 | +{ "start": 192937984, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
610 | +{ "start": 195035136, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
611 | +{ "start": 197132288, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
612 | +{ "start": 199229440, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
613 | +{ "start": 201326592, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
614 | +{ "start": 203423744, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
615 | +{ "start": 205520896, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
616 | +{ "start": 207618048, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
617 | +{ "start": 209715200, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
618 | +{ "start": 211812352, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
619 | +{ "start": 213909504, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
620 | +{ "start": 216006656, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
621 | +{ "start": 218103808, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
622 | +{ "start": 220200960, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
623 | +{ "start": 222298112, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
624 | +{ "start": 224395264, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
625 | +{ "start": 226492416, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
626 | +{ "start": 228589568, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
627 | +{ "start": 230686720, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
628 | +{ "start": 232783872, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
629 | +{ "start": 234881024, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
630 | +{ "start": 236978176, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
631 | +{ "start": 239075328, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
632 | +{ "start": 241172480, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
633 | +{ "start": 243269632, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
634 | +{ "start": 245366784, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
635 | +{ "start": 247463936, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
636 | +{ "start": 249561088, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
637 | +{ "start": 251658240, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
638 | +{ "start": 253755392, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
639 | +{ "start": 255852544, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
640 | +{ "start": 257949696, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
641 | +{ "start": 260046848, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET }, | ||
642 | +{ "start": 262144000, "length": 1310720, "depth": 0, "zero": false, "data": true, "offset": OFFSET }] | ||
643 | |||
644 | === Testing Image create, default === | ||
645 | |||
646 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/IMGFMT-create-test.IMGFMT', fmt=IMGFMT size=4294967296 | ||
647 | |||
648 | === Read created image, default opts ==== | ||
649 | |||
650 | -4 GiB (0x10007a000) bytes not allocated at offset 0 bytes (0x0) | ||
651 | +[{ "start": 0, "length": 4295467008, "depth": 0, "zero": true, "data": false }] | ||
652 | |||
653 | === Read created image, force_size_calc=chs ==== | ||
654 | |||
655 | -4 GiB (0x10007a000) bytes not allocated at offset 0 bytes (0x0) | ||
656 | +[{ "start": 0, "length": 4295467008, "depth": 0, "zero": true, "data": false }] | ||
657 | |||
658 | === Read created image, force_size_calc=current_size ==== | ||
659 | |||
660 | -4 GiB (0x10007a000) bytes not allocated at offset 0 bytes (0x0) | ||
661 | +[{ "start": 0, "length": 4295467008, "depth": 0, "zero": true, "data": false }] | ||
662 | |||
663 | === Testing Image create, force_size === | ||
664 | |||
665 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/IMGFMT-create-test.IMGFMT', fmt=IMGFMT size=4294967296 | ||
666 | |||
667 | === Read created image, default opts ==== | ||
668 | |||
669 | -4 GiB (0x100000000) bytes not allocated at offset 0 bytes (0x0) | ||
670 | +[{ "start": 0, "length": 4294967296, "depth": 0, "zero": true, "data": false }] | ||
671 | |||
672 | === Read created image, force_size_calc=chs ==== | ||
673 | |||
674 | -4 GiB (0x100000000) bytes not allocated at offset 0 bytes (0x0) | ||
675 | +[{ "start": 0, "length": 4294967296, "depth": 0, "zero": true, "data": false }] | ||
676 | |||
677 | === Read created image, force_size_calc=current_size ==== | ||
678 | |||
679 | -4 GiB (0x100000000) bytes not allocated at offset 0 bytes (0x0) | ||
680 | +[{ "start": 0, "length": 4294967296, "depth": 0, "zero": true, "data": false }] | ||
38 | *** done | 681 | *** done |
39 | -- | 682 | -- |
40 | 2.24.1 | 683 | 2.26.2 |
41 | 684 | ||
42 | 685 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | qcow2_can_store_new_dirty_bitmap works wrong, as it considers only | 3 | It's false by default, no needs to set it. We are going to drop this |
4 | bitmaps already stored in the qcow2 image and ignores persistent | 4 | variable at all, so drop it now here, it doesn't hurt. |
5 | BdrvDirtyBitmap objects. | ||
6 | |||
7 | So, let's instead count persistent BdrvDirtyBitmaps. We load all qcow2 | ||
8 | bitmaps on open, so there should not be any bitmap in the image for | ||
9 | which we don't have BdrvDirtyBitmaps version. If it is - it's a kind of | ||
10 | corruption, and no reason to check for corruptions here (open() and | ||
11 | close() are better places for it). | ||
12 | 5 | ||
13 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 6 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
14 | Message-id: 20191014115126.15360-2-vsementsov@virtuozzo.com | 7 | Reviewed-by: Eric Blake <eblake@redhat.com> |
15 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 8 | Message-Id: <20200528094405.145708-6-vsementsov@virtuozzo.com> |
16 | Cc: qemu-stable@nongnu.org | ||
17 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 9 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
18 | --- | 10 | --- |
19 | block/qcow2-bitmap.c | 41 ++++++++++++++++++----------------------- | 11 | block/crypto.c | 1 - |
20 | 1 file changed, 18 insertions(+), 23 deletions(-) | 12 | 1 file changed, 1 deletion(-) |
21 | 13 | ||
22 | diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c | 14 | diff --git a/block/crypto.c b/block/crypto.c |
23 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/block/qcow2-bitmap.c | 16 | --- a/block/crypto.c |
25 | +++ b/block/qcow2-bitmap.c | 17 | +++ b/block/crypto.c |
26 | @@ -XXX,XX +XXX,XX @@ bool coroutine_fn qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs, | 18 | @@ -XXX,XX +XXX,XX @@ static int block_crypto_get_info_luks(BlockDriverState *bs, |
27 | Error **errp) | 19 | return ret; |
28 | { | ||
29 | BDRVQcow2State *s = bs->opaque; | ||
30 | - bool found; | ||
31 | - Qcow2BitmapList *bm_list; | ||
32 | + BdrvDirtyBitmap *bitmap; | ||
33 | + uint64_t bitmap_directory_size = 0; | ||
34 | + uint32_t nb_bitmaps = 0; | ||
35 | + | ||
36 | + if (bdrv_find_dirty_bitmap(bs, name)) { | ||
37 | + error_setg(errp, "Bitmap already exists: %s", name); | ||
38 | + return false; | ||
39 | + } | ||
40 | |||
41 | if (s->qcow_version < 3) { | ||
42 | /* Without autoclear_features, we would always have to assume | ||
43 | @@ -XXX,XX +XXX,XX @@ bool coroutine_fn qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs, | ||
44 | goto fail; | ||
45 | } | 20 | } |
46 | 21 | ||
47 | - if (s->nb_bitmaps == 0) { | 22 | - bdi->unallocated_blocks_are_zero = false; |
48 | - return true; | 23 | bdi->cluster_size = subbdi.cluster_size; |
49 | + FOR_EACH_DIRTY_BITMAP(bs, bitmap) { | 24 | |
50 | + if (bdrv_dirty_bitmap_get_persistence(bitmap)) { | 25 | return 0; |
51 | + nb_bitmaps++; | ||
52 | + bitmap_directory_size += | ||
53 | + calc_dir_entry_size(strlen(bdrv_dirty_bitmap_name(bitmap)), 0); | ||
54 | + } | ||
55 | } | ||
56 | + nb_bitmaps++; | ||
57 | + bitmap_directory_size += calc_dir_entry_size(strlen(name), 0); | ||
58 | |||
59 | - if (s->nb_bitmaps >= QCOW2_MAX_BITMAPS) { | ||
60 | + if (nb_bitmaps > QCOW2_MAX_BITMAPS) { | ||
61 | error_setg(errp, | ||
62 | "Maximum number of persistent bitmaps is already reached"); | ||
63 | goto fail; | ||
64 | } | ||
65 | |||
66 | - if (s->bitmap_directory_size + calc_dir_entry_size(strlen(name), 0) > | ||
67 | - QCOW2_MAX_BITMAP_DIRECTORY_SIZE) | ||
68 | - { | ||
69 | + if (bitmap_directory_size > QCOW2_MAX_BITMAP_DIRECTORY_SIZE) { | ||
70 | error_setg(errp, "Not enough space in the bitmap directory"); | ||
71 | goto fail; | ||
72 | } | ||
73 | |||
74 | - qemu_co_mutex_lock(&s->lock); | ||
75 | - bm_list = bitmap_list_load(bs, s->bitmap_directory_offset, | ||
76 | - s->bitmap_directory_size, errp); | ||
77 | - qemu_co_mutex_unlock(&s->lock); | ||
78 | - if (bm_list == NULL) { | ||
79 | - goto fail; | ||
80 | - } | ||
81 | - | ||
82 | - found = find_bitmap_by_name(bm_list, name); | ||
83 | - bitmap_list_free(bm_list); | ||
84 | - if (found) { | ||
85 | - error_setg(errp, "Bitmap with the same name is already stored"); | ||
86 | - goto fail; | ||
87 | - } | ||
88 | - | ||
89 | return true; | ||
90 | |||
91 | fail: | ||
92 | -- | 26 | -- |
93 | 2.24.1 | 27 | 2.26.2 |
94 | 28 | ||
95 | 29 | diff view generated by jsdifflib |
1 | From: PanNengyuan <pannengyuan@huawei.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | This avoid a memory leak when qom-set is called to set throttle_group | 3 | We set bdi->unallocated_blocks_are_zero = iscsilun->lbprz, but |
4 | limits, here is an easy way to reproduce: | 4 | iscsi_co_block_status doesn't return 0 in case of iscsilun->lbprz, it |
5 | returns ZERO when appropriate. So actually unallocated_blocks_are_zero | ||
6 | is useless (it doesn't affect the only user of the field: | ||
7 | bdrv_co_block_status()). Drop it now. | ||
5 | 8 | ||
6 | 1. run qemu-iotests as follow and check the result with asan: | 9 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
7 | ./check -qcow2 184 | 10 | Reviewed-by: Eric Blake <eblake@redhat.com> |
8 | 11 | Message-Id: <20200528094405.145708-7-vsementsov@virtuozzo.com> | |
9 | Following is the asan output backtrack: | ||
10 | Direct leak of 912 byte(s) in 3 object(s) allocated from: | ||
11 | #0 0xffff8d7ab3c3 in __interceptor_calloc (/lib64/libasan.so.4+0xd33c3) | ||
12 | #1 0xffff8d4c31cb in g_malloc0 (/lib64/libglib-2.0.so.0+0x571cb) | ||
13 | #2 0x190c857 in qobject_input_start_struct /mnt/sdc/qemu-master/qemu-4.2.0-rc0/qapi/qobject-input-visitor.c:295 | ||
14 | #3 0x19070df in visit_start_struct /mnt/sdc/qemu-master/qemu-4.2.0-rc0/qapi/qapi-visit-core.c:49 | ||
15 | #4 0x1948b87 in visit_type_ThrottleLimits qapi/qapi-visit-block-core.c:3759 | ||
16 | #5 0x17e4aa3 in throttle_group_set_limits /mnt/sdc/qemu-master/qemu-4.2.0-rc0/block/throttle-groups.c:900 | ||
17 | #6 0x1650eff in object_property_set /mnt/sdc/qemu-master/qemu-4.2.0-rc0/qom/object.c:1272 | ||
18 | #7 0x1658517 in object_property_set_qobject /mnt/sdc/qemu-master/qemu-4.2.0-rc0/qom/qom-qobject.c:26 | ||
19 | #8 0x15880bb in qmp_qom_set /mnt/sdc/qemu-master/qemu-4.2.0-rc0/qom/qom-qmp-cmds.c:74 | ||
20 | #9 0x157e3e3 in qmp_marshal_qom_set qapi/qapi-commands-qom.c:154 | ||
21 | |||
22 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
23 | Signed-off-by: PanNengyuan <pannengyuan@huawei.com> | ||
24 | Message-id: 1574835614-42028-1-git-send-email-pannengyuan@huawei.com | ||
25 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 12 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
26 | --- | 13 | --- |
27 | block/throttle-groups.c | 4 ++-- | 14 | block/iscsi.c | 1 - |
28 | 1 file changed, 2 insertions(+), 2 deletions(-) | 15 | 1 file changed, 1 deletion(-) |
29 | 16 | ||
30 | diff --git a/block/throttle-groups.c b/block/throttle-groups.c | 17 | diff --git a/block/iscsi.c b/block/iscsi.c |
31 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/block/throttle-groups.c | 19 | --- a/block/iscsi.c |
33 | +++ b/block/throttle-groups.c | 20 | +++ b/block/iscsi.c |
34 | @@ -XXX,XX +XXX,XX @@ static void throttle_group_set_limits(Object *obj, Visitor *v, | 21 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn iscsi_co_truncate(BlockDriverState *bs, int64_t offset, |
22 | static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) | ||
35 | { | 23 | { |
36 | ThrottleGroup *tg = THROTTLE_GROUP(obj); | 24 | IscsiLun *iscsilun = bs->opaque; |
37 | ThrottleConfig cfg; | 25 | - bdi->unallocated_blocks_are_zero = iscsilun->lbprz; |
38 | - ThrottleLimits arg = { 0 }; | 26 | bdi->cluster_size = iscsilun->cluster_size; |
39 | - ThrottleLimits *argp = &arg; | 27 | return 0; |
40 | + ThrottleLimits *argp; | ||
41 | Error *local_err = NULL; | ||
42 | |||
43 | visit_type_ThrottleLimits(v, name, &argp, &local_err); | ||
44 | @@ -XXX,XX +XXX,XX @@ static void throttle_group_set_limits(Object *obj, Visitor *v, | ||
45 | unlock: | ||
46 | qemu_mutex_unlock(&tg->lock); | ||
47 | ret: | ||
48 | + qapi_free_ThrottleLimits(argp); | ||
49 | error_propagate(errp, local_err); | ||
50 | return; | ||
51 | } | 28 | } |
52 | -- | 29 | -- |
53 | 2.24.1 | 30 | 2.26.2 |
54 | 31 | ||
55 | 32 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Probably due to blind copy-pasting, we have several instances of "qocw2" | ||
2 | in our iotests. Fix them. | ||
3 | 1 | ||
4 | Reported-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
6 | Message-id: 20191107163708.833192-2-mreitz@redhat.com | ||
7 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
8 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | --- | ||
11 | tests/qemu-iotests/060 | 2 +- | ||
12 | tests/qemu-iotests/061 | 2 +- | ||
13 | tests/qemu-iotests/062 | 2 +- | ||
14 | tests/qemu-iotests/066 | 2 +- | ||
15 | tests/qemu-iotests/068 | 2 +- | ||
16 | tests/qemu-iotests/108 | 2 +- | ||
17 | tests/qemu-iotests/138 | 2 +- | ||
18 | tests/qemu-iotests/261 | 2 +- | ||
19 | 8 files changed, 8 insertions(+), 8 deletions(-) | ||
20 | |||
21 | diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 | ||
22 | index XXXXXXX..XXXXXXX 100755 | ||
23 | --- a/tests/qemu-iotests/060 | ||
24 | +++ b/tests/qemu-iotests/060 | ||
25 | @@ -XXX,XX +XXX,XX @@ _filter_io_error() | ||
26 | . ./common.rc | ||
27 | . ./common.filter | ||
28 | |||
29 | -# This tests qocw2-specific low-level functionality | ||
30 | +# This tests qcow2-specific low-level functionality | ||
31 | _supported_fmt qcow2 | ||
32 | _supported_proto file | ||
33 | _supported_os Linux | ||
34 | diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 | ||
35 | index XXXXXXX..XXXXXXX 100755 | ||
36 | --- a/tests/qemu-iotests/061 | ||
37 | +++ b/tests/qemu-iotests/061 | ||
38 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
39 | . ./common.rc | ||
40 | . ./common.filter | ||
41 | |||
42 | -# This tests qocw2-specific low-level functionality | ||
43 | +# This tests qcow2-specific low-level functionality | ||
44 | _supported_fmt qcow2 | ||
45 | _supported_proto file | ||
46 | _supported_os Linux | ||
47 | diff --git a/tests/qemu-iotests/062 b/tests/qemu-iotests/062 | ||
48 | index XXXXXXX..XXXXXXX 100755 | ||
49 | --- a/tests/qemu-iotests/062 | ||
50 | +++ b/tests/qemu-iotests/062 | ||
51 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
52 | . ./common.rc | ||
53 | . ./common.filter | ||
54 | |||
55 | -# This tests qocw2-specific low-level functionality | ||
56 | +# This tests qcow2-specific low-level functionality | ||
57 | _supported_fmt qcow2 | ||
58 | _supported_proto generic | ||
59 | |||
60 | diff --git a/tests/qemu-iotests/066 b/tests/qemu-iotests/066 | ||
61 | index XXXXXXX..XXXXXXX 100755 | ||
62 | --- a/tests/qemu-iotests/066 | ||
63 | +++ b/tests/qemu-iotests/066 | ||
64 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
65 | . ./common.rc | ||
66 | . ./common.filter | ||
67 | |||
68 | -# This tests qocw2-specific low-level functionality | ||
69 | +# This tests qcow2-specific low-level functionality | ||
70 | _supported_fmt qcow2 | ||
71 | _supported_proto generic | ||
72 | |||
73 | diff --git a/tests/qemu-iotests/068 b/tests/qemu-iotests/068 | ||
74 | index XXXXXXX..XXXXXXX 100755 | ||
75 | --- a/tests/qemu-iotests/068 | ||
76 | +++ b/tests/qemu-iotests/068 | ||
77 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
78 | . ./common.rc | ||
79 | . ./common.filter | ||
80 | |||
81 | -# This tests qocw2-specific low-level functionality | ||
82 | +# This tests qcow2-specific low-level functionality | ||
83 | _supported_fmt qcow2 | ||
84 | _supported_proto generic | ||
85 | |||
86 | diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108 | ||
87 | index XXXXXXX..XXXXXXX 100755 | ||
88 | --- a/tests/qemu-iotests/108 | ||
89 | +++ b/tests/qemu-iotests/108 | ||
90 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
91 | . ./common.rc | ||
92 | . ./common.filter | ||
93 | |||
94 | -# This tests qocw2-specific low-level functionality | ||
95 | +# This tests qcow2-specific low-level functionality | ||
96 | _supported_fmt qcow2 | ||
97 | _supported_proto file | ||
98 | _supported_os Linux | ||
99 | diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138 | ||
100 | index XXXXXXX..XXXXXXX 100755 | ||
101 | --- a/tests/qemu-iotests/138 | ||
102 | +++ b/tests/qemu-iotests/138 | ||
103 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
104 | . ./common.rc | ||
105 | . ./common.filter | ||
106 | |||
107 | -# This tests qocw2-specific low-level functionality | ||
108 | +# This tests qcow2-specific low-level functionality | ||
109 | _supported_fmt qcow2 | ||
110 | _supported_proto file | ||
111 | _supported_os Linux | ||
112 | diff --git a/tests/qemu-iotests/261 b/tests/qemu-iotests/261 | ||
113 | index XXXXXXX..XXXXXXX 100755 | ||
114 | --- a/tests/qemu-iotests/261 | ||
115 | +++ b/tests/qemu-iotests/261 | ||
116 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
117 | . ./common.rc | ||
118 | . ./common.filter | ||
119 | |||
120 | -# This tests qocw2-specific low-level functionality | ||
121 | +# This tests qcow2-specific low-level functionality | ||
122 | _supported_fmt qcow2 | ||
123 | _supported_proto file | ||
124 | _supported_os Linux | ||
125 | -- | ||
126 | 2.24.1 | ||
127 | |||
128 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This is useful for tests that want to whitelist fields from dump-header | ||
2 | (with grep) but still print all header extensions. | ||
3 | 1 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
5 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
6 | Message-id: 20191107163708.833192-3-mreitz@redhat.com | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
8 | --- | ||
9 | tests/qemu-iotests/qcow2.py | 5 +++++ | ||
10 | 1 file changed, 5 insertions(+) | ||
11 | |||
12 | diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py | ||
13 | index XXXXXXX..XXXXXXX 100755 | ||
14 | --- a/tests/qemu-iotests/qcow2.py | ||
15 | +++ b/tests/qemu-iotests/qcow2.py | ||
16 | @@ -XXX,XX +XXX,XX @@ def cmd_dump_header(fd): | ||
17 | h.dump() | ||
18 | h.dump_extensions() | ||
19 | |||
20 | +def cmd_dump_header_exts(fd): | ||
21 | + h = QcowHeader(fd) | ||
22 | + h.dump_extensions() | ||
23 | + | ||
24 | def cmd_set_header(fd, name, value): | ||
25 | try: | ||
26 | value = int(value, 0) | ||
27 | @@ -XXX,XX +XXX,XX @@ def cmd_set_feature_bit(fd, group, bit): | ||
28 | |||
29 | cmds = [ | ||
30 | [ 'dump-header', cmd_dump_header, 0, 'Dump image header and header extensions' ], | ||
31 | + [ 'dump-header-exts', cmd_dump_header_exts, 0, 'Dump image header extensions' ], | ||
32 | [ 'set-header', cmd_set_header, 2, 'Set a field in the header'], | ||
33 | [ 'add-header-ext', cmd_add_header_ext, 2, 'Add a header extension' ], | ||
34 | [ 'add-header-ext-stdio', cmd_add_header_ext_stdio, 1, 'Add a header extension, data from stdin' ], | ||
35 | -- | ||
36 | 2.24.1 | ||
37 | |||
38 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This test can run just fine with other values for refcount_bits, so we | ||
2 | should filter the value from qcow2.py's dump-header. In fact, we can | ||
3 | filter everything but the feature bits and header extensions, because | ||
4 | that is what the test is about. | ||
5 | 1 | ||
6 | (036 currently ignores user-specified image options, but that will be | ||
7 | fixed in the next patch.) | ||
8 | |||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
11 | Message-id: 20191107163708.833192-6-mreitz@redhat.com | ||
12 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
13 | --- | ||
14 | tests/qemu-iotests/036 | 9 ++++--- | ||
15 | tests/qemu-iotests/036.out | 48 -------------------------------------- | ||
16 | 2 files changed, 6 insertions(+), 51 deletions(-) | ||
17 | |||
18 | diff --git a/tests/qemu-iotests/036 b/tests/qemu-iotests/036 | ||
19 | index XXXXXXX..XXXXXXX 100755 | ||
20 | --- a/tests/qemu-iotests/036 | ||
21 | +++ b/tests/qemu-iotests/036 | ||
22 | @@ -XXX,XX +XXX,XX @@ $PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 63 | ||
23 | |||
24 | # Without feature table | ||
25 | $PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 | ||
26 | -$PYTHON qcow2.py "$TEST_IMG" dump-header | ||
27 | +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep features | ||
28 | +$PYTHON qcow2.py "$TEST_IMG" dump-header-exts | ||
29 | _img_info | ||
30 | |||
31 | # With feature table containing bit 63 | ||
32 | @@ -XXX,XX +XXX,XX @@ echo === Create image with unknown autoclear feature bit === | ||
33 | echo | ||
34 | _make_test_img 64M | ||
35 | $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 | ||
36 | -$PYTHON qcow2.py "$TEST_IMG" dump-header | ||
37 | +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep features | ||
38 | +$PYTHON qcow2.py "$TEST_IMG" dump-header-exts | ||
39 | |||
40 | echo | ||
41 | echo === Repair image === | ||
42 | echo | ||
43 | _check_test_img -r all | ||
44 | |||
45 | -$PYTHON qcow2.py "$TEST_IMG" dump-header | ||
46 | +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep features | ||
47 | +$PYTHON qcow2.py "$TEST_IMG" dump-header-exts | ||
48 | |||
49 | # success, all done | ||
50 | echo "*** done" | ||
51 | diff --git a/tests/qemu-iotests/036.out b/tests/qemu-iotests/036.out | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/tests/qemu-iotests/036.out | ||
54 | +++ b/tests/qemu-iotests/036.out | ||
55 | @@ -XXX,XX +XXX,XX @@ QA output created by 036 | ||
56 | === Image with unknown incompatible feature bit === | ||
57 | |||
58 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
59 | -magic 0x514649fb | ||
60 | -version 3 | ||
61 | -backing_file_offset 0x0 | ||
62 | -backing_file_size 0x0 | ||
63 | -cluster_bits 16 | ||
64 | -size 67108864 | ||
65 | -crypt_method 0 | ||
66 | -l1_size 1 | ||
67 | -l1_table_offset 0x30000 | ||
68 | -refcount_table_offset 0x10000 | ||
69 | -refcount_table_clusters 1 | ||
70 | -nb_snapshots 0 | ||
71 | -snapshot_offset 0x0 | ||
72 | incompatible_features [63] | ||
73 | compatible_features [] | ||
74 | autoclear_features [] | ||
75 | -refcount_order 4 | ||
76 | -header_length 104 | ||
77 | - | ||
78 | qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000 | ||
79 | qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature | ||
80 | |||
81 | @@ -XXX,XX +XXX,XX @@ qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): tes | ||
82 | === Create image with unknown autoclear feature bit === | ||
83 | |||
84 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
85 | -magic 0x514649fb | ||
86 | -version 3 | ||
87 | -backing_file_offset 0x0 | ||
88 | -backing_file_size 0x0 | ||
89 | -cluster_bits 16 | ||
90 | -size 67108864 | ||
91 | -crypt_method 0 | ||
92 | -l1_size 1 | ||
93 | -l1_table_offset 0x30000 | ||
94 | -refcount_table_offset 0x10000 | ||
95 | -refcount_table_clusters 1 | ||
96 | -nb_snapshots 0 | ||
97 | -snapshot_offset 0x0 | ||
98 | incompatible_features [] | ||
99 | compatible_features [] | ||
100 | autoclear_features [63] | ||
101 | -refcount_order 4 | ||
102 | -header_length 104 | ||
103 | - | ||
104 | Header extension: | ||
105 | magic 0x6803f857 | ||
106 | length 192 | ||
107 | @@ -XXX,XX +XXX,XX @@ data <binary> | ||
108 | === Repair image === | ||
109 | |||
110 | No errors were found on the image. | ||
111 | -magic 0x514649fb | ||
112 | -version 3 | ||
113 | -backing_file_offset 0x0 | ||
114 | -backing_file_size 0x0 | ||
115 | -cluster_bits 16 | ||
116 | -size 67108864 | ||
117 | -crypt_method 0 | ||
118 | -l1_size 1 | ||
119 | -l1_table_offset 0x30000 | ||
120 | -refcount_table_offset 0x10000 | ||
121 | -refcount_table_clusters 1 | ||
122 | -nb_snapshots 0 | ||
123 | -snapshot_offset 0x0 | ||
124 | incompatible_features [] | ||
125 | compatible_features [] | ||
126 | autoclear_features [] | ||
127 | -refcount_order 4 | ||
128 | -header_length 104 | ||
129 | - | ||
130 | Header extension: | ||
131 | magic 0x6803f857 | ||
132 | length 192 | ||
133 | -- | ||
134 | 2.24.1 | ||
135 | |||
136 | diff view generated by jsdifflib |
1 | This will allow us to add more options than just -b. | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | raw_co_block_status() in block/file-posix.c never returns 0, so |
4 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 4 | unallocated_blocks_are_zero is useless (it doesn't affect the only user |
5 | Message-id: 20191107163708.833192-9-mreitz@redhat.com | 5 | of the field: bdrv_co_block_status()). Drop it. |
6 | |||
7 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
8 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
9 | Message-Id: <20200528094405.145708-8-vsementsov@virtuozzo.com> | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
7 | --- | 11 | --- |
8 | tests/qemu-iotests/common.rc | 28 ++++++++++++++++++++-------- | 12 | block/file-posix.c | 3 --- |
9 | 1 file changed, 20 insertions(+), 8 deletions(-) | 13 | 1 file changed, 3 deletions(-) |
10 | 14 | ||
11 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | 15 | diff --git a/block/file-posix.c b/block/file-posix.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/tests/qemu-iotests/common.rc | 17 | --- a/block/file-posix.c |
14 | +++ b/tests/qemu-iotests/common.rc | 18 | +++ b/block/file-posix.c |
15 | @@ -XXX,XX +XXX,XX @@ _make_test_img() | 19 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_pwrite_zeroes( |
16 | # extra qemu-img options can be added by tests | 20 | |
17 | # at least one argument (the image size) needs to be added | 21 | static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) |
18 | local extra_img_options="" | 22 | { |
19 | - local image_size=$* | 23 | - BDRVRawState *s = bs->opaque; |
20 | local optstr="" | 24 | - |
21 | local img_name="" | 25 | - bdi->unallocated_blocks_are_zero = s->discard_zeroes; |
22 | local use_backing=0 | 26 | return 0; |
23 | local backing_file="" | 27 | } |
24 | local object_options="" | ||
25 | + local misc_params=() | ||
26 | |||
27 | if [ -n "$TEST_IMG_FILE" ]; then | ||
28 | img_name=$TEST_IMG_FILE | ||
29 | @@ -XXX,XX +XXX,XX @@ _make_test_img() | ||
30 | optstr=$(_optstr_add "$optstr" "key-secret=keysec0") | ||
31 | fi | ||
32 | |||
33 | - if [ "$1" = "-b" ]; then | ||
34 | - use_backing=1 | ||
35 | - backing_file=$2 | ||
36 | - image_size=$3 | ||
37 | - fi | ||
38 | + for param; do | ||
39 | + if [ "$use_backing" = "1" -a -z "$backing_file" ]; then | ||
40 | + backing_file=$param | ||
41 | + continue | ||
42 | + fi | ||
43 | + | ||
44 | + case "$param" in | ||
45 | + -b) | ||
46 | + use_backing=1 | ||
47 | + ;; | ||
48 | + | ||
49 | + *) | ||
50 | + misc_params=("${misc_params[@]}" "$param") | ||
51 | + ;; | ||
52 | + esac | ||
53 | + done | ||
54 | + | ||
55 | if [ \( "$IMGFMT" = "qcow2" -o "$IMGFMT" = "qed" \) -a -n "$CLUSTER_SIZE" ]; then | ||
56 | optstr=$(_optstr_add "$optstr" "cluster_size=$CLUSTER_SIZE") | ||
57 | fi | ||
58 | @@ -XXX,XX +XXX,XX @@ _make_test_img() | ||
59 | # XXX(hch): have global image options? | ||
60 | ( | ||
61 | if [ $use_backing = 1 ]; then | ||
62 | - $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" $image_size 2>&1 | ||
63 | + $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" "${misc_params[@]}" 2>&1 | ||
64 | else | ||
65 | - $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" $image_size 2>&1 | ||
66 | + $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" "${misc_params[@]}" 2>&1 | ||
67 | fi | ||
68 | ) | _filter_img_create | ||
69 | 28 | ||
70 | -- | 29 | -- |
71 | 2.24.1 | 30 | 2.26.2 |
72 | 31 | ||
73 | 32 | diff view generated by jsdifflib |
1 | IMGOPTS can never be empty for qcow2, because the check scripts adds | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | compat=1.1 unless the user specified any compat option themselves. | ||
3 | Thus, this block does not do anything and can be dropped. | ||
4 | 2 | ||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | vhdx doesn't have .bdrv_co_block_status handler, so DATA|ALLOCATED is |
6 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 4 | always assumed for it in bdrv_co_block_status(). |
7 | Message-id: 20191107163708.833192-8-mreitz@redhat.com | 5 | unallocated_blocks_are_zero is useless (it doesn't affect the only user |
6 | of the field: bdrv_co_block_status()), drop it. | ||
7 | |||
8 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
9 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
10 | Message-Id: <20200528094405.145708-9-vsementsov@virtuozzo.com> | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 11 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
9 | --- | 12 | --- |
10 | tests/qemu-iotests/050 | 4 ---- | 13 | block/vhdx.c | 3 --- |
11 | 1 file changed, 4 deletions(-) | 14 | 1 file changed, 3 deletions(-) |
12 | 15 | ||
13 | diff --git a/tests/qemu-iotests/050 b/tests/qemu-iotests/050 | 16 | diff --git a/block/vhdx.c b/block/vhdx.c |
14 | index XXXXXXX..XXXXXXX 100755 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/tests/qemu-iotests/050 | 18 | --- a/block/vhdx.c |
16 | +++ b/tests/qemu-iotests/050 | 19 | +++ b/block/vhdx.c |
17 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 20 | @@ -XXX,XX +XXX,XX @@ static int vhdx_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) |
18 | _supported_fmt qcow2 qed | 21 | |
19 | _supported_proto file | 22 | bdi->cluster_size = s->block_size; |
20 | 23 | ||
21 | -if test "$IMGFMT" = qcow2 && test $IMGOPTS = ""; then | 24 | - bdi->unallocated_blocks_are_zero = |
22 | - IMGOPTS=compat=1.1 | 25 | - (s->params.data_bits & VHDX_PARAMS_HAS_PARENT) == 0; |
23 | -fi | ||
24 | - | 26 | - |
25 | echo | 27 | return 0; |
26 | echo "== Creating images ==" | 28 | } |
27 | 29 | ||
28 | -- | 30 | -- |
29 | 2.24.1 | 31 | 2.26.2 |
30 | 32 | ||
31 | 33 | diff view generated by jsdifflib |
1 | Some tests require compat=1.1 and thus set IMGOPTS='compat=1.1' | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | globally. That is not how it should be done; instead, they should | ||
3 | simply set _unsupported_imgopts to compat=0.10 (compat=1.1 is the | ||
4 | default anyway). | ||
5 | 2 | ||
6 | This makes the tests heed user-specified $IMGOPTS. Some do not work | 3 | Currently this field only set by qed and qcow2. But in fact, all |
7 | with all image options, though, so we need to disable them accordingly. | 4 | backing-supporting formats (parallels, qcow, qcow2, qed, vmdk) share |
5 | these semantics: on unallocated blocks, if there is no backing file they | ||
6 | just memset the buffer with zeroes. | ||
8 | 7 | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | So, document this behavior for .supports_backing and drop |
10 | Reviewed-by: Maxim Levitsky <mlevitsky@redhat.com> | 9 | .unallocated_blocks_are_zero |
11 | Message-id: 20191107163708.833192-7-mreitz@redhat.com | 10 | |
11 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
12 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
13 | Message-Id: <20200528094405.145708-10-vsementsov@virtuozzo.com> | ||
12 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 14 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
13 | --- | 15 | --- |
14 | tests/qemu-iotests/036 | 3 +-- | 16 | include/block/block.h | 5 ----- |
15 | tests/qemu-iotests/060 | 4 ++-- | 17 | include/block/block_int.h | 12 +++++++++++- |
16 | tests/qemu-iotests/062 | 3 ++- | 18 | block/io.c | 9 ++------- |
17 | tests/qemu-iotests/066 | 3 ++- | 19 | block/qcow2.c | 1 - |
18 | tests/qemu-iotests/068 | 3 ++- | 20 | block/qed.c | 1 - |
19 | tests/qemu-iotests/098 | 4 ++-- | 21 | 5 files changed, 13 insertions(+), 15 deletions(-) |
20 | 6 files changed, 11 insertions(+), 9 deletions(-) | ||
21 | 22 | ||
22 | diff --git a/tests/qemu-iotests/036 b/tests/qemu-iotests/036 | 23 | diff --git a/include/block/block.h b/include/block/block.h |
23 | index XXXXXXX..XXXXXXX 100755 | 24 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/tests/qemu-iotests/036 | 25 | --- a/include/block/block.h |
25 | +++ b/tests/qemu-iotests/036 | 26 | +++ b/include/block/block.h |
26 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 27 | @@ -XXX,XX +XXX,XX @@ typedef struct BlockDriverInfo { |
27 | # This tests qcow2-specific low-level functionality | 28 | /* offset at which the VM state can be saved (0 if not possible) */ |
28 | _supported_fmt qcow2 | 29 | int64_t vm_state_offset; |
29 | _supported_proto file | 30 | bool is_dirty; |
31 | - /* | ||
32 | - * True if unallocated blocks read back as zeroes. This is equivalent | ||
33 | - * to the LBPRZ flag in the SCSI logical block provisioning page. | ||
34 | - */ | ||
35 | - bool unallocated_blocks_are_zero; | ||
36 | /* | ||
37 | * True if this block driver only supports compressed writes | ||
38 | */ | ||
39 | diff --git a/include/block/block_int.h b/include/block/block_int.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/include/block/block_int.h | ||
42 | +++ b/include/block/block_int.h | ||
43 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
44 | */ | ||
45 | bool bdrv_needs_filename; | ||
46 | |||
47 | - /* Set if a driver can support backing files */ | ||
48 | + /* | ||
49 | + * Set if a driver can support backing files. This also implies the | ||
50 | + * following semantics: | ||
51 | + * | ||
52 | + * - Return status 0 of .bdrv_co_block_status means that corresponding | ||
53 | + * blocks are not allocated in this layer of backing-chain | ||
54 | + * - For such (unallocated) blocks, read will: | ||
55 | + * - fill buffer with zeros if there is no backing file | ||
56 | + * - read from the backing file otherwise, where the block layer | ||
57 | + * takes care of reading zeros beyond EOF if backing file is short | ||
58 | + */ | ||
59 | bool supports_backing; | ||
60 | |||
61 | /* For handling image reopen for split or non-split files */ | ||
62 | diff --git a/block/io.c b/block/io.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/block/io.c | ||
65 | +++ b/block/io.c | ||
66 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs, | ||
67 | |||
68 | if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) { | ||
69 | ret |= BDRV_BLOCK_ALLOCATED; | ||
70 | - } else if (want_zero) { | ||
71 | + } else if (want_zero && bs->drv->supports_backing) { | ||
72 | if (bs->backing) { | ||
73 | BlockDriverState *bs2 = bs->backing->bs; | ||
74 | int64_t size2 = bdrv_getlength(bs2); | ||
75 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs, | ||
76 | ret |= BDRV_BLOCK_ZERO; | ||
77 | } | ||
78 | } else { | ||
79 | - BlockDriverInfo bdi; | ||
80 | - int ret2 = bdrv_get_info(bs, &bdi); | ||
30 | - | 81 | - |
31 | # Only qcow2v3 and later supports feature bits | 82 | - if (ret2 == 0 && bdi.unallocated_blocks_are_zero) { |
32 | -IMGOPTS="compat=1.1" | 83 | - ret |= BDRV_BLOCK_ZERO; |
33 | +_unsupported_imgopts 'compat=0.10' | 84 | - } |
34 | 85 | + ret |= BDRV_BLOCK_ZERO; | |
35 | echo | 86 | } |
36 | echo === Image with unknown incompatible feature bit === | 87 | } |
37 | diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 | 88 | |
38 | index XXXXXXX..XXXXXXX 100755 | 89 | diff --git a/block/qcow2.c b/block/qcow2.c |
39 | --- a/tests/qemu-iotests/060 | 90 | index XXXXXXX..XXXXXXX 100644 |
40 | +++ b/tests/qemu-iotests/060 | 91 | --- a/block/qcow2.c |
41 | @@ -XXX,XX +XXX,XX @@ _filter_io_error() | 92 | +++ b/block/qcow2.c |
42 | _supported_fmt qcow2 | 93 | @@ -XXX,XX +XXX,XX @@ err: |
43 | _supported_proto file | 94 | static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) |
44 | _supported_os Linux | 95 | { |
45 | +# These tests only work for compat=1.1 images with refcount_bits=16 | 96 | BDRVQcow2State *s = bs->opaque; |
46 | +_unsupported_imgopts 'compat=0.10' 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | 97 | - bdi->unallocated_blocks_are_zero = true; |
47 | 98 | bdi->cluster_size = s->cluster_size; | |
48 | # The repair process will create a large file - so check for availability first | 99 | bdi->vm_state_offset = qcow2_vm_state_offset(s); |
49 | _require_large_file 64G | 100 | return 0; |
50 | @@ -XXX,XX +XXX,XX @@ l1_offset=196608 # 0x30000 (XXX: just an assumption) | 101 | diff --git a/block/qed.c b/block/qed.c |
51 | l2_offset=262144 # 0x40000 (XXX: just an assumption) | 102 | index XXXXXXX..XXXXXXX 100644 |
52 | l2_offset_after_snapshot=524288 # 0x80000 (XXX: just an assumption) | 103 | --- a/block/qed.c |
53 | 104 | +++ b/block/qed.c | |
54 | -IMGOPTS="compat=1.1" | 105 | @@ -XXX,XX +XXX,XX @@ static int bdrv_qed_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) |
55 | - | 106 | memset(bdi, 0, sizeof(*bdi)); |
56 | OPEN_RW="open -o overlap-check=all $TEST_IMG" | 107 | bdi->cluster_size = s->header.cluster_size; |
57 | # Overlap checks are done before write operations only, therefore opening an | 108 | bdi->is_dirty = s->header.features & QED_F_NEED_CHECK; |
58 | # image read-only makes the overlap-check option irrelevant | 109 | - bdi->unallocated_blocks_are_zero = true; |
59 | diff --git a/tests/qemu-iotests/062 b/tests/qemu-iotests/062 | 110 | return 0; |
60 | index XXXXXXX..XXXXXXX 100755 | 111 | } |
61 | --- a/tests/qemu-iotests/062 | ||
62 | +++ b/tests/qemu-iotests/062 | ||
63 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
64 | # This tests qcow2-specific low-level functionality | ||
65 | _supported_fmt qcow2 | ||
66 | _supported_proto generic | ||
67 | +# We need zero clusters and snapshots | ||
68 | +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' | ||
69 | |||
70 | -IMGOPTS="compat=1.1" | ||
71 | IMG_SIZE=64M | ||
72 | |||
73 | echo | ||
74 | diff --git a/tests/qemu-iotests/066 b/tests/qemu-iotests/066 | ||
75 | index XXXXXXX..XXXXXXX 100755 | ||
76 | --- a/tests/qemu-iotests/066 | ||
77 | +++ b/tests/qemu-iotests/066 | ||
78 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
79 | # This tests qcow2-specific low-level functionality | ||
80 | _supported_fmt qcow2 | ||
81 | _supported_proto generic | ||
82 | +# We need zero clusters and snapshots | ||
83 | +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' | ||
84 | |||
85 | # Intentionally create an unaligned image | ||
86 | -IMGOPTS="compat=1.1" | ||
87 | IMG_SIZE=$((64 * 1024 * 1024 + 512)) | ||
88 | |||
89 | echo | ||
90 | diff --git a/tests/qemu-iotests/068 b/tests/qemu-iotests/068 | ||
91 | index XXXXXXX..XXXXXXX 100755 | ||
92 | --- a/tests/qemu-iotests/068 | ||
93 | +++ b/tests/qemu-iotests/068 | ||
94 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
95 | # This tests qcow2-specific low-level functionality | ||
96 | _supported_fmt qcow2 | ||
97 | _supported_proto generic | ||
98 | +# Internal snapshots are (currently) impossible with refcount_bits=1 | ||
99 | +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' | ||
100 | |||
101 | -IMGOPTS="compat=1.1" | ||
102 | IMG_SIZE=128K | ||
103 | |||
104 | case "$QEMU_DEFAULT_MACHINE" in | ||
105 | diff --git a/tests/qemu-iotests/098 b/tests/qemu-iotests/098 | ||
106 | index XXXXXXX..XXXXXXX 100755 | ||
107 | --- a/tests/qemu-iotests/098 | ||
108 | +++ b/tests/qemu-iotests/098 | ||
109 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
110 | |||
111 | _supported_fmt qcow2 | ||
112 | _supported_proto file | ||
113 | - | ||
114 | -IMGOPTS="compat=1.1" | ||
115 | +# The code path we want to test here only works for compat=1.1 images | ||
116 | +_unsupported_imgopts 'compat=0.10' | ||
117 | |||
118 | for event in l1_update empty_image_prepare reftable_update refblock_alloc; do | ||
119 | 112 | ||
120 | -- | 113 | -- |
121 | 2.24.1 | 114 | 2.26.2 |
122 | 115 | ||
123 | 116 | diff view generated by jsdifflib |
1 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 1 | From: Eric Blake <eblake@redhat.com> |
---|---|---|---|
2 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | 2 | |
3 | Message-id: 20191107163708.833192-13-mreitz@redhat.com | 3 | The other four drivers that support backing files (qcow, qcow2, |
4 | parallels, vmdk) all rely on the block layer to populate zeroes when | ||
5 | reading beyond EOF of a short backing file. We can simplify the qed | ||
6 | code by doing likewise. | ||
7 | |||
8 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
9 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
10 | Message-Id: <20200528094405.145708-11-vsementsov@virtuozzo.com> | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 11 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
5 | --- | 12 | --- |
6 | tests/qemu-iotests/071 | 4 ++-- | 13 | block/qed.h | 1 - |
7 | tests/qemu-iotests/174 | 2 +- | 14 | block/qed.c | 64 +++++------------------------------------------------ |
8 | tests/qemu-iotests/178 | 4 ++-- | 15 | 2 files changed, 6 insertions(+), 59 deletions(-) |
9 | tests/qemu-iotests/197 | 4 ++-- | ||
10 | tests/qemu-iotests/215 | 4 ++-- | ||
11 | 5 files changed, 9 insertions(+), 9 deletions(-) | ||
12 | 16 | ||
13 | diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 | 17 | diff --git a/block/qed.h b/block/qed.h |
14 | index XXXXXXX..XXXXXXX 100755 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/tests/qemu-iotests/071 | 19 | --- a/block/qed.h |
16 | +++ b/tests/qemu-iotests/071 | 20 | +++ b/block/qed.h |
17 | @@ -XXX,XX +XXX,XX @@ echo | 21 | @@ -XXX,XX +XXX,XX @@ typedef struct QEDAIOCB { |
18 | echo "=== Testing blkverify through filename ===" | 22 | |
19 | echo | 23 | /* Current cluster scatter-gather list */ |
20 | 24 | QEMUIOVector cur_qiov; | |
21 | -TEST_IMG="$TEST_IMG.base" IMGOPTS="" IMGFMT="raw" _make_test_img $IMG_SIZE |\ | 25 | - QEMUIOVector *backing_qiov; |
22 | +TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\ | 26 | uint64_t cur_pos; /* position on block device, in bytes */ |
23 | _filter_imgfmt | 27 | uint64_t cur_cluster; /* cluster offset in image file */ |
24 | _make_test_img $IMG_SIZE | 28 | unsigned int cur_nclusters; /* number of clusters being accessed */ |
25 | $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \ | 29 | diff --git a/block/qed.c b/block/qed.c |
26 | @@ -XXX,XX +XXX,XX @@ echo | 30 | index XXXXXXX..XXXXXXX 100644 |
27 | echo "=== Testing blkverify through file blockref ===" | 31 | --- a/block/qed.c |
28 | echo | 32 | +++ b/block/qed.c |
29 | 33 | @@ -XXX,XX +XXX,XX @@ static BDRVQEDState *acb_to_s(QEDAIOCB *acb) | |
30 | -TEST_IMG="$TEST_IMG.base" IMGOPTS="" IMGFMT="raw" _make_test_img $IMG_SIZE |\ | 34 | * @s: QED state |
31 | +TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\ | 35 | * @pos: Byte position in device |
32 | _filter_imgfmt | 36 | * @qiov: Destination I/O vector |
33 | _make_test_img $IMG_SIZE | 37 | - * @backing_qiov: Possibly shortened copy of qiov, to be allocated here |
34 | $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" \ | 38 | - * @cb: Completion function |
35 | diff --git a/tests/qemu-iotests/174 b/tests/qemu-iotests/174 | 39 | - * @opaque: User data for completion function |
36 | index XXXXXXX..XXXXXXX 100755 | 40 | * |
37 | --- a/tests/qemu-iotests/174 | 41 | * This function reads qiov->size bytes starting at pos from the backing file. |
38 | +++ b/tests/qemu-iotests/174 | 42 | * If there is no backing file then zeroes are read. |
39 | @@ -XXX,XX +XXX,XX @@ _unsupported_fmt raw | 43 | */ |
40 | 44 | static int coroutine_fn qed_read_backing_file(BDRVQEDState *s, uint64_t pos, | |
41 | 45 | - QEMUIOVector *qiov, | |
42 | size=256K | 46 | - QEMUIOVector **backing_qiov) |
43 | -IMGFMT=raw IMGKEYSECRET= IMGOPTS= _make_test_img $size | _filter_imgfmt | 47 | + QEMUIOVector *qiov) |
44 | +IMGFMT=raw IMGKEYSECRET= _make_test_img --no-opts $size | _filter_imgfmt | 48 | { |
45 | 49 | - uint64_t backing_length = 0; | |
46 | echo | 50 | - size_t size; |
47 | echo "== reading wrong format should fail ==" | 51 | - int ret; |
48 | diff --git a/tests/qemu-iotests/178 b/tests/qemu-iotests/178 | 52 | - |
49 | index XXXXXXX..XXXXXXX 100755 | 53 | - /* If there is a backing file, get its length. Treat the absence of a |
50 | --- a/tests/qemu-iotests/178 | 54 | - * backing file like a zero length backing file. |
51 | +++ b/tests/qemu-iotests/178 | 55 | - */ |
52 | @@ -XXX,XX +XXX,XX @@ $QEMU_IMG measure -O foo "$TEST_IMG" # unknown image file format | 56 | if (s->bs->backing) { |
53 | 57 | - int64_t l = bdrv_getlength(s->bs->backing->bs); | |
54 | make_test_img_with_fmt() { | 58 | - if (l < 0) { |
55 | # Shadow global variables within this function | 59 | - return l; |
56 | - local IMGFMT="$1" IMGOPTS="" | 60 | - } |
57 | - _make_test_img "$2" | 61 | - backing_length = l; |
58 | + local IMGFMT="$1" | 62 | - } |
59 | + _make_test_img --no-opts "$2" | 63 | - |
64 | - /* Zero all sectors if reading beyond the end of the backing file */ | ||
65 | - if (pos >= backing_length || | ||
66 | - pos + qiov->size > backing_length) { | ||
67 | - qemu_iovec_memset(qiov, 0, 0, qiov->size); | ||
68 | - } | ||
69 | - | ||
70 | - /* Complete now if there are no backing file sectors to read */ | ||
71 | - if (pos >= backing_length) { | ||
72 | - return 0; | ||
73 | - } | ||
74 | - | ||
75 | - /* If the read straddles the end of the backing file, shorten it */ | ||
76 | - size = MIN((uint64_t)backing_length - pos, qiov->size); | ||
77 | - | ||
78 | - assert(*backing_qiov == NULL); | ||
79 | - *backing_qiov = g_new(QEMUIOVector, 1); | ||
80 | - qemu_iovec_init(*backing_qiov, qiov->niov); | ||
81 | - qemu_iovec_concat(*backing_qiov, qiov, 0, size); | ||
82 | - | ||
83 | - BLKDBG_EVENT(s->bs->file, BLKDBG_READ_BACKING_AIO); | ||
84 | - ret = bdrv_co_preadv(s->bs->backing, pos, size, *backing_qiov, 0); | ||
85 | - if (ret < 0) { | ||
86 | - return ret; | ||
87 | + BLKDBG_EVENT(s->bs->file, BLKDBG_READ_BACKING_AIO); | ||
88 | + return bdrv_co_preadv(s->bs->backing, pos, qiov->size, qiov, 0); | ||
89 | } | ||
90 | + qemu_iovec_memset(qiov, 0, 0, qiov->size); | ||
91 | return 0; | ||
60 | } | 92 | } |
61 | 93 | ||
62 | qemu_io_with_fmt() { | 94 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qed_copy_from_backing_file(BDRVQEDState *s, |
63 | diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197 | 95 | uint64_t offset) |
64 | index XXXXXXX..XXXXXXX 100755 | 96 | { |
65 | --- a/tests/qemu-iotests/197 | 97 | QEMUIOVector qiov; |
66 | +++ b/tests/qemu-iotests/197 | 98 | - QEMUIOVector *backing_qiov = NULL; |
67 | @@ -XXX,XX +XXX,XX @@ if [ "$IMGFMT" = "vpc" ]; then | 99 | int ret; |
68 | fi | 100 | |
69 | _make_test_img 4G | 101 | /* Skip copy entirely if there is no work to do */ |
70 | $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io | 102 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qed_copy_from_backing_file(BDRVQEDState *s, |
71 | -IMGPROTO=file IMGFMT=qcow2 IMGOPTS= TEST_IMG_FILE="$TEST_WRAP" \ | 103 | |
72 | - _make_test_img -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create | 104 | qemu_iovec_init_buf(&qiov, qemu_blockalign(s->bs, len), len); |
73 | +IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \ | 105 | |
74 | + _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create | 106 | - ret = qed_read_backing_file(s, pos, &qiov, &backing_qiov); |
75 | $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io | 107 | - |
76 | 108 | - if (backing_qiov) { | |
77 | # Ensure that a read of two clusters, but where one is already allocated, | 109 | - qemu_iovec_destroy(backing_qiov); |
78 | diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215 | 110 | - g_free(backing_qiov); |
79 | index XXXXXXX..XXXXXXX 100755 | 111 | - backing_qiov = NULL; |
80 | --- a/tests/qemu-iotests/215 | 112 | - } |
81 | +++ b/tests/qemu-iotests/215 | 113 | + ret = qed_read_backing_file(s, pos, &qiov); |
82 | @@ -XXX,XX +XXX,XX @@ if [ "$IMGFMT" = "vpc" ]; then | 114 | |
83 | fi | 115 | if (ret) { |
84 | _make_test_img 4G | 116 | goto out; |
85 | $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io | 117 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qed_aio_read_data(void *opaque, int ret, |
86 | -IMGPROTO=file IMGFMT=qcow2 IMGOPTS= TEST_IMG_FILE="$TEST_WRAP" \ | 118 | qemu_iovec_memset(&acb->cur_qiov, 0, 0, acb->cur_qiov.size); |
87 | - _make_test_img -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create | 119 | r = 0; |
88 | +IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \ | 120 | } else if (ret != QED_CLUSTER_FOUND) { |
89 | + _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create | 121 | - r = qed_read_backing_file(s, acb->cur_pos, &acb->cur_qiov, |
90 | $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io | 122 | - &acb->backing_qiov); |
91 | 123 | + r = qed_read_backing_file(s, acb->cur_pos, &acb->cur_qiov); | |
92 | # Ensure that a read of two clusters, but where one is already allocated, | 124 | } else { |
125 | BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); | ||
126 | r = bdrv_co_preadv(bs->file, offset, acb->cur_qiov.size, | ||
127 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qed_aio_next_io(QEDAIOCB *acb) | ||
128 | while (1) { | ||
129 | trace_qed_aio_next_io(s, acb, 0, acb->cur_pos + acb->cur_qiov.size); | ||
130 | |||
131 | - if (acb->backing_qiov) { | ||
132 | - qemu_iovec_destroy(acb->backing_qiov); | ||
133 | - g_free(acb->backing_qiov); | ||
134 | - acb->backing_qiov = NULL; | ||
135 | - } | ||
136 | - | ||
137 | acb->qiov_offset += acb->cur_qiov.size; | ||
138 | acb->cur_pos += acb->cur_qiov.size; | ||
139 | qemu_iovec_reset(&acb->cur_qiov); | ||
93 | -- | 140 | -- |
94 | 2.24.1 | 141 | 2.26.2 |
95 | 142 | ||
96 | 143 | diff view generated by jsdifflib |