1 | The following changes since commit f17783e706ab9c7b3a2b69cf48e4f0ba40664f54: | 1 | The following changes since commit 03a3a62fbd0aa5227e978eef3c67d3978aec9e5f: |
---|---|---|---|
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 tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-09-07 10:29:06 -0400) |
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://gitlab.com/stefanha/qemu.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 503ca1262bab2c11c533a4816d1ff4297d4f58a6: | 9 | for you to fetch changes up to 631c872614aca91eaf947c1748f0f27f99635d92: |
10 | 10 | ||
11 | backup-top: Begin drain earlier (2020-01-06 14:26:23 +0100) | 11 | tests/qtest: Introduce tests for UFS (2023-09-07 14:01:29 -0400) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches: | 14 | Pull request |
15 | - Minor fixes and tests from the freeze period (too minor to be included | 15 | |
16 | in 4.2) | 16 | - Jeuk Kim's emulated UFS device |
17 | - Allow many bash iotests to test qcow2's external data file feature | 17 | - Fabiano Rosas' IOThread GSource "name" debugging aid |
18 | - Add compress filter driver | ||
19 | - Fix Python iotests after 6f6e1698a6 | ||
20 | - Fix for the backup job | ||
21 | 18 | ||
22 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
23 | Andrey Shinkevich (3): | ||
24 | block: introduce compress filter driver | ||
25 | qcow2: Allow writing compressed data of multiple clusters | ||
26 | tests/qemu-iotests: add case to write compressed data of multiple | ||
27 | clusters | ||
28 | 20 | ||
29 | Max Reitz (28): | 21 | Fabiano Rosas (1): |
30 | block: Add bdrv_qapi_perm_to_blk_perm() | 22 | iothread: Set the GSource "name" field |
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 | 23 | ||
59 | PanNengyuan (1): | 24 | Jeuk Kim (4): |
60 | throttle-groups: fix memory leak in throttle_group_set_limit: | 25 | hw/ufs: Initial commit for emulated Universal-Flash-Storage |
26 | hw/ufs: Support for Query Transfer Requests | ||
27 | hw/ufs: Support for UFS logical unit | ||
28 | tests/qtest: Introduce tests for UFS | ||
61 | 29 | ||
62 | Philippe Mathieu-Daudé (1): | 30 | MAINTAINERS | 7 + |
63 | tests/qemu-iotests: Update tests to recent desugarized -accel option | 31 | docs/specs/pci-ids.rst | 2 + |
64 | 32 | meson.build | 1 + | |
65 | Vladimir Sementsov-Ogievskiy (1): | 33 | hw/ufs/trace.h | 1 + |
66 | qcow2-bitmaps: fix qcow2_can_store_new_dirty_bitmap | 34 | hw/ufs/ufs.h | 131 ++++ |
67 | 35 | include/block/ufs.h | 1090 +++++++++++++++++++++++++++ | |
68 | block.c | 47 +++++---- | 36 | include/hw/pci/pci.h | 1 + |
69 | block/Makefile.objs | 1 + | 37 | include/hw/pci/pci_ids.h | 1 + |
70 | block/backup-top.c | 4 +- | 38 | include/scsi/constants.h | 1 + |
71 | block/blkdebug.c | 93 ++++++++++++++++- | 39 | hw/ufs/lu.c | 1445 ++++++++++++++++++++++++++++++++++++ |
72 | block/filter-compress.c | 168 +++++++++++++++++++++++++++++++ | 40 | hw/ufs/ufs.c | 1502 ++++++++++++++++++++++++++++++++++++++ |
73 | block/qcow2-bitmap.c | 41 ++++---- | 41 | iothread.c | 14 +- |
74 | block/qcow2.c | 102 ++++++++++++++----- | 42 | tests/qtest/ufs-test.c | 587 +++++++++++++++ |
75 | block/throttle-groups.c | 4 +- | 43 | hw/Kconfig | 1 + |
76 | include/block/block.h | 1 + | 44 | hw/meson.build | 1 + |
77 | qapi/block-core.json | 24 ++++- | 45 | hw/ufs/Kconfig | 4 + |
78 | tests/qemu-iotests/007 | 5 +- | 46 | hw/ufs/meson.build | 1 + |
79 | tests/qemu-iotests/014 | 2 + | 47 | hw/ufs/trace-events | 58 ++ |
80 | tests/qemu-iotests/015 | 5 +- | 48 | tests/qtest/meson.build | 1 + |
81 | tests/qemu-iotests/019 | 6 +- | 49 | 19 files changed, 4843 insertions(+), 6 deletions(-) |
82 | tests/qemu-iotests/020 | 6 +- | 50 | create mode 100644 hw/ufs/trace.h |
83 | tests/qemu-iotests/024 | 10 +- | 51 | create mode 100644 hw/ufs/ufs.h |
84 | tests/qemu-iotests/026 | 5 +- | 52 | create mode 100644 include/block/ufs.h |
85 | tests/qemu-iotests/028 | 2 +- | 53 | create mode 100644 hw/ufs/lu.c |
86 | tests/qemu-iotests/029 | 7 +- | 54 | create mode 100644 hw/ufs/ufs.c |
87 | tests/qemu-iotests/031 | 9 +- | 55 | create mode 100644 tests/qtest/ufs-test.c |
88 | tests/qemu-iotests/031.out | 36 +++---- | 56 | create mode 100644 hw/ufs/Kconfig |
89 | tests/qemu-iotests/036 | 15 +-- | 57 | create mode 100644 hw/ufs/meson.build |
90 | tests/qemu-iotests/036.out | 66 ++---------- | 58 | create mode 100644 hw/ufs/trace-events |
91 | tests/qemu-iotests/039 | 27 ++--- | ||
92 | tests/qemu-iotests/039.out | 22 ++-- | ||
93 | tests/qemu-iotests/041 | 44 ++++++++ | ||
94 | tests/qemu-iotests/041.out | 4 +- | ||
95 | tests/qemu-iotests/043 | 4 +- | ||
96 | tests/qemu-iotests/046 | 2 + | ||
97 | tests/qemu-iotests/048 | 4 +- | ||
98 | tests/qemu-iotests/050 | 8 +- | ||
99 | tests/qemu-iotests/051 | 7 +- | ||
100 | tests/qemu-iotests/053 | 4 +- | ||
101 | tests/qemu-iotests/058 | 7 +- | ||
102 | tests/qemu-iotests/059 | 20 ++-- | ||
103 | tests/qemu-iotests/060 | 14 +-- | ||
104 | tests/qemu-iotests/060.out | 20 ++-- | ||
105 | tests/qemu-iotests/061 | 63 ++++++------ | ||
106 | tests/qemu-iotests/061.out | 72 ++++++------- | ||
107 | tests/qemu-iotests/062 | 5 +- | ||
108 | tests/qemu-iotests/063 | 18 ++-- | ||
109 | tests/qemu-iotests/063.out | 3 +- | ||
110 | tests/qemu-iotests/066 | 7 +- | ||
111 | tests/qemu-iotests/067 | 6 +- | ||
112 | tests/qemu-iotests/068 | 6 +- | ||
113 | tests/qemu-iotests/069 | 2 +- | ||
114 | tests/qemu-iotests/071 | 7 +- | ||
115 | tests/qemu-iotests/073 | 4 + | ||
116 | tests/qemu-iotests/074 | 4 +- | ||
117 | tests/qemu-iotests/079 | 3 +- | ||
118 | tests/qemu-iotests/080 | 7 +- | ||
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 +- | ||
173 | tests/qemu-iotests/200 | 7 +- | ||
174 | tests/qemu-iotests/201 | 6 +- | ||
175 | tests/qemu-iotests/214 | 46 ++++++++- | ||
176 | tests/qemu-iotests/214.out | 14 +++ | ||
177 | tests/qemu-iotests/215 | 6 +- | ||
178 | tests/qemu-iotests/217 | 3 +- | ||
179 | tests/qemu-iotests/220 | 5 +- | ||
180 | tests/qemu-iotests/225 | 2 +- | ||
181 | tests/qemu-iotests/229 | 3 +- | ||
182 | tests/qemu-iotests/232 | 4 +- | ||
183 | tests/qemu-iotests/235 | 2 +- | ||
184 | tests/qemu-iotests/243 | 10 +- | ||
185 | tests/qemu-iotests/244 | 15 +-- | ||
186 | tests/qemu-iotests/247 | 4 +- | ||
187 | tests/qemu-iotests/249 | 4 +- | ||
188 | tests/qemu-iotests/250 | 5 +- | ||
189 | tests/qemu-iotests/252 | 2 +- | ||
190 | tests/qemu-iotests/261 | 5 +- | ||
191 | tests/qemu-iotests/265 | 2 +- | ||
192 | tests/qemu-iotests/267 | 17 ++-- | ||
193 | tests/qemu-iotests/273 | 3 + | ||
194 | tests/qemu-iotests/check | 6 +- | ||
195 | tests/qemu-iotests/common.filter | 47 ++++++++- | ||
196 | tests/qemu-iotests/common.rc | 63 ++++++++++-- | ||
197 | tests/qemu-iotests/iotests.py | 18 ++-- | ||
198 | tests/qemu-iotests/qcow2.py | 23 ++++- | ||
199 | 131 files changed, 1139 insertions(+), 552 deletions(-) | ||
200 | create mode 100644 block/filter-compress.c | ||
201 | 59 | ||
202 | -- | 60 | -- |
203 | 2.24.1 | 61 | 2.41.0 |
204 | |||
205 | diff view generated by jsdifflib |
1 | We need some way to correlate QAPI BlockPermission values with | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | BLK_PERM_* flags. We could: | ||
3 | 2 | ||
4 | (1) have the same order in the QAPI definition as the the BLK_PERM_* | 3 | Having a name in the source helps with debugging core dumps when one |
5 | flags are in LSb-first order. However, then there is no guarantee | 4 | might not have access to TLS data to cross-reference AioContexts with |
6 | that they actually match (e.g. when someone modifies the QAPI schema | 5 | their addresses. |
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 | 6 | ||
11 | (2) define the BLK_PERM_* flags based on the BlockPermission values. | 7 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
12 | But this way whenever someone were to modify the QAPI order | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
13 | (perfectly sensible in theory), the BLK_PERM_* values would change. | 9 | Message-id: 20230905180359.14083-1-farosas@suse.de |
14 | Because these values are used for file locking, this might break | 10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
15 | file locking between different qemu versions. | 11 | --- |
12 | iothread.c | 14 ++++++++------ | ||
13 | 1 file changed, 8 insertions(+), 6 deletions(-) | ||
16 | 14 | ||
17 | Therefore, go the slightly more cumbersome way: Add a function to | 15 | diff --git a/iothread.c b/iothread.c |
18 | translate from the QAPI constants to the BLK_PERM_* flags. | ||
19 | |||
20 | Signed-off-by: Max Reitz <mreitz@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> | ||
24 | --- | ||
25 | block.c | 18 ++++++++++++++++++ | ||
26 | include/block/block.h | 1 + | ||
27 | 2 files changed, 19 insertions(+) | ||
28 | |||
29 | diff --git a/block.c b/block.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/block.c | 17 | --- a/iothread.c |
32 | +++ b/block.c | 18 | +++ b/iothread.c |
33 | @@ -XXX,XX +XXX,XX @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, | 19 | @@ -XXX,XX +XXX,XX @@ static void iothread_instance_finalize(Object *obj) |
34 | *nshared = shared; | 20 | qemu_sem_destroy(&iothread->init_done_sem); |
35 | } | 21 | } |
36 | 22 | ||
37 | +uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm) | 23 | -static void iothread_init_gcontext(IOThread *iothread) |
38 | +{ | 24 | +static void iothread_init_gcontext(IOThread *iothread, const char *thread_name) |
39 | + static const uint64_t permissions[] = { | 25 | { |
40 | + [BLOCK_PERMISSION_CONSISTENT_READ] = BLK_PERM_CONSISTENT_READ, | 26 | GSource *source; |
41 | + [BLOCK_PERMISSION_WRITE] = BLK_PERM_WRITE, | 27 | + g_autofree char *name = g_strdup_printf("%s aio-context", thread_name); |
42 | + [BLOCK_PERMISSION_WRITE_UNCHANGED] = BLK_PERM_WRITE_UNCHANGED, | 28 | |
43 | + [BLOCK_PERMISSION_RESIZE] = BLK_PERM_RESIZE, | 29 | iothread->worker_context = g_main_context_new(); |
44 | + [BLOCK_PERMISSION_GRAPH_MOD] = BLK_PERM_GRAPH_MOD, | 30 | source = aio_get_g_source(iothread_get_aio_context(iothread)); |
45 | + }; | 31 | + g_source_set_name(source, name); |
32 | g_source_attach(source, iothread->worker_context); | ||
33 | g_source_unref(source); | ||
34 | iothread->main_loop = g_main_loop_new(iothread->worker_context, TRUE); | ||
35 | @@ -XXX,XX +XXX,XX @@ static void iothread_init(EventLoopBase *base, Error **errp) | ||
36 | { | ||
37 | Error *local_error = NULL; | ||
38 | IOThread *iothread = IOTHREAD(base); | ||
39 | - char *thread_name; | ||
40 | + g_autofree char *thread_name = NULL; | ||
41 | |||
42 | iothread->stopping = false; | ||
43 | iothread->running = true; | ||
44 | @@ -XXX,XX +XXX,XX @@ static void iothread_init(EventLoopBase *base, Error **errp) | ||
45 | return; | ||
46 | } | ||
47 | |||
48 | + thread_name = g_strdup_printf("IO %s", | ||
49 | + object_get_canonical_path_component(OBJECT(base))); | ||
46 | + | 50 | + |
47 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(permissions) != BLOCK_PERMISSION__MAX); | 51 | /* |
48 | + QEMU_BUILD_BUG_ON(1UL << ARRAY_SIZE(permissions) != BLK_PERM_ALL + 1); | 52 | * Init one GMainContext for the iothread unconditionally, even if |
49 | + | 53 | * it's not used |
50 | + assert(qapi_perm < BLOCK_PERMISSION__MAX); | 54 | */ |
51 | + | 55 | - iothread_init_gcontext(iothread); |
52 | + return permissions[qapi_perm]; | 56 | + iothread_init_gcontext(iothread, thread_name); |
53 | +} | 57 | |
54 | + | 58 | iothread_set_aio_context_params(base, &local_error); |
55 | static void bdrv_replace_child_noperm(BdrvChild *child, | 59 | if (local_error) { |
56 | BlockDriverState *new_bs) | 60 | @@ -XXX,XX +XXX,XX @@ static void iothread_init(EventLoopBase *base, Error **errp) |
57 | { | 61 | /* This assumes we are called from a thread with useful CPU affinity for us |
58 | diff --git a/include/block/block.h b/include/block/block.h | 62 | * to inherit. |
59 | index XXXXXXX..XXXXXXX 100644 | 63 | */ |
60 | --- a/include/block/block.h | 64 | - thread_name = g_strdup_printf("IO %s", |
61 | +++ b/include/block/block.h | 65 | - object_get_canonical_path_component(OBJECT(base))); |
62 | @@ -XXX,XX +XXX,XX @@ enum { | 66 | qemu_thread_create(&iothread->thread, thread_name, iothread_run, |
63 | }; | 67 | iothread, QEMU_THREAD_JOINABLE); |
64 | 68 | - g_free(thread_name); | |
65 | char *bdrv_perm_names(uint64_t perm); | 69 | |
66 | +uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm); | 70 | /* Wait for initialization to complete */ |
67 | 71 | while (iothread->thread_id == -1) { | |
68 | /* disk I/O throttling */ | ||
69 | void bdrv_init(void); | ||
70 | -- | 72 | -- |
71 | 2.24.1 | 73 | 2.41.0 |
72 | 74 | ||
73 | 75 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We can save some LoC in xdbg_graph_add_edge() by using | ||
2 | bdrv_qapi_perm_to_blk_perm(). | ||
3 | 1 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
5 | Message-id: 20191108123455.39445-3-mreitz@redhat.com | ||
6 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
8 | --- | ||
9 | block.c | 29 ++++++++--------------------- | ||
10 | 1 file changed, 8 insertions(+), 21 deletions(-) | ||
11 | |||
12 | diff --git a/block.c b/block.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/block.c | ||
15 | +++ b/block.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void xdbg_graph_add_node(XDbgBlockGraphConstructor *gr, void *node, | ||
17 | static void xdbg_graph_add_edge(XDbgBlockGraphConstructor *gr, void *parent, | ||
18 | const BdrvChild *child) | ||
19 | { | ||
20 | - typedef struct { | ||
21 | - unsigned int flag; | ||
22 | - BlockPermission num; | ||
23 | - } PermissionMap; | ||
24 | - | ||
25 | - static const PermissionMap permissions[] = { | ||
26 | - { BLK_PERM_CONSISTENT_READ, BLOCK_PERMISSION_CONSISTENT_READ }, | ||
27 | - { BLK_PERM_WRITE, BLOCK_PERMISSION_WRITE }, | ||
28 | - { BLK_PERM_WRITE_UNCHANGED, BLOCK_PERMISSION_WRITE_UNCHANGED }, | ||
29 | - { BLK_PERM_RESIZE, BLOCK_PERMISSION_RESIZE }, | ||
30 | - { BLK_PERM_GRAPH_MOD, BLOCK_PERMISSION_GRAPH_MOD }, | ||
31 | - { 0, 0 } | ||
32 | - }; | ||
33 | - const PermissionMap *p; | ||
34 | + BlockPermission qapi_perm; | ||
35 | XDbgBlockGraphEdge *edge; | ||
36 | |||
37 | - QEMU_BUILD_BUG_ON(1UL << (ARRAY_SIZE(permissions) - 1) != BLK_PERM_ALL + 1); | ||
38 | - | ||
39 | edge = g_new0(XDbgBlockGraphEdge, 1); | ||
40 | |||
41 | edge->parent = xdbg_graph_node_num(gr, parent); | ||
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 | + | ||
51 | + if (flag & child->perm) { | ||
52 | + QAPI_LIST_ADD(edge->perm, qapi_perm); | ||
53 | } | ||
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 | } | ||
59 | } | ||
60 | |||
61 | -- | ||
62 | 2.24.1 | ||
63 | |||
64 | diff view generated by jsdifflib |
1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | 1 | From: Jeuk Kim <jeuk20.kim@samsung.com> |
---|---|---|---|
2 | 2 | ||
3 | Allow writing all the data compressed through the filter driver. | 3 | Universal Flash Storage (UFS) is a high-performance mass storage device |
4 | The written data will be aligned by the cluster size. | 4 | with a serial interface. It is primarily used as a high-performance |
5 | Based on the QEMU current implementation, that data can be written to | 5 | data storage device for embedded applications. |
6 | unallocated clusters only. May be used for a backup job. | ||
7 | 6 | ||
8 | Suggested-by: Max Reitz <mreitz@redhat.com> | 7 | This commit contains code for UFS device to be recognized |
9 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | 8 | as a UFS PCI device. |
10 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 9 | Patches to handle UFS logical unit and Transfer Request will follow. |
11 | Message-id: 1575288906-551879-2-git-send-email-andrey.shinkevich@virtuozzo.com | 10 | |
12 | [mreitz: Replace NULL bdrv_get_format_name() by "(no format)"] | 11 | Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com> |
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 12 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
13 | Message-id: 10232660d462ee5cd10cf673f1a9a1205fc8276c.1693980783.git.jeuk20.kim@gmail.com | ||
14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
14 | --- | 15 | --- |
15 | block/Makefile.objs | 1 + | 16 | MAINTAINERS | 6 + |
16 | block/filter-compress.c | 168 ++++++++++++++++++++++++++++++++++++++++ | 17 | docs/specs/pci-ids.rst | 2 + |
17 | qapi/block-core.json | 10 ++- | 18 | meson.build | 1 + |
18 | 3 files changed, 175 insertions(+), 4 deletions(-) | 19 | hw/ufs/trace.h | 1 + |
19 | create mode 100644 block/filter-compress.c | 20 | hw/ufs/ufs.h | 42 ++ |
21 | include/block/ufs.h | 1090 ++++++++++++++++++++++++++++++++++++++ | ||
22 | include/hw/pci/pci.h | 1 + | ||
23 | include/hw/pci/pci_ids.h | 1 + | ||
24 | hw/ufs/ufs.c | 278 ++++++++++ | ||
25 | hw/Kconfig | 1 + | ||
26 | hw/meson.build | 1 + | ||
27 | hw/ufs/Kconfig | 4 + | ||
28 | hw/ufs/meson.build | 1 + | ||
29 | hw/ufs/trace-events | 32 ++ | ||
30 | 14 files changed, 1461 insertions(+) | ||
31 | create mode 100644 hw/ufs/trace.h | ||
32 | create mode 100644 hw/ufs/ufs.h | ||
33 | create mode 100644 include/block/ufs.h | ||
34 | create mode 100644 hw/ufs/ufs.c | ||
35 | create mode 100644 hw/ufs/Kconfig | ||
36 | create mode 100644 hw/ufs/meson.build | ||
37 | create mode 100644 hw/ufs/trace-events | ||
20 | 38 | ||
21 | diff --git a/block/Makefile.objs b/block/Makefile.objs | 39 | diff --git a/MAINTAINERS b/MAINTAINERS |
22 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/block/Makefile.objs | 41 | --- a/MAINTAINERS |
24 | +++ b/block/Makefile.objs | 42 | +++ b/MAINTAINERS |
25 | @@ -XXX,XX +XXX,XX @@ block-obj-y += crypto.o | 43 | @@ -XXX,XX +XXX,XX @@ F: tests/qtest/nvme-test.c |
26 | 44 | F: docs/system/devices/nvme.rst | |
27 | block-obj-y += aio_task.o | 45 | T: git git://git.infradead.org/qemu-nvme.git nvme-next |
28 | block-obj-y += backup-top.o | 46 | |
29 | +block-obj-y += filter-compress.o | 47 | +ufs |
30 | 48 | +M: Jeuk Kim <jeuk20.kim@samsung.com> | |
31 | common-obj-y += stream.o | 49 | +S: Supported |
32 | 50 | +F: hw/ufs/* | |
33 | diff --git a/block/filter-compress.c b/block/filter-compress.c | 51 | +F: include/block/ufs.h |
52 | + | ||
53 | megasas | ||
54 | M: Hannes Reinecke <hare@suse.com> | ||
55 | L: qemu-block@nongnu.org | ||
56 | diff --git a/docs/specs/pci-ids.rst b/docs/specs/pci-ids.rst | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/docs/specs/pci-ids.rst | ||
59 | +++ b/docs/specs/pci-ids.rst | ||
60 | @@ -XXX,XX +XXX,XX @@ PCI devices (other than virtio): | ||
61 | PCI PVPanic device (``-device pvpanic-pci``) | ||
62 | 1b36:0012 | ||
63 | PCI ACPI ERST device (``-device acpi-erst``) | ||
64 | +1b36:0013 | ||
65 | + PCI UFS device (``-device ufs``) | ||
66 | |||
67 | All these devices are documented in :doc:`index`. | ||
68 | |||
69 | diff --git a/meson.build b/meson.build | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/meson.build | ||
72 | +++ b/meson.build | ||
73 | @@ -XXX,XX +XXX,XX @@ if have_system | ||
74 | 'hw/ssi', | ||
75 | 'hw/timer', | ||
76 | 'hw/tpm', | ||
77 | + 'hw/ufs', | ||
78 | 'hw/usb', | ||
79 | 'hw/vfio', | ||
80 | 'hw/virtio', | ||
81 | diff --git a/hw/ufs/trace.h b/hw/ufs/trace.h | ||
34 | new file mode 100644 | 82 | new file mode 100644 |
35 | index XXXXXXX..XXXXXXX | 83 | index XXXXXXX..XXXXXXX |
36 | --- /dev/null | 84 | --- /dev/null |
37 | +++ b/block/filter-compress.c | 85 | +++ b/hw/ufs/trace.h |
86 | @@ -0,0 +1 @@ | ||
87 | +#include "trace/trace-hw_ufs.h" | ||
88 | diff --git a/hw/ufs/ufs.h b/hw/ufs/ufs.h | ||
89 | new file mode 100644 | ||
90 | index XXXXXXX..XXXXXXX | ||
91 | --- /dev/null | ||
92 | +++ b/hw/ufs/ufs.h | ||
38 | @@ -XXX,XX +XXX,XX @@ | 93 | @@ -XXX,XX +XXX,XX @@ |
39 | +/* | 94 | +/* |
40 | + * Compress filter block driver | 95 | + * QEMU UFS |
41 | + * | 96 | + * |
42 | + * Copyright (c) 2019 Virtuozzo International GmbH | 97 | + * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved. |
43 | + * | 98 | + * |
44 | + * Author: | 99 | + * Written by Jeuk Kim <jeuk20.kim@samsung.com> |
45 | + * Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | ||
46 | + * (based on block/copy-on-read.c by Max Reitz) | ||
47 | + * | 100 | + * |
48 | + * This program is free software; you can redistribute it and/or | 101 | + * SPDX-License-Identifier: GPL-2.0-or-later |
49 | + * modify it under the terms of the GNU General Public License as | 102 | + */ |
50 | + * published by the Free Software Foundation; either version 2 or | 103 | + |
51 | + * (at your option) any later version of the License. | 104 | +#ifndef HW_UFS_UFS_H |
105 | +#define HW_UFS_UFS_H | ||
106 | + | ||
107 | +#include "hw/pci/pci_device.h" | ||
108 | +#include "hw/scsi/scsi.h" | ||
109 | +#include "block/ufs.h" | ||
110 | + | ||
111 | +#define UFS_MAX_LUS 32 | ||
112 | +#define UFS_BLOCK_SIZE 4096 | ||
113 | + | ||
114 | +typedef struct UfsParams { | ||
115 | + char *serial; | ||
116 | + uint8_t nutrs; /* Number of UTP Transfer Request Slots */ | ||
117 | + uint8_t nutmrs; /* Number of UTP Task Management Request Slots */ | ||
118 | +} UfsParams; | ||
119 | + | ||
120 | +typedef struct UfsHc { | ||
121 | + PCIDevice parent_obj; | ||
122 | + MemoryRegion iomem; | ||
123 | + UfsReg reg; | ||
124 | + UfsParams params; | ||
125 | + uint32_t reg_size; | ||
126 | + | ||
127 | + qemu_irq irq; | ||
128 | + QEMUBH *doorbell_bh; | ||
129 | + QEMUBH *complete_bh; | ||
130 | +} UfsHc; | ||
131 | + | ||
132 | +#define TYPE_UFS "ufs" | ||
133 | +#define UFS(obj) OBJECT_CHECK(UfsHc, (obj), TYPE_UFS) | ||
134 | + | ||
135 | +#endif /* HW_UFS_UFS_H */ | ||
136 | diff --git a/include/block/ufs.h b/include/block/ufs.h | ||
137 | new file mode 100644 | ||
138 | index XXXXXXX..XXXXXXX | ||
139 | --- /dev/null | ||
140 | +++ b/include/block/ufs.h | ||
141 | @@ -XXX,XX +XXX,XX @@ | ||
142 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
143 | + | ||
144 | +#ifndef BLOCK_UFS_H | ||
145 | +#define BLOCK_UFS_H | ||
146 | + | ||
147 | +#include "hw/registerfields.h" | ||
148 | + | ||
149 | +typedef struct QEMU_PACKED UfsReg { | ||
150 | + uint32_t cap; | ||
151 | + uint32_t rsvd0; | ||
152 | + uint32_t ver; | ||
153 | + uint32_t rsvd1; | ||
154 | + uint32_t hcpid; | ||
155 | + uint32_t hcmid; | ||
156 | + uint32_t ahit; | ||
157 | + uint32_t rsvd2; | ||
158 | + uint32_t is; | ||
159 | + uint32_t ie; | ||
160 | + uint32_t rsvd3[2]; | ||
161 | + uint32_t hcs; | ||
162 | + uint32_t hce; | ||
163 | + uint32_t uecpa; | ||
164 | + uint32_t uecdl; | ||
165 | + uint32_t uecn; | ||
166 | + uint32_t uect; | ||
167 | + uint32_t uecdme; | ||
168 | + uint32_t utriacr; | ||
169 | + uint32_t utrlba; | ||
170 | + uint32_t utrlbau; | ||
171 | + uint32_t utrldbr; | ||
172 | + uint32_t utrlclr; | ||
173 | + uint32_t utrlrsr; | ||
174 | + uint32_t utrlcnr; | ||
175 | + uint32_t rsvd4[2]; | ||
176 | + uint32_t utmrlba; | ||
177 | + uint32_t utmrlbau; | ||
178 | + uint32_t utmrldbr; | ||
179 | + uint32_t utmrlclr; | ||
180 | + uint32_t utmrlrsr; | ||
181 | + uint32_t rsvd5[3]; | ||
182 | + uint32_t uiccmd; | ||
183 | + uint32_t ucmdarg1; | ||
184 | + uint32_t ucmdarg2; | ||
185 | + uint32_t ucmdarg3; | ||
186 | + uint32_t rsvd6[4]; | ||
187 | + uint32_t rsvd7[4]; | ||
188 | + uint32_t rsvd8[16]; | ||
189 | + uint32_t ccap; | ||
190 | +} UfsReg; | ||
191 | + | ||
192 | +REG32(CAP, offsetof(UfsReg, cap)) | ||
193 | + FIELD(CAP, NUTRS, 0, 5) | ||
194 | + FIELD(CAP, RTT, 8, 8) | ||
195 | + FIELD(CAP, NUTMRS, 16, 3) | ||
196 | + FIELD(CAP, AUTOH8, 23, 1) | ||
197 | + FIELD(CAP, 64AS, 24, 1) | ||
198 | + FIELD(CAP, OODDS, 25, 1) | ||
199 | + FIELD(CAP, UICDMETMS, 26, 1) | ||
200 | + FIELD(CAP, CS, 28, 1) | ||
201 | +REG32(VER, offsetof(UfsReg, ver)) | ||
202 | +REG32(HCPID, offsetof(UfsReg, hcpid)) | ||
203 | +REG32(HCMID, offsetof(UfsReg, hcmid)) | ||
204 | +REG32(AHIT, offsetof(UfsReg, ahit)) | ||
205 | +REG32(IS, offsetof(UfsReg, is)) | ||
206 | + FIELD(IS, UTRCS, 0, 1) | ||
207 | + FIELD(IS, UDEPRI, 1, 1) | ||
208 | + FIELD(IS, UE, 2, 1) | ||
209 | + FIELD(IS, UTMS, 3, 1) | ||
210 | + FIELD(IS, UPMS, 4, 1) | ||
211 | + FIELD(IS, UHXS, 5, 1) | ||
212 | + FIELD(IS, UHES, 6, 1) | ||
213 | + FIELD(IS, ULLS, 7, 1) | ||
214 | + FIELD(IS, ULSS, 8, 1) | ||
215 | + FIELD(IS, UTMRCS, 9, 1) | ||
216 | + FIELD(IS, UCCS, 10, 1) | ||
217 | + FIELD(IS, DFES, 11, 1) | ||
218 | + FIELD(IS, UTPES, 12, 1) | ||
219 | + FIELD(IS, HCFES, 16, 1) | ||
220 | + FIELD(IS, SBFES, 17, 1) | ||
221 | + FIELD(IS, CEFES, 18, 1) | ||
222 | +REG32(IE, offsetof(UfsReg, ie)) | ||
223 | + FIELD(IE, UTRCE, 0, 1) | ||
224 | + FIELD(IE, UDEPRIE, 1, 1) | ||
225 | + FIELD(IE, UEE, 2, 1) | ||
226 | + FIELD(IE, UTMSE, 3, 1) | ||
227 | + FIELD(IE, UPMSE, 4, 1) | ||
228 | + FIELD(IE, UHXSE, 5, 1) | ||
229 | + FIELD(IE, UHESE, 6, 1) | ||
230 | + FIELD(IE, ULLSE, 7, 1) | ||
231 | + FIELD(IE, ULSSE, 8, 1) | ||
232 | + FIELD(IE, UTMRCE, 9, 1) | ||
233 | + FIELD(IE, UCCE, 10, 1) | ||
234 | + FIELD(IE, DFEE, 11, 1) | ||
235 | + FIELD(IE, UTPEE, 12, 1) | ||
236 | + FIELD(IE, HCFEE, 16, 1) | ||
237 | + FIELD(IE, SBFEE, 17, 1) | ||
238 | + FIELD(IE, CEFEE, 18, 1) | ||
239 | +REG32(HCS, offsetof(UfsReg, hcs)) | ||
240 | + FIELD(HCS, DP, 0, 1) | ||
241 | + FIELD(HCS, UTRLRDY, 1, 1) | ||
242 | + FIELD(HCS, UTMRLRDY, 2, 1) | ||
243 | + FIELD(HCS, UCRDY, 3, 1) | ||
244 | + FIELD(HCS, UPMCRS, 8, 3) | ||
245 | +REG32(HCE, offsetof(UfsReg, hce)) | ||
246 | + FIELD(HCE, HCE, 0, 1) | ||
247 | + FIELD(HCE, CGE, 1, 1) | ||
248 | +REG32(UECPA, offsetof(UfsReg, uecpa)) | ||
249 | +REG32(UECDL, offsetof(UfsReg, uecdl)) | ||
250 | +REG32(UECN, offsetof(UfsReg, uecn)) | ||
251 | +REG32(UECT, offsetof(UfsReg, uect)) | ||
252 | +REG32(UECDME, offsetof(UfsReg, uecdme)) | ||
253 | +REG32(UTRIACR, offsetof(UfsReg, utriacr)) | ||
254 | +REG32(UTRLBA, offsetof(UfsReg, utrlba)) | ||
255 | + FIELD(UTRLBA, UTRLBA, 9, 22) | ||
256 | +REG32(UTRLBAU, offsetof(UfsReg, utrlbau)) | ||
257 | +REG32(UTRLDBR, offsetof(UfsReg, utrldbr)) | ||
258 | +REG32(UTRLCLR, offsetof(UfsReg, utrlclr)) | ||
259 | +REG32(UTRLRSR, offsetof(UfsReg, utrlrsr)) | ||
260 | +REG32(UTRLCNR, offsetof(UfsReg, utrlcnr)) | ||
261 | +REG32(UTMRLBA, offsetof(UfsReg, utmrlba)) | ||
262 | + FIELD(UTMRLBA, UTMRLBA, 9, 22) | ||
263 | +REG32(UTMRLBAU, offsetof(UfsReg, utmrlbau)) | ||
264 | +REG32(UTMRLDBR, offsetof(UfsReg, utmrldbr)) | ||
265 | +REG32(UTMRLCLR, offsetof(UfsReg, utmrlclr)) | ||
266 | +REG32(UTMRLRSR, offsetof(UfsReg, utmrlrsr)) | ||
267 | +REG32(UICCMD, offsetof(UfsReg, uiccmd)) | ||
268 | +REG32(UCMDARG1, offsetof(UfsReg, ucmdarg1)) | ||
269 | +REG32(UCMDARG2, offsetof(UfsReg, ucmdarg2)) | ||
270 | +REG32(UCMDARG3, offsetof(UfsReg, ucmdarg3)) | ||
271 | +REG32(CCAP, offsetof(UfsReg, ccap)) | ||
272 | + | ||
273 | +#define UFS_INTR_MASK \ | ||
274 | + ((1 << R_IS_CEFES_SHIFT) | (1 << R_IS_SBFES_SHIFT) | \ | ||
275 | + (1 << R_IS_HCFES_SHIFT) | (1 << R_IS_UTPES_SHIFT) | \ | ||
276 | + (1 << R_IS_DFES_SHIFT) | (1 << R_IS_UCCS_SHIFT) | \ | ||
277 | + (1 << R_IS_UTMRCS_SHIFT) | (1 << R_IS_ULSS_SHIFT) | \ | ||
278 | + (1 << R_IS_ULLS_SHIFT) | (1 << R_IS_UHES_SHIFT) | \ | ||
279 | + (1 << R_IS_UHXS_SHIFT) | (1 << R_IS_UPMS_SHIFT) | \ | ||
280 | + (1 << R_IS_UTMS_SHIFT) | (1 << R_IS_UE_SHIFT) | \ | ||
281 | + (1 << R_IS_UDEPRI_SHIFT) | (1 << R_IS_UTRCS_SHIFT)) | ||
282 | + | ||
283 | +#define UFS_UPIU_HEADER_TRANSACTION_TYPE_SHIFT 24 | ||
284 | +#define UFS_UPIU_HEADER_TRANSACTION_TYPE_MASK 0xff | ||
285 | +#define UFS_UPIU_HEADER_TRANSACTION_TYPE(dword0) \ | ||
286 | + ((be32_to_cpu(dword0) >> UFS_UPIU_HEADER_TRANSACTION_TYPE_SHIFT) & \ | ||
287 | + UFS_UPIU_HEADER_TRANSACTION_TYPE_MASK) | ||
288 | + | ||
289 | +#define UFS_UPIU_HEADER_QUERY_FUNC_SHIFT 16 | ||
290 | +#define UFS_UPIU_HEADER_QUERY_FUNC_MASK 0xff | ||
291 | +#define UFS_UPIU_HEADER_QUERY_FUNC(dword1) \ | ||
292 | + ((be32_to_cpu(dword1) >> UFS_UPIU_HEADER_QUERY_FUNC_SHIFT) & \ | ||
293 | + UFS_UPIU_HEADER_QUERY_FUNC_MASK) | ||
294 | + | ||
295 | +#define UFS_UPIU_HEADER_DATA_SEGMENT_LENGTH_SHIFT 0 | ||
296 | +#define UFS_UPIU_HEADER_DATA_SEGMENT_LENGTH_MASK 0xffff | ||
297 | +#define UFS_UPIU_HEADER_DATA_SEGMENT_LENGTH(dword2) \ | ||
298 | + ((be32_to_cpu(dword2) >> UFS_UPIU_HEADER_DATA_SEGMENT_LENGTH_SHIFT) & \ | ||
299 | + UFS_UPIU_HEADER_DATA_SEGMENT_LENGTH_MASK) | ||
300 | + | ||
301 | +typedef struct QEMU_PACKED DeviceDescriptor { | ||
302 | + uint8_t length; | ||
303 | + uint8_t descriptor_idn; | ||
304 | + uint8_t device; | ||
305 | + uint8_t device_class; | ||
306 | + uint8_t device_sub_class; | ||
307 | + uint8_t protocol; | ||
308 | + uint8_t number_lu; | ||
309 | + uint8_t number_wlu; | ||
310 | + uint8_t boot_enable; | ||
311 | + uint8_t descr_access_en; | ||
312 | + uint8_t init_power_mode; | ||
313 | + uint8_t high_priority_lun; | ||
314 | + uint8_t secure_removal_type; | ||
315 | + uint8_t security_lu; | ||
316 | + uint8_t background_ops_term_lat; | ||
317 | + uint8_t init_active_icc_level; | ||
318 | + uint16_t spec_version; | ||
319 | + uint16_t manufacture_date; | ||
320 | + uint8_t manufacturer_name; | ||
321 | + uint8_t product_name; | ||
322 | + uint8_t serial_number; | ||
323 | + uint8_t oem_id; | ||
324 | + uint16_t manufacturer_id; | ||
325 | + uint8_t ud_0_base_offset; | ||
326 | + uint8_t ud_config_p_length; | ||
327 | + uint8_t device_rtt_cap; | ||
328 | + uint16_t periodic_rtc_update; | ||
329 | + uint8_t ufs_features_support; | ||
330 | + uint8_t ffu_timeout; | ||
331 | + uint8_t queue_depth; | ||
332 | + uint16_t device_version; | ||
333 | + uint8_t num_secure_wp_area; | ||
334 | + uint32_t psa_max_data_size; | ||
335 | + uint8_t psa_state_timeout; | ||
336 | + uint8_t product_revision_level; | ||
337 | + uint8_t reserved[36]; | ||
338 | + uint32_t extended_ufs_features_support; | ||
339 | + uint8_t write_booster_buffer_preserve_user_space_en; | ||
340 | + uint8_t write_booster_buffer_type; | ||
341 | + uint32_t num_shared_write_booster_buffer_alloc_units; | ||
342 | +} DeviceDescriptor; | ||
343 | + | ||
344 | +typedef struct QEMU_PACKED GeometryDescriptor { | ||
345 | + uint8_t length; | ||
346 | + uint8_t descriptor_idn; | ||
347 | + uint8_t media_technology; | ||
348 | + uint8_t reserved; | ||
349 | + uint64_t total_raw_device_capacity; | ||
350 | + uint8_t max_number_lu; | ||
351 | + uint32_t segment_size; | ||
352 | + uint8_t allocation_unit_size; | ||
353 | + uint8_t min_addr_block_size; | ||
354 | + uint8_t optimal_read_block_size; | ||
355 | + uint8_t optimal_write_block_size; | ||
356 | + uint8_t max_in_buffer_size; | ||
357 | + uint8_t max_out_buffer_size; | ||
358 | + uint8_t rpmb_read_write_size; | ||
359 | + uint8_t dynamic_capacity_resource_policy; | ||
360 | + uint8_t data_ordering; | ||
361 | + uint8_t max_context_id_number; | ||
362 | + uint8_t sys_data_tag_unit_size; | ||
363 | + uint8_t sys_data_tag_res_size; | ||
364 | + uint8_t supported_sec_r_types; | ||
365 | + uint16_t supported_memory_types; | ||
366 | + uint32_t system_code_max_n_alloc_u; | ||
367 | + uint16_t system_code_cap_adj_fac; | ||
368 | + uint32_t non_persist_max_n_alloc_u; | ||
369 | + uint16_t non_persist_cap_adj_fac; | ||
370 | + uint32_t enhanced_1_max_n_alloc_u; | ||
371 | + uint16_t enhanced_1_cap_adj_fac; | ||
372 | + uint32_t enhanced_2_max_n_alloc_u; | ||
373 | + uint16_t enhanced_2_cap_adj_fac; | ||
374 | + uint32_t enhanced_3_max_n_alloc_u; | ||
375 | + uint16_t enhanced_3_cap_adj_fac; | ||
376 | + uint32_t enhanced_4_max_n_alloc_u; | ||
377 | + uint16_t enhanced_4_cap_adj_fac; | ||
378 | + uint32_t optimal_logical_block_size; | ||
379 | + uint8_t reserved2[7]; | ||
380 | + uint32_t write_booster_buffer_max_n_alloc_units; | ||
381 | + uint8_t device_max_write_booster_l_us; | ||
382 | + uint8_t write_booster_buffer_cap_adj_fac; | ||
383 | + uint8_t supported_write_booster_buffer_user_space_reduction_types; | ||
384 | + uint8_t supported_write_booster_buffer_types; | ||
385 | +} GeometryDescriptor; | ||
386 | + | ||
387 | +#define UFS_GEOMETRY_CAPACITY_SHIFT 9 | ||
388 | + | ||
389 | +typedef struct QEMU_PACKED UnitDescriptor { | ||
390 | + uint8_t length; | ||
391 | + uint8_t descriptor_idn; | ||
392 | + uint8_t unit_index; | ||
393 | + uint8_t lu_enable; | ||
394 | + uint8_t boot_lun_id; | ||
395 | + uint8_t lu_write_protect; | ||
396 | + uint8_t lu_queue_depth; | ||
397 | + uint8_t psa_sensitive; | ||
398 | + uint8_t memory_type; | ||
399 | + uint8_t data_reliability; | ||
400 | + uint8_t logical_block_size; | ||
401 | + uint64_t logical_block_count; | ||
402 | + uint32_t erase_block_size; | ||
403 | + uint8_t provisioning_type; | ||
404 | + uint64_t phy_mem_resource_count; | ||
405 | + uint16_t context_capabilities; | ||
406 | + uint8_t large_unit_granularity_m1; | ||
407 | + uint8_t reserved[6]; | ||
408 | + uint32_t lu_num_write_booster_buffer_alloc_units; | ||
409 | +} UnitDescriptor; | ||
410 | + | ||
411 | +typedef struct QEMU_PACKED RpmbUnitDescriptor { | ||
412 | + uint8_t length; | ||
413 | + uint8_t descriptor_idn; | ||
414 | + uint8_t unit_index; | ||
415 | + uint8_t lu_enable; | ||
416 | + uint8_t boot_lun_id; | ||
417 | + uint8_t lu_write_protect; | ||
418 | + uint8_t lu_queue_depth; | ||
419 | + uint8_t psa_sensitive; | ||
420 | + uint8_t memory_type; | ||
421 | + uint8_t reserved; | ||
422 | + uint8_t logical_block_size; | ||
423 | + uint64_t logical_block_count; | ||
424 | + uint32_t erase_block_size; | ||
425 | + uint8_t provisioning_type; | ||
426 | + uint64_t phy_mem_resource_count; | ||
427 | + uint8_t reserved2[3]; | ||
428 | +} RpmbUnitDescriptor; | ||
429 | + | ||
430 | +typedef struct QEMU_PACKED PowerParametersDescriptor { | ||
431 | + uint8_t length; | ||
432 | + uint8_t descriptor_idn; | ||
433 | + uint16_t active_icc_levels_vcc[16]; | ||
434 | + uint16_t active_icc_levels_vccq[16]; | ||
435 | + uint16_t active_icc_levels_vccq_2[16]; | ||
436 | +} PowerParametersDescriptor; | ||
437 | + | ||
438 | +typedef struct QEMU_PACKED InterconnectDescriptor { | ||
439 | + uint8_t length; | ||
440 | + uint8_t descriptor_idn; | ||
441 | + uint16_t bcd_unipro_version; | ||
442 | + uint16_t bcd_mphy_version; | ||
443 | +} InterconnectDescriptor; | ||
444 | + | ||
445 | +typedef struct QEMU_PACKED StringDescriptor { | ||
446 | + uint8_t length; | ||
447 | + uint8_t descriptor_idn; | ||
448 | + uint16_t UC[126]; | ||
449 | +} StringDescriptor; | ||
450 | + | ||
451 | +typedef struct QEMU_PACKED DeviceHealthDescriptor { | ||
452 | + uint8_t length; | ||
453 | + uint8_t descriptor_idn; | ||
454 | + uint8_t pre_eol_info; | ||
455 | + uint8_t device_life_time_est_a; | ||
456 | + uint8_t device_life_time_est_b; | ||
457 | + uint8_t vendor_prop_info[32]; | ||
458 | + uint32_t refresh_total_count; | ||
459 | + uint32_t refresh_progress; | ||
460 | +} DeviceHealthDescriptor; | ||
461 | + | ||
462 | +typedef struct QEMU_PACKED Flags { | ||
463 | + uint8_t reserved; | ||
464 | + uint8_t device_init; | ||
465 | + uint8_t permanent_wp_en; | ||
466 | + uint8_t power_on_wp_en; | ||
467 | + uint8_t background_ops_en; | ||
468 | + uint8_t device_life_span_mode_en; | ||
469 | + uint8_t purge_enable; | ||
470 | + uint8_t refresh_enable; | ||
471 | + uint8_t phy_resource_removal; | ||
472 | + uint8_t busy_rtc; | ||
473 | + uint8_t reserved2; | ||
474 | + uint8_t permanently_disable_fw_update; | ||
475 | + uint8_t reserved3[2]; | ||
476 | + uint8_t wb_en; | ||
477 | + uint8_t wb_buffer_flush_en; | ||
478 | + uint8_t wb_buffer_flush_during_hibernate; | ||
479 | + uint8_t reserved4[2]; | ||
480 | +} Flags; | ||
481 | + | ||
482 | +typedef struct Attributes { | ||
483 | + uint8_t boot_lun_en; | ||
484 | + uint8_t reserved; | ||
485 | + uint8_t current_power_mode; | ||
486 | + uint8_t active_icc_level; | ||
487 | + uint8_t out_of_order_data_en; | ||
488 | + uint8_t background_op_status; | ||
489 | + uint8_t purge_status; | ||
490 | + uint8_t max_data_in_size; | ||
491 | + uint8_t max_data_out_size; | ||
492 | + uint32_t dyn_cap_needed; | ||
493 | + uint8_t ref_clk_freq; | ||
494 | + uint8_t config_descr_lock; | ||
495 | + uint8_t max_num_of_rtt; | ||
496 | + uint16_t exception_event_control; | ||
497 | + uint16_t exception_event_status; | ||
498 | + uint32_t seconds_passed; | ||
499 | + uint16_t context_conf; | ||
500 | + uint8_t device_ffu_status; | ||
501 | + uint8_t psa_state; | ||
502 | + uint32_t psa_data_size; | ||
503 | + uint8_t ref_clk_gating_wait_time; | ||
504 | + uint8_t device_case_rough_temperaure; | ||
505 | + uint8_t device_too_high_temp_boundary; | ||
506 | + uint8_t device_too_low_temp_boundary; | ||
507 | + uint8_t throttling_status; | ||
508 | + uint8_t wb_buffer_flush_status; | ||
509 | + uint8_t available_wb_buffer_size; | ||
510 | + uint8_t wb_buffer_life_time_est; | ||
511 | + uint32_t current_wb_buffer_size; | ||
512 | + uint8_t refresh_status; | ||
513 | + uint8_t refresh_freq; | ||
514 | + uint8_t refresh_unit; | ||
515 | + uint8_t refresh_method; | ||
516 | +} Attributes; | ||
517 | + | ||
518 | +#define UFS_TRANSACTION_SPECIFIC_FIELD_SIZE 20 | ||
519 | +#define UFS_MAX_QUERY_DATA_SIZE 256 | ||
520 | + | ||
521 | +/* Command response result code */ | ||
522 | +typedef enum CommandRespCode { | ||
523 | + UFS_COMMAND_RESULT_SUCESS = 0x00, | ||
524 | + UFS_COMMAND_RESULT_FAIL = 0x01, | ||
525 | +} CommandRespCode; | ||
526 | + | ||
527 | +enum { | ||
528 | + UFS_UPIU_FLAG_UNDERFLOW = 0x20, | ||
529 | + UFS_UPIU_FLAG_OVERFLOW = 0x40, | ||
530 | +}; | ||
531 | + | ||
532 | +typedef struct QEMU_PACKED UtpUpiuHeader { | ||
533 | + uint8_t trans_type; | ||
534 | + uint8_t flags; | ||
535 | + uint8_t lun; | ||
536 | + uint8_t task_tag; | ||
537 | + uint8_t iid_cmd_set_type; | ||
538 | + uint8_t query_func; | ||
539 | + uint8_t response; | ||
540 | + uint8_t scsi_status; | ||
541 | + uint8_t ehs_len; | ||
542 | + uint8_t device_inf; | ||
543 | + uint16_t data_segment_length; | ||
544 | +} UtpUpiuHeader; | ||
545 | + | ||
546 | +/* | ||
547 | + * The code below is copied from the linux kernel | ||
548 | + * ("include/uapi/scsi/scsi_bsg_ufs.h") and modified to fit the qemu style. | ||
549 | + */ | ||
550 | + | ||
551 | +typedef struct QEMU_PACKED UtpUpiuQuery { | ||
552 | + uint8_t opcode; | ||
553 | + uint8_t idn; | ||
554 | + uint8_t index; | ||
555 | + uint8_t selector; | ||
556 | + uint16_t reserved_osf; | ||
557 | + uint16_t length; | ||
558 | + uint32_t value; | ||
559 | + uint32_t reserved[2]; | ||
560 | + /* EHS length should be 0. We don't have to worry about EHS area. */ | ||
561 | + uint8_t data[UFS_MAX_QUERY_DATA_SIZE]; | ||
562 | +} UtpUpiuQuery; | ||
563 | + | ||
564 | +#define UFS_CDB_SIZE 16 | ||
565 | + | ||
566 | +/* | ||
567 | + * struct UtpUpiuCmd - Command UPIU structure | ||
568 | + * @data_transfer_len: Data Transfer Length DW-3 | ||
569 | + * @cdb: Command Descriptor Block CDB DW-4 to DW-7 | ||
570 | + */ | ||
571 | +typedef struct QEMU_PACKED UtpUpiuCmd { | ||
572 | + uint32_t exp_data_transfer_len; | ||
573 | + uint8_t cdb[UFS_CDB_SIZE]; | ||
574 | +} UtpUpiuCmd; | ||
575 | + | ||
576 | +/* | ||
577 | + * struct UtpUpiuReq - general upiu request structure | ||
578 | + * @header:UPIU header structure DW-0 to DW-2 | ||
579 | + * @sc: fields structure for scsi command DW-3 to DW-7 | ||
580 | + * @qr: fields structure for query request DW-3 to DW-7 | ||
581 | + * @uc: use utp_upiu_query to host the 4 dwords of uic command | ||
582 | + */ | ||
583 | +typedef struct QEMU_PACKED UtpUpiuReq { | ||
584 | + UtpUpiuHeader header; | ||
585 | + union { | ||
586 | + UtpUpiuCmd sc; | ||
587 | + UtpUpiuQuery qr; | ||
588 | + }; | ||
589 | +} UtpUpiuReq; | ||
590 | + | ||
591 | +/* | ||
592 | + * The code below is copied from the linux kernel ("include/ufs/ufshci.h") and | ||
593 | + * modified to fit the qemu style. | ||
594 | + */ | ||
595 | + | ||
596 | +enum { | ||
597 | + UFS_PWR_OK = 0x0, | ||
598 | + UFS_PWR_LOCAL = 0x01, | ||
599 | + UFS_PWR_REMOTE = 0x02, | ||
600 | + UFS_PWR_BUSY = 0x03, | ||
601 | + UFS_PWR_ERROR_CAP = 0x04, | ||
602 | + UFS_PWR_FATAL_ERROR = 0x05, | ||
603 | +}; | ||
604 | + | ||
605 | +/* UIC Commands */ | ||
606 | +enum uic_cmd_dme { | ||
607 | + UFS_UIC_CMD_DME_GET = 0x01, | ||
608 | + UFS_UIC_CMD_DME_SET = 0x02, | ||
609 | + UFS_UIC_CMD_DME_PEER_GET = 0x03, | ||
610 | + UFS_UIC_CMD_DME_PEER_SET = 0x04, | ||
611 | + UFS_UIC_CMD_DME_POWERON = 0x10, | ||
612 | + UFS_UIC_CMD_DME_POWEROFF = 0x11, | ||
613 | + UFS_UIC_CMD_DME_ENABLE = 0x12, | ||
614 | + UFS_UIC_CMD_DME_RESET = 0x14, | ||
615 | + UFS_UIC_CMD_DME_END_PT_RST = 0x15, | ||
616 | + UFS_UIC_CMD_DME_LINK_STARTUP = 0x16, | ||
617 | + UFS_UIC_CMD_DME_HIBER_ENTER = 0x17, | ||
618 | + UFS_UIC_CMD_DME_HIBER_EXIT = 0x18, | ||
619 | + UFS_UIC_CMD_DME_TEST_MODE = 0x1A, | ||
620 | +}; | ||
621 | + | ||
622 | +/* UIC Config result code / Generic error code */ | ||
623 | +enum { | ||
624 | + UFS_UIC_CMD_RESULT_SUCCESS = 0x00, | ||
625 | + UFS_UIC_CMD_RESULT_INVALID_ATTR = 0x01, | ||
626 | + UFS_UIC_CMD_RESULT_FAILURE = 0x01, | ||
627 | + UFS_UIC_CMD_RESULT_INVALID_ATTR_VALUE = 0x02, | ||
628 | + UFS_UIC_CMD_RESULT_READ_ONLY_ATTR = 0x03, | ||
629 | + UFS_UIC_CMD_RESULT_WRITE_ONLY_ATTR = 0x04, | ||
630 | + UFS_UIC_CMD_RESULT_BAD_INDEX = 0x05, | ||
631 | + UFS_UIC_CMD_RESULT_LOCKED_ATTR = 0x06, | ||
632 | + UFS_UIC_CMD_RESULT_BAD_TEST_FEATURE_INDEX = 0x07, | ||
633 | + UFS_UIC_CMD_RESULT_PEER_COMM_FAILURE = 0x08, | ||
634 | + UFS_UIC_CMD_RESULT_BUSY = 0x09, | ||
635 | + UFS_UIC_CMD_RESULT_DME_FAILURE = 0x0A, | ||
636 | +}; | ||
637 | + | ||
638 | +#define UFS_MASK_UIC_COMMAND_RESULT 0xFF | ||
639 | + | ||
640 | +/* | ||
641 | + * Request Descriptor Definitions | ||
642 | + */ | ||
643 | + | ||
644 | +/* Transfer request command type */ | ||
645 | +enum { | ||
646 | + UFS_UTP_CMD_TYPE_SCSI = 0x0, | ||
647 | + UFS_UTP_CMD_TYPE_UFS = 0x1, | ||
648 | + UFS_UTP_CMD_TYPE_DEV_MANAGE = 0x2, | ||
649 | +}; | ||
650 | + | ||
651 | +/* To accommodate UFS2.0 required Command type */ | ||
652 | +enum { | ||
653 | + UFS_UTP_CMD_TYPE_UFS_STORAGE = 0x1, | ||
654 | +}; | ||
655 | + | ||
656 | +enum { | ||
657 | + UFS_UTP_SCSI_COMMAND = 0x00000000, | ||
658 | + UFS_UTP_NATIVE_UFS_COMMAND = 0x10000000, | ||
659 | + UFS_UTP_DEVICE_MANAGEMENT_FUNCTION = 0x20000000, | ||
660 | + UFS_UTP_REQ_DESC_INT_CMD = 0x01000000, | ||
661 | + UFS_UTP_REQ_DESC_CRYPTO_ENABLE_CMD = 0x00800000, | ||
662 | +}; | ||
663 | + | ||
664 | +/* UTP Transfer Request Data Direction (DD) */ | ||
665 | +enum { | ||
666 | + UFS_UTP_NO_DATA_TRANSFER = 0x00000000, | ||
667 | + UFS_UTP_HOST_TO_DEVICE = 0x02000000, | ||
668 | + UFS_UTP_DEVICE_TO_HOST = 0x04000000, | ||
669 | +}; | ||
670 | + | ||
671 | +/* Overall command status values */ | ||
672 | +enum UtpOcsCodes { | ||
673 | + UFS_OCS_SUCCESS = 0x0, | ||
674 | + UFS_OCS_INVALID_CMD_TABLE_ATTR = 0x1, | ||
675 | + UFS_OCS_INVALID_PRDT_ATTR = 0x2, | ||
676 | + UFS_OCS_MISMATCH_DATA_BUF_SIZE = 0x3, | ||
677 | + UFS_OCS_MISMATCH_RESP_UPIU_SIZE = 0x4, | ||
678 | + UFS_OCS_PEER_COMM_FAILURE = 0x5, | ||
679 | + UFS_OCS_ABORTED = 0x6, | ||
680 | + UFS_OCS_FATAL_ERROR = 0x7, | ||
681 | + UFS_OCS_DEVICE_FATAL_ERROR = 0x8, | ||
682 | + UFS_OCS_INVALID_CRYPTO_CONFIG = 0x9, | ||
683 | + UFS_OCS_GENERAL_CRYPTO_ERROR = 0xa, | ||
684 | + UFS_OCS_INVALID_COMMAND_STATUS = 0xf, | ||
685 | +}; | ||
686 | + | ||
687 | +enum { | ||
688 | + UFS_MASK_OCS = 0x0F, | ||
689 | +}; | ||
690 | + | ||
691 | +/* | ||
692 | + * struct UfshcdSgEntry - UFSHCI PRD Entry | ||
693 | + * @addr: Physical address; DW-0 and DW-1. | ||
694 | + * @reserved: Reserved for future use DW-2 | ||
695 | + * @size: size of physical segment DW-3 | ||
696 | + */ | ||
697 | +typedef struct QEMU_PACKED UfshcdSgEntry { | ||
698 | + uint64_t addr; | ||
699 | + uint32_t reserved; | ||
700 | + uint32_t size; | ||
701 | + /* | ||
702 | + * followed by variant-specific fields if | ||
703 | + * CONFIG_SCSI_UFS_VARIABLE_SG_ENTRY_SIZE has been defined. | ||
704 | + */ | ||
705 | +} UfshcdSgEntry; | ||
706 | + | ||
707 | +/* | ||
708 | + * struct RequestDescHeader - Descriptor Header common to both UTRD and UTMRD | ||
709 | + * @dword0: Descriptor Header DW0 | ||
710 | + * @dword1: Descriptor Header DW1 | ||
711 | + * @dword2: Descriptor Header DW2 | ||
712 | + * @dword3: Descriptor Header DW3 | ||
713 | + */ | ||
714 | +typedef struct QEMU_PACKED RequestDescHeader { | ||
715 | + uint32_t dword_0; | ||
716 | + uint32_t dword_1; | ||
717 | + uint32_t dword_2; | ||
718 | + uint32_t dword_3; | ||
719 | +} RequestDescHeader; | ||
720 | + | ||
721 | +/* | ||
722 | + * struct UtpTransferReqDesc - UTP Transfer Request Descriptor (UTRD) | ||
723 | + * @header: UTRD header DW-0 to DW-3 | ||
724 | + * @command_desc_base_addr_lo: UCD base address low DW-4 | ||
725 | + * @command_desc_base_addr_hi: UCD base address high DW-5 | ||
726 | + * @response_upiu_length: response UPIU length DW-6 | ||
727 | + * @response_upiu_offset: response UPIU offset DW-6 | ||
728 | + * @prd_table_length: Physical region descriptor length DW-7 | ||
729 | + * @prd_table_offset: Physical region descriptor offset DW-7 | ||
730 | + */ | ||
731 | +typedef struct QEMU_PACKED UtpTransferReqDesc { | ||
732 | + /* DW 0-3 */ | ||
733 | + RequestDescHeader header; | ||
734 | + | ||
735 | + /* DW 4-5*/ | ||
736 | + uint32_t command_desc_base_addr_lo; | ||
737 | + uint32_t command_desc_base_addr_hi; | ||
738 | + | ||
739 | + /* DW 6 */ | ||
740 | + uint16_t response_upiu_length; | ||
741 | + uint16_t response_upiu_offset; | ||
742 | + | ||
743 | + /* DW 7 */ | ||
744 | + uint16_t prd_table_length; | ||
745 | + uint16_t prd_table_offset; | ||
746 | +} UtpTransferReqDesc; | ||
747 | + | ||
748 | +/* | ||
749 | + * UTMRD structure. | ||
750 | + */ | ||
751 | +typedef struct QEMU_PACKED UtpTaskReqDesc { | ||
752 | + /* DW 0-3 */ | ||
753 | + RequestDescHeader header; | ||
754 | + | ||
755 | + /* DW 4-11 - Task request UPIU structure */ | ||
756 | + struct { | ||
757 | + UtpUpiuHeader req_header; | ||
758 | + uint32_t input_param1; | ||
759 | + uint32_t input_param2; | ||
760 | + uint32_t input_param3; | ||
761 | + uint32_t reserved1[2]; | ||
762 | + } upiu_req; | ||
763 | + | ||
764 | + /* DW 12-19 - Task Management Response UPIU structure */ | ||
765 | + struct { | ||
766 | + UtpUpiuHeader rsp_header; | ||
767 | + uint32_t output_param1; | ||
768 | + uint32_t output_param2; | ||
769 | + uint32_t reserved2[3]; | ||
770 | + } upiu_rsp; | ||
771 | +} UtpTaskReqDesc; | ||
772 | + | ||
773 | +/* | ||
774 | + * The code below is copied from the linux kernel ("include/ufs/ufs.h") and | ||
775 | + * modified to fit the qemu style. | ||
776 | + */ | ||
777 | + | ||
778 | +#define UFS_GENERAL_UPIU_REQUEST_SIZE (sizeof(UtpUpiuReq)) | ||
779 | +#define UFS_QUERY_DESC_MAX_SIZE 255 | ||
780 | +#define UFS_QUERY_DESC_MIN_SIZE 2 | ||
781 | +#define UFS_QUERY_DESC_HDR_SIZE 2 | ||
782 | +#define UFS_QUERY_OSF_SIZE (GENERAL_UPIU_REQUEST_SIZE - (sizeof(UtpUpiuHeader))) | ||
783 | +#define UFS_SENSE_SIZE 18 | ||
784 | + | ||
785 | +/* | ||
786 | + * UFS device may have standard LUs and LUN id could be from 0x00 to | ||
787 | + * 0x7F. Standard LUs use "Peripheral Device Addressing Format". | ||
788 | + * UFS device may also have the Well Known LUs (also referred as W-LU) | ||
789 | + * which again could be from 0x00 to 0x7F. For W-LUs, device only use | ||
790 | + * the "Extended Addressing Format" which means the W-LUNs would be | ||
791 | + * from 0xc100 (SCSI_W_LUN_BASE) onwards. | ||
792 | + * This means max. LUN number reported from UFS device could be 0xC17F. | ||
793 | + */ | ||
794 | +#define UFS_UPIU_MAX_UNIT_NUM_ID 0x7F | ||
795 | +#define UFS_UPIU_WLUN_ID (1 << 7) | ||
796 | + | ||
797 | +/* WriteBooster buffer is available only for the logical unit from 0 to 7 */ | ||
798 | +#define UFS_UPIU_MAX_WB_LUN_ID 8 | ||
799 | + | ||
800 | +/* | ||
801 | + * WriteBooster buffer lifetime has a limit setted by vendor. | ||
802 | + * If it is over the limit, WriteBooster feature will be disabled. | ||
803 | + */ | ||
804 | +#define UFS_WB_EXCEED_LIFETIME 0x0B | ||
805 | + | ||
806 | +/* | ||
807 | + * In UFS Spec, the Extra Header Segment (EHS) starts from byte 32 in UPIU | ||
808 | + * request/response packet | ||
809 | + */ | ||
810 | +#define UFS_EHS_OFFSET_IN_RESPONSE 32 | ||
811 | + | ||
812 | +/* Well known logical unit id in LUN field of UPIU */ | ||
813 | +enum { | ||
814 | + UFS_UPIU_REPORT_LUNS_WLUN = 0x81, | ||
815 | + UFS_UPIU_UFS_DEVICE_WLUN = 0xD0, | ||
816 | + UFS_UPIU_BOOT_WLUN = 0xB0, | ||
817 | + UFS_UPIU_RPMB_WLUN = 0xC4, | ||
818 | +}; | ||
819 | + | ||
820 | +/* | ||
821 | + * UFS Protocol Information Unit related definitions | ||
822 | + */ | ||
823 | + | ||
824 | +/* Task management functions */ | ||
825 | +enum { | ||
826 | + UFS_ABORT_TASK = 0x01, | ||
827 | + UFS_ABORT_TASK_SET = 0x02, | ||
828 | + UFS_CLEAR_TASK_SET = 0x04, | ||
829 | + UFS_LOGICAL_RESET = 0x08, | ||
830 | + UFS_QUERY_TASK = 0x80, | ||
831 | + UFS_QUERY_TASK_SET = 0x81, | ||
832 | +}; | ||
833 | + | ||
834 | +/* UTP UPIU Transaction Codes Initiator to Target */ | ||
835 | +enum { | ||
836 | + UFS_UPIU_TRANSACTION_NOP_OUT = 0x00, | ||
837 | + UFS_UPIU_TRANSACTION_COMMAND = 0x01, | ||
838 | + UFS_UPIU_TRANSACTION_DATA_OUT = 0x02, | ||
839 | + UFS_UPIU_TRANSACTION_TASK_REQ = 0x04, | ||
840 | + UFS_UPIU_TRANSACTION_QUERY_REQ = 0x16, | ||
841 | +}; | ||
842 | + | ||
843 | +/* UTP UPIU Transaction Codes Target to Initiator */ | ||
844 | +enum { | ||
845 | + UFS_UPIU_TRANSACTION_NOP_IN = 0x20, | ||
846 | + UFS_UPIU_TRANSACTION_RESPONSE = 0x21, | ||
847 | + UFS_UPIU_TRANSACTION_DATA_IN = 0x22, | ||
848 | + UFS_UPIU_TRANSACTION_TASK_RSP = 0x24, | ||
849 | + UFS_UPIU_TRANSACTION_READY_XFER = 0x31, | ||
850 | + UFS_UPIU_TRANSACTION_QUERY_RSP = 0x36, | ||
851 | + UFS_UPIU_TRANSACTION_REJECT_UPIU = 0x3F, | ||
852 | +}; | ||
853 | + | ||
854 | +/* UPIU Read/Write flags */ | ||
855 | +enum { | ||
856 | + UFS_UPIU_CMD_FLAGS_NONE = 0x00, | ||
857 | + UFS_UPIU_CMD_FLAGS_WRITE = 0x20, | ||
858 | + UFS_UPIU_CMD_FLAGS_READ = 0x40, | ||
859 | +}; | ||
860 | + | ||
861 | +/* UPIU Task Attributes */ | ||
862 | +enum { | ||
863 | + UFS_UPIU_TASK_ATTR_SIMPLE = 0x00, | ||
864 | + UFS_UPIU_TASK_ATTR_ORDERED = 0x01, | ||
865 | + UFS_UPIU_TASK_ATTR_HEADQ = 0x02, | ||
866 | + UFS_UPIU_TASK_ATTR_ACA = 0x03, | ||
867 | +}; | ||
868 | + | ||
869 | +/* UPIU Query request function */ | ||
870 | +enum { | ||
871 | + UFS_UPIU_QUERY_FUNC_STANDARD_READ_REQUEST = 0x01, | ||
872 | + UFS_UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST = 0x81, | ||
873 | +}; | ||
874 | + | ||
875 | +/* Flag idn for Query Requests*/ | ||
876 | +enum flag_idn { | ||
877 | + UFS_QUERY_FLAG_IDN_FDEVICEINIT = 0x01, | ||
878 | + UFS_QUERY_FLAG_IDN_PERMANENT_WPE = 0x02, | ||
879 | + UFS_QUERY_FLAG_IDN_PWR_ON_WPE = 0x03, | ||
880 | + UFS_QUERY_FLAG_IDN_BKOPS_EN = 0x04, | ||
881 | + UFS_QUERY_FLAG_IDN_LIFE_SPAN_MODE_ENABLE = 0x05, | ||
882 | + UFS_QUERY_FLAG_IDN_PURGE_ENABLE = 0x06, | ||
883 | + UFS_QUERY_FLAG_IDN_REFRESH_ENABLE = 0x07, | ||
884 | + UFS_QUERY_FLAG_IDN_FPHYRESOURCEREMOVAL = 0x08, | ||
885 | + UFS_QUERY_FLAG_IDN_BUSY_RTC = 0x09, | ||
886 | + UFS_QUERY_FLAG_IDN_RESERVED3 = 0x0A, | ||
887 | + UFS_QUERY_FLAG_IDN_PERMANENTLY_DISABLE_FW_UPDATE = 0x0B, | ||
888 | + UFS_QUERY_FLAG_IDN_WB_EN = 0x0E, | ||
889 | + UFS_QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN = 0x0F, | ||
890 | + UFS_QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8 = 0x10, | ||
891 | + UFS_QUERY_FLAG_IDN_HPB_RESET = 0x11, | ||
892 | + UFS_QUERY_FLAG_IDN_HPB_EN = 0x12, | ||
893 | + UFS_QUERY_FLAG_IDN_COUNT, | ||
894 | +}; | ||
895 | + | ||
896 | +/* Attribute idn for Query requests */ | ||
897 | +enum attr_idn { | ||
898 | + UFS_QUERY_ATTR_IDN_BOOT_LU_EN = 0x00, | ||
899 | + UFS_QUERY_ATTR_IDN_MAX_HPB_SINGLE_CMD = 0x01, | ||
900 | + UFS_QUERY_ATTR_IDN_POWER_MODE = 0x02, | ||
901 | + UFS_QUERY_ATTR_IDN_ACTIVE_ICC_LVL = 0x03, | ||
902 | + UFS_QUERY_ATTR_IDN_OOO_DATA_EN = 0x04, | ||
903 | + UFS_QUERY_ATTR_IDN_BKOPS_STATUS = 0x05, | ||
904 | + UFS_QUERY_ATTR_IDN_PURGE_STATUS = 0x06, | ||
905 | + UFS_QUERY_ATTR_IDN_MAX_DATA_IN = 0x07, | ||
906 | + UFS_QUERY_ATTR_IDN_MAX_DATA_OUT = 0x08, | ||
907 | + UFS_QUERY_ATTR_IDN_DYN_CAP_NEEDED = 0x09, | ||
908 | + UFS_QUERY_ATTR_IDN_REF_CLK_FREQ = 0x0A, | ||
909 | + UFS_QUERY_ATTR_IDN_CONF_DESC_LOCK = 0x0B, | ||
910 | + UFS_QUERY_ATTR_IDN_MAX_NUM_OF_RTT = 0x0C, | ||
911 | + UFS_QUERY_ATTR_IDN_EE_CONTROL = 0x0D, | ||
912 | + UFS_QUERY_ATTR_IDN_EE_STATUS = 0x0E, | ||
913 | + UFS_QUERY_ATTR_IDN_SECONDS_PASSED = 0x0F, | ||
914 | + UFS_QUERY_ATTR_IDN_CNTX_CONF = 0x10, | ||
915 | + UFS_QUERY_ATTR_IDN_CORR_PRG_BLK_NUM = 0x11, | ||
916 | + UFS_QUERY_ATTR_IDN_RESERVED2 = 0x12, | ||
917 | + UFS_QUERY_ATTR_IDN_RESERVED3 = 0x13, | ||
918 | + UFS_QUERY_ATTR_IDN_FFU_STATUS = 0x14, | ||
919 | + UFS_QUERY_ATTR_IDN_PSA_STATE = 0x15, | ||
920 | + UFS_QUERY_ATTR_IDN_PSA_DATA_SIZE = 0x16, | ||
921 | + UFS_QUERY_ATTR_IDN_REF_CLK_GATING_WAIT_TIME = 0x17, | ||
922 | + UFS_QUERY_ATTR_IDN_CASE_ROUGH_TEMP = 0x18, | ||
923 | + UFS_QUERY_ATTR_IDN_HIGH_TEMP_BOUND = 0x19, | ||
924 | + UFS_QUERY_ATTR_IDN_LOW_TEMP_BOUND = 0x1A, | ||
925 | + UFS_QUERY_ATTR_IDN_THROTTLING_STATUS = 0x1B, | ||
926 | + UFS_QUERY_ATTR_IDN_WB_FLUSH_STATUS = 0x1C, | ||
927 | + UFS_QUERY_ATTR_IDN_AVAIL_WB_BUFF_SIZE = 0x1D, | ||
928 | + UFS_QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST = 0x1E, | ||
929 | + UFS_QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE = 0x1F, | ||
930 | + UFS_QUERY_ATTR_IDN_REFRESH_STATUS = 0x2C, | ||
931 | + UFS_QUERY_ATTR_IDN_REFRESH_FREQ = 0x2D, | ||
932 | + UFS_QUERY_ATTR_IDN_REFRESH_UNIT = 0x2E, | ||
933 | + UFS_QUERY_ATTR_IDN_COUNT, | ||
934 | +}; | ||
935 | + | ||
936 | +/* Descriptor idn for Query requests */ | ||
937 | +enum desc_idn { | ||
938 | + UFS_QUERY_DESC_IDN_DEVICE = 0x0, | ||
939 | + UFS_QUERY_DESC_IDN_CONFIGURATION = 0x1, | ||
940 | + UFS_QUERY_DESC_IDN_UNIT = 0x2, | ||
941 | + UFS_QUERY_DESC_IDN_RFU_0 = 0x3, | ||
942 | + UFS_QUERY_DESC_IDN_INTERCONNECT = 0x4, | ||
943 | + UFS_QUERY_DESC_IDN_STRING = 0x5, | ||
944 | + UFS_QUERY_DESC_IDN_RFU_1 = 0x6, | ||
945 | + UFS_QUERY_DESC_IDN_GEOMETRY = 0x7, | ||
946 | + UFS_QUERY_DESC_IDN_POWER = 0x8, | ||
947 | + UFS_QUERY_DESC_IDN_HEALTH = 0x9, | ||
948 | + UFS_QUERY_DESC_IDN_MAX, | ||
949 | +}; | ||
950 | + | ||
951 | +enum desc_header_offset { | ||
952 | + UFS_QUERY_DESC_LENGTH_OFFSET = 0x00, | ||
953 | + UFS_QUERY_DESC_DESC_TYPE_OFFSET = 0x01, | ||
954 | +}; | ||
955 | + | ||
956 | +/* Unit descriptor parameters offsets in bytes*/ | ||
957 | +enum unit_desc_param { | ||
958 | + UFS_UNIT_DESC_PARAM_LEN = 0x0, | ||
959 | + UFS_UNIT_DESC_PARAM_TYPE = 0x1, | ||
960 | + UFS_UNIT_DESC_PARAM_UNIT_INDEX = 0x2, | ||
961 | + UFS_UNIT_DESC_PARAM_LU_ENABLE = 0x3, | ||
962 | + UFS_UNIT_DESC_PARAM_BOOT_LUN_ID = 0x4, | ||
963 | + UFS_UNIT_DESC_PARAM_LU_WR_PROTECT = 0x5, | ||
964 | + UFS_UNIT_DESC_PARAM_LU_Q_DEPTH = 0x6, | ||
965 | + UFS_UNIT_DESC_PARAM_PSA_SENSITIVE = 0x7, | ||
966 | + UFS_UNIT_DESC_PARAM_MEM_TYPE = 0x8, | ||
967 | + UFS_UNIT_DESC_PARAM_DATA_RELIABILITY = 0x9, | ||
968 | + UFS_UNIT_DESC_PARAM_LOGICAL_BLK_SIZE = 0xA, | ||
969 | + UFS_UNIT_DESC_PARAM_LOGICAL_BLK_COUNT = 0xB, | ||
970 | + UFS_UNIT_DESC_PARAM_ERASE_BLK_SIZE = 0x13, | ||
971 | + UFS_UNIT_DESC_PARAM_PROVISIONING_TYPE = 0x17, | ||
972 | + UFS_UNIT_DESC_PARAM_PHY_MEM_RSRC_CNT = 0x18, | ||
973 | + UFS_UNIT_DESC_PARAM_CTX_CAPABILITIES = 0x20, | ||
974 | + UFS_UNIT_DESC_PARAM_LARGE_UNIT_SIZE_M1 = 0x22, | ||
975 | + UFS_UNIT_DESC_PARAM_HPB_LU_MAX_ACTIVE_RGNS = 0x23, | ||
976 | + UFS_UNIT_DESC_PARAM_HPB_PIN_RGN_START_OFF = 0x25, | ||
977 | + UFS_UNIT_DESC_PARAM_HPB_NUM_PIN_RGNS = 0x27, | ||
978 | + UFS_UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS = 0x29, | ||
979 | +}; | ||
980 | + | ||
981 | +/* RPMB Unit descriptor parameters offsets in bytes*/ | ||
982 | +enum rpmb_unit_desc_param { | ||
983 | + UFS_RPMB_UNIT_DESC_PARAM_LEN = 0x0, | ||
984 | + UFS_RPMB_UNIT_DESC_PARAM_TYPE = 0x1, | ||
985 | + UFS_RPMB_UNIT_DESC_PARAM_UNIT_INDEX = 0x2, | ||
986 | + UFS_RPMB_UNIT_DESC_PARAM_LU_ENABLE = 0x3, | ||
987 | + UFS_RPMB_UNIT_DESC_PARAM_BOOT_LUN_ID = 0x4, | ||
988 | + UFS_RPMB_UNIT_DESC_PARAM_LU_WR_PROTECT = 0x5, | ||
989 | + UFS_RPMB_UNIT_DESC_PARAM_LU_Q_DEPTH = 0x6, | ||
990 | + UFS_RPMB_UNIT_DESC_PARAM_PSA_SENSITIVE = 0x7, | ||
991 | + UFS_RPMB_UNIT_DESC_PARAM_MEM_TYPE = 0x8, | ||
992 | + UFS_RPMB_UNIT_DESC_PARAM_REGION_EN = 0x9, | ||
993 | + UFS_RPMB_UNIT_DESC_PARAM_LOGICAL_BLK_SIZE = 0xA, | ||
994 | + UFS_RPMB_UNIT_DESC_PARAM_LOGICAL_BLK_COUNT = 0xB, | ||
995 | + UFS_RPMB_UNIT_DESC_PARAM_REGION0_SIZE = 0x13, | ||
996 | + UFS_RPMB_UNIT_DESC_PARAM_REGION1_SIZE = 0x14, | ||
997 | + UFS_RPMB_UNIT_DESC_PARAM_REGION2_SIZE = 0x15, | ||
998 | + UFS_RPMB_UNIT_DESC_PARAM_REGION3_SIZE = 0x16, | ||
999 | + UFS_RPMB_UNIT_DESC_PARAM_PROVISIONING_TYPE = 0x17, | ||
1000 | + UFS_RPMB_UNIT_DESC_PARAM_PHY_MEM_RSRC_CNT = 0x18, | ||
1001 | +}; | ||
1002 | + | ||
1003 | +/* Device descriptor parameters offsets in bytes*/ | ||
1004 | +enum device_desc_param { | ||
1005 | + UFS_DEVICE_DESC_PARAM_LEN = 0x0, | ||
1006 | + UFS_DEVICE_DESC_PARAM_TYPE = 0x1, | ||
1007 | + UFS_DEVICE_DESC_PARAM_DEVICE_TYPE = 0x2, | ||
1008 | + UFS_DEVICE_DESC_PARAM_DEVICE_CLASS = 0x3, | ||
1009 | + UFS_DEVICE_DESC_PARAM_DEVICE_SUB_CLASS = 0x4, | ||
1010 | + UFS_DEVICE_DESC_PARAM_PRTCL = 0x5, | ||
1011 | + UFS_DEVICE_DESC_PARAM_NUM_LU = 0x6, | ||
1012 | + UFS_DEVICE_DESC_PARAM_NUM_WLU = 0x7, | ||
1013 | + UFS_DEVICE_DESC_PARAM_BOOT_ENBL = 0x8, | ||
1014 | + UFS_DEVICE_DESC_PARAM_DESC_ACCSS_ENBL = 0x9, | ||
1015 | + UFS_DEVICE_DESC_PARAM_INIT_PWR_MODE = 0xA, | ||
1016 | + UFS_DEVICE_DESC_PARAM_HIGH_PR_LUN = 0xB, | ||
1017 | + UFS_DEVICE_DESC_PARAM_SEC_RMV_TYPE = 0xC, | ||
1018 | + UFS_DEVICE_DESC_PARAM_SEC_LU = 0xD, | ||
1019 | + UFS_DEVICE_DESC_PARAM_BKOP_TERM_LT = 0xE, | ||
1020 | + UFS_DEVICE_DESC_PARAM_ACTVE_ICC_LVL = 0xF, | ||
1021 | + UFS_DEVICE_DESC_PARAM_SPEC_VER = 0x10, | ||
1022 | + UFS_DEVICE_DESC_PARAM_MANF_DATE = 0x12, | ||
1023 | + UFS_DEVICE_DESC_PARAM_MANF_NAME = 0x14, | ||
1024 | + UFS_DEVICE_DESC_PARAM_PRDCT_NAME = 0x15, | ||
1025 | + UFS_DEVICE_DESC_PARAM_SN = 0x16, | ||
1026 | + UFS_DEVICE_DESC_PARAM_OEM_ID = 0x17, | ||
1027 | + UFS_DEVICE_DESC_PARAM_MANF_ID = 0x18, | ||
1028 | + UFS_DEVICE_DESC_PARAM_UD_OFFSET = 0x1A, | ||
1029 | + UFS_DEVICE_DESC_PARAM_UD_LEN = 0x1B, | ||
1030 | + UFS_DEVICE_DESC_PARAM_RTT_CAP = 0x1C, | ||
1031 | + UFS_DEVICE_DESC_PARAM_FRQ_RTC = 0x1D, | ||
1032 | + UFS_DEVICE_DESC_PARAM_UFS_FEAT = 0x1F, | ||
1033 | + UFS_DEVICE_DESC_PARAM_FFU_TMT = 0x20, | ||
1034 | + UFS_DEVICE_DESC_PARAM_Q_DPTH = 0x21, | ||
1035 | + UFS_DEVICE_DESC_PARAM_DEV_VER = 0x22, | ||
1036 | + UFS_DEVICE_DESC_PARAM_NUM_SEC_WPA = 0x24, | ||
1037 | + UFS_DEVICE_DESC_PARAM_PSA_MAX_DATA = 0x25, | ||
1038 | + UFS_DEVICE_DESC_PARAM_PSA_TMT = 0x29, | ||
1039 | + UFS_DEVICE_DESC_PARAM_PRDCT_REV = 0x2A, | ||
1040 | + UFS_DEVICE_DESC_PARAM_HPB_VER = 0x40, | ||
1041 | + UFS_DEVICE_DESC_PARAM_HPB_CONTROL = 0x42, | ||
1042 | + UFS_DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP = 0x4F, | ||
1043 | + UFS_DEVICE_DESC_PARAM_WB_PRESRV_USRSPC_EN = 0x53, | ||
1044 | + UFS_DEVICE_DESC_PARAM_WB_TYPE = 0x54, | ||
1045 | + UFS_DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS = 0x55, | ||
1046 | +}; | ||
1047 | + | ||
1048 | +/* Interconnect descriptor parameters offsets in bytes*/ | ||
1049 | +enum interconnect_desc_param { | ||
1050 | + UFS_INTERCONNECT_DESC_PARAM_LEN = 0x0, | ||
1051 | + UFS_INTERCONNECT_DESC_PARAM_TYPE = 0x1, | ||
1052 | + UFS_INTERCONNECT_DESC_PARAM_UNIPRO_VER = 0x2, | ||
1053 | + UFS_INTERCONNECT_DESC_PARAM_MPHY_VER = 0x4, | ||
1054 | +}; | ||
1055 | + | ||
1056 | +/* Geometry descriptor parameters offsets in bytes*/ | ||
1057 | +enum geometry_desc_param { | ||
1058 | + UFS_GEOMETRY_DESC_PARAM_LEN = 0x0, | ||
1059 | + UFS_GEOMETRY_DESC_PARAM_TYPE = 0x1, | ||
1060 | + UFS_GEOMETRY_DESC_PARAM_DEV_CAP = 0x4, | ||
1061 | + UFS_GEOMETRY_DESC_PARAM_MAX_NUM_LUN = 0xC, | ||
1062 | + UFS_GEOMETRY_DESC_PARAM_SEG_SIZE = 0xD, | ||
1063 | + UFS_GEOMETRY_DESC_PARAM_ALLOC_UNIT_SIZE = 0x11, | ||
1064 | + UFS_GEOMETRY_DESC_PARAM_MIN_BLK_SIZE = 0x12, | ||
1065 | + UFS_GEOMETRY_DESC_PARAM_OPT_RD_BLK_SIZE = 0x13, | ||
1066 | + UFS_GEOMETRY_DESC_PARAM_OPT_WR_BLK_SIZE = 0x14, | ||
1067 | + UFS_GEOMETRY_DESC_PARAM_MAX_IN_BUF_SIZE = 0x15, | ||
1068 | + UFS_GEOMETRY_DESC_PARAM_MAX_OUT_BUF_SIZE = 0x16, | ||
1069 | + UFS_GEOMETRY_DESC_PARAM_RPMB_RW_SIZE = 0x17, | ||
1070 | + UFS_GEOMETRY_DESC_PARAM_DYN_CAP_RSRC_PLC = 0x18, | ||
1071 | + UFS_GEOMETRY_DESC_PARAM_DATA_ORDER = 0x19, | ||
1072 | + UFS_GEOMETRY_DESC_PARAM_MAX_NUM_CTX = 0x1A, | ||
1073 | + UFS_GEOMETRY_DESC_PARAM_TAG_UNIT_SIZE = 0x1B, | ||
1074 | + UFS_GEOMETRY_DESC_PARAM_TAG_RSRC_SIZE = 0x1C, | ||
1075 | + UFS_GEOMETRY_DESC_PARAM_SEC_RM_TYPES = 0x1D, | ||
1076 | + UFS_GEOMETRY_DESC_PARAM_MEM_TYPES = 0x1E, | ||
1077 | + UFS_GEOMETRY_DESC_PARAM_SCM_MAX_NUM_UNITS = 0x20, | ||
1078 | + UFS_GEOMETRY_DESC_PARAM_SCM_CAP_ADJ_FCTR = 0x24, | ||
1079 | + UFS_GEOMETRY_DESC_PARAM_NPM_MAX_NUM_UNITS = 0x26, | ||
1080 | + UFS_GEOMETRY_DESC_PARAM_NPM_CAP_ADJ_FCTR = 0x2A, | ||
1081 | + UFS_GEOMETRY_DESC_PARAM_ENM1_MAX_NUM_UNITS = 0x2C, | ||
1082 | + UFS_GEOMETRY_DESC_PARAM_ENM1_CAP_ADJ_FCTR = 0x30, | ||
1083 | + UFS_GEOMETRY_DESC_PARAM_ENM2_MAX_NUM_UNITS = 0x32, | ||
1084 | + UFS_GEOMETRY_DESC_PARAM_ENM2_CAP_ADJ_FCTR = 0x36, | ||
1085 | + UFS_GEOMETRY_DESC_PARAM_ENM3_MAX_NUM_UNITS = 0x38, | ||
1086 | + UFS_GEOMETRY_DESC_PARAM_ENM3_CAP_ADJ_FCTR = 0x3C, | ||
1087 | + UFS_GEOMETRY_DESC_PARAM_ENM4_MAX_NUM_UNITS = 0x3E, | ||
1088 | + UFS_GEOMETRY_DESC_PARAM_ENM4_CAP_ADJ_FCTR = 0x42, | ||
1089 | + UFS_GEOMETRY_DESC_PARAM_OPT_LOG_BLK_SIZE = 0x44, | ||
1090 | + UFS_GEOMETRY_DESC_PARAM_HPB_REGION_SIZE = 0x48, | ||
1091 | + UFS_GEOMETRY_DESC_PARAM_HPB_NUMBER_LU = 0x49, | ||
1092 | + UFS_GEOMETRY_DESC_PARAM_HPB_SUBREGION_SIZE = 0x4A, | ||
1093 | + UFS_GEOMETRY_DESC_PARAM_HPB_MAX_ACTIVE_REGS = 0x4B, | ||
1094 | + UFS_GEOMETRY_DESC_PARAM_WB_MAX_ALLOC_UNITS = 0x4F, | ||
1095 | + UFS_GEOMETRY_DESC_PARAM_WB_MAX_WB_LUNS = 0x53, | ||
1096 | + UFS_GEOMETRY_DESC_PARAM_WB_BUFF_CAP_ADJ = 0x54, | ||
1097 | + UFS_GEOMETRY_DESC_PARAM_WB_SUP_RED_TYPE = 0x55, | ||
1098 | + UFS_GEOMETRY_DESC_PARAM_WB_SUP_WB_TYPE = 0x56, | ||
1099 | +}; | ||
1100 | + | ||
1101 | +/* Health descriptor parameters offsets in bytes*/ | ||
1102 | +enum health_desc_param { | ||
1103 | + UFS_HEALTH_DESC_PARAM_LEN = 0x0, | ||
1104 | + UFS_HEALTH_DESC_PARAM_TYPE = 0x1, | ||
1105 | + UFS_HEALTH_DESC_PARAM_EOL_INFO = 0x2, | ||
1106 | + UFS_HEALTH_DESC_PARAM_LIFE_TIME_EST_A = 0x3, | ||
1107 | + UFS_HEALTH_DESC_PARAM_LIFE_TIME_EST_B = 0x4, | ||
1108 | +}; | ||
1109 | + | ||
1110 | +/* WriteBooster buffer mode */ | ||
1111 | +enum { | ||
1112 | + UFS_WB_BUF_MODE_LU_DEDICATED = 0x0, | ||
1113 | + UFS_WB_BUF_MODE_SHARED = 0x1, | ||
1114 | +}; | ||
1115 | + | ||
1116 | +/* | ||
1117 | + * Logical Unit Write Protect | ||
1118 | + * 00h: LU not write protected | ||
1119 | + * 01h: LU write protected when fPowerOnWPEn =1 | ||
1120 | + * 02h: LU permanently write protected when fPermanentWPEn =1 | ||
1121 | + */ | ||
1122 | +enum ufs_lu_wp_type { | ||
1123 | + UFS_LU_NO_WP = 0x00, | ||
1124 | + UFS_LU_POWER_ON_WP = 0x01, | ||
1125 | + UFS_LU_PERM_WP = 0x02, | ||
1126 | +}; | ||
1127 | + | ||
1128 | +/* UTP QUERY Transaction Specific Fields OpCode */ | ||
1129 | +enum query_opcode { | ||
1130 | + UFS_UPIU_QUERY_OPCODE_NOP = 0x0, | ||
1131 | + UFS_UPIU_QUERY_OPCODE_READ_DESC = 0x1, | ||
1132 | + UFS_UPIU_QUERY_OPCODE_WRITE_DESC = 0x2, | ||
1133 | + UFS_UPIU_QUERY_OPCODE_READ_ATTR = 0x3, | ||
1134 | + UFS_UPIU_QUERY_OPCODE_WRITE_ATTR = 0x4, | ||
1135 | + UFS_UPIU_QUERY_OPCODE_READ_FLAG = 0x5, | ||
1136 | + UFS_UPIU_QUERY_OPCODE_SET_FLAG = 0x6, | ||
1137 | + UFS_UPIU_QUERY_OPCODE_CLEAR_FLAG = 0x7, | ||
1138 | + UFS_UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8, | ||
1139 | +}; | ||
1140 | + | ||
1141 | +/* Query response result code */ | ||
1142 | +typedef enum QueryRespCode { | ||
1143 | + UFS_QUERY_RESULT_SUCCESS = 0x00, | ||
1144 | + UFS_QUERY_RESULT_NOT_READABLE = 0xF6, | ||
1145 | + UFS_QUERY_RESULT_NOT_WRITEABLE = 0xF7, | ||
1146 | + UFS_QUERY_RESULT_ALREADY_WRITTEN = 0xF8, | ||
1147 | + UFS_QUERY_RESULT_INVALID_LENGTH = 0xF9, | ||
1148 | + UFS_QUERY_RESULT_INVALID_VALUE = 0xFA, | ||
1149 | + UFS_QUERY_RESULT_INVALID_SELECTOR = 0xFB, | ||
1150 | + UFS_QUERY_RESULT_INVALID_INDEX = 0xFC, | ||
1151 | + UFS_QUERY_RESULT_INVALID_IDN = 0xFD, | ||
1152 | + UFS_QUERY_RESULT_INVALID_OPCODE = 0xFE, | ||
1153 | + UFS_QUERY_RESULT_GENERAL_FAILURE = 0xFF, | ||
1154 | +} QueryRespCode; | ||
1155 | + | ||
1156 | +/* UTP Transfer Request Command Type (CT) */ | ||
1157 | +enum { | ||
1158 | + UFS_UPIU_COMMAND_SET_TYPE_SCSI = 0x0, | ||
1159 | + UFS_UPIU_COMMAND_SET_TYPE_UFS = 0x1, | ||
1160 | + UFS_UPIU_COMMAND_SET_TYPE_QUERY = 0x2, | ||
1161 | +}; | ||
1162 | + | ||
1163 | +/* Task management service response */ | ||
1164 | +enum { | ||
1165 | + UFS_UPIU_TASK_MANAGEMENT_FUNC_COMPL = 0x00, | ||
1166 | + UFS_UPIU_TASK_MANAGEMENT_FUNC_NOT_SUPPORTED = 0x04, | ||
1167 | + UFS_UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED = 0x08, | ||
1168 | + UFS_UPIU_TASK_MANAGEMENT_FUNC_FAILED = 0x05, | ||
1169 | + UFS_UPIU_INCORRECT_LOGICAL_UNIT_NO = 0x09, | ||
1170 | +}; | ||
1171 | + | ||
1172 | +/* UFS device power modes */ | ||
1173 | +enum ufs_dev_pwr_mode { | ||
1174 | + UFS_ACTIVE_PWR_MODE = 1, | ||
1175 | + UFS_SLEEP_PWR_MODE = 2, | ||
1176 | + UFS_POWERDOWN_PWR_MODE = 3, | ||
1177 | + UFS_DEEPSLEEP_PWR_MODE = 4, | ||
1178 | +}; | ||
1179 | + | ||
1180 | +/* | ||
1181 | + * struct UtpCmdRsp - Response UPIU structure | ||
1182 | + * @residual_transfer_count: Residual transfer count DW-3 | ||
1183 | + * @reserved: Reserved double words DW-4 to DW-7 | ||
1184 | + * @sense_data_len: Sense data length DW-8 U16 | ||
1185 | + * @sense_data: Sense data field DW-8 to DW-12 | ||
1186 | + */ | ||
1187 | +typedef struct QEMU_PACKED UtpCmdRsp { | ||
1188 | + uint32_t residual_transfer_count; | ||
1189 | + uint32_t reserved[4]; | ||
1190 | + uint16_t sense_data_len; | ||
1191 | + uint8_t sense_data[UFS_SENSE_SIZE]; | ||
1192 | +} UtpCmdRsp; | ||
1193 | + | ||
1194 | +/* | ||
1195 | + * struct UtpUpiuRsp - general upiu response structure | ||
1196 | + * @header: UPIU header structure DW-0 to DW-2 | ||
1197 | + * @sr: fields structure for scsi command DW-3 to DW-12 | ||
1198 | + * @qr: fields structure for query request DW-3 to DW-7 | ||
1199 | + */ | ||
1200 | +typedef struct QEMU_PACKED UtpUpiuRsp { | ||
1201 | + UtpUpiuHeader header; | ||
1202 | + union { | ||
1203 | + UtpCmdRsp sr; | ||
1204 | + UtpUpiuQuery qr; | ||
1205 | + }; | ||
1206 | +} UtpUpiuRsp; | ||
1207 | + | ||
1208 | +static inline void _ufs_check_size(void) | ||
1209 | +{ | ||
1210 | + QEMU_BUILD_BUG_ON(sizeof(UfsReg) != 0x104); | ||
1211 | + QEMU_BUILD_BUG_ON(sizeof(DeviceDescriptor) != 89); | ||
1212 | + QEMU_BUILD_BUG_ON(sizeof(GeometryDescriptor) != 87); | ||
1213 | + QEMU_BUILD_BUG_ON(sizeof(UnitDescriptor) != 45); | ||
1214 | + QEMU_BUILD_BUG_ON(sizeof(RpmbUnitDescriptor) != 35); | ||
1215 | + QEMU_BUILD_BUG_ON(sizeof(PowerParametersDescriptor) != 98); | ||
1216 | + QEMU_BUILD_BUG_ON(sizeof(InterconnectDescriptor) != 6); | ||
1217 | + QEMU_BUILD_BUG_ON(sizeof(StringDescriptor) != 254); | ||
1218 | + QEMU_BUILD_BUG_ON(sizeof(DeviceHealthDescriptor) != 45); | ||
1219 | + QEMU_BUILD_BUG_ON(sizeof(Flags) != 0x13); | ||
1220 | + QEMU_BUILD_BUG_ON(sizeof(UtpUpiuHeader) != 12); | ||
1221 | + QEMU_BUILD_BUG_ON(sizeof(UtpUpiuQuery) != 276); | ||
1222 | + QEMU_BUILD_BUG_ON(sizeof(UtpUpiuCmd) != 20); | ||
1223 | + QEMU_BUILD_BUG_ON(sizeof(UtpUpiuReq) != 288); | ||
1224 | + QEMU_BUILD_BUG_ON(sizeof(UfshcdSgEntry) != 16); | ||
1225 | + QEMU_BUILD_BUG_ON(sizeof(RequestDescHeader) != 16); | ||
1226 | + QEMU_BUILD_BUG_ON(sizeof(UtpTransferReqDesc) != 32); | ||
1227 | + QEMU_BUILD_BUG_ON(sizeof(UtpTaskReqDesc) != 80); | ||
1228 | + QEMU_BUILD_BUG_ON(sizeof(UtpCmdRsp) != 40); | ||
1229 | + QEMU_BUILD_BUG_ON(sizeof(UtpUpiuRsp) != 288); | ||
1230 | +} | ||
1231 | +#endif | ||
1232 | diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h | ||
1233 | index XXXXXXX..XXXXXXX 100644 | ||
1234 | --- a/include/hw/pci/pci.h | ||
1235 | +++ b/include/hw/pci/pci.h | ||
1236 | @@ -XXX,XX +XXX,XX @@ extern bool pci_available; | ||
1237 | #define PCI_DEVICE_ID_REDHAT_NVME 0x0010 | ||
1238 | #define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0011 | ||
1239 | #define PCI_DEVICE_ID_REDHAT_ACPI_ERST 0x0012 | ||
1240 | +#define PCI_DEVICE_ID_REDHAT_UFS 0x0013 | ||
1241 | #define PCI_DEVICE_ID_REDHAT_QXL 0x0100 | ||
1242 | |||
1243 | #define FMT_PCIBUS PRIx64 | ||
1244 | diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h | ||
1245 | index XXXXXXX..XXXXXXX 100644 | ||
1246 | --- a/include/hw/pci/pci_ids.h | ||
1247 | +++ b/include/hw/pci/pci_ids.h | ||
1248 | @@ -XXX,XX +XXX,XX @@ | ||
1249 | #define PCI_CLASS_STORAGE_SATA 0x0106 | ||
1250 | #define PCI_CLASS_STORAGE_SAS 0x0107 | ||
1251 | #define PCI_CLASS_STORAGE_EXPRESS 0x0108 | ||
1252 | +#define PCI_CLASS_STORAGE_UFS 0x0109 | ||
1253 | #define PCI_CLASS_STORAGE_OTHER 0x0180 | ||
1254 | |||
1255 | #define PCI_BASE_CLASS_NETWORK 0x02 | ||
1256 | diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c | ||
1257 | new file mode 100644 | ||
1258 | index XXXXXXX..XXXXXXX | ||
1259 | --- /dev/null | ||
1260 | +++ b/hw/ufs/ufs.c | ||
1261 | @@ -XXX,XX +XXX,XX @@ | ||
1262 | +/* | ||
1263 | + * QEMU Universal Flash Storage (UFS) Controller | ||
52 | + * | 1264 | + * |
53 | + * This program is distributed in the hope that it will be useful, | 1265 | + * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved. |
54 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
55 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
56 | + * GNU General Public License for more details. | ||
57 | + * | 1266 | + * |
58 | + * You should have received a copy of the GNU General Public License | 1267 | + * Written by Jeuk Kim <jeuk20.kim@samsung.com> |
59 | + * along with this program; if not, see <http://www.gnu.org/licenses/>. | 1268 | + * |
1269 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
60 | + */ | 1270 | + */ |
61 | + | 1271 | + |
62 | +#include "qemu/osdep.h" | 1272 | +#include "qemu/osdep.h" |
63 | +#include "block/block_int.h" | ||
64 | +#include "qemu/module.h" | ||
65 | +#include "qapi/error.h" | 1273 | +#include "qapi/error.h" |
66 | + | 1274 | +#include "migration/vmstate.h" |
67 | + | 1275 | +#include "trace.h" |
68 | +static int compress_open(BlockDriverState *bs, QDict *options, int flags, | 1276 | +#include "ufs.h" |
69 | + Error **errp) | 1277 | + |
1278 | +/* The QEMU-UFS device follows spec version 3.1 */ | ||
1279 | +#define UFS_SPEC_VER 0x00000310 | ||
1280 | +#define UFS_MAX_NUTRS 32 | ||
1281 | +#define UFS_MAX_NUTMRS 8 | ||
1282 | + | ||
1283 | +static void ufs_irq_check(UfsHc *u) | ||
70 | +{ | 1284 | +{ |
71 | + bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, | 1285 | + PCIDevice *pci = PCI_DEVICE(u); |
72 | + errp); | 1286 | + |
73 | + if (!bs->file) { | 1287 | + if ((u->reg.is & UFS_INTR_MASK) & u->reg.ie) { |
74 | + return -EINVAL; | 1288 | + trace_ufs_irq_raise(); |
1289 | + pci_irq_assert(pci); | ||
1290 | + } else { | ||
1291 | + trace_ufs_irq_lower(); | ||
1292 | + pci_irq_deassert(pci); | ||
75 | + } | 1293 | + } |
76 | + | 1294 | +} |
77 | + if (!bs->file->bs->drv || !block_driver_can_compress(bs->file->bs->drv)) { | 1295 | + |
78 | + error_setg(errp, | 1296 | +static void ufs_process_uiccmd(UfsHc *u, uint32_t val) |
79 | + "Compression is not supported for underlying format: %s", | 1297 | +{ |
80 | + bdrv_get_format_name(bs->file->bs) ?: "(no format)"); | 1298 | + trace_ufs_process_uiccmd(val, u->reg.ucmdarg1, u->reg.ucmdarg2, |
81 | + | 1299 | + u->reg.ucmdarg3); |
82 | + return -ENOTSUP; | 1300 | + /* |
1301 | + * Only the essential uic commands for running drivers on Linux and Windows | ||
1302 | + * are implemented. | ||
1303 | + */ | ||
1304 | + switch (val) { | ||
1305 | + case UFS_UIC_CMD_DME_LINK_STARTUP: | ||
1306 | + u->reg.hcs = FIELD_DP32(u->reg.hcs, HCS, DP, 1); | ||
1307 | + u->reg.hcs = FIELD_DP32(u->reg.hcs, HCS, UTRLRDY, 1); | ||
1308 | + u->reg.hcs = FIELD_DP32(u->reg.hcs, HCS, UTMRLRDY, 1); | ||
1309 | + u->reg.ucmdarg2 = UFS_UIC_CMD_RESULT_SUCCESS; | ||
1310 | + break; | ||
1311 | + /* TODO: Revisit it when Power Management is implemented */ | ||
1312 | + case UFS_UIC_CMD_DME_HIBER_ENTER: | ||
1313 | + u->reg.is = FIELD_DP32(u->reg.is, IS, UHES, 1); | ||
1314 | + u->reg.hcs = FIELD_DP32(u->reg.hcs, HCS, UPMCRS, UFS_PWR_LOCAL); | ||
1315 | + u->reg.ucmdarg2 = UFS_UIC_CMD_RESULT_SUCCESS; | ||
1316 | + break; | ||
1317 | + case UFS_UIC_CMD_DME_HIBER_EXIT: | ||
1318 | + u->reg.is = FIELD_DP32(u->reg.is, IS, UHXS, 1); | ||
1319 | + u->reg.hcs = FIELD_DP32(u->reg.hcs, HCS, UPMCRS, UFS_PWR_LOCAL); | ||
1320 | + u->reg.ucmdarg2 = UFS_UIC_CMD_RESULT_SUCCESS; | ||
1321 | + break; | ||
1322 | + default: | ||
1323 | + u->reg.ucmdarg2 = UFS_UIC_CMD_RESULT_FAILURE; | ||
83 | + } | 1324 | + } |
84 | + | 1325 | + |
85 | + bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED | | 1326 | + u->reg.is = FIELD_DP32(u->reg.is, IS, UCCS, 1); |
86 | + (BDRV_REQ_FUA & bs->file->bs->supported_write_flags); | 1327 | + |
87 | + | 1328 | + ufs_irq_check(u); |
88 | + bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED | | ||
89 | + ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & | ||
90 | + bs->file->bs->supported_zero_flags); | ||
91 | + | ||
92 | + return 0; | ||
93 | +} | 1329 | +} |
94 | + | 1330 | + |
95 | + | 1331 | +static void ufs_write_reg(UfsHc *u, hwaddr offset, uint32_t data, unsigned size) |
96 | +static int64_t compress_getlength(BlockDriverState *bs) | ||
97 | +{ | 1332 | +{ |
98 | + return bdrv_getlength(bs->file->bs); | 1333 | + switch (offset) { |
1334 | + case A_IS: | ||
1335 | + u->reg.is &= ~data; | ||
1336 | + ufs_irq_check(u); | ||
1337 | + break; | ||
1338 | + case A_IE: | ||
1339 | + u->reg.ie = data; | ||
1340 | + ufs_irq_check(u); | ||
1341 | + break; | ||
1342 | + case A_HCE: | ||
1343 | + if (!FIELD_EX32(u->reg.hce, HCE, HCE) && FIELD_EX32(data, HCE, HCE)) { | ||
1344 | + u->reg.hcs = FIELD_DP32(u->reg.hcs, HCS, UCRDY, 1); | ||
1345 | + u->reg.hce = FIELD_DP32(u->reg.hce, HCE, HCE, 1); | ||
1346 | + } else if (FIELD_EX32(u->reg.hce, HCE, HCE) && | ||
1347 | + !FIELD_EX32(data, HCE, HCE)) { | ||
1348 | + u->reg.hcs = 0; | ||
1349 | + u->reg.hce = FIELD_DP32(u->reg.hce, HCE, HCE, 0); | ||
1350 | + } | ||
1351 | + break; | ||
1352 | + case A_UTRLBA: | ||
1353 | + u->reg.utrlba = data & R_UTRLBA_UTRLBA_MASK; | ||
1354 | + break; | ||
1355 | + case A_UTRLBAU: | ||
1356 | + u->reg.utrlbau = data; | ||
1357 | + break; | ||
1358 | + case A_UTRLDBR: | ||
1359 | + /* Not yet supported */ | ||
1360 | + break; | ||
1361 | + case A_UTRLRSR: | ||
1362 | + u->reg.utrlrsr = data; | ||
1363 | + break; | ||
1364 | + case A_UTRLCNR: | ||
1365 | + u->reg.utrlcnr &= ~data; | ||
1366 | + break; | ||
1367 | + case A_UTMRLBA: | ||
1368 | + u->reg.utmrlba = data & R_UTMRLBA_UTMRLBA_MASK; | ||
1369 | + break; | ||
1370 | + case A_UTMRLBAU: | ||
1371 | + u->reg.utmrlbau = data; | ||
1372 | + break; | ||
1373 | + case A_UICCMD: | ||
1374 | + ufs_process_uiccmd(u, data); | ||
1375 | + break; | ||
1376 | + case A_UCMDARG1: | ||
1377 | + u->reg.ucmdarg1 = data; | ||
1378 | + break; | ||
1379 | + case A_UCMDARG2: | ||
1380 | + u->reg.ucmdarg2 = data; | ||
1381 | + break; | ||
1382 | + case A_UCMDARG3: | ||
1383 | + u->reg.ucmdarg3 = data; | ||
1384 | + break; | ||
1385 | + case A_UTRLCLR: | ||
1386 | + case A_UTMRLDBR: | ||
1387 | + case A_UTMRLCLR: | ||
1388 | + case A_UTMRLRSR: | ||
1389 | + trace_ufs_err_unsupport_register_offset(offset); | ||
1390 | + break; | ||
1391 | + default: | ||
1392 | + trace_ufs_err_invalid_register_offset(offset); | ||
1393 | + break; | ||
1394 | + } | ||
99 | +} | 1395 | +} |
100 | + | 1396 | + |
101 | + | 1397 | +static uint64_t ufs_mmio_read(void *opaque, hwaddr addr, unsigned size) |
102 | +static int coroutine_fn compress_co_preadv_part(BlockDriverState *bs, | ||
103 | + uint64_t offset, uint64_t bytes, | ||
104 | + QEMUIOVector *qiov, | ||
105 | + size_t qiov_offset, | ||
106 | + int flags) | ||
107 | +{ | 1398 | +{ |
108 | + return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, | 1399 | + UfsHc *u = (UfsHc *)opaque; |
109 | + flags); | 1400 | + uint8_t *ptr = (uint8_t *)&u->reg; |
1401 | + uint64_t value; | ||
1402 | + | ||
1403 | + if (addr > sizeof(u->reg) - size) { | ||
1404 | + trace_ufs_err_invalid_register_offset(addr); | ||
1405 | + return 0; | ||
1406 | + } | ||
1407 | + | ||
1408 | + value = *(uint32_t *)(ptr + addr); | ||
1409 | + trace_ufs_mmio_read(addr, value, size); | ||
1410 | + return value; | ||
110 | +} | 1411 | +} |
111 | + | 1412 | + |
112 | + | 1413 | +static void ufs_mmio_write(void *opaque, hwaddr addr, uint64_t data, |
113 | +static int coroutine_fn compress_co_pwritev_part(BlockDriverState *bs, | 1414 | + unsigned size) |
114 | + uint64_t offset, | ||
115 | + uint64_t bytes, | ||
116 | + QEMUIOVector *qiov, | ||
117 | + size_t qiov_offset, int flags) | ||
118 | +{ | 1415 | +{ |
119 | + return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, | 1416 | + UfsHc *u = (UfsHc *)opaque; |
120 | + flags | BDRV_REQ_WRITE_COMPRESSED); | 1417 | + |
121 | +} | 1418 | + if (addr > sizeof(u->reg) - size) { |
122 | + | 1419 | + trace_ufs_err_invalid_register_offset(addr); |
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; | 1420 | + return; |
146 | + } | 1421 | + } |
147 | + | 1422 | + |
148 | + ret = bdrv_get_info(bs->file->bs, &bdi); | 1423 | + trace_ufs_mmio_write(addr, data, size); |
149 | + if (ret < 0 || bdi.cluster_size == 0) { | 1424 | + ufs_write_reg(u, addr, data, size); |
1425 | +} | ||
1426 | + | ||
1427 | +static const MemoryRegionOps ufs_mmio_ops = { | ||
1428 | + .read = ufs_mmio_read, | ||
1429 | + .write = ufs_mmio_write, | ||
1430 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
1431 | + .impl = { | ||
1432 | + .min_access_size = 4, | ||
1433 | + .max_access_size = 4, | ||
1434 | + }, | ||
1435 | +}; | ||
1436 | + | ||
1437 | +static bool ufs_check_constraints(UfsHc *u, Error **errp) | ||
1438 | +{ | ||
1439 | + if (u->params.nutrs > UFS_MAX_NUTRS) { | ||
1440 | + error_setg(errp, "nutrs must be less than or equal to %d", | ||
1441 | + UFS_MAX_NUTRS); | ||
1442 | + return false; | ||
1443 | + } | ||
1444 | + | ||
1445 | + if (u->params.nutmrs > UFS_MAX_NUTMRS) { | ||
1446 | + error_setg(errp, "nutmrs must be less than or equal to %d", | ||
1447 | + UFS_MAX_NUTMRS); | ||
1448 | + return false; | ||
1449 | + } | ||
1450 | + | ||
1451 | + return true; | ||
1452 | +} | ||
1453 | + | ||
1454 | +static void ufs_init_pci(UfsHc *u, PCIDevice *pci_dev) | ||
1455 | +{ | ||
1456 | + uint8_t *pci_conf = pci_dev->config; | ||
1457 | + | ||
1458 | + pci_conf[PCI_INTERRUPT_PIN] = 1; | ||
1459 | + pci_config_set_prog_interface(pci_conf, 0x1); | ||
1460 | + | ||
1461 | + memory_region_init_io(&u->iomem, OBJECT(u), &ufs_mmio_ops, u, "ufs", | ||
1462 | + u->reg_size); | ||
1463 | + pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &u->iomem); | ||
1464 | + u->irq = pci_allocate_irq(pci_dev); | ||
1465 | +} | ||
1466 | + | ||
1467 | +static void ufs_init_hc(UfsHc *u) | ||
1468 | +{ | ||
1469 | + uint32_t cap = 0; | ||
1470 | + | ||
1471 | + u->reg_size = pow2ceil(sizeof(UfsReg)); | ||
1472 | + | ||
1473 | + memset(&u->reg, 0, sizeof(u->reg)); | ||
1474 | + cap = FIELD_DP32(cap, CAP, NUTRS, (u->params.nutrs - 1)); | ||
1475 | + cap = FIELD_DP32(cap, CAP, RTT, 2); | ||
1476 | + cap = FIELD_DP32(cap, CAP, NUTMRS, (u->params.nutmrs - 1)); | ||
1477 | + cap = FIELD_DP32(cap, CAP, AUTOH8, 0); | ||
1478 | + cap = FIELD_DP32(cap, CAP, 64AS, 1); | ||
1479 | + cap = FIELD_DP32(cap, CAP, OODDS, 0); | ||
1480 | + cap = FIELD_DP32(cap, CAP, UICDMETMS, 0); | ||
1481 | + cap = FIELD_DP32(cap, CAP, CS, 0); | ||
1482 | + u->reg.cap = cap; | ||
1483 | + u->reg.ver = UFS_SPEC_VER; | ||
1484 | +} | ||
1485 | + | ||
1486 | +static void ufs_realize(PCIDevice *pci_dev, Error **errp) | ||
1487 | +{ | ||
1488 | + UfsHc *u = UFS(pci_dev); | ||
1489 | + | ||
1490 | + if (!ufs_check_constraints(u, errp)) { | ||
150 | + return; | 1491 | + return; |
151 | + } | 1492 | + } |
152 | + | 1493 | + |
153 | + bs->bl.request_alignment = bdi.cluster_size; | 1494 | + ufs_init_hc(u); |
1495 | + ufs_init_pci(u, pci_dev); | ||
154 | +} | 1496 | +} |
155 | + | 1497 | + |
156 | + | 1498 | +static Property ufs_props[] = { |
157 | +static void compress_eject(BlockDriverState *bs, bool eject_flag) | 1499 | + DEFINE_PROP_STRING("serial", UfsHc, params.serial), |
1500 | + DEFINE_PROP_UINT8("nutrs", UfsHc, params.nutrs, 32), | ||
1501 | + DEFINE_PROP_UINT8("nutmrs", UfsHc, params.nutmrs, 8), | ||
1502 | + DEFINE_PROP_END_OF_LIST(), | ||
1503 | +}; | ||
1504 | + | ||
1505 | +static const VMStateDescription ufs_vmstate = { | ||
1506 | + .name = "ufs", | ||
1507 | + .unmigratable = 1, | ||
1508 | +}; | ||
1509 | + | ||
1510 | +static void ufs_class_init(ObjectClass *oc, void *data) | ||
158 | +{ | 1511 | +{ |
159 | + bdrv_eject(bs->file->bs, eject_flag); | 1512 | + DeviceClass *dc = DEVICE_CLASS(oc); |
1513 | + PCIDeviceClass *pc = PCI_DEVICE_CLASS(oc); | ||
1514 | + | ||
1515 | + pc->realize = ufs_realize; | ||
1516 | + pc->vendor_id = PCI_VENDOR_ID_REDHAT; | ||
1517 | + pc->device_id = PCI_DEVICE_ID_REDHAT_UFS; | ||
1518 | + pc->class_id = PCI_CLASS_STORAGE_UFS; | ||
1519 | + | ||
1520 | + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); | ||
1521 | + dc->desc = "Universal Flash Storage"; | ||
1522 | + device_class_set_props(dc, ufs_props); | ||
1523 | + dc->vmsd = &ufs_vmstate; | ||
160 | +} | 1524 | +} |
161 | + | 1525 | + |
162 | + | 1526 | +static const TypeInfo ufs_info = { |
163 | +static void compress_lock_medium(BlockDriverState *bs, bool locked) | 1527 | + .name = TYPE_UFS, |
1528 | + .parent = TYPE_PCI_DEVICE, | ||
1529 | + .class_init = ufs_class_init, | ||
1530 | + .instance_size = sizeof(UfsHc), | ||
1531 | + .interfaces = (InterfaceInfo[]){ { INTERFACE_PCIE_DEVICE }, {} }, | ||
1532 | +}; | ||
1533 | + | ||
1534 | +static void ufs_register_types(void) | ||
164 | +{ | 1535 | +{ |
165 | + bdrv_lock_medium(bs->file->bs, locked); | 1536 | + type_register_static(&ufs_info); |
166 | +} | 1537 | +} |
167 | + | 1538 | + |
168 | + | 1539 | +type_init(ufs_register_types) |
169 | +static bool compress_recurse_is_first_non_filter(BlockDriverState *bs, | 1540 | diff --git a/hw/Kconfig b/hw/Kconfig |
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 | 1541 | index XXXXXXX..XXXXXXX 100644 |
209 | --- a/qapi/block-core.json | 1542 | --- a/hw/Kconfig |
210 | +++ b/qapi/block-core.json | 1543 | +++ b/hw/Kconfig |
1544 | @@ -XXX,XX +XXX,XX @@ source smbios/Kconfig | ||
1545 | source ssi/Kconfig | ||
1546 | source timer/Kconfig | ||
1547 | source tpm/Kconfig | ||
1548 | +source ufs/Kconfig | ||
1549 | source usb/Kconfig | ||
1550 | source virtio/Kconfig | ||
1551 | source vfio/Kconfig | ||
1552 | diff --git a/hw/meson.build b/hw/meson.build | ||
1553 | index XXXXXXX..XXXXXXX 100644 | ||
1554 | --- a/hw/meson.build | ||
1555 | +++ b/hw/meson.build | ||
1556 | @@ -XXX,XX +XXX,XX @@ subdir('smbios') | ||
1557 | subdir('ssi') | ||
1558 | subdir('timer') | ||
1559 | subdir('tpm') | ||
1560 | +subdir('ufs') | ||
1561 | subdir('usb') | ||
1562 | subdir('vfio') | ||
1563 | subdir('virtio') | ||
1564 | diff --git a/hw/ufs/Kconfig b/hw/ufs/Kconfig | ||
1565 | new file mode 100644 | ||
1566 | index XXXXXXX..XXXXXXX | ||
1567 | --- /dev/null | ||
1568 | +++ b/hw/ufs/Kconfig | ||
211 | @@ -XXX,XX +XXX,XX @@ | 1569 | @@ -XXX,XX +XXX,XX @@ |
212 | # @copy-on-read: Since 3.0 | 1570 | +config UFS_PCI |
213 | # @blklogwrites: Since 3.0 | 1571 | + bool |
214 | # @blkreplay: Since 4.2 | 1572 | + default y if PCI_DEVICES |
215 | +# @compress: Since 5.0 | 1573 | + depends on PCI |
216 | # | 1574 | diff --git a/hw/ufs/meson.build b/hw/ufs/meson.build |
217 | # Since: 2.9 | 1575 | new file mode 100644 |
218 | ## | 1576 | index XXXXXXX..XXXXXXX |
219 | { 'enum': 'BlockdevDriver', | 1577 | --- /dev/null |
220 | 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs', | 1578 | +++ b/hw/ufs/meson.build |
221 | - 'cloop', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'gluster', | 1579 | @@ -0,0 +1 @@ |
222 | - 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 'luks', | 1580 | +system_ss.add(when: 'CONFIG_UFS_PCI', if_true: files('ufs.c')) |
223 | - 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', 'qcow', | 1581 | diff --git a/hw/ufs/trace-events b/hw/ufs/trace-events |
224 | - 'qcow2', 'qed', 'quorum', 'raw', 'rbd', | 1582 | new file mode 100644 |
225 | + 'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', | 1583 | index XXXXXXX..XXXXXXX |
226 | + 'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', | 1584 | --- /dev/null |
227 | + 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', | 1585 | +++ b/hw/ufs/trace-events |
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 @@ | 1586 | @@ -XXX,XX +XXX,XX @@ |
233 | 'blkreplay': 'BlockdevOptionsBlkreplay', | 1587 | +# ufs.c |
234 | 'bochs': 'BlockdevOptionsGenericFormat', | 1588 | +ufs_irq_raise(void) "INTx" |
235 | 'cloop': 'BlockdevOptionsGenericFormat', | 1589 | +ufs_irq_lower(void) "INTx" |
236 | + 'compress': 'BlockdevOptionsGenericFormat', | 1590 | +ufs_mmio_read(uint64_t addr, uint64_t data, unsigned size) "addr 0x%"PRIx64" data 0x%"PRIx64" size %d" |
237 | 'copy-on-read':'BlockdevOptionsGenericFormat', | 1591 | +ufs_mmio_write(uint64_t addr, uint64_t data, unsigned size) "addr 0x%"PRIx64" data 0x%"PRIx64" size %d" |
238 | 'dmg': 'BlockdevOptionsGenericFormat', | 1592 | +ufs_process_db(uint32_t slot) "UTRLDBR slot %"PRIu32"" |
239 | 'file': 'BlockdevOptionsFile', | 1593 | +ufs_process_req(uint32_t slot) "UTRLDBR slot %"PRIu32"" |
1594 | +ufs_complete_req(uint32_t slot) "UTRLDBR slot %"PRIu32"" | ||
1595 | +ufs_sendback_req(uint32_t slot) "UTRLDBR slot %"PRIu32"" | ||
1596 | +ufs_exec_nop_cmd(uint32_t slot) "UTRLDBR slot %"PRIu32"" | ||
1597 | +ufs_exec_scsi_cmd(uint32_t slot, uint8_t lun, uint8_t opcode) "slot %"PRIu32", lun 0x%"PRIx8", opcode 0x%"PRIx8"" | ||
1598 | +ufs_exec_query_cmd(uint32_t slot, uint8_t opcode) "slot %"PRIu32", opcode 0x%"PRIx8"" | ||
1599 | +ufs_process_uiccmd(uint32_t uiccmd, uint32_t ucmdarg1, uint32_t ucmdarg2, uint32_t ucmdarg3) "uiccmd 0x%"PRIx32", ucmdarg1 0x%"PRIx32", ucmdarg2 0x%"PRIx32", ucmdarg3 0x%"PRIx32"" | ||
1600 | + | ||
1601 | +# error condition | ||
1602 | +ufs_err_dma_read_utrd(uint32_t slot, uint64_t addr) "failed to read utrd. UTRLDBR slot %"PRIu32", UTRD dma addr %"PRIu64"" | ||
1603 | +ufs_err_dma_read_req_upiu(uint32_t slot, uint64_t addr) "failed to read req upiu. UTRLDBR slot %"PRIu32", request upiu addr %"PRIu64"" | ||
1604 | +ufs_err_dma_read_prdt(uint32_t slot, uint64_t addr) "failed to read prdt. UTRLDBR slot %"PRIu32", prdt addr %"PRIu64"" | ||
1605 | +ufs_err_dma_write_utrd(uint32_t slot, uint64_t addr) "failed to write utrd. UTRLDBR slot %"PRIu32", UTRD dma addr %"PRIu64"" | ||
1606 | +ufs_err_dma_write_rsp_upiu(uint32_t slot, uint64_t addr) "failed to write rsp upiu. UTRLDBR slot %"PRIu32", response upiu addr %"PRIu64"" | ||
1607 | +ufs_err_utrl_slot_busy(uint32_t slot) "UTRLDBR slot %"PRIu32" is busy" | ||
1608 | +ufs_err_unsupport_register_offset(uint32_t offset) "Register offset 0x%"PRIx32" is not yet supported" | ||
1609 | +ufs_err_invalid_register_offset(uint32_t offset) "Register offset 0x%"PRIx32" is invalid" | ||
1610 | +ufs_err_scsi_cmd_invalid_lun(uint8_t lun) "scsi command has invalid lun: 0x%"PRIx8"" | ||
1611 | +ufs_err_query_flag_not_readable(uint8_t idn) "query flag idn 0x%"PRIx8" is denied to read" | ||
1612 | +ufs_err_query_flag_not_writable(uint8_t idn) "query flag idn 0x%"PRIx8" is denied to write" | ||
1613 | +ufs_err_query_attr_not_readable(uint8_t idn) "query attribute idn 0x%"PRIx8" is denied to read" | ||
1614 | +ufs_err_query_attr_not_writable(uint8_t idn) "query attribute idn 0x%"PRIx8" is denied to write" | ||
1615 | +ufs_err_query_invalid_opcode(uint8_t opcode) "query request has invalid opcode. opcode: 0x%"PRIx8"" | ||
1616 | +ufs_err_query_invalid_idn(uint8_t opcode, uint8_t idn) "query request has invalid idn. opcode: 0x%"PRIx8", idn 0x%"PRIx8"" | ||
1617 | +ufs_err_query_invalid_index(uint8_t opcode, uint8_t index) "query request has invalid index. opcode: 0x%"PRIx8", index 0x%"PRIx8"" | ||
1618 | +ufs_err_invalid_trans_code(uint32_t slot, uint8_t trans_code) "request upiu has invalid transaction code. slot: %"PRIu32", trans_code: 0x%"PRIx8"" | ||
240 | -- | 1619 | -- |
241 | 2.24.1 | 1620 | 2.41.0 |
242 | |||
243 | diff view generated by jsdifflib |
1 | Sometimes it is useful to be able to add a node to the block graph that | 1 | From: Jeuk Kim <jeuk20.kim@samsung.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 | This commit makes the UFS device support query |
6 | needs to take or cannot share, because this might result in assertion | 4 | and nop out transfer requests. |
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 | 5 | ||
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 6 | The next patch would be support for UFS logical |
12 | Message-id: 20191108123455.39445-4-mreitz@redhat.com | 7 | unit and scsi command transfer request. |
13 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 8 | |
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 9 | Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com> |
10 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
11 | Message-id: ff7a5f0fd26761936a553ffb89d3df0ba62844e9.1693980783.git.jeuk20.kim@gmail.com | ||
12 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
15 | --- | 13 | --- |
16 | block/blkdebug.c | 93 +++++++++++++++++++++++++++++++++++++++++++- | 14 | hw/ufs/ufs.h | 46 +++ |
17 | qapi/block-core.json | 14 ++++++- | 15 | hw/ufs/ufs.c | 988 +++++++++++++++++++++++++++++++++++++++++++- |
18 | 2 files changed, 105 insertions(+), 2 deletions(-) | 16 | hw/ufs/trace-events | 1 + |
17 | 3 files changed, 1033 insertions(+), 2 deletions(-) | ||
19 | 18 | ||
20 | diff --git a/block/blkdebug.c b/block/blkdebug.c | 19 | diff --git a/hw/ufs/ufs.h b/hw/ufs/ufs.h |
21 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/block/blkdebug.c | 21 | --- a/hw/ufs/ufs.h |
23 | +++ b/block/blkdebug.c | 22 | +++ b/hw/ufs/ufs.h |
24 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
25 | #include "qemu/cutils.h" | 24 | #define UFS_MAX_LUS 32 |
26 | #include "qemu/config-file.h" | 25 | #define UFS_BLOCK_SIZE 4096 |
27 | #include "block/block_int.h" | 26 | |
28 | +#include "block/qdict.h" | 27 | +typedef enum UfsRequestState { |
29 | #include "qemu/module.h" | 28 | + UFS_REQUEST_IDLE = 0, |
30 | #include "qemu/option.h" | 29 | + UFS_REQUEST_READY = 1, |
31 | +#include "qapi/qapi-visit-block-core.h" | 30 | + UFS_REQUEST_RUNNING = 2, |
32 | #include "qapi/qmp/qdict.h" | 31 | + UFS_REQUEST_COMPLETE = 3, |
33 | +#include "qapi/qmp/qlist.h" | 32 | + UFS_REQUEST_ERROR = 4, |
34 | #include "qapi/qmp/qstring.h" | 33 | +} UfsRequestState; |
35 | +#include "qapi/qobject-input-visitor.h" | 34 | + |
36 | #include "sysemu/qtest.h" | 35 | +typedef enum UfsReqResult { |
37 | 36 | + UFS_REQUEST_SUCCESS = 0, | |
38 | typedef struct BDRVBlkdebugState { | 37 | + UFS_REQUEST_FAIL = 1, |
39 | @@ -XXX,XX +XXX,XX @@ typedef struct BDRVBlkdebugState { | 38 | +} UfsReqResult; |
40 | uint64_t opt_discard; | 39 | + |
41 | uint64_t max_discard; | 40 | +typedef struct UfsRequest { |
42 | 41 | + struct UfsHc *hc; | |
43 | + uint64_t take_child_perms; | 42 | + UfsRequestState state; |
44 | + uint64_t unshare_child_perms; | 43 | + int slot; |
45 | + | 44 | + |
46 | /* For blkdebug_refresh_filename() */ | 45 | + UtpTransferReqDesc utrd; |
47 | char *config_file; | 46 | + UtpUpiuReq req_upiu; |
48 | 47 | + UtpUpiuRsp rsp_upiu; | |
49 | @@ -XXX,XX +XXX,XX @@ static void blkdebug_parse_filename(const char *filename, QDict *options, | 48 | + |
50 | qdict_put_str(options, "x-image", filename); | 49 | + /* for scsi command */ |
50 | + QEMUSGList *sg; | ||
51 | +} UfsRequest; | ||
52 | + | ||
53 | typedef struct UfsParams { | ||
54 | char *serial; | ||
55 | uint8_t nutrs; /* Number of UTP Transfer Request Slots */ | ||
56 | @@ -XXX,XX +XXX,XX @@ typedef struct UfsHc { | ||
57 | UfsReg reg; | ||
58 | UfsParams params; | ||
59 | uint32_t reg_size; | ||
60 | + UfsRequest *req_list; | ||
61 | + | ||
62 | + DeviceDescriptor device_desc; | ||
63 | + GeometryDescriptor geometry_desc; | ||
64 | + Attributes attributes; | ||
65 | + Flags flags; | ||
66 | |||
67 | qemu_irq irq; | ||
68 | QEMUBH *doorbell_bh; | ||
69 | @@ -XXX,XX +XXX,XX @@ typedef struct UfsHc { | ||
70 | #define TYPE_UFS "ufs" | ||
71 | #define UFS(obj) OBJECT_CHECK(UfsHc, (obj), TYPE_UFS) | ||
72 | |||
73 | +typedef enum UfsQueryFlagPerm { | ||
74 | + UFS_QUERY_FLAG_NONE = 0x0, | ||
75 | + UFS_QUERY_FLAG_READ = 0x1, | ||
76 | + UFS_QUERY_FLAG_SET = 0x2, | ||
77 | + UFS_QUERY_FLAG_CLEAR = 0x4, | ||
78 | + UFS_QUERY_FLAG_TOGGLE = 0x8, | ||
79 | +} UfsQueryFlagPerm; | ||
80 | + | ||
81 | +typedef enum UfsQueryAttrPerm { | ||
82 | + UFS_QUERY_ATTR_NONE = 0x0, | ||
83 | + UFS_QUERY_ATTR_READ = 0x1, | ||
84 | + UFS_QUERY_ATTR_WRITE = 0x2, | ||
85 | +} UfsQueryAttrPerm; | ||
86 | + | ||
87 | #endif /* HW_UFS_UFS_H */ | ||
88 | diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/hw/ufs/ufs.c | ||
91 | +++ b/hw/ufs/ufs.c | ||
92 | @@ -XXX,XX +XXX,XX @@ | ||
93 | #include "ufs.h" | ||
94 | |||
95 | /* The QEMU-UFS device follows spec version 3.1 */ | ||
96 | -#define UFS_SPEC_VER 0x00000310 | ||
97 | +#define UFS_SPEC_VER 0x0310 | ||
98 | #define UFS_MAX_NUTRS 32 | ||
99 | #define UFS_MAX_NUTMRS 8 | ||
100 | |||
101 | +static MemTxResult ufs_addr_read(UfsHc *u, hwaddr addr, void *buf, int size) | ||
102 | +{ | ||
103 | + hwaddr hi = addr + size - 1; | ||
104 | + | ||
105 | + if (hi < addr) { | ||
106 | + return MEMTX_DECODE_ERROR; | ||
107 | + } | ||
108 | + | ||
109 | + if (!FIELD_EX32(u->reg.cap, CAP, 64AS) && (hi >> 32)) { | ||
110 | + return MEMTX_DECODE_ERROR; | ||
111 | + } | ||
112 | + | ||
113 | + return pci_dma_read(PCI_DEVICE(u), addr, buf, size); | ||
114 | +} | ||
115 | + | ||
116 | +static MemTxResult ufs_addr_write(UfsHc *u, hwaddr addr, const void *buf, | ||
117 | + int size) | ||
118 | +{ | ||
119 | + hwaddr hi = addr + size - 1; | ||
120 | + if (hi < addr) { | ||
121 | + return MEMTX_DECODE_ERROR; | ||
122 | + } | ||
123 | + | ||
124 | + if (!FIELD_EX32(u->reg.cap, CAP, 64AS) && (hi >> 32)) { | ||
125 | + return MEMTX_DECODE_ERROR; | ||
126 | + } | ||
127 | + | ||
128 | + return pci_dma_write(PCI_DEVICE(u), addr, buf, size); | ||
129 | +} | ||
130 | + | ||
131 | +static void ufs_complete_req(UfsRequest *req, UfsReqResult req_result); | ||
132 | + | ||
133 | +static inline hwaddr ufs_get_utrd_addr(UfsHc *u, uint32_t slot) | ||
134 | +{ | ||
135 | + hwaddr utrl_base_addr = (((hwaddr)u->reg.utrlbau) << 32) + u->reg.utrlba; | ||
136 | + hwaddr utrd_addr = utrl_base_addr + slot * sizeof(UtpTransferReqDesc); | ||
137 | + | ||
138 | + return utrd_addr; | ||
139 | +} | ||
140 | + | ||
141 | +static inline hwaddr ufs_get_req_upiu_base_addr(const UtpTransferReqDesc *utrd) | ||
142 | +{ | ||
143 | + uint32_t cmd_desc_base_addr_lo = | ||
144 | + le32_to_cpu(utrd->command_desc_base_addr_lo); | ||
145 | + uint32_t cmd_desc_base_addr_hi = | ||
146 | + le32_to_cpu(utrd->command_desc_base_addr_hi); | ||
147 | + | ||
148 | + return (((hwaddr)cmd_desc_base_addr_hi) << 32) + cmd_desc_base_addr_lo; | ||
149 | +} | ||
150 | + | ||
151 | +static inline hwaddr ufs_get_rsp_upiu_base_addr(const UtpTransferReqDesc *utrd) | ||
152 | +{ | ||
153 | + hwaddr req_upiu_base_addr = ufs_get_req_upiu_base_addr(utrd); | ||
154 | + uint32_t rsp_upiu_byte_off = | ||
155 | + le16_to_cpu(utrd->response_upiu_offset) * sizeof(uint32_t); | ||
156 | + return req_upiu_base_addr + rsp_upiu_byte_off; | ||
157 | +} | ||
158 | + | ||
159 | +static MemTxResult ufs_dma_read_utrd(UfsRequest *req) | ||
160 | +{ | ||
161 | + UfsHc *u = req->hc; | ||
162 | + hwaddr utrd_addr = ufs_get_utrd_addr(u, req->slot); | ||
163 | + MemTxResult ret; | ||
164 | + | ||
165 | + ret = ufs_addr_read(u, utrd_addr, &req->utrd, sizeof(req->utrd)); | ||
166 | + if (ret) { | ||
167 | + trace_ufs_err_dma_read_utrd(req->slot, utrd_addr); | ||
168 | + } | ||
169 | + return ret; | ||
170 | +} | ||
171 | + | ||
172 | +static MemTxResult ufs_dma_read_req_upiu(UfsRequest *req) | ||
173 | +{ | ||
174 | + UfsHc *u = req->hc; | ||
175 | + hwaddr req_upiu_base_addr = ufs_get_req_upiu_base_addr(&req->utrd); | ||
176 | + UtpUpiuReq *req_upiu = &req->req_upiu; | ||
177 | + uint32_t copy_size; | ||
178 | + uint16_t data_segment_length; | ||
179 | + MemTxResult ret; | ||
180 | + | ||
181 | + /* | ||
182 | + * To know the size of the req_upiu, we need to read the | ||
183 | + * data_segment_length in the header first. | ||
184 | + */ | ||
185 | + ret = ufs_addr_read(u, req_upiu_base_addr, &req_upiu->header, | ||
186 | + sizeof(UtpUpiuHeader)); | ||
187 | + if (ret) { | ||
188 | + trace_ufs_err_dma_read_req_upiu(req->slot, req_upiu_base_addr); | ||
189 | + return ret; | ||
190 | + } | ||
191 | + data_segment_length = be16_to_cpu(req_upiu->header.data_segment_length); | ||
192 | + | ||
193 | + copy_size = sizeof(UtpUpiuHeader) + UFS_TRANSACTION_SPECIFIC_FIELD_SIZE + | ||
194 | + data_segment_length; | ||
195 | + | ||
196 | + ret = ufs_addr_read(u, req_upiu_base_addr, &req->req_upiu, copy_size); | ||
197 | + if (ret) { | ||
198 | + trace_ufs_err_dma_read_req_upiu(req->slot, req_upiu_base_addr); | ||
199 | + } | ||
200 | + return ret; | ||
201 | +} | ||
202 | + | ||
203 | +static MemTxResult ufs_dma_read_prdt(UfsRequest *req) | ||
204 | +{ | ||
205 | + UfsHc *u = req->hc; | ||
206 | + uint16_t prdt_len = le16_to_cpu(req->utrd.prd_table_length); | ||
207 | + uint16_t prdt_byte_off = | ||
208 | + le16_to_cpu(req->utrd.prd_table_offset) * sizeof(uint32_t); | ||
209 | + uint32_t prdt_size = prdt_len * sizeof(UfshcdSgEntry); | ||
210 | + g_autofree UfshcdSgEntry *prd_entries = NULL; | ||
211 | + hwaddr req_upiu_base_addr, prdt_base_addr; | ||
212 | + int err; | ||
213 | + | ||
214 | + assert(!req->sg); | ||
215 | + | ||
216 | + if (prdt_size == 0) { | ||
217 | + return MEMTX_OK; | ||
218 | + } | ||
219 | + prd_entries = g_new(UfshcdSgEntry, prdt_size); | ||
220 | + | ||
221 | + req_upiu_base_addr = ufs_get_req_upiu_base_addr(&req->utrd); | ||
222 | + prdt_base_addr = req_upiu_base_addr + prdt_byte_off; | ||
223 | + | ||
224 | + err = ufs_addr_read(u, prdt_base_addr, prd_entries, prdt_size); | ||
225 | + if (err) { | ||
226 | + trace_ufs_err_dma_read_prdt(req->slot, prdt_base_addr); | ||
227 | + return err; | ||
228 | + } | ||
229 | + | ||
230 | + req->sg = g_malloc0(sizeof(QEMUSGList)); | ||
231 | + pci_dma_sglist_init(req->sg, PCI_DEVICE(u), prdt_len); | ||
232 | + | ||
233 | + for (uint16_t i = 0; i < prdt_len; ++i) { | ||
234 | + hwaddr data_dma_addr = le64_to_cpu(prd_entries[i].addr); | ||
235 | + uint32_t data_byte_count = le32_to_cpu(prd_entries[i].size) + 1; | ||
236 | + qemu_sglist_add(req->sg, data_dma_addr, data_byte_count); | ||
237 | + } | ||
238 | + return MEMTX_OK; | ||
239 | +} | ||
240 | + | ||
241 | +static MemTxResult ufs_dma_read_upiu(UfsRequest *req) | ||
242 | +{ | ||
243 | + MemTxResult ret; | ||
244 | + | ||
245 | + ret = ufs_dma_read_utrd(req); | ||
246 | + if (ret) { | ||
247 | + return ret; | ||
248 | + } | ||
249 | + | ||
250 | + ret = ufs_dma_read_req_upiu(req); | ||
251 | + if (ret) { | ||
252 | + return ret; | ||
253 | + } | ||
254 | + | ||
255 | + ret = ufs_dma_read_prdt(req); | ||
256 | + if (ret) { | ||
257 | + return ret; | ||
258 | + } | ||
259 | + | ||
260 | + return 0; | ||
261 | +} | ||
262 | + | ||
263 | +static MemTxResult ufs_dma_write_utrd(UfsRequest *req) | ||
264 | +{ | ||
265 | + UfsHc *u = req->hc; | ||
266 | + hwaddr utrd_addr = ufs_get_utrd_addr(u, req->slot); | ||
267 | + MemTxResult ret; | ||
268 | + | ||
269 | + ret = ufs_addr_write(u, utrd_addr, &req->utrd, sizeof(req->utrd)); | ||
270 | + if (ret) { | ||
271 | + trace_ufs_err_dma_write_utrd(req->slot, utrd_addr); | ||
272 | + } | ||
273 | + return ret; | ||
274 | +} | ||
275 | + | ||
276 | +static MemTxResult ufs_dma_write_rsp_upiu(UfsRequest *req) | ||
277 | +{ | ||
278 | + UfsHc *u = req->hc; | ||
279 | + hwaddr rsp_upiu_base_addr = ufs_get_rsp_upiu_base_addr(&req->utrd); | ||
280 | + uint32_t rsp_upiu_byte_len = | ||
281 | + le16_to_cpu(req->utrd.response_upiu_length) * sizeof(uint32_t); | ||
282 | + uint16_t data_segment_length = | ||
283 | + be16_to_cpu(req->rsp_upiu.header.data_segment_length); | ||
284 | + uint32_t copy_size = sizeof(UtpUpiuHeader) + | ||
285 | + UFS_TRANSACTION_SPECIFIC_FIELD_SIZE + | ||
286 | + data_segment_length; | ||
287 | + MemTxResult ret; | ||
288 | + | ||
289 | + if (copy_size > rsp_upiu_byte_len) { | ||
290 | + copy_size = rsp_upiu_byte_len; | ||
291 | + } | ||
292 | + | ||
293 | + ret = ufs_addr_write(u, rsp_upiu_base_addr, &req->rsp_upiu, copy_size); | ||
294 | + if (ret) { | ||
295 | + trace_ufs_err_dma_write_rsp_upiu(req->slot, rsp_upiu_base_addr); | ||
296 | + } | ||
297 | + return ret; | ||
298 | +} | ||
299 | + | ||
300 | +static MemTxResult ufs_dma_write_upiu(UfsRequest *req) | ||
301 | +{ | ||
302 | + MemTxResult ret; | ||
303 | + | ||
304 | + ret = ufs_dma_write_rsp_upiu(req); | ||
305 | + if (ret) { | ||
306 | + return ret; | ||
307 | + } | ||
308 | + | ||
309 | + return ufs_dma_write_utrd(req); | ||
310 | +} | ||
311 | + | ||
312 | static void ufs_irq_check(UfsHc *u) | ||
313 | { | ||
314 | PCIDevice *pci = PCI_DEVICE(u); | ||
315 | @@ -XXX,XX +XXX,XX @@ static void ufs_irq_check(UfsHc *u) | ||
316 | } | ||
51 | } | 317 | } |
52 | 318 | ||
53 | +static int blkdebug_parse_perm_list(uint64_t *dest, QDict *options, | 319 | +static void ufs_process_db(UfsHc *u, uint32_t val) |
54 | + const char *prefix, Error **errp) | 320 | +{ |
55 | +{ | 321 | + unsigned long doorbell; |
56 | + int ret = 0; | 322 | + uint32_t slot; |
57 | + QDict *subqdict = NULL; | 323 | + uint32_t nutrs = u->params.nutrs; |
58 | + QObject *crumpled_subqdict = NULL; | 324 | + UfsRequest *req; |
59 | + Visitor *v = NULL; | 325 | + |
60 | + BlockPermissionList *perm_list = NULL, *element; | 326 | + val &= ~u->reg.utrldbr; |
61 | + Error *local_err = NULL; | 327 | + if (!val) { |
62 | + | 328 | + return; |
63 | + *dest = 0; | 329 | + } |
64 | + | 330 | + |
65 | + qdict_extract_subqdict(options, &subqdict, prefix); | 331 | + doorbell = val; |
66 | + if (!qdict_size(subqdict)) { | 332 | + slot = find_first_bit(&doorbell, nutrs); |
67 | + goto out; | 333 | + |
68 | + } | 334 | + while (slot < nutrs) { |
69 | + | 335 | + req = &u->req_list[slot]; |
70 | + crumpled_subqdict = qdict_crumple(subqdict, errp); | 336 | + if (req->state == UFS_REQUEST_ERROR) { |
71 | + if (!crumpled_subqdict) { | 337 | + trace_ufs_err_utrl_slot_error(req->slot); |
72 | + ret = -EINVAL; | 338 | + return; |
73 | + goto out; | 339 | + } |
74 | + } | 340 | + |
75 | + | 341 | + if (req->state != UFS_REQUEST_IDLE) { |
76 | + v = qobject_input_visitor_new(crumpled_subqdict); | 342 | + trace_ufs_err_utrl_slot_busy(req->slot); |
77 | + visit_type_BlockPermissionList(v, NULL, &perm_list, &local_err); | 343 | + return; |
78 | + if (local_err) { | 344 | + } |
79 | + error_propagate(errp, local_err); | 345 | + |
80 | + ret = -EINVAL; | 346 | + trace_ufs_process_db(slot); |
81 | + goto out; | 347 | + req->state = UFS_REQUEST_READY; |
82 | + } | 348 | + slot = find_next_bit(&doorbell, nutrs, slot + 1); |
83 | + | 349 | + } |
84 | + for (element = perm_list; element; element = element->next) { | 350 | + |
85 | + *dest |= bdrv_qapi_perm_to_blk_perm(element->value); | 351 | + qemu_bh_schedule(u->doorbell_bh); |
86 | + } | 352 | +} |
87 | + | 353 | + |
88 | +out: | 354 | static void ufs_process_uiccmd(UfsHc *u, uint32_t val) |
89 | + qapi_free_BlockPermissionList(perm_list); | 355 | { |
90 | + visit_free(v); | 356 | trace_ufs_process_uiccmd(val, u->reg.ucmdarg1, u->reg.ucmdarg2, |
91 | + qobject_unref(subqdict); | 357 | @@ -XXX,XX +XXX,XX @@ static void ufs_write_reg(UfsHc *u, hwaddr offset, uint32_t data, unsigned size) |
92 | + qobject_unref(crumpled_subqdict); | 358 | u->reg.utrlbau = data; |
93 | + return ret; | 359 | break; |
94 | +} | 360 | case A_UTRLDBR: |
95 | + | 361 | - /* Not yet supported */ |
96 | +static int blkdebug_parse_perms(BDRVBlkdebugState *s, QDict *options, | 362 | + ufs_process_db(u, data); |
97 | + Error **errp) | 363 | + u->reg.utrldbr |= data; |
98 | +{ | 364 | break; |
99 | + int ret; | 365 | case A_UTRLRSR: |
100 | + | 366 | u->reg.utrlrsr = data; |
101 | + ret = blkdebug_parse_perm_list(&s->take_child_perms, options, | 367 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps ufs_mmio_ops = { |
102 | + "take-child-perms.", errp); | 368 | }, |
103 | + if (ret < 0) { | 369 | }; |
370 | |||
371 | +static void ufs_build_upiu_header(UfsRequest *req, uint8_t trans_type, | ||
372 | + uint8_t flags, uint8_t response, | ||
373 | + uint8_t scsi_status, | ||
374 | + uint16_t data_segment_length) | ||
375 | +{ | ||
376 | + memcpy(&req->rsp_upiu.header, &req->req_upiu.header, sizeof(UtpUpiuHeader)); | ||
377 | + req->rsp_upiu.header.trans_type = trans_type; | ||
378 | + req->rsp_upiu.header.flags = flags; | ||
379 | + req->rsp_upiu.header.response = response; | ||
380 | + req->rsp_upiu.header.scsi_status = scsi_status; | ||
381 | + req->rsp_upiu.header.data_segment_length = cpu_to_be16(data_segment_length); | ||
382 | +} | ||
383 | + | ||
384 | +static UfsReqResult ufs_exec_nop_cmd(UfsRequest *req) | ||
385 | +{ | ||
386 | + trace_ufs_exec_nop_cmd(req->slot); | ||
387 | + ufs_build_upiu_header(req, UFS_UPIU_TRANSACTION_NOP_IN, 0, 0, 0, 0); | ||
388 | + return UFS_REQUEST_SUCCESS; | ||
389 | +} | ||
390 | + | ||
391 | +/* | ||
392 | + * This defines the permission of flags based on their IDN. There are some | ||
393 | + * things that are declared read-only, which is inconsistent with the ufs spec, | ||
394 | + * because we want to return an error for features that are not yet supported. | ||
395 | + */ | ||
396 | +static const int flag_permission[UFS_QUERY_FLAG_IDN_COUNT] = { | ||
397 | + [UFS_QUERY_FLAG_IDN_FDEVICEINIT] = UFS_QUERY_FLAG_READ | UFS_QUERY_FLAG_SET, | ||
398 | + /* Write protection is not supported */ | ||
399 | + [UFS_QUERY_FLAG_IDN_PERMANENT_WPE] = UFS_QUERY_FLAG_READ, | ||
400 | + [UFS_QUERY_FLAG_IDN_PWR_ON_WPE] = UFS_QUERY_FLAG_READ, | ||
401 | + [UFS_QUERY_FLAG_IDN_BKOPS_EN] = UFS_QUERY_FLAG_READ | UFS_QUERY_FLAG_SET | | ||
402 | + UFS_QUERY_FLAG_CLEAR | | ||
403 | + UFS_QUERY_FLAG_TOGGLE, | ||
404 | + [UFS_QUERY_FLAG_IDN_LIFE_SPAN_MODE_ENABLE] = | ||
405 | + UFS_QUERY_FLAG_READ | UFS_QUERY_FLAG_SET | UFS_QUERY_FLAG_CLEAR | | ||
406 | + UFS_QUERY_FLAG_TOGGLE, | ||
407 | + /* Purge Operation is not supported */ | ||
408 | + [UFS_QUERY_FLAG_IDN_PURGE_ENABLE] = UFS_QUERY_FLAG_NONE, | ||
409 | + /* Refresh Operation is not supported */ | ||
410 | + [UFS_QUERY_FLAG_IDN_REFRESH_ENABLE] = UFS_QUERY_FLAG_NONE, | ||
411 | + /* Physical Resource Removal is not supported */ | ||
412 | + [UFS_QUERY_FLAG_IDN_FPHYRESOURCEREMOVAL] = UFS_QUERY_FLAG_READ, | ||
413 | + [UFS_QUERY_FLAG_IDN_BUSY_RTC] = UFS_QUERY_FLAG_READ, | ||
414 | + [UFS_QUERY_FLAG_IDN_PERMANENTLY_DISABLE_FW_UPDATE] = UFS_QUERY_FLAG_READ, | ||
415 | + /* Write Booster is not supported */ | ||
416 | + [UFS_QUERY_FLAG_IDN_WB_EN] = UFS_QUERY_FLAG_READ, | ||
417 | + [UFS_QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN] = UFS_QUERY_FLAG_READ, | ||
418 | + [UFS_QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8] = UFS_QUERY_FLAG_READ, | ||
419 | +}; | ||
420 | + | ||
421 | +static inline QueryRespCode ufs_flag_check_idn_valid(uint8_t idn, int op) | ||
422 | +{ | ||
423 | + if (idn >= UFS_QUERY_FLAG_IDN_COUNT) { | ||
424 | + return UFS_QUERY_RESULT_INVALID_IDN; | ||
425 | + } | ||
426 | + | ||
427 | + if (!(flag_permission[idn] & op)) { | ||
428 | + if (op == UFS_QUERY_FLAG_READ) { | ||
429 | + trace_ufs_err_query_flag_not_readable(idn); | ||
430 | + return UFS_QUERY_RESULT_NOT_READABLE; | ||
431 | + } | ||
432 | + trace_ufs_err_query_flag_not_writable(idn); | ||
433 | + return UFS_QUERY_RESULT_NOT_WRITEABLE; | ||
434 | + } | ||
435 | + | ||
436 | + return UFS_QUERY_RESULT_SUCCESS; | ||
437 | +} | ||
438 | + | ||
439 | +static const int attr_permission[UFS_QUERY_ATTR_IDN_COUNT] = { | ||
440 | + /* booting is not supported */ | ||
441 | + [UFS_QUERY_ATTR_IDN_BOOT_LU_EN] = UFS_QUERY_ATTR_READ, | ||
442 | + [UFS_QUERY_ATTR_IDN_POWER_MODE] = UFS_QUERY_ATTR_READ, | ||
443 | + [UFS_QUERY_ATTR_IDN_ACTIVE_ICC_LVL] = | ||
444 | + UFS_QUERY_ATTR_READ | UFS_QUERY_ATTR_WRITE, | ||
445 | + [UFS_QUERY_ATTR_IDN_OOO_DATA_EN] = UFS_QUERY_ATTR_READ, | ||
446 | + [UFS_QUERY_ATTR_IDN_BKOPS_STATUS] = UFS_QUERY_ATTR_READ, | ||
447 | + [UFS_QUERY_ATTR_IDN_PURGE_STATUS] = UFS_QUERY_ATTR_READ, | ||
448 | + [UFS_QUERY_ATTR_IDN_MAX_DATA_IN] = | ||
449 | + UFS_QUERY_ATTR_READ | UFS_QUERY_ATTR_WRITE, | ||
450 | + [UFS_QUERY_ATTR_IDN_MAX_DATA_OUT] = | ||
451 | + UFS_QUERY_ATTR_READ | UFS_QUERY_ATTR_WRITE, | ||
452 | + [UFS_QUERY_ATTR_IDN_DYN_CAP_NEEDED] = UFS_QUERY_ATTR_READ, | ||
453 | + [UFS_QUERY_ATTR_IDN_REF_CLK_FREQ] = | ||
454 | + UFS_QUERY_ATTR_READ | UFS_QUERY_ATTR_WRITE, | ||
455 | + [UFS_QUERY_ATTR_IDN_CONF_DESC_LOCK] = UFS_QUERY_ATTR_READ, | ||
456 | + [UFS_QUERY_ATTR_IDN_MAX_NUM_OF_RTT] = | ||
457 | + UFS_QUERY_ATTR_READ | UFS_QUERY_ATTR_WRITE, | ||
458 | + [UFS_QUERY_ATTR_IDN_EE_CONTROL] = | ||
459 | + UFS_QUERY_ATTR_READ | UFS_QUERY_ATTR_WRITE, | ||
460 | + [UFS_QUERY_ATTR_IDN_EE_STATUS] = UFS_QUERY_ATTR_READ, | ||
461 | + [UFS_QUERY_ATTR_IDN_SECONDS_PASSED] = UFS_QUERY_ATTR_WRITE, | ||
462 | + [UFS_QUERY_ATTR_IDN_CNTX_CONF] = UFS_QUERY_ATTR_READ, | ||
463 | + [UFS_QUERY_ATTR_IDN_FFU_STATUS] = UFS_QUERY_ATTR_READ, | ||
464 | + [UFS_QUERY_ATTR_IDN_PSA_STATE] = UFS_QUERY_ATTR_READ | UFS_QUERY_ATTR_WRITE, | ||
465 | + [UFS_QUERY_ATTR_IDN_PSA_DATA_SIZE] = | ||
466 | + UFS_QUERY_ATTR_READ | UFS_QUERY_ATTR_WRITE, | ||
467 | + [UFS_QUERY_ATTR_IDN_REF_CLK_GATING_WAIT_TIME] = UFS_QUERY_ATTR_READ, | ||
468 | + [UFS_QUERY_ATTR_IDN_CASE_ROUGH_TEMP] = UFS_QUERY_ATTR_READ, | ||
469 | + [UFS_QUERY_ATTR_IDN_HIGH_TEMP_BOUND] = UFS_QUERY_ATTR_READ, | ||
470 | + [UFS_QUERY_ATTR_IDN_LOW_TEMP_BOUND] = UFS_QUERY_ATTR_READ, | ||
471 | + [UFS_QUERY_ATTR_IDN_THROTTLING_STATUS] = UFS_QUERY_ATTR_READ, | ||
472 | + [UFS_QUERY_ATTR_IDN_WB_FLUSH_STATUS] = UFS_QUERY_ATTR_READ, | ||
473 | + [UFS_QUERY_ATTR_IDN_AVAIL_WB_BUFF_SIZE] = UFS_QUERY_ATTR_READ, | ||
474 | + [UFS_QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST] = UFS_QUERY_ATTR_READ, | ||
475 | + [UFS_QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE] = UFS_QUERY_ATTR_READ, | ||
476 | + /* refresh operation is not supported */ | ||
477 | + [UFS_QUERY_ATTR_IDN_REFRESH_STATUS] = UFS_QUERY_ATTR_READ, | ||
478 | + [UFS_QUERY_ATTR_IDN_REFRESH_FREQ] = UFS_QUERY_ATTR_READ, | ||
479 | + [UFS_QUERY_ATTR_IDN_REFRESH_UNIT] = UFS_QUERY_ATTR_READ, | ||
480 | +}; | ||
481 | + | ||
482 | +static inline QueryRespCode ufs_attr_check_idn_valid(uint8_t idn, int op) | ||
483 | +{ | ||
484 | + if (idn >= UFS_QUERY_ATTR_IDN_COUNT) { | ||
485 | + return UFS_QUERY_RESULT_INVALID_IDN; | ||
486 | + } | ||
487 | + | ||
488 | + if (!(attr_permission[idn] & op)) { | ||
489 | + if (op == UFS_QUERY_ATTR_READ) { | ||
490 | + trace_ufs_err_query_attr_not_readable(idn); | ||
491 | + return UFS_QUERY_RESULT_NOT_READABLE; | ||
492 | + } | ||
493 | + trace_ufs_err_query_attr_not_writable(idn); | ||
494 | + return UFS_QUERY_RESULT_NOT_WRITEABLE; | ||
495 | + } | ||
496 | + | ||
497 | + return UFS_QUERY_RESULT_SUCCESS; | ||
498 | +} | ||
499 | + | ||
500 | +static QueryRespCode ufs_exec_query_flag(UfsRequest *req, int op) | ||
501 | +{ | ||
502 | + UfsHc *u = req->hc; | ||
503 | + uint8_t idn = req->req_upiu.qr.idn; | ||
504 | + uint32_t value; | ||
505 | + QueryRespCode ret; | ||
506 | + | ||
507 | + ret = ufs_flag_check_idn_valid(idn, op); | ||
508 | + if (ret) { | ||
104 | + return ret; | 509 | + return ret; |
105 | + } | 510 | + } |
106 | + | 511 | + |
107 | + ret = blkdebug_parse_perm_list(&s->unshare_child_perms, options, | 512 | + if (idn == UFS_QUERY_FLAG_IDN_FDEVICEINIT) { |
108 | + "unshare-child-perms.", errp); | 513 | + value = 0; |
109 | + if (ret < 0) { | 514 | + } else if (op == UFS_QUERY_FLAG_READ) { |
515 | + value = *(((uint8_t *)&u->flags) + idn); | ||
516 | + } else if (op == UFS_QUERY_FLAG_SET) { | ||
517 | + value = 1; | ||
518 | + } else if (op == UFS_QUERY_FLAG_CLEAR) { | ||
519 | + value = 0; | ||
520 | + } else if (op == UFS_QUERY_FLAG_TOGGLE) { | ||
521 | + value = *(((uint8_t *)&u->flags) + idn); | ||
522 | + value = !value; | ||
523 | + } else { | ||
524 | + trace_ufs_err_query_invalid_opcode(op); | ||
525 | + return UFS_QUERY_RESULT_INVALID_OPCODE; | ||
526 | + } | ||
527 | + | ||
528 | + *(((uint8_t *)&u->flags) + idn) = value; | ||
529 | + req->rsp_upiu.qr.value = cpu_to_be32(value); | ||
530 | + return UFS_QUERY_RESULT_SUCCESS; | ||
531 | +} | ||
532 | + | ||
533 | +static uint32_t ufs_read_attr_value(UfsHc *u, uint8_t idn) | ||
534 | +{ | ||
535 | + switch (idn) { | ||
536 | + case UFS_QUERY_ATTR_IDN_BOOT_LU_EN: | ||
537 | + return u->attributes.boot_lun_en; | ||
538 | + case UFS_QUERY_ATTR_IDN_POWER_MODE: | ||
539 | + return u->attributes.current_power_mode; | ||
540 | + case UFS_QUERY_ATTR_IDN_ACTIVE_ICC_LVL: | ||
541 | + return u->attributes.active_icc_level; | ||
542 | + case UFS_QUERY_ATTR_IDN_OOO_DATA_EN: | ||
543 | + return u->attributes.out_of_order_data_en; | ||
544 | + case UFS_QUERY_ATTR_IDN_BKOPS_STATUS: | ||
545 | + return u->attributes.background_op_status; | ||
546 | + case UFS_QUERY_ATTR_IDN_PURGE_STATUS: | ||
547 | + return u->attributes.purge_status; | ||
548 | + case UFS_QUERY_ATTR_IDN_MAX_DATA_IN: | ||
549 | + return u->attributes.max_data_in_size; | ||
550 | + case UFS_QUERY_ATTR_IDN_MAX_DATA_OUT: | ||
551 | + return u->attributes.max_data_out_size; | ||
552 | + case UFS_QUERY_ATTR_IDN_DYN_CAP_NEEDED: | ||
553 | + return be32_to_cpu(u->attributes.dyn_cap_needed); | ||
554 | + case UFS_QUERY_ATTR_IDN_REF_CLK_FREQ: | ||
555 | + return u->attributes.ref_clk_freq; | ||
556 | + case UFS_QUERY_ATTR_IDN_CONF_DESC_LOCK: | ||
557 | + return u->attributes.config_descr_lock; | ||
558 | + case UFS_QUERY_ATTR_IDN_MAX_NUM_OF_RTT: | ||
559 | + return u->attributes.max_num_of_rtt; | ||
560 | + case UFS_QUERY_ATTR_IDN_EE_CONTROL: | ||
561 | + return be16_to_cpu(u->attributes.exception_event_control); | ||
562 | + case UFS_QUERY_ATTR_IDN_EE_STATUS: | ||
563 | + return be16_to_cpu(u->attributes.exception_event_status); | ||
564 | + case UFS_QUERY_ATTR_IDN_SECONDS_PASSED: | ||
565 | + return be32_to_cpu(u->attributes.seconds_passed); | ||
566 | + case UFS_QUERY_ATTR_IDN_CNTX_CONF: | ||
567 | + return be16_to_cpu(u->attributes.context_conf); | ||
568 | + case UFS_QUERY_ATTR_IDN_FFU_STATUS: | ||
569 | + return u->attributes.device_ffu_status; | ||
570 | + case UFS_QUERY_ATTR_IDN_PSA_STATE: | ||
571 | + return be32_to_cpu(u->attributes.psa_state); | ||
572 | + case UFS_QUERY_ATTR_IDN_PSA_DATA_SIZE: | ||
573 | + return be32_to_cpu(u->attributes.psa_data_size); | ||
574 | + case UFS_QUERY_ATTR_IDN_REF_CLK_GATING_WAIT_TIME: | ||
575 | + return u->attributes.ref_clk_gating_wait_time; | ||
576 | + case UFS_QUERY_ATTR_IDN_CASE_ROUGH_TEMP: | ||
577 | + return u->attributes.device_case_rough_temperaure; | ||
578 | + case UFS_QUERY_ATTR_IDN_HIGH_TEMP_BOUND: | ||
579 | + return u->attributes.device_too_high_temp_boundary; | ||
580 | + case UFS_QUERY_ATTR_IDN_LOW_TEMP_BOUND: | ||
581 | + return u->attributes.device_too_low_temp_boundary; | ||
582 | + case UFS_QUERY_ATTR_IDN_THROTTLING_STATUS: | ||
583 | + return u->attributes.throttling_status; | ||
584 | + case UFS_QUERY_ATTR_IDN_WB_FLUSH_STATUS: | ||
585 | + return u->attributes.wb_buffer_flush_status; | ||
586 | + case UFS_QUERY_ATTR_IDN_AVAIL_WB_BUFF_SIZE: | ||
587 | + return u->attributes.available_wb_buffer_size; | ||
588 | + case UFS_QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST: | ||
589 | + return u->attributes.wb_buffer_life_time_est; | ||
590 | + case UFS_QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE: | ||
591 | + return be32_to_cpu(u->attributes.current_wb_buffer_size); | ||
592 | + case UFS_QUERY_ATTR_IDN_REFRESH_STATUS: | ||
593 | + return u->attributes.refresh_status; | ||
594 | + case UFS_QUERY_ATTR_IDN_REFRESH_FREQ: | ||
595 | + return u->attributes.refresh_freq; | ||
596 | + case UFS_QUERY_ATTR_IDN_REFRESH_UNIT: | ||
597 | + return u->attributes.refresh_unit; | ||
598 | + } | ||
599 | + return 0; | ||
600 | +} | ||
601 | + | ||
602 | +static void ufs_write_attr_value(UfsHc *u, uint8_t idn, uint32_t value) | ||
603 | +{ | ||
604 | + switch (idn) { | ||
605 | + case UFS_QUERY_ATTR_IDN_ACTIVE_ICC_LVL: | ||
606 | + u->attributes.active_icc_level = value; | ||
607 | + break; | ||
608 | + case UFS_QUERY_ATTR_IDN_MAX_DATA_IN: | ||
609 | + u->attributes.max_data_in_size = value; | ||
610 | + break; | ||
611 | + case UFS_QUERY_ATTR_IDN_MAX_DATA_OUT: | ||
612 | + u->attributes.max_data_out_size = value; | ||
613 | + break; | ||
614 | + case UFS_QUERY_ATTR_IDN_REF_CLK_FREQ: | ||
615 | + u->attributes.ref_clk_freq = value; | ||
616 | + break; | ||
617 | + case UFS_QUERY_ATTR_IDN_MAX_NUM_OF_RTT: | ||
618 | + u->attributes.max_num_of_rtt = value; | ||
619 | + break; | ||
620 | + case UFS_QUERY_ATTR_IDN_EE_CONTROL: | ||
621 | + u->attributes.exception_event_control = cpu_to_be16(value); | ||
622 | + break; | ||
623 | + case UFS_QUERY_ATTR_IDN_SECONDS_PASSED: | ||
624 | + u->attributes.seconds_passed = cpu_to_be32(value); | ||
625 | + break; | ||
626 | + case UFS_QUERY_ATTR_IDN_PSA_STATE: | ||
627 | + u->attributes.psa_state = value; | ||
628 | + break; | ||
629 | + case UFS_QUERY_ATTR_IDN_PSA_DATA_SIZE: | ||
630 | + u->attributes.psa_data_size = cpu_to_be32(value); | ||
631 | + break; | ||
632 | + } | ||
633 | +} | ||
634 | + | ||
635 | +static QueryRespCode ufs_exec_query_attr(UfsRequest *req, int op) | ||
636 | +{ | ||
637 | + UfsHc *u = req->hc; | ||
638 | + uint8_t idn = req->req_upiu.qr.idn; | ||
639 | + uint32_t value; | ||
640 | + QueryRespCode ret; | ||
641 | + | ||
642 | + ret = ufs_attr_check_idn_valid(idn, op); | ||
643 | + if (ret) { | ||
110 | + return ret; | 644 | + return ret; |
111 | + } | 645 | + } |
112 | + | 646 | + |
113 | + return 0; | 647 | + if (op == UFS_QUERY_ATTR_READ) { |
114 | +} | 648 | + value = ufs_read_attr_value(u, idn); |
115 | + | 649 | + } else { |
116 | static QemuOptsList runtime_opts = { | 650 | + value = be32_to_cpu(req->req_upiu.qr.value); |
117 | .name = "blkdebug", | 651 | + ufs_write_attr_value(u, idn, value); |
118 | .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), | 652 | + } |
119 | @@ -XXX,XX +XXX,XX @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, | 653 | + |
120 | /* Set initial state */ | 654 | + req->rsp_upiu.qr.value = cpu_to_be32(value); |
121 | s->state = 1; | 655 | + return UFS_QUERY_RESULT_SUCCESS; |
122 | 656 | +} | |
123 | + /* Parse permissions modifiers before opening the image file */ | 657 | + |
124 | + ret = blkdebug_parse_perms(s, options, errp); | 658 | +static const RpmbUnitDescriptor rpmb_unit_desc = { |
125 | + if (ret < 0) { | 659 | + .length = sizeof(RpmbUnitDescriptor), |
126 | + goto out; | 660 | + .descriptor_idn = 2, |
127 | + } | 661 | + .unit_index = UFS_UPIU_RPMB_WLUN, |
128 | + | 662 | + .lu_enable = 0, |
129 | /* Open the image file */ | 663 | +}; |
130 | bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image", | 664 | + |
131 | bs, &child_file, false, &local_err); | 665 | +static QueryRespCode ufs_read_unit_desc(UfsRequest *req) |
132 | @@ -XXX,XX +XXX,XX @@ static int blkdebug_reopen_prepare(BDRVReopenState *reopen_state, | 666 | +{ |
133 | return 0; | 667 | + uint8_t lun = req->req_upiu.qr.index; |
668 | + | ||
669 | + if (lun != UFS_UPIU_RPMB_WLUN && lun > UFS_MAX_LUS) { | ||
670 | + trace_ufs_err_query_invalid_index(req->req_upiu.qr.opcode, lun); | ||
671 | + return UFS_QUERY_RESULT_INVALID_INDEX; | ||
672 | + } | ||
673 | + | ||
674 | + if (lun == UFS_UPIU_RPMB_WLUN) { | ||
675 | + memcpy(&req->rsp_upiu.qr.data, &rpmb_unit_desc, rpmb_unit_desc.length); | ||
676 | + } else { | ||
677 | + /* unit descriptor is not yet supported */ | ||
678 | + return UFS_QUERY_RESULT_INVALID_INDEX; | ||
679 | + } | ||
680 | + | ||
681 | + return UFS_QUERY_RESULT_SUCCESS; | ||
682 | +} | ||
683 | + | ||
684 | +static inline StringDescriptor manufacturer_str_desc(void) | ||
685 | +{ | ||
686 | + StringDescriptor desc = { | ||
687 | + .length = 0x12, | ||
688 | + .descriptor_idn = UFS_QUERY_DESC_IDN_STRING, | ||
689 | + }; | ||
690 | + desc.UC[0] = cpu_to_be16('R'); | ||
691 | + desc.UC[1] = cpu_to_be16('E'); | ||
692 | + desc.UC[2] = cpu_to_be16('D'); | ||
693 | + desc.UC[3] = cpu_to_be16('H'); | ||
694 | + desc.UC[4] = cpu_to_be16('A'); | ||
695 | + desc.UC[5] = cpu_to_be16('T'); | ||
696 | + return desc; | ||
697 | +} | ||
698 | + | ||
699 | +static inline StringDescriptor product_name_str_desc(void) | ||
700 | +{ | ||
701 | + StringDescriptor desc = { | ||
702 | + .length = 0x22, | ||
703 | + .descriptor_idn = UFS_QUERY_DESC_IDN_STRING, | ||
704 | + }; | ||
705 | + desc.UC[0] = cpu_to_be16('Q'); | ||
706 | + desc.UC[1] = cpu_to_be16('E'); | ||
707 | + desc.UC[2] = cpu_to_be16('M'); | ||
708 | + desc.UC[3] = cpu_to_be16('U'); | ||
709 | + desc.UC[4] = cpu_to_be16(' '); | ||
710 | + desc.UC[5] = cpu_to_be16('U'); | ||
711 | + desc.UC[6] = cpu_to_be16('F'); | ||
712 | + desc.UC[7] = cpu_to_be16('S'); | ||
713 | + return desc; | ||
714 | +} | ||
715 | + | ||
716 | +static inline StringDescriptor product_rev_level_str_desc(void) | ||
717 | +{ | ||
718 | + StringDescriptor desc = { | ||
719 | + .length = 0x0a, | ||
720 | + .descriptor_idn = UFS_QUERY_DESC_IDN_STRING, | ||
721 | + }; | ||
722 | + desc.UC[0] = cpu_to_be16('0'); | ||
723 | + desc.UC[1] = cpu_to_be16('0'); | ||
724 | + desc.UC[2] = cpu_to_be16('0'); | ||
725 | + desc.UC[3] = cpu_to_be16('1'); | ||
726 | + return desc; | ||
727 | +} | ||
728 | + | ||
729 | +static const StringDescriptor null_str_desc = { | ||
730 | + .length = 0x02, | ||
731 | + .descriptor_idn = UFS_QUERY_DESC_IDN_STRING, | ||
732 | +}; | ||
733 | + | ||
734 | +static QueryRespCode ufs_read_string_desc(UfsRequest *req) | ||
735 | +{ | ||
736 | + UfsHc *u = req->hc; | ||
737 | + uint8_t index = req->req_upiu.qr.index; | ||
738 | + StringDescriptor desc; | ||
739 | + | ||
740 | + if (index == u->device_desc.manufacturer_name) { | ||
741 | + desc = manufacturer_str_desc(); | ||
742 | + memcpy(&req->rsp_upiu.qr.data, &desc, desc.length); | ||
743 | + } else if (index == u->device_desc.product_name) { | ||
744 | + desc = product_name_str_desc(); | ||
745 | + memcpy(&req->rsp_upiu.qr.data, &desc, desc.length); | ||
746 | + } else if (index == u->device_desc.serial_number) { | ||
747 | + memcpy(&req->rsp_upiu.qr.data, &null_str_desc, null_str_desc.length); | ||
748 | + } else if (index == u->device_desc.oem_id) { | ||
749 | + memcpy(&req->rsp_upiu.qr.data, &null_str_desc, null_str_desc.length); | ||
750 | + } else if (index == u->device_desc.product_revision_level) { | ||
751 | + desc = product_rev_level_str_desc(); | ||
752 | + memcpy(&req->rsp_upiu.qr.data, &desc, desc.length); | ||
753 | + } else { | ||
754 | + trace_ufs_err_query_invalid_index(req->req_upiu.qr.opcode, index); | ||
755 | + return UFS_QUERY_RESULT_INVALID_INDEX; | ||
756 | + } | ||
757 | + return UFS_QUERY_RESULT_SUCCESS; | ||
758 | +} | ||
759 | + | ||
760 | +static inline InterconnectDescriptor interconnect_desc(void) | ||
761 | +{ | ||
762 | + InterconnectDescriptor desc = { | ||
763 | + .length = sizeof(InterconnectDescriptor), | ||
764 | + .descriptor_idn = UFS_QUERY_DESC_IDN_INTERCONNECT, | ||
765 | + }; | ||
766 | + desc.bcd_unipro_version = cpu_to_be16(0x180); | ||
767 | + desc.bcd_mphy_version = cpu_to_be16(0x410); | ||
768 | + return desc; | ||
769 | +} | ||
770 | + | ||
771 | +static QueryRespCode ufs_read_desc(UfsRequest *req) | ||
772 | +{ | ||
773 | + UfsHc *u = req->hc; | ||
774 | + QueryRespCode status; | ||
775 | + uint8_t idn = req->req_upiu.qr.idn; | ||
776 | + uint16_t length = be16_to_cpu(req->req_upiu.qr.length); | ||
777 | + InterconnectDescriptor desc; | ||
778 | + | ||
779 | + switch (idn) { | ||
780 | + case UFS_QUERY_DESC_IDN_DEVICE: | ||
781 | + memcpy(&req->rsp_upiu.qr.data, &u->device_desc, sizeof(u->device_desc)); | ||
782 | + status = UFS_QUERY_RESULT_SUCCESS; | ||
783 | + break; | ||
784 | + case UFS_QUERY_DESC_IDN_UNIT: | ||
785 | + status = ufs_read_unit_desc(req); | ||
786 | + break; | ||
787 | + case UFS_QUERY_DESC_IDN_GEOMETRY: | ||
788 | + memcpy(&req->rsp_upiu.qr.data, &u->geometry_desc, | ||
789 | + sizeof(u->geometry_desc)); | ||
790 | + status = UFS_QUERY_RESULT_SUCCESS; | ||
791 | + break; | ||
792 | + case UFS_QUERY_DESC_IDN_INTERCONNECT: { | ||
793 | + desc = interconnect_desc(); | ||
794 | + memcpy(&req->rsp_upiu.qr.data, &desc, sizeof(InterconnectDescriptor)); | ||
795 | + status = UFS_QUERY_RESULT_SUCCESS; | ||
796 | + break; | ||
797 | + } | ||
798 | + case UFS_QUERY_DESC_IDN_STRING: | ||
799 | + status = ufs_read_string_desc(req); | ||
800 | + break; | ||
801 | + case UFS_QUERY_DESC_IDN_POWER: | ||
802 | + /* mocking of power descriptor is not supported */ | ||
803 | + memset(&req->rsp_upiu.qr.data, 0, sizeof(PowerParametersDescriptor)); | ||
804 | + req->rsp_upiu.qr.data[0] = sizeof(PowerParametersDescriptor); | ||
805 | + req->rsp_upiu.qr.data[1] = UFS_QUERY_DESC_IDN_POWER; | ||
806 | + status = UFS_QUERY_RESULT_SUCCESS; | ||
807 | + break; | ||
808 | + case UFS_QUERY_DESC_IDN_HEALTH: | ||
809 | + /* mocking of health descriptor is not supported */ | ||
810 | + memset(&req->rsp_upiu.qr.data, 0, sizeof(DeviceHealthDescriptor)); | ||
811 | + req->rsp_upiu.qr.data[0] = sizeof(DeviceHealthDescriptor); | ||
812 | + req->rsp_upiu.qr.data[1] = UFS_QUERY_DESC_IDN_HEALTH; | ||
813 | + status = UFS_QUERY_RESULT_SUCCESS; | ||
814 | + break; | ||
815 | + default: | ||
816 | + length = 0; | ||
817 | + trace_ufs_err_query_invalid_idn(req->req_upiu.qr.opcode, idn); | ||
818 | + status = UFS_QUERY_RESULT_INVALID_IDN; | ||
819 | + } | ||
820 | + | ||
821 | + if (length > req->rsp_upiu.qr.data[0]) { | ||
822 | + length = req->rsp_upiu.qr.data[0]; | ||
823 | + } | ||
824 | + req->rsp_upiu.qr.opcode = req->req_upiu.qr.opcode; | ||
825 | + req->rsp_upiu.qr.idn = req->req_upiu.qr.idn; | ||
826 | + req->rsp_upiu.qr.index = req->req_upiu.qr.index; | ||
827 | + req->rsp_upiu.qr.selector = req->req_upiu.qr.selector; | ||
828 | + req->rsp_upiu.qr.length = cpu_to_be16(length); | ||
829 | + | ||
830 | + return status; | ||
831 | +} | ||
832 | + | ||
833 | +static QueryRespCode ufs_exec_query_read(UfsRequest *req) | ||
834 | +{ | ||
835 | + QueryRespCode status; | ||
836 | + switch (req->req_upiu.qr.opcode) { | ||
837 | + case UFS_UPIU_QUERY_OPCODE_NOP: | ||
838 | + status = UFS_QUERY_RESULT_SUCCESS; | ||
839 | + break; | ||
840 | + case UFS_UPIU_QUERY_OPCODE_READ_DESC: | ||
841 | + status = ufs_read_desc(req); | ||
842 | + break; | ||
843 | + case UFS_UPIU_QUERY_OPCODE_READ_ATTR: | ||
844 | + status = ufs_exec_query_attr(req, UFS_QUERY_ATTR_READ); | ||
845 | + break; | ||
846 | + case UFS_UPIU_QUERY_OPCODE_READ_FLAG: | ||
847 | + status = ufs_exec_query_flag(req, UFS_QUERY_FLAG_READ); | ||
848 | + break; | ||
849 | + default: | ||
850 | + trace_ufs_err_query_invalid_opcode(req->req_upiu.qr.opcode); | ||
851 | + status = UFS_QUERY_RESULT_INVALID_OPCODE; | ||
852 | + break; | ||
853 | + } | ||
854 | + | ||
855 | + return status; | ||
856 | +} | ||
857 | + | ||
858 | +static QueryRespCode ufs_exec_query_write(UfsRequest *req) | ||
859 | +{ | ||
860 | + QueryRespCode status; | ||
861 | + switch (req->req_upiu.qr.opcode) { | ||
862 | + case UFS_UPIU_QUERY_OPCODE_NOP: | ||
863 | + status = UFS_QUERY_RESULT_SUCCESS; | ||
864 | + break; | ||
865 | + case UFS_UPIU_QUERY_OPCODE_WRITE_DESC: | ||
866 | + /* write descriptor is not supported */ | ||
867 | + status = UFS_QUERY_RESULT_NOT_WRITEABLE; | ||
868 | + break; | ||
869 | + case UFS_UPIU_QUERY_OPCODE_WRITE_ATTR: | ||
870 | + status = ufs_exec_query_attr(req, UFS_QUERY_ATTR_WRITE); | ||
871 | + break; | ||
872 | + case UFS_UPIU_QUERY_OPCODE_SET_FLAG: | ||
873 | + status = ufs_exec_query_flag(req, UFS_QUERY_FLAG_SET); | ||
874 | + break; | ||
875 | + case UFS_UPIU_QUERY_OPCODE_CLEAR_FLAG: | ||
876 | + status = ufs_exec_query_flag(req, UFS_QUERY_FLAG_CLEAR); | ||
877 | + break; | ||
878 | + case UFS_UPIU_QUERY_OPCODE_TOGGLE_FLAG: | ||
879 | + status = ufs_exec_query_flag(req, UFS_QUERY_FLAG_TOGGLE); | ||
880 | + break; | ||
881 | + default: | ||
882 | + trace_ufs_err_query_invalid_opcode(req->req_upiu.qr.opcode); | ||
883 | + status = UFS_QUERY_RESULT_INVALID_OPCODE; | ||
884 | + break; | ||
885 | + } | ||
886 | + | ||
887 | + return status; | ||
888 | +} | ||
889 | + | ||
890 | +static UfsReqResult ufs_exec_query_cmd(UfsRequest *req) | ||
891 | +{ | ||
892 | + uint8_t query_func = req->req_upiu.header.query_func; | ||
893 | + uint16_t data_segment_length; | ||
894 | + QueryRespCode status; | ||
895 | + | ||
896 | + trace_ufs_exec_query_cmd(req->slot, req->req_upiu.qr.opcode); | ||
897 | + if (query_func == UFS_UPIU_QUERY_FUNC_STANDARD_READ_REQUEST) { | ||
898 | + status = ufs_exec_query_read(req); | ||
899 | + } else if (query_func == UFS_UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST) { | ||
900 | + status = ufs_exec_query_write(req); | ||
901 | + } else { | ||
902 | + status = UFS_QUERY_RESULT_GENERAL_FAILURE; | ||
903 | + } | ||
904 | + | ||
905 | + data_segment_length = be16_to_cpu(req->rsp_upiu.qr.length); | ||
906 | + ufs_build_upiu_header(req, UFS_UPIU_TRANSACTION_QUERY_RSP, 0, status, 0, | ||
907 | + data_segment_length); | ||
908 | + | ||
909 | + if (status != UFS_QUERY_RESULT_SUCCESS) { | ||
910 | + return UFS_REQUEST_FAIL; | ||
911 | + } | ||
912 | + return UFS_REQUEST_SUCCESS; | ||
913 | +} | ||
914 | + | ||
915 | +static void ufs_exec_req(UfsRequest *req) | ||
916 | +{ | ||
917 | + UfsReqResult req_result; | ||
918 | + | ||
919 | + if (ufs_dma_read_upiu(req)) { | ||
920 | + return; | ||
921 | + } | ||
922 | + | ||
923 | + switch (req->req_upiu.header.trans_type) { | ||
924 | + case UFS_UPIU_TRANSACTION_NOP_OUT: | ||
925 | + req_result = ufs_exec_nop_cmd(req); | ||
926 | + break; | ||
927 | + case UFS_UPIU_TRANSACTION_COMMAND: | ||
928 | + /* Not yet implemented */ | ||
929 | + req_result = UFS_REQUEST_FAIL; | ||
930 | + break; | ||
931 | + case UFS_UPIU_TRANSACTION_QUERY_REQ: | ||
932 | + req_result = ufs_exec_query_cmd(req); | ||
933 | + break; | ||
934 | + default: | ||
935 | + trace_ufs_err_invalid_trans_code(req->slot, | ||
936 | + req->req_upiu.header.trans_type); | ||
937 | + req_result = UFS_REQUEST_FAIL; | ||
938 | + } | ||
939 | + | ||
940 | + ufs_complete_req(req, req_result); | ||
941 | +} | ||
942 | + | ||
943 | +static void ufs_process_req(void *opaque) | ||
944 | +{ | ||
945 | + UfsHc *u = opaque; | ||
946 | + UfsRequest *req; | ||
947 | + int slot; | ||
948 | + | ||
949 | + for (slot = 0; slot < u->params.nutrs; slot++) { | ||
950 | + req = &u->req_list[slot]; | ||
951 | + | ||
952 | + if (req->state != UFS_REQUEST_READY) { | ||
953 | + continue; | ||
954 | + } | ||
955 | + trace_ufs_process_req(slot); | ||
956 | + req->state = UFS_REQUEST_RUNNING; | ||
957 | + | ||
958 | + ufs_exec_req(req); | ||
959 | + } | ||
960 | +} | ||
961 | + | ||
962 | +static void ufs_complete_req(UfsRequest *req, UfsReqResult req_result) | ||
963 | +{ | ||
964 | + UfsHc *u = req->hc; | ||
965 | + assert(req->state == UFS_REQUEST_RUNNING); | ||
966 | + | ||
967 | + if (req_result == UFS_REQUEST_SUCCESS) { | ||
968 | + req->utrd.header.dword_2 = cpu_to_le32(UFS_OCS_SUCCESS); | ||
969 | + } else { | ||
970 | + req->utrd.header.dword_2 = cpu_to_le32(UFS_OCS_INVALID_CMD_TABLE_ATTR); | ||
971 | + } | ||
972 | + | ||
973 | + trace_ufs_complete_req(req->slot); | ||
974 | + req->state = UFS_REQUEST_COMPLETE; | ||
975 | + qemu_bh_schedule(u->complete_bh); | ||
976 | +} | ||
977 | + | ||
978 | +static void ufs_clear_req(UfsRequest *req) | ||
979 | +{ | ||
980 | + if (req->sg != NULL) { | ||
981 | + qemu_sglist_destroy(req->sg); | ||
982 | + g_free(req->sg); | ||
983 | + req->sg = NULL; | ||
984 | + } | ||
985 | + | ||
986 | + memset(&req->utrd, 0, sizeof(req->utrd)); | ||
987 | + memset(&req->req_upiu, 0, sizeof(req->req_upiu)); | ||
988 | + memset(&req->rsp_upiu, 0, sizeof(req->rsp_upiu)); | ||
989 | +} | ||
990 | + | ||
991 | +static void ufs_sendback_req(void *opaque) | ||
992 | +{ | ||
993 | + UfsHc *u = opaque; | ||
994 | + UfsRequest *req; | ||
995 | + int slot; | ||
996 | + | ||
997 | + for (slot = 0; slot < u->params.nutrs; slot++) { | ||
998 | + req = &u->req_list[slot]; | ||
999 | + | ||
1000 | + if (req->state != UFS_REQUEST_COMPLETE) { | ||
1001 | + continue; | ||
1002 | + } | ||
1003 | + | ||
1004 | + if (ufs_dma_write_upiu(req)) { | ||
1005 | + req->state = UFS_REQUEST_ERROR; | ||
1006 | + continue; | ||
1007 | + } | ||
1008 | + | ||
1009 | + /* | ||
1010 | + * TODO: UTP Transfer Request Interrupt Aggregation Control is not yet | ||
1011 | + * supported | ||
1012 | + */ | ||
1013 | + if (le32_to_cpu(req->utrd.header.dword_2) != UFS_OCS_SUCCESS || | ||
1014 | + le32_to_cpu(req->utrd.header.dword_0) & UFS_UTP_REQ_DESC_INT_CMD) { | ||
1015 | + u->reg.is = FIELD_DP32(u->reg.is, IS, UTRCS, 1); | ||
1016 | + } | ||
1017 | + | ||
1018 | + u->reg.utrldbr &= ~(1 << slot); | ||
1019 | + u->reg.utrlcnr |= (1 << slot); | ||
1020 | + | ||
1021 | + trace_ufs_sendback_req(req->slot); | ||
1022 | + | ||
1023 | + ufs_clear_req(req); | ||
1024 | + req->state = UFS_REQUEST_IDLE; | ||
1025 | + } | ||
1026 | + | ||
1027 | + ufs_irq_check(u); | ||
1028 | +} | ||
1029 | + | ||
1030 | static bool ufs_check_constraints(UfsHc *u, Error **errp) | ||
1031 | { | ||
1032 | if (u->params.nutrs > UFS_MAX_NUTRS) { | ||
1033 | @@ -XXX,XX +XXX,XX @@ static void ufs_init_pci(UfsHc *u, PCIDevice *pci_dev) | ||
1034 | u->irq = pci_allocate_irq(pci_dev); | ||
134 | } | 1035 | } |
135 | 1036 | ||
136 | +static void blkdebug_child_perm(BlockDriverState *bs, BdrvChild *c, | 1037 | +static void ufs_init_state(UfsHc *u) |
137 | + const BdrvChildRole *role, | 1038 | +{ |
138 | + BlockReopenQueue *reopen_queue, | 1039 | + u->req_list = g_new0(UfsRequest, u->params.nutrs); |
139 | + uint64_t perm, uint64_t shared, | 1040 | + |
140 | + uint64_t *nperm, uint64_t *nshared) | 1041 | + for (int i = 0; i < u->params.nutrs; i++) { |
141 | +{ | 1042 | + u->req_list[i].hc = u; |
142 | + BDRVBlkdebugState *s = bs->opaque; | 1043 | + u->req_list[i].slot = i; |
143 | + | 1044 | + u->req_list[i].sg = NULL; |
144 | + bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared, | 1045 | + u->req_list[i].state = UFS_REQUEST_IDLE; |
145 | + nperm, nshared); | 1046 | + } |
146 | + | 1047 | + |
147 | + *nperm |= s->take_child_perms; | 1048 | + u->doorbell_bh = qemu_bh_new_guarded(ufs_process_req, u, |
148 | + *nshared &= ~s->unshare_child_perms; | 1049 | + &DEVICE(u)->mem_reentrancy_guard); |
149 | +} | 1050 | + u->complete_bh = qemu_bh_new_guarded(ufs_sendback_req, u, |
150 | + | 1051 | + &DEVICE(u)->mem_reentrancy_guard); |
151 | static const char *const blkdebug_strong_runtime_opts[] = { | 1052 | +} |
152 | "config", | 1053 | + |
153 | "inject-error.", | 1054 | static void ufs_init_hc(UfsHc *u) |
154 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_blkdebug = { | 1055 | { |
155 | .bdrv_file_open = blkdebug_open, | 1056 | uint32_t cap = 0; |
156 | .bdrv_close = blkdebug_close, | 1057 | @@ -XXX,XX +XXX,XX @@ static void ufs_init_hc(UfsHc *u) |
157 | .bdrv_reopen_prepare = blkdebug_reopen_prepare, | 1058 | cap = FIELD_DP32(cap, CAP, CS, 0); |
158 | - .bdrv_child_perm = bdrv_filter_default_perms, | 1059 | u->reg.cap = cap; |
159 | + .bdrv_child_perm = blkdebug_child_perm, | 1060 | u->reg.ver = UFS_SPEC_VER; |
160 | 1061 | + | |
161 | .bdrv_getlength = blkdebug_getlength, | 1062 | + memset(&u->device_desc, 0, sizeof(DeviceDescriptor)); |
162 | .bdrv_refresh_filename = blkdebug_refresh_filename, | 1063 | + u->device_desc.length = sizeof(DeviceDescriptor); |
163 | diff --git a/qapi/block-core.json b/qapi/block-core.json | 1064 | + u->device_desc.descriptor_idn = UFS_QUERY_DESC_IDN_DEVICE; |
1065 | + u->device_desc.device_sub_class = 0x01; | ||
1066 | + u->device_desc.number_lu = 0x00; | ||
1067 | + u->device_desc.number_wlu = 0x04; | ||
1068 | + /* TODO: Revisit it when Power Management is implemented */ | ||
1069 | + u->device_desc.init_power_mode = 0x01; /* Active Mode */ | ||
1070 | + u->device_desc.high_priority_lun = 0x7F; /* Same Priority */ | ||
1071 | + u->device_desc.spec_version = cpu_to_be16(UFS_SPEC_VER); | ||
1072 | + u->device_desc.manufacturer_name = 0x00; | ||
1073 | + u->device_desc.product_name = 0x01; | ||
1074 | + u->device_desc.serial_number = 0x02; | ||
1075 | + u->device_desc.oem_id = 0x03; | ||
1076 | + u->device_desc.ud_0_base_offset = 0x16; | ||
1077 | + u->device_desc.ud_config_p_length = 0x1A; | ||
1078 | + u->device_desc.device_rtt_cap = 0x02; | ||
1079 | + u->device_desc.queue_depth = u->params.nutrs; | ||
1080 | + u->device_desc.product_revision_level = 0x04; | ||
1081 | + | ||
1082 | + memset(&u->geometry_desc, 0, sizeof(GeometryDescriptor)); | ||
1083 | + u->geometry_desc.length = sizeof(GeometryDescriptor); | ||
1084 | + u->geometry_desc.descriptor_idn = UFS_QUERY_DESC_IDN_GEOMETRY; | ||
1085 | + u->geometry_desc.max_number_lu = (UFS_MAX_LUS == 32) ? 0x1 : 0x0; | ||
1086 | + u->geometry_desc.segment_size = cpu_to_be32(0x2000); /* 4KB */ | ||
1087 | + u->geometry_desc.allocation_unit_size = 0x1; /* 4KB */ | ||
1088 | + u->geometry_desc.min_addr_block_size = 0x8; /* 4KB */ | ||
1089 | + u->geometry_desc.max_in_buffer_size = 0x8; | ||
1090 | + u->geometry_desc.max_out_buffer_size = 0x8; | ||
1091 | + u->geometry_desc.rpmb_read_write_size = 0x40; | ||
1092 | + u->geometry_desc.data_ordering = | ||
1093 | + 0x0; /* out-of-order data transfer is not supported */ | ||
1094 | + u->geometry_desc.max_context_id_number = 0x5; | ||
1095 | + u->geometry_desc.supported_memory_types = cpu_to_be16(0x8001); | ||
1096 | + | ||
1097 | + memset(&u->attributes, 0, sizeof(u->attributes)); | ||
1098 | + u->attributes.max_data_in_size = 0x08; | ||
1099 | + u->attributes.max_data_out_size = 0x08; | ||
1100 | + u->attributes.ref_clk_freq = 0x01; /* 26 MHz */ | ||
1101 | + /* configure descriptor is not supported */ | ||
1102 | + u->attributes.config_descr_lock = 0x01; | ||
1103 | + u->attributes.max_num_of_rtt = 0x02; | ||
1104 | + | ||
1105 | + memset(&u->flags, 0, sizeof(u->flags)); | ||
1106 | + u->flags.permanently_disable_fw_update = 1; | ||
1107 | } | ||
1108 | |||
1109 | static void ufs_realize(PCIDevice *pci_dev, Error **errp) | ||
1110 | @@ -XXX,XX +XXX,XX @@ static void ufs_realize(PCIDevice *pci_dev, Error **errp) | ||
1111 | return; | ||
1112 | } | ||
1113 | |||
1114 | + ufs_init_state(u); | ||
1115 | ufs_init_hc(u); | ||
1116 | ufs_init_pci(u, pci_dev); | ||
1117 | } | ||
1118 | |||
1119 | +static void ufs_exit(PCIDevice *pci_dev) | ||
1120 | +{ | ||
1121 | + UfsHc *u = UFS(pci_dev); | ||
1122 | + | ||
1123 | + qemu_bh_delete(u->doorbell_bh); | ||
1124 | + qemu_bh_delete(u->complete_bh); | ||
1125 | + | ||
1126 | + for (int i = 0; i < u->params.nutrs; i++) { | ||
1127 | + ufs_clear_req(&u->req_list[i]); | ||
1128 | + } | ||
1129 | + g_free(u->req_list); | ||
1130 | +} | ||
1131 | + | ||
1132 | static Property ufs_props[] = { | ||
1133 | DEFINE_PROP_STRING("serial", UfsHc, params.serial), | ||
1134 | DEFINE_PROP_UINT8("nutrs", UfsHc, params.nutrs, 32), | ||
1135 | @@ -XXX,XX +XXX,XX @@ static void ufs_class_init(ObjectClass *oc, void *data) | ||
1136 | PCIDeviceClass *pc = PCI_DEVICE_CLASS(oc); | ||
1137 | |||
1138 | pc->realize = ufs_realize; | ||
1139 | + pc->exit = ufs_exit; | ||
1140 | pc->vendor_id = PCI_VENDOR_ID_REDHAT; | ||
1141 | pc->device_id = PCI_DEVICE_ID_REDHAT_UFS; | ||
1142 | pc->class_id = PCI_CLASS_STORAGE_UFS; | ||
1143 | diff --git a/hw/ufs/trace-events b/hw/ufs/trace-events | ||
164 | index XXXXXXX..XXXXXXX 100644 | 1144 | index XXXXXXX..XXXXXXX 100644 |
165 | --- a/qapi/block-core.json | 1145 | --- a/hw/ufs/trace-events |
166 | +++ b/qapi/block-core.json | 1146 | +++ b/hw/ufs/trace-events |
167 | @@ -XXX,XX +XXX,XX @@ | 1147 | @@ -XXX,XX +XXX,XX @@ ufs_err_dma_read_req_upiu(uint32_t slot, uint64_t addr) "failed to read req upiu |
168 | # | 1148 | ufs_err_dma_read_prdt(uint32_t slot, uint64_t addr) "failed to read prdt. UTRLDBR slot %"PRIu32", prdt addr %"PRIu64"" |
169 | # @set-state: array of state-change descriptions | 1149 | ufs_err_dma_write_utrd(uint32_t slot, uint64_t addr) "failed to write utrd. UTRLDBR slot %"PRIu32", UTRD dma addr %"PRIu64"" |
170 | # | 1150 | ufs_err_dma_write_rsp_upiu(uint32_t slot, uint64_t addr) "failed to write rsp upiu. UTRLDBR slot %"PRIu32", response upiu addr %"PRIu64"" |
171 | +# @take-child-perms: Permissions to take on @image in addition to what | 1151 | +ufs_err_utrl_slot_error(uint32_t slot) "UTRLDBR slot %"PRIu32" is in error" |
172 | +# is necessary anyway (which depends on how the | 1152 | ufs_err_utrl_slot_busy(uint32_t slot) "UTRLDBR slot %"PRIu32" is busy" |
173 | +# blkdebug node is used). Defaults to none. | 1153 | ufs_err_unsupport_register_offset(uint32_t offset) "Register offset 0x%"PRIx32" is not yet supported" |
174 | +# (since 5.0) | 1154 | ufs_err_invalid_register_offset(uint32_t offset) "Register offset 0x%"PRIx32" is invalid" |
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 | -- | 1155 | -- |
196 | 2.24.1 | 1156 | 2.41.0 |
197 | |||
198 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Callers can use this new parameter to expect failure during the | ||
2 | completion process. | ||
3 | 1 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
5 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
6 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
7 | Message-id: 20191108123455.39445-5-mreitz@redhat.com | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | --- | ||
10 | tests/qemu-iotests/iotests.py | 18 ++++++++++++------ | ||
11 | 1 file changed, 12 insertions(+), 6 deletions(-) | ||
12 | |||
13 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tests/qemu-iotests/iotests.py | ||
16 | +++ b/tests/qemu-iotests/iotests.py | ||
17 | @@ -XXX,XX +XXX,XX @@ class QMPTestCase(unittest.TestCase): | ||
18 | self.assert_no_active_block_jobs() | ||
19 | return result | ||
20 | |||
21 | - def wait_until_completed(self, drive='drive0', check_offset=True, wait=60.0): | ||
22 | + def wait_until_completed(self, drive='drive0', check_offset=True, wait=60.0, | ||
23 | + error=None): | ||
24 | '''Wait for a block job to finish, returning the event''' | ||
25 | while True: | ||
26 | for event in self.vm.get_qmp_events(wait=wait): | ||
27 | if event['event'] == 'BLOCK_JOB_COMPLETED': | ||
28 | self.assert_qmp(event, 'data/device', drive) | ||
29 | - self.assert_qmp_absent(event, 'data/error') | ||
30 | - if check_offset: | ||
31 | - self.assert_qmp(event, 'data/offset', event['data']['len']) | ||
32 | + if error is None: | ||
33 | + self.assert_qmp_absent(event, 'data/error') | ||
34 | + if check_offset: | ||
35 | + self.assert_qmp(event, 'data/offset', | ||
36 | + event['data']['len']) | ||
37 | + else: | ||
38 | + self.assert_qmp(event, 'data/error', error) | ||
39 | self.assert_no_active_block_jobs() | ||
40 | return event | ||
41 | elif event['event'] == 'JOB_STATUS_CHANGE': | ||
42 | @@ -XXX,XX +XXX,XX @@ class QMPTestCase(unittest.TestCase): | ||
43 | self.assert_qmp(event, 'data/type', 'mirror') | ||
44 | self.assert_qmp(event, 'data/offset', event['data']['len']) | ||
45 | |||
46 | - def complete_and_wait(self, drive='drive0', wait_ready=True): | ||
47 | + def complete_and_wait(self, drive='drive0', wait_ready=True, | ||
48 | + completion_error=None): | ||
49 | '''Complete a block job and wait for it to finish''' | ||
50 | if wait_ready: | ||
51 | self.wait_ready(drive=drive) | ||
52 | @@ -XXX,XX +XXX,XX @@ class QMPTestCase(unittest.TestCase): | ||
53 | result = self.vm.qmp('block-job-complete', device=drive) | ||
54 | self.assert_qmp(result, 'return', {}) | ||
55 | |||
56 | - event = self.wait_until_completed(drive=drive) | ||
57 | + event = self.wait_until_completed(drive=drive, error=completion_error) | ||
58 | self.assert_qmp(event, 'data/type', 'mirror') | ||
59 | |||
60 | def pause_wait(self, job_id='job0'): | ||
61 | -- | ||
62 | 2.24.1 | ||
63 | |||
64 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
2 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.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 | --- | ||
8 | tests/qemu-iotests/041 | 44 ++++++++++++++++++++++++++++++++++++++ | ||
9 | tests/qemu-iotests/041.out | 4 ++-- | ||
10 | 2 files changed, 46 insertions(+), 2 deletions(-) | ||
11 | 1 | ||
12 | diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 | ||
13 | index XXXXXXX..XXXXXXX 100755 | ||
14 | --- a/tests/qemu-iotests/041 | ||
15 | +++ b/tests/qemu-iotests/041 | ||
16 | @@ -XXX,XX +XXX,XX @@ class TestOrphanedSource(iotests.QMPTestCase): | ||
17 | target='dest-ro') | ||
18 | self.assert_qmp(result, 'error/class', 'GenericError') | ||
19 | |||
20 | + def test_failing_permission_in_complete(self): | ||
21 | + self.assert_no_active_block_jobs() | ||
22 | + | ||
23 | + # Unshare consistent-read on the target | ||
24 | + # (The mirror job does not care) | ||
25 | + result = self.vm.qmp('blockdev-add', | ||
26 | + driver='blkdebug', | ||
27 | + node_name='dest-perm', | ||
28 | + image='dest', | ||
29 | + unshare_child_perms=['consistent-read']) | ||
30 | + self.assert_qmp(result, 'return', {}) | ||
31 | + | ||
32 | + result = self.vm.qmp('blockdev-mirror', job_id='job', device='src', | ||
33 | + sync='full', target='dest', | ||
34 | + filter_node_name='mirror-filter') | ||
35 | + self.assert_qmp(result, 'return', {}) | ||
36 | + | ||
37 | + # Require consistent-read on the source | ||
38 | + # (We can only add this node once the job has started, or it | ||
39 | + # will complain that it does not want to run on non-root nodes) | ||
40 | + result = self.vm.qmp('blockdev-add', | ||
41 | + driver='blkdebug', | ||
42 | + node_name='src-perm', | ||
43 | + image='src', | ||
44 | + take_child_perms=['consistent-read']) | ||
45 | + self.assert_qmp(result, 'return', {}) | ||
46 | + | ||
47 | + # While completing, mirror will attempt to replace src by | ||
48 | + # dest, which must fail because src-perm requires | ||
49 | + # consistent-read but dest-perm does not share it; thus | ||
50 | + # aborting the job when it is supposed to complete | ||
51 | + self.complete_and_wait('job', | ||
52 | + completion_error='Operation not permitted') | ||
53 | + | ||
54 | + # Assert that all of our nodes are still there (except for the | ||
55 | + # mirror filter, which should be gone despite the failure) | ||
56 | + nodes = self.vm.qmp('query-named-block-nodes')['return'] | ||
57 | + nodes = [node['node-name'] for node in nodes] | ||
58 | + | ||
59 | + for expect in ('src', 'src-perm', 'dest', 'dest-perm'): | ||
60 | + self.assertTrue(expect in nodes, '%s disappeared' % expect) | ||
61 | + self.assertFalse('mirror-filter' in nodes, | ||
62 | + 'Mirror filter node did not disappear') | ||
63 | + | ||
64 | if __name__ == '__main__': | ||
65 | iotests.main(supported_fmts=['qcow2', 'qed'], | ||
66 | supported_protocols=['file']) | ||
67 | diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/tests/qemu-iotests/041.out | ||
70 | +++ b/tests/qemu-iotests/041.out | ||
71 | @@ -XXX,XX +XXX,XX @@ | ||
72 | -.......................................................................................... | ||
73 | +........................................................................................... | ||
74 | ---------------------------------------------------------------------- | ||
75 | -Ran 90 tests | ||
76 | +Ran 91 tests | ||
77 | |||
78 | OK | ||
79 | -- | ||
80 | 2.24.1 | ||
81 | |||
82 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: PanNengyuan <pannengyuan@huawei.com> | ||
2 | 1 | ||
3 | This avoid a memory leak when qom-set is called to set throttle_group | ||
4 | limits, here is an easy way to reproduce: | ||
5 | |||
6 | 1. run qemu-iotests as follow and check the result with asan: | ||
7 | ./check -qcow2 184 | ||
8 | |||
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> | ||
26 | --- | ||
27 | block/throttle-groups.c | 4 ++-- | ||
28 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
29 | |||
30 | diff --git a/block/throttle-groups.c b/block/throttle-groups.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/block/throttle-groups.c | ||
33 | +++ b/block/throttle-groups.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static void throttle_group_set_limits(Object *obj, Visitor *v, | ||
35 | { | ||
36 | ThrottleGroup *tg = THROTTLE_GROUP(obj); | ||
37 | ThrottleConfig cfg; | ||
38 | - ThrottleLimits arg = { 0 }; | ||
39 | - ThrottleLimits *argp = &arg; | ||
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 | } | ||
52 | -- | ||
53 | 2.24.1 | ||
54 | |||
55 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Jeuk Kim <jeuk20.kim@samsung.com> |
---|---|---|---|
2 | 2 | ||
3 | qcow2_can_store_new_dirty_bitmap works wrong, as it considers only | 3 | This commit adds support for ufs logical unit. |
4 | bitmaps already stored in the qcow2 image and ignores persistent | 4 | The LU handles processing for the SCSI command, |
5 | BdrvDirtyBitmap objects. | 5 | unit descriptor query request. |
6 | 6 | ||
7 | So, let's instead count persistent BdrvDirtyBitmaps. We load all qcow2 | 7 | This commit enables the UFS device to process |
8 | bitmaps on open, so there should not be any bitmap in the image for | 8 | IO requests. |
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 | 9 | ||
13 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 10 | Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com> |
14 | Message-id: 20191014115126.15360-2-vsementsov@virtuozzo.com | 11 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
15 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 12 | Message-id: beacc504376ab6a14b1a3830bb3c69382cf6aebc.1693980783.git.jeuk20.kim@gmail.com |
16 | Cc: qemu-stable@nongnu.org | 13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
17 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
18 | --- | 14 | --- |
19 | block/qcow2-bitmap.c | 41 ++++++++++++++++++----------------------- | 15 | hw/ufs/ufs.h | 43 ++ |
20 | 1 file changed, 18 insertions(+), 23 deletions(-) | 16 | include/scsi/constants.h | 1 + |
17 | hw/ufs/lu.c | 1445 ++++++++++++++++++++++++++++++++++++++ | ||
18 | hw/ufs/ufs.c | 252 ++++++- | ||
19 | hw/ufs/meson.build | 2 +- | ||
20 | hw/ufs/trace-events | 25 + | ||
21 | 6 files changed, 1761 insertions(+), 7 deletions(-) | ||
22 | create mode 100644 hw/ufs/lu.c | ||
21 | 23 | ||
22 | diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c | 24 | diff --git a/hw/ufs/ufs.h b/hw/ufs/ufs.h |
23 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/block/qcow2-bitmap.c | 26 | --- a/hw/ufs/ufs.h |
25 | +++ b/block/qcow2-bitmap.c | 27 | +++ b/hw/ufs/ufs.h |
26 | @@ -XXX,XX +XXX,XX @@ bool coroutine_fn qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs, | 28 | @@ -XXX,XX +XXX,XX @@ |
27 | Error **errp) | 29 | #define UFS_MAX_LUS 32 |
30 | #define UFS_BLOCK_SIZE 4096 | ||
31 | |||
32 | +typedef struct UfsBusClass { | ||
33 | + BusClass parent_class; | ||
34 | + bool (*parent_check_address)(BusState *bus, DeviceState *dev, Error **errp); | ||
35 | +} UfsBusClass; | ||
36 | + | ||
37 | +typedef struct UfsBus { | ||
38 | + SCSIBus parent_bus; | ||
39 | +} UfsBus; | ||
40 | + | ||
41 | +#define TYPE_UFS_BUS "ufs-bus" | ||
42 | +DECLARE_OBJ_CHECKERS(UfsBus, UfsBusClass, UFS_BUS, TYPE_UFS_BUS) | ||
43 | + | ||
44 | typedef enum UfsRequestState { | ||
45 | UFS_REQUEST_IDLE = 0, | ||
46 | UFS_REQUEST_READY = 1, | ||
47 | @@ -XXX,XX +XXX,XX @@ typedef enum UfsRequestState { | ||
48 | typedef enum UfsReqResult { | ||
49 | UFS_REQUEST_SUCCESS = 0, | ||
50 | UFS_REQUEST_FAIL = 1, | ||
51 | + UFS_REQUEST_NO_COMPLETE = 2, | ||
52 | } UfsReqResult; | ||
53 | |||
54 | typedef struct UfsRequest { | ||
55 | @@ -XXX,XX +XXX,XX @@ typedef struct UfsRequest { | ||
56 | QEMUSGList *sg; | ||
57 | } UfsRequest; | ||
58 | |||
59 | +typedef struct UfsLu { | ||
60 | + SCSIDevice qdev; | ||
61 | + uint8_t lun; | ||
62 | + UnitDescriptor unit_desc; | ||
63 | +} UfsLu; | ||
64 | + | ||
65 | +typedef struct UfsWLu { | ||
66 | + SCSIDevice qdev; | ||
67 | + uint8_t lun; | ||
68 | +} UfsWLu; | ||
69 | + | ||
70 | typedef struct UfsParams { | ||
71 | char *serial; | ||
72 | uint8_t nutrs; /* Number of UTP Transfer Request Slots */ | ||
73 | @@ -XXX,XX +XXX,XX @@ typedef struct UfsParams { | ||
74 | |||
75 | typedef struct UfsHc { | ||
76 | PCIDevice parent_obj; | ||
77 | + UfsBus bus; | ||
78 | MemoryRegion iomem; | ||
79 | UfsReg reg; | ||
80 | UfsParams params; | ||
81 | uint32_t reg_size; | ||
82 | UfsRequest *req_list; | ||
83 | |||
84 | + UfsLu *lus[UFS_MAX_LUS]; | ||
85 | + UfsWLu *report_wlu; | ||
86 | + UfsWLu *dev_wlu; | ||
87 | + UfsWLu *boot_wlu; | ||
88 | + UfsWLu *rpmb_wlu; | ||
89 | DeviceDescriptor device_desc; | ||
90 | GeometryDescriptor geometry_desc; | ||
91 | Attributes attributes; | ||
92 | @@ -XXX,XX +XXX,XX @@ typedef struct UfsHc { | ||
93 | #define TYPE_UFS "ufs" | ||
94 | #define UFS(obj) OBJECT_CHECK(UfsHc, (obj), TYPE_UFS) | ||
95 | |||
96 | +#define TYPE_UFS_LU "ufs-lu" | ||
97 | +#define UFSLU(obj) OBJECT_CHECK(UfsLu, (obj), TYPE_UFS_LU) | ||
98 | + | ||
99 | +#define TYPE_UFS_WLU "ufs-wlu" | ||
100 | +#define UFSWLU(obj) OBJECT_CHECK(UfsWLu, (obj), TYPE_UFS_WLU) | ||
101 | + | ||
102 | typedef enum UfsQueryFlagPerm { | ||
103 | UFS_QUERY_FLAG_NONE = 0x0, | ||
104 | UFS_QUERY_FLAG_READ = 0x1, | ||
105 | @@ -XXX,XX +XXX,XX @@ typedef enum UfsQueryAttrPerm { | ||
106 | UFS_QUERY_ATTR_WRITE = 0x2, | ||
107 | } UfsQueryAttrPerm; | ||
108 | |||
109 | +static inline bool is_wlun(uint8_t lun) | ||
110 | +{ | ||
111 | + return (lun == UFS_UPIU_REPORT_LUNS_WLUN || | ||
112 | + lun == UFS_UPIU_UFS_DEVICE_WLUN || lun == UFS_UPIU_BOOT_WLUN || | ||
113 | + lun == UFS_UPIU_RPMB_WLUN); | ||
114 | +} | ||
115 | + | ||
116 | #endif /* HW_UFS_UFS_H */ | ||
117 | diff --git a/include/scsi/constants.h b/include/scsi/constants.h | ||
118 | index XXXXXXX..XXXXXXX 100644 | ||
119 | --- a/include/scsi/constants.h | ||
120 | +++ b/include/scsi/constants.h | ||
121 | @@ -XXX,XX +XXX,XX @@ | ||
122 | #define MODE_PAGE_FLEXIBLE_DISK_GEOMETRY 0x05 | ||
123 | #define MODE_PAGE_CACHING 0x08 | ||
124 | #define MODE_PAGE_AUDIO_CTL 0x0e | ||
125 | +#define MODE_PAGE_CONTROL 0x0a | ||
126 | #define MODE_PAGE_POWER 0x1a | ||
127 | #define MODE_PAGE_FAULT_FAIL 0x1c | ||
128 | #define MODE_PAGE_TO_PROTECT 0x1d | ||
129 | diff --git a/hw/ufs/lu.c b/hw/ufs/lu.c | ||
130 | new file mode 100644 | ||
131 | index XXXXXXX..XXXXXXX | ||
132 | --- /dev/null | ||
133 | +++ b/hw/ufs/lu.c | ||
134 | @@ -XXX,XX +XXX,XX @@ | ||
135 | +/* | ||
136 | + * QEMU UFS Logical Unit | ||
137 | + * | ||
138 | + * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved. | ||
139 | + * | ||
140 | + * Written by Jeuk Kim <jeuk20.kim@samsung.com> | ||
141 | + * | ||
142 | + * This code is licensed under the GNU GPL v2 or later. | ||
143 | + */ | ||
144 | + | ||
145 | +#include "qemu/osdep.h" | ||
146 | +#include "qemu/units.h" | ||
147 | +#include "qapi/error.h" | ||
148 | +#include "qemu/memalign.h" | ||
149 | +#include "hw/scsi/scsi.h" | ||
150 | +#include "scsi/constants.h" | ||
151 | +#include "sysemu/block-backend.h" | ||
152 | +#include "qemu/cutils.h" | ||
153 | +#include "trace.h" | ||
154 | +#include "ufs.h" | ||
155 | + | ||
156 | +/* | ||
157 | + * The code below handling SCSI commands is copied from hw/scsi/scsi-disk.c, | ||
158 | + * with minor adjustments to make it work for UFS. | ||
159 | + */ | ||
160 | + | ||
161 | +#define SCSI_DMA_BUF_SIZE (128 * KiB) | ||
162 | +#define SCSI_MAX_INQUIRY_LEN 256 | ||
163 | +#define SCSI_INQUIRY_DATA_SIZE 36 | ||
164 | +#define SCSI_MAX_MODE_LEN 256 | ||
165 | + | ||
166 | +typedef struct UfsSCSIReq { | ||
167 | + SCSIRequest req; | ||
168 | + /* Both sector and sector_count are in terms of BDRV_SECTOR_SIZE bytes. */ | ||
169 | + uint64_t sector; | ||
170 | + uint32_t sector_count; | ||
171 | + uint32_t buflen; | ||
172 | + bool started; | ||
173 | + bool need_fua_emulation; | ||
174 | + struct iovec iov; | ||
175 | + QEMUIOVector qiov; | ||
176 | + BlockAcctCookie acct; | ||
177 | +} UfsSCSIReq; | ||
178 | + | ||
179 | +static void ufs_scsi_free_request(SCSIRequest *req) | ||
180 | +{ | ||
181 | + UfsSCSIReq *r = DO_UPCAST(UfsSCSIReq, req, req); | ||
182 | + | ||
183 | + qemu_vfree(r->iov.iov_base); | ||
184 | +} | ||
185 | + | ||
186 | +static void scsi_check_condition(UfsSCSIReq *r, SCSISense sense) | ||
187 | +{ | ||
188 | + trace_ufs_scsi_check_condition(r->req.tag, sense.key, sense.asc, | ||
189 | + sense.ascq); | ||
190 | + scsi_req_build_sense(&r->req, sense); | ||
191 | + scsi_req_complete(&r->req, CHECK_CONDITION); | ||
192 | +} | ||
193 | + | ||
194 | +static int ufs_scsi_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf, | ||
195 | + uint32_t outbuf_len) | ||
196 | +{ | ||
197 | + UfsHc *u = UFS(req->bus->qbus.parent); | ||
198 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, req->dev); | ||
199 | + uint8_t page_code = req->cmd.buf[2]; | ||
200 | + int start, buflen = 0; | ||
201 | + | ||
202 | + if (outbuf_len < SCSI_INQUIRY_DATA_SIZE) { | ||
203 | + return -1; | ||
204 | + } | ||
205 | + | ||
206 | + outbuf[buflen++] = lu->qdev.type & 0x1f; | ||
207 | + outbuf[buflen++] = page_code; | ||
208 | + outbuf[buflen++] = 0x00; | ||
209 | + outbuf[buflen++] = 0x00; | ||
210 | + start = buflen; | ||
211 | + | ||
212 | + switch (page_code) { | ||
213 | + case 0x00: /* Supported page codes, mandatory */ | ||
214 | + { | ||
215 | + trace_ufs_scsi_emulate_vpd_page_00(req->cmd.xfer); | ||
216 | + outbuf[buflen++] = 0x00; /* list of supported pages (this page) */ | ||
217 | + if (u->params.serial) { | ||
218 | + outbuf[buflen++] = 0x80; /* unit serial number */ | ||
219 | + } | ||
220 | + outbuf[buflen++] = 0x87; /* mode page policy */ | ||
221 | + break; | ||
222 | + } | ||
223 | + case 0x80: /* Device serial number, optional */ | ||
224 | + { | ||
225 | + int l; | ||
226 | + | ||
227 | + if (!u->params.serial) { | ||
228 | + trace_ufs_scsi_emulate_vpd_page_80_not_supported(); | ||
229 | + return -1; | ||
230 | + } | ||
231 | + | ||
232 | + l = strlen(u->params.serial); | ||
233 | + if (l > SCSI_INQUIRY_DATA_SIZE) { | ||
234 | + l = SCSI_INQUIRY_DATA_SIZE; | ||
235 | + } | ||
236 | + | ||
237 | + trace_ufs_scsi_emulate_vpd_page_80(req->cmd.xfer); | ||
238 | + memcpy(outbuf + buflen, u->params.serial, l); | ||
239 | + buflen += l; | ||
240 | + break; | ||
241 | + } | ||
242 | + case 0x87: /* Mode Page Policy, mandatory */ | ||
243 | + { | ||
244 | + trace_ufs_scsi_emulate_vpd_page_87(req->cmd.xfer); | ||
245 | + outbuf[buflen++] = 0x3f; /* apply to all mode pages and subpages */ | ||
246 | + outbuf[buflen++] = 0xff; | ||
247 | + outbuf[buflen++] = 0; /* shared */ | ||
248 | + outbuf[buflen++] = 0; | ||
249 | + break; | ||
250 | + } | ||
251 | + default: | ||
252 | + return -1; | ||
253 | + } | ||
254 | + /* done with EVPD */ | ||
255 | + assert(buflen - start <= 255); | ||
256 | + outbuf[start - 1] = buflen - start; | ||
257 | + return buflen; | ||
258 | +} | ||
259 | + | ||
260 | +static int ufs_scsi_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf, | ||
261 | + uint32_t outbuf_len) | ||
262 | +{ | ||
263 | + int buflen = 0; | ||
264 | + | ||
265 | + if (outbuf_len < SCSI_INQUIRY_DATA_SIZE) { | ||
266 | + return -1; | ||
267 | + } | ||
268 | + | ||
269 | + if (req->cmd.buf[1] & 0x1) { | ||
270 | + /* Vital product data */ | ||
271 | + return ufs_scsi_emulate_vpd_page(req, outbuf, outbuf_len); | ||
272 | + } | ||
273 | + | ||
274 | + /* Standard INQUIRY data */ | ||
275 | + if (req->cmd.buf[2] != 0) { | ||
276 | + return -1; | ||
277 | + } | ||
278 | + | ||
279 | + /* PAGE CODE == 0 */ | ||
280 | + buflen = req->cmd.xfer; | ||
281 | + if (buflen > SCSI_MAX_INQUIRY_LEN) { | ||
282 | + buflen = SCSI_MAX_INQUIRY_LEN; | ||
283 | + } | ||
284 | + | ||
285 | + if (is_wlun(req->lun)) { | ||
286 | + outbuf[0] = TYPE_WLUN; | ||
287 | + } else { | ||
288 | + outbuf[0] = 0; | ||
289 | + } | ||
290 | + outbuf[1] = 0; | ||
291 | + | ||
292 | + strpadcpy((char *)&outbuf[16], 16, "QEMU UFS", ' '); | ||
293 | + strpadcpy((char *)&outbuf[8], 8, "QEMU", ' '); | ||
294 | + | ||
295 | + memset(&outbuf[32], 0, 4); | ||
296 | + | ||
297 | + outbuf[2] = 0x06; /* SPC-4 */ | ||
298 | + outbuf[3] = 0x2; | ||
299 | + | ||
300 | + if (buflen > SCSI_INQUIRY_DATA_SIZE) { | ||
301 | + outbuf[4] = buflen - 5; /* Additional Length = (Len - 1) - 4 */ | ||
302 | + } else { | ||
303 | + /* | ||
304 | + * If the allocation length of CDB is too small, the additional | ||
305 | + * length is not adjusted | ||
306 | + */ | ||
307 | + outbuf[4] = SCSI_INQUIRY_DATA_SIZE - 5; | ||
308 | + } | ||
309 | + | ||
310 | + /* Support TCQ. */ | ||
311 | + outbuf[7] = req->bus->info->tcq ? 0x02 : 0; | ||
312 | + return buflen; | ||
313 | +} | ||
314 | + | ||
315 | +static int mode_sense_page(UfsLu *lu, int page, uint8_t **p_outbuf, | ||
316 | + int page_control) | ||
317 | +{ | ||
318 | + static const int mode_sense_valid[0x3f] = { | ||
319 | + [MODE_PAGE_CACHING] = 1, | ||
320 | + [MODE_PAGE_R_W_ERROR] = 1, | ||
321 | + [MODE_PAGE_CONTROL] = 1, | ||
322 | + }; | ||
323 | + | ||
324 | + uint8_t *p = *p_outbuf + 2; | ||
325 | + int length; | ||
326 | + | ||
327 | + assert(page < ARRAY_SIZE(mode_sense_valid)); | ||
328 | + if ((mode_sense_valid[page]) == 0) { | ||
329 | + return -1; | ||
330 | + } | ||
331 | + | ||
332 | + /* | ||
333 | + * If Changeable Values are requested, a mask denoting those mode parameters | ||
334 | + * that are changeable shall be returned. As we currently don't support | ||
335 | + * parameter changes via MODE_SELECT all bits are returned set to zero. | ||
336 | + * The buffer was already memset to zero by the caller of this function. | ||
337 | + */ | ||
338 | + switch (page) { | ||
339 | + case MODE_PAGE_CACHING: | ||
340 | + length = 0x12; | ||
341 | + if (page_control == 1 || /* Changeable Values */ | ||
342 | + blk_enable_write_cache(lu->qdev.conf.blk)) { | ||
343 | + p[0] = 4; /* WCE */ | ||
344 | + } | ||
345 | + break; | ||
346 | + | ||
347 | + case MODE_PAGE_R_W_ERROR: | ||
348 | + length = 10; | ||
349 | + if (page_control == 1) { /* Changeable Values */ | ||
350 | + break; | ||
351 | + } | ||
352 | + p[0] = 0x80; /* Automatic Write Reallocation Enabled */ | ||
353 | + break; | ||
354 | + | ||
355 | + case MODE_PAGE_CONTROL: | ||
356 | + length = 10; | ||
357 | + if (page_control == 1) { /* Changeable Values */ | ||
358 | + break; | ||
359 | + } | ||
360 | + p[1] = 0x10; /* Queue Algorithm modifier */ | ||
361 | + p[8] = 0xff; /* Busy Timeout Period */ | ||
362 | + p[9] = 0xff; | ||
363 | + break; | ||
364 | + | ||
365 | + default: | ||
366 | + return -1; | ||
367 | + } | ||
368 | + | ||
369 | + assert(length < 256); | ||
370 | + (*p_outbuf)[0] = page; | ||
371 | + (*p_outbuf)[1] = length; | ||
372 | + *p_outbuf += length + 2; | ||
373 | + return length + 2; | ||
374 | +} | ||
375 | + | ||
376 | +static int ufs_scsi_emulate_mode_sense(UfsSCSIReq *r, uint8_t *outbuf) | ||
377 | +{ | ||
378 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
379 | + bool dbd; | ||
380 | + int page, buflen, ret, page_control; | ||
381 | + uint8_t *p; | ||
382 | + uint8_t dev_specific_param = 0; | ||
383 | + | ||
384 | + dbd = (r->req.cmd.buf[1] & 0x8) != 0; | ||
385 | + if (!dbd) { | ||
386 | + return -1; | ||
387 | + } | ||
388 | + | ||
389 | + page = r->req.cmd.buf[2] & 0x3f; | ||
390 | + page_control = (r->req.cmd.buf[2] & 0xc0) >> 6; | ||
391 | + | ||
392 | + trace_ufs_scsi_emulate_mode_sense((r->req.cmd.buf[0] == MODE_SENSE) ? 6 : | ||
393 | + 10, | ||
394 | + page, r->req.cmd.xfer, page_control); | ||
395 | + memset(outbuf, 0, r->req.cmd.xfer); | ||
396 | + p = outbuf; | ||
397 | + | ||
398 | + if (!blk_is_writable(lu->qdev.conf.blk)) { | ||
399 | + dev_specific_param |= 0x80; /* Readonly. */ | ||
400 | + } | ||
401 | + | ||
402 | + p[2] = 0; /* Medium type. */ | ||
403 | + p[3] = dev_specific_param; | ||
404 | + p[6] = p[7] = 0; /* Block descriptor length. */ | ||
405 | + p += 8; | ||
406 | + | ||
407 | + if (page_control == 3) { | ||
408 | + /* Saved Values */ | ||
409 | + scsi_check_condition(r, SENSE_CODE(SAVING_PARAMS_NOT_SUPPORTED)); | ||
410 | + return -1; | ||
411 | + } | ||
412 | + | ||
413 | + if (page == 0x3f) { | ||
414 | + for (page = 0; page <= 0x3e; page++) { | ||
415 | + mode_sense_page(lu, page, &p, page_control); | ||
416 | + } | ||
417 | + } else { | ||
418 | + ret = mode_sense_page(lu, page, &p, page_control); | ||
419 | + if (ret == -1) { | ||
420 | + return -1; | ||
421 | + } | ||
422 | + } | ||
423 | + | ||
424 | + buflen = p - outbuf; | ||
425 | + /* | ||
426 | + * The mode data length field specifies the length in bytes of the | ||
427 | + * following data that is available to be transferred. The mode data | ||
428 | + * length does not include itself. | ||
429 | + */ | ||
430 | + outbuf[0] = ((buflen - 2) >> 8) & 0xff; | ||
431 | + outbuf[1] = (buflen - 2) & 0xff; | ||
432 | + return buflen; | ||
433 | +} | ||
434 | + | ||
435 | +/* | ||
436 | + * scsi_handle_rw_error has two return values. False means that the error | ||
437 | + * must be ignored, true means that the error has been processed and the | ||
438 | + * caller should not do anything else for this request. Note that | ||
439 | + * scsi_handle_rw_error always manages its reference counts, independent | ||
440 | + * of the return value. | ||
441 | + */ | ||
442 | +static bool scsi_handle_rw_error(UfsSCSIReq *r, int ret, bool acct_failed) | ||
443 | +{ | ||
444 | + bool is_read = (r->req.cmd.mode == SCSI_XFER_FROM_DEV); | ||
445 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
446 | + SCSISense sense = SENSE_CODE(NO_SENSE); | ||
447 | + int error = 0; | ||
448 | + bool req_has_sense = false; | ||
449 | + BlockErrorAction action; | ||
450 | + int status; | ||
451 | + | ||
452 | + if (ret < 0) { | ||
453 | + status = scsi_sense_from_errno(-ret, &sense); | ||
454 | + error = -ret; | ||
455 | + } else { | ||
456 | + /* A passthrough command has completed with nonzero status. */ | ||
457 | + status = ret; | ||
458 | + if (status == CHECK_CONDITION) { | ||
459 | + req_has_sense = true; | ||
460 | + error = scsi_sense_buf_to_errno(r->req.sense, sizeof(r->req.sense)); | ||
461 | + } else { | ||
462 | + error = EINVAL; | ||
463 | + } | ||
464 | + } | ||
465 | + | ||
466 | + /* | ||
467 | + * Check whether the error has to be handled by the guest or should | ||
468 | + * rather follow the rerror=/werror= settings. Guest-handled errors | ||
469 | + * are usually retried immediately, so do not post them to QMP and | ||
470 | + * do not account them as failed I/O. | ||
471 | + */ | ||
472 | + if (req_has_sense && scsi_sense_buf_is_guest_recoverable( | ||
473 | + r->req.sense, sizeof(r->req.sense))) { | ||
474 | + action = BLOCK_ERROR_ACTION_REPORT; | ||
475 | + acct_failed = false; | ||
476 | + } else { | ||
477 | + action = blk_get_error_action(lu->qdev.conf.blk, is_read, error); | ||
478 | + blk_error_action(lu->qdev.conf.blk, action, is_read, error); | ||
479 | + } | ||
480 | + | ||
481 | + switch (action) { | ||
482 | + case BLOCK_ERROR_ACTION_REPORT: | ||
483 | + if (acct_failed) { | ||
484 | + block_acct_failed(blk_get_stats(lu->qdev.conf.blk), &r->acct); | ||
485 | + } | ||
486 | + if (!req_has_sense && status == CHECK_CONDITION) { | ||
487 | + scsi_req_build_sense(&r->req, sense); | ||
488 | + } | ||
489 | + scsi_req_complete(&r->req, status); | ||
490 | + return true; | ||
491 | + | ||
492 | + case BLOCK_ERROR_ACTION_IGNORE: | ||
493 | + return false; | ||
494 | + | ||
495 | + case BLOCK_ERROR_ACTION_STOP: | ||
496 | + scsi_req_retry(&r->req); | ||
497 | + return true; | ||
498 | + | ||
499 | + default: | ||
500 | + g_assert_not_reached(); | ||
501 | + } | ||
502 | +} | ||
503 | + | ||
504 | +static bool ufs_scsi_req_check_error(UfsSCSIReq *r, int ret, bool acct_failed) | ||
505 | +{ | ||
506 | + if (r->req.io_canceled) { | ||
507 | + scsi_req_cancel_complete(&r->req); | ||
508 | + return true; | ||
509 | + } | ||
510 | + | ||
511 | + if (ret < 0) { | ||
512 | + return scsi_handle_rw_error(r, ret, acct_failed); | ||
513 | + } | ||
514 | + | ||
515 | + return false; | ||
516 | +} | ||
517 | + | ||
518 | +static void scsi_aio_complete(void *opaque, int ret) | ||
519 | +{ | ||
520 | + UfsSCSIReq *r = (UfsSCSIReq *)opaque; | ||
521 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
522 | + | ||
523 | + assert(r->req.aiocb != NULL); | ||
524 | + r->req.aiocb = NULL; | ||
525 | + aio_context_acquire(blk_get_aio_context(lu->qdev.conf.blk)); | ||
526 | + if (ufs_scsi_req_check_error(r, ret, true)) { | ||
527 | + goto done; | ||
528 | + } | ||
529 | + | ||
530 | + block_acct_done(blk_get_stats(lu->qdev.conf.blk), &r->acct); | ||
531 | + scsi_req_complete(&r->req, GOOD); | ||
532 | + | ||
533 | +done: | ||
534 | + aio_context_release(blk_get_aio_context(lu->qdev.conf.blk)); | ||
535 | + scsi_req_unref(&r->req); | ||
536 | +} | ||
537 | + | ||
538 | +static int32_t ufs_scsi_emulate_command(SCSIRequest *req, uint8_t *buf) | ||
539 | +{ | ||
540 | + UfsSCSIReq *r = DO_UPCAST(UfsSCSIReq, req, req); | ||
541 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, req->dev); | ||
542 | + uint32_t last_block = 0; | ||
543 | + uint8_t *outbuf; | ||
544 | + int buflen; | ||
545 | + | ||
546 | + switch (req->cmd.buf[0]) { | ||
547 | + case INQUIRY: | ||
548 | + case MODE_SENSE_10: | ||
549 | + case START_STOP: | ||
550 | + case REQUEST_SENSE: | ||
551 | + break; | ||
552 | + | ||
553 | + default: | ||
554 | + if (!blk_is_available(lu->qdev.conf.blk)) { | ||
555 | + scsi_check_condition(r, SENSE_CODE(NO_MEDIUM)); | ||
556 | + return 0; | ||
557 | + } | ||
558 | + break; | ||
559 | + } | ||
560 | + | ||
561 | + /* | ||
562 | + * FIXME: we shouldn't return anything bigger than 4k, but the code | ||
563 | + * requires the buffer to be as big as req->cmd.xfer in several | ||
564 | + * places. So, do not allow CDBs with a very large ALLOCATION | ||
565 | + * LENGTH. The real fix would be to modify scsi_read_data and | ||
566 | + * dma_buf_read, so that they return data beyond the buflen | ||
567 | + * as all zeros. | ||
568 | + */ | ||
569 | + if (req->cmd.xfer > 65536) { | ||
570 | + goto illegal_request; | ||
571 | + } | ||
572 | + r->buflen = MAX(4096, req->cmd.xfer); | ||
573 | + | ||
574 | + if (!r->iov.iov_base) { | ||
575 | + r->iov.iov_base = blk_blockalign(lu->qdev.conf.blk, r->buflen); | ||
576 | + } | ||
577 | + | ||
578 | + outbuf = r->iov.iov_base; | ||
579 | + memset(outbuf, 0, r->buflen); | ||
580 | + switch (req->cmd.buf[0]) { | ||
581 | + case TEST_UNIT_READY: | ||
582 | + assert(blk_is_available(lu->qdev.conf.blk)); | ||
583 | + break; | ||
584 | + case INQUIRY: | ||
585 | + buflen = ufs_scsi_emulate_inquiry(req, outbuf, r->buflen); | ||
586 | + if (buflen < 0) { | ||
587 | + goto illegal_request; | ||
588 | + } | ||
589 | + break; | ||
590 | + case MODE_SENSE_10: | ||
591 | + buflen = ufs_scsi_emulate_mode_sense(r, outbuf); | ||
592 | + if (buflen < 0) { | ||
593 | + goto illegal_request; | ||
594 | + } | ||
595 | + break; | ||
596 | + case READ_CAPACITY_10: | ||
597 | + /* The normal LEN field for this command is zero. */ | ||
598 | + memset(outbuf, 0, 8); | ||
599 | + if (lu->qdev.max_lba > 0) { | ||
600 | + last_block = lu->qdev.max_lba - 1; | ||
601 | + }; | ||
602 | + outbuf[0] = (last_block >> 24) & 0xff; | ||
603 | + outbuf[1] = (last_block >> 16) & 0xff; | ||
604 | + outbuf[2] = (last_block >> 8) & 0xff; | ||
605 | + outbuf[3] = last_block & 0xff; | ||
606 | + outbuf[4] = (lu->qdev.blocksize >> 24) & 0xff; | ||
607 | + outbuf[5] = (lu->qdev.blocksize >> 16) & 0xff; | ||
608 | + outbuf[6] = (lu->qdev.blocksize >> 8) & 0xff; | ||
609 | + outbuf[7] = lu->qdev.blocksize & 0xff; | ||
610 | + break; | ||
611 | + case REQUEST_SENSE: | ||
612 | + /* Just return "NO SENSE". */ | ||
613 | + buflen = scsi_convert_sense(NULL, 0, outbuf, r->buflen, | ||
614 | + (req->cmd.buf[1] & 1) == 0); | ||
615 | + if (buflen < 0) { | ||
616 | + goto illegal_request; | ||
617 | + } | ||
618 | + break; | ||
619 | + case SYNCHRONIZE_CACHE: | ||
620 | + /* The request is used as the AIO opaque value, so add a ref. */ | ||
621 | + scsi_req_ref(&r->req); | ||
622 | + block_acct_start(blk_get_stats(lu->qdev.conf.blk), &r->acct, 0, | ||
623 | + BLOCK_ACCT_FLUSH); | ||
624 | + r->req.aiocb = blk_aio_flush(lu->qdev.conf.blk, scsi_aio_complete, r); | ||
625 | + return 0; | ||
626 | + case VERIFY_10: | ||
627 | + trace_ufs_scsi_emulate_command_VERIFY((req->cmd.buf[1] >> 1) & 3); | ||
628 | + if (req->cmd.buf[1] & 6) { | ||
629 | + goto illegal_request; | ||
630 | + } | ||
631 | + break; | ||
632 | + case SERVICE_ACTION_IN_16: | ||
633 | + /* Service Action In subcommands. */ | ||
634 | + if ((req->cmd.buf[1] & 31) == SAI_READ_CAPACITY_16) { | ||
635 | + trace_ufs_scsi_emulate_command_SAI_16(); | ||
636 | + memset(outbuf, 0, req->cmd.xfer); | ||
637 | + | ||
638 | + if (lu->qdev.max_lba > 0) { | ||
639 | + last_block = lu->qdev.max_lba - 1; | ||
640 | + }; | ||
641 | + outbuf[0] = 0; | ||
642 | + outbuf[1] = 0; | ||
643 | + outbuf[2] = 0; | ||
644 | + outbuf[3] = 0; | ||
645 | + outbuf[4] = (last_block >> 24) & 0xff; | ||
646 | + outbuf[5] = (last_block >> 16) & 0xff; | ||
647 | + outbuf[6] = (last_block >> 8) & 0xff; | ||
648 | + outbuf[7] = last_block & 0xff; | ||
649 | + outbuf[8] = (lu->qdev.blocksize >> 24) & 0xff; | ||
650 | + outbuf[9] = (lu->qdev.blocksize >> 16) & 0xff; | ||
651 | + outbuf[10] = (lu->qdev.blocksize >> 8) & 0xff; | ||
652 | + outbuf[11] = lu->qdev.blocksize & 0xff; | ||
653 | + outbuf[12] = 0; | ||
654 | + outbuf[13] = get_physical_block_exp(&lu->qdev.conf); | ||
655 | + | ||
656 | + if (lu->unit_desc.provisioning_type == 2 || | ||
657 | + lu->unit_desc.provisioning_type == 3) { | ||
658 | + outbuf[14] = 0x80; | ||
659 | + } | ||
660 | + /* Protection, exponent and lowest lba field left blank. */ | ||
661 | + break; | ||
662 | + } | ||
663 | + trace_ufs_scsi_emulate_command_SAI_unsupported(); | ||
664 | + goto illegal_request; | ||
665 | + case MODE_SELECT_10: | ||
666 | + trace_ufs_scsi_emulate_command_MODE_SELECT_10(r->req.cmd.xfer); | ||
667 | + break; | ||
668 | + case START_STOP: | ||
669 | + /* | ||
670 | + * TODO: START_STOP is not yet implemented. It always returns success. | ||
671 | + * Revisit it when ufs power management is implemented. | ||
672 | + */ | ||
673 | + trace_ufs_scsi_emulate_command_START_STOP(); | ||
674 | + break; | ||
675 | + case FORMAT_UNIT: | ||
676 | + trace_ufs_scsi_emulate_command_FORMAT_UNIT(); | ||
677 | + break; | ||
678 | + case SEND_DIAGNOSTIC: | ||
679 | + trace_ufs_scsi_emulate_command_SEND_DIAGNOSTIC(); | ||
680 | + break; | ||
681 | + default: | ||
682 | + trace_ufs_scsi_emulate_command_UNKNOWN(buf[0], | ||
683 | + scsi_command_name(buf[0])); | ||
684 | + scsi_check_condition(r, SENSE_CODE(INVALID_OPCODE)); | ||
685 | + return 0; | ||
686 | + } | ||
687 | + assert(!r->req.aiocb); | ||
688 | + r->iov.iov_len = MIN(r->buflen, req->cmd.xfer); | ||
689 | + if (r->iov.iov_len == 0) { | ||
690 | + scsi_req_complete(&r->req, GOOD); | ||
691 | + } | ||
692 | + if (r->req.cmd.mode == SCSI_XFER_TO_DEV) { | ||
693 | + assert(r->iov.iov_len == req->cmd.xfer); | ||
694 | + return -r->iov.iov_len; | ||
695 | + } else { | ||
696 | + return r->iov.iov_len; | ||
697 | + } | ||
698 | + | ||
699 | +illegal_request: | ||
700 | + if (r->req.status == -1) { | ||
701 | + scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); | ||
702 | + } | ||
703 | + return 0; | ||
704 | +} | ||
705 | + | ||
706 | +static void ufs_scsi_emulate_read_data(SCSIRequest *req) | ||
707 | +{ | ||
708 | + UfsSCSIReq *r = DO_UPCAST(UfsSCSIReq, req, req); | ||
709 | + int buflen = r->iov.iov_len; | ||
710 | + | ||
711 | + if (buflen) { | ||
712 | + trace_ufs_scsi_emulate_read_data(buflen); | ||
713 | + r->iov.iov_len = 0; | ||
714 | + r->started = true; | ||
715 | + scsi_req_data(&r->req, buflen); | ||
716 | + return; | ||
717 | + } | ||
718 | + | ||
719 | + /* This also clears the sense buffer for REQUEST SENSE. */ | ||
720 | + scsi_req_complete(&r->req, GOOD); | ||
721 | +} | ||
722 | + | ||
723 | +static int ufs_scsi_check_mode_select(UfsLu *lu, int page, uint8_t *inbuf, | ||
724 | + int inlen) | ||
725 | +{ | ||
726 | + uint8_t mode_current[SCSI_MAX_MODE_LEN]; | ||
727 | + uint8_t mode_changeable[SCSI_MAX_MODE_LEN]; | ||
728 | + uint8_t *p; | ||
729 | + int len, expected_len, changeable_len, i; | ||
730 | + | ||
731 | + /* | ||
732 | + * The input buffer does not include the page header, so it is | ||
733 | + * off by 2 bytes. | ||
734 | + */ | ||
735 | + expected_len = inlen + 2; | ||
736 | + if (expected_len > SCSI_MAX_MODE_LEN) { | ||
737 | + return -1; | ||
738 | + } | ||
739 | + | ||
740 | + /* MODE_PAGE_ALLS is only valid for MODE SENSE commands */ | ||
741 | + if (page == MODE_PAGE_ALLS) { | ||
742 | + return -1; | ||
743 | + } | ||
744 | + | ||
745 | + p = mode_current; | ||
746 | + memset(mode_current, 0, inlen + 2); | ||
747 | + len = mode_sense_page(lu, page, &p, 0); | ||
748 | + if (len < 0 || len != expected_len) { | ||
749 | + return -1; | ||
750 | + } | ||
751 | + | ||
752 | + p = mode_changeable; | ||
753 | + memset(mode_changeable, 0, inlen + 2); | ||
754 | + changeable_len = mode_sense_page(lu, page, &p, 1); | ||
755 | + assert(changeable_len == len); | ||
756 | + | ||
757 | + /* | ||
758 | + * Check that unchangeable bits are the same as what MODE SENSE | ||
759 | + * would return. | ||
760 | + */ | ||
761 | + for (i = 2; i < len; i++) { | ||
762 | + if (((mode_current[i] ^ inbuf[i - 2]) & ~mode_changeable[i]) != 0) { | ||
763 | + return -1; | ||
764 | + } | ||
765 | + } | ||
766 | + return 0; | ||
767 | +} | ||
768 | + | ||
769 | +static void ufs_scsi_apply_mode_select(UfsLu *lu, int page, uint8_t *p) | ||
770 | +{ | ||
771 | + switch (page) { | ||
772 | + case MODE_PAGE_CACHING: | ||
773 | + blk_set_enable_write_cache(lu->qdev.conf.blk, (p[0] & 4) != 0); | ||
774 | + break; | ||
775 | + | ||
776 | + default: | ||
777 | + break; | ||
778 | + } | ||
779 | +} | ||
780 | + | ||
781 | +static int mode_select_pages(UfsSCSIReq *r, uint8_t *p, int len, bool change) | ||
782 | +{ | ||
783 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
784 | + | ||
785 | + while (len > 0) { | ||
786 | + int page, page_len; | ||
787 | + | ||
788 | + page = p[0] & 0x3f; | ||
789 | + if (p[0] & 0x40) { | ||
790 | + goto invalid_param; | ||
791 | + } else { | ||
792 | + if (len < 2) { | ||
793 | + goto invalid_param_len; | ||
794 | + } | ||
795 | + page_len = p[1]; | ||
796 | + p += 2; | ||
797 | + len -= 2; | ||
798 | + } | ||
799 | + | ||
800 | + if (page_len > len) { | ||
801 | + goto invalid_param_len; | ||
802 | + } | ||
803 | + | ||
804 | + if (!change) { | ||
805 | + if (ufs_scsi_check_mode_select(lu, page, p, page_len) < 0) { | ||
806 | + goto invalid_param; | ||
807 | + } | ||
808 | + } else { | ||
809 | + ufs_scsi_apply_mode_select(lu, page, p); | ||
810 | + } | ||
811 | + | ||
812 | + p += page_len; | ||
813 | + len -= page_len; | ||
814 | + } | ||
815 | + return 0; | ||
816 | + | ||
817 | +invalid_param: | ||
818 | + scsi_check_condition(r, SENSE_CODE(INVALID_PARAM)); | ||
819 | + return -1; | ||
820 | + | ||
821 | +invalid_param_len: | ||
822 | + scsi_check_condition(r, SENSE_CODE(INVALID_PARAM_LEN)); | ||
823 | + return -1; | ||
824 | +} | ||
825 | + | ||
826 | +static void ufs_scsi_emulate_mode_select(UfsSCSIReq *r, uint8_t *inbuf) | ||
827 | +{ | ||
828 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
829 | + uint8_t *p = inbuf; | ||
830 | + int len = r->req.cmd.xfer; | ||
831 | + int hdr_len = 8; | ||
832 | + int bd_len; | ||
833 | + int pass; | ||
834 | + | ||
835 | + /* We only support PF=1, SP=0. */ | ||
836 | + if ((r->req.cmd.buf[1] & 0x11) != 0x10) { | ||
837 | + goto invalid_field; | ||
838 | + } | ||
839 | + | ||
840 | + if (len < hdr_len) { | ||
841 | + goto invalid_param_len; | ||
842 | + } | ||
843 | + | ||
844 | + bd_len = lduw_be_p(&p[6]); | ||
845 | + if (bd_len != 0) { | ||
846 | + goto invalid_param; | ||
847 | + } | ||
848 | + | ||
849 | + len -= hdr_len; | ||
850 | + p += hdr_len; | ||
851 | + | ||
852 | + /* Ensure no change is made if there is an error! */ | ||
853 | + for (pass = 0; pass < 2; pass++) { | ||
854 | + if (mode_select_pages(r, p, len, pass == 1) < 0) { | ||
855 | + assert(pass == 0); | ||
856 | + return; | ||
857 | + } | ||
858 | + } | ||
859 | + | ||
860 | + if (!blk_enable_write_cache(lu->qdev.conf.blk)) { | ||
861 | + /* The request is used as the AIO opaque value, so add a ref. */ | ||
862 | + scsi_req_ref(&r->req); | ||
863 | + block_acct_start(blk_get_stats(lu->qdev.conf.blk), &r->acct, 0, | ||
864 | + BLOCK_ACCT_FLUSH); | ||
865 | + r->req.aiocb = blk_aio_flush(lu->qdev.conf.blk, scsi_aio_complete, r); | ||
866 | + return; | ||
867 | + } | ||
868 | + | ||
869 | + scsi_req_complete(&r->req, GOOD); | ||
870 | + return; | ||
871 | + | ||
872 | +invalid_param: | ||
873 | + scsi_check_condition(r, SENSE_CODE(INVALID_PARAM)); | ||
874 | + return; | ||
875 | + | ||
876 | +invalid_param_len: | ||
877 | + scsi_check_condition(r, SENSE_CODE(INVALID_PARAM_LEN)); | ||
878 | + return; | ||
879 | + | ||
880 | +invalid_field: | ||
881 | + scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); | ||
882 | +} | ||
883 | + | ||
884 | +/* block_num and nb_blocks expected to be in qdev blocksize */ | ||
885 | +static inline bool check_lba_range(UfsLu *lu, uint64_t block_num, | ||
886 | + uint32_t nb_blocks) | ||
887 | +{ | ||
888 | + /* | ||
889 | + * The first line tests that no overflow happens when computing the last | ||
890 | + * block. The second line tests that the last accessed block is in | ||
891 | + * range. | ||
892 | + * | ||
893 | + * Careful, the computations should not underflow for nb_blocks == 0, | ||
894 | + * and a 0-block read to the first LBA beyond the end of device is | ||
895 | + * valid. | ||
896 | + */ | ||
897 | + return (block_num <= block_num + nb_blocks && | ||
898 | + block_num + nb_blocks <= lu->qdev.max_lba + 1); | ||
899 | +} | ||
900 | + | ||
901 | +static void ufs_scsi_emulate_write_data(SCSIRequest *req) | ||
902 | +{ | ||
903 | + UfsSCSIReq *r = DO_UPCAST(UfsSCSIReq, req, req); | ||
904 | + | ||
905 | + if (r->iov.iov_len) { | ||
906 | + int buflen = r->iov.iov_len; | ||
907 | + trace_ufs_scsi_emulate_write_data(buflen); | ||
908 | + r->iov.iov_len = 0; | ||
909 | + scsi_req_data(&r->req, buflen); | ||
910 | + return; | ||
911 | + } | ||
912 | + | ||
913 | + switch (req->cmd.buf[0]) { | ||
914 | + case MODE_SELECT_10: | ||
915 | + /* This also clears the sense buffer for REQUEST SENSE. */ | ||
916 | + ufs_scsi_emulate_mode_select(r, r->iov.iov_base); | ||
917 | + break; | ||
918 | + default: | ||
919 | + abort(); | ||
920 | + } | ||
921 | +} | ||
922 | + | ||
923 | +/* Return a pointer to the data buffer. */ | ||
924 | +static uint8_t *ufs_scsi_get_buf(SCSIRequest *req) | ||
925 | +{ | ||
926 | + UfsSCSIReq *r = DO_UPCAST(UfsSCSIReq, req, req); | ||
927 | + | ||
928 | + return (uint8_t *)r->iov.iov_base; | ||
929 | +} | ||
930 | + | ||
931 | +static int32_t ufs_scsi_dma_command(SCSIRequest *req, uint8_t *buf) | ||
932 | +{ | ||
933 | + UfsSCSIReq *r = DO_UPCAST(UfsSCSIReq, req, req); | ||
934 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, req->dev); | ||
935 | + uint32_t len; | ||
936 | + uint8_t command; | ||
937 | + | ||
938 | + command = buf[0]; | ||
939 | + | ||
940 | + if (!blk_is_available(lu->qdev.conf.blk)) { | ||
941 | + scsi_check_condition(r, SENSE_CODE(NO_MEDIUM)); | ||
942 | + return 0; | ||
943 | + } | ||
944 | + | ||
945 | + len = scsi_data_cdb_xfer(r->req.cmd.buf); | ||
946 | + switch (command) { | ||
947 | + case READ_6: | ||
948 | + case READ_10: | ||
949 | + trace_ufs_scsi_dma_command_READ(r->req.cmd.lba, len); | ||
950 | + if (r->req.cmd.buf[1] & 0xe0) { | ||
951 | + goto illegal_request; | ||
952 | + } | ||
953 | + if (!check_lba_range(lu, r->req.cmd.lba, len)) { | ||
954 | + goto illegal_lba; | ||
955 | + } | ||
956 | + r->sector = r->req.cmd.lba * (lu->qdev.blocksize / BDRV_SECTOR_SIZE); | ||
957 | + r->sector_count = len * (lu->qdev.blocksize / BDRV_SECTOR_SIZE); | ||
958 | + break; | ||
959 | + case WRITE_6: | ||
960 | + case WRITE_10: | ||
961 | + trace_ufs_scsi_dma_command_WRITE(r->req.cmd.lba, len); | ||
962 | + if (!blk_is_writable(lu->qdev.conf.blk)) { | ||
963 | + scsi_check_condition(r, SENSE_CODE(WRITE_PROTECTED)); | ||
964 | + return 0; | ||
965 | + } | ||
966 | + if (r->req.cmd.buf[1] & 0xe0) { | ||
967 | + goto illegal_request; | ||
968 | + } | ||
969 | + if (!check_lba_range(lu, r->req.cmd.lba, len)) { | ||
970 | + goto illegal_lba; | ||
971 | + } | ||
972 | + r->sector = r->req.cmd.lba * (lu->qdev.blocksize / BDRV_SECTOR_SIZE); | ||
973 | + r->sector_count = len * (lu->qdev.blocksize / BDRV_SECTOR_SIZE); | ||
974 | + break; | ||
975 | + default: | ||
976 | + abort(); | ||
977 | + illegal_request: | ||
978 | + scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); | ||
979 | + return 0; | ||
980 | + illegal_lba: | ||
981 | + scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE)); | ||
982 | + return 0; | ||
983 | + } | ||
984 | + r->need_fua_emulation = ((r->req.cmd.buf[1] & 8) != 0); | ||
985 | + if (r->sector_count == 0) { | ||
986 | + scsi_req_complete(&r->req, GOOD); | ||
987 | + } | ||
988 | + assert(r->iov.iov_len == 0); | ||
989 | + if (r->req.cmd.mode == SCSI_XFER_TO_DEV) { | ||
990 | + return -r->sector_count * BDRV_SECTOR_SIZE; | ||
991 | + } else { | ||
992 | + return r->sector_count * BDRV_SECTOR_SIZE; | ||
993 | + } | ||
994 | +} | ||
995 | + | ||
996 | +static void scsi_write_do_fua(UfsSCSIReq *r) | ||
997 | +{ | ||
998 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
999 | + | ||
1000 | + assert(r->req.aiocb == NULL); | ||
1001 | + assert(!r->req.io_canceled); | ||
1002 | + | ||
1003 | + if (r->need_fua_emulation) { | ||
1004 | + block_acct_start(blk_get_stats(lu->qdev.conf.blk), &r->acct, 0, | ||
1005 | + BLOCK_ACCT_FLUSH); | ||
1006 | + r->req.aiocb = blk_aio_flush(lu->qdev.conf.blk, scsi_aio_complete, r); | ||
1007 | + return; | ||
1008 | + } | ||
1009 | + | ||
1010 | + scsi_req_complete(&r->req, GOOD); | ||
1011 | + scsi_req_unref(&r->req); | ||
1012 | +} | ||
1013 | + | ||
1014 | +static void scsi_dma_complete_noio(UfsSCSIReq *r, int ret) | ||
1015 | +{ | ||
1016 | + assert(r->req.aiocb == NULL); | ||
1017 | + if (ufs_scsi_req_check_error(r, ret, false)) { | ||
1018 | + goto done; | ||
1019 | + } | ||
1020 | + | ||
1021 | + r->sector += r->sector_count; | ||
1022 | + r->sector_count = 0; | ||
1023 | + if (r->req.cmd.mode == SCSI_XFER_TO_DEV) { | ||
1024 | + scsi_write_do_fua(r); | ||
1025 | + return; | ||
1026 | + } else { | ||
1027 | + scsi_req_complete(&r->req, GOOD); | ||
1028 | + } | ||
1029 | + | ||
1030 | +done: | ||
1031 | + scsi_req_unref(&r->req); | ||
1032 | +} | ||
1033 | + | ||
1034 | +static void scsi_dma_complete(void *opaque, int ret) | ||
1035 | +{ | ||
1036 | + UfsSCSIReq *r = (UfsSCSIReq *)opaque; | ||
1037 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
1038 | + | ||
1039 | + assert(r->req.aiocb != NULL); | ||
1040 | + r->req.aiocb = NULL; | ||
1041 | + | ||
1042 | + aio_context_acquire(blk_get_aio_context(lu->qdev.conf.blk)); | ||
1043 | + if (ret < 0) { | ||
1044 | + block_acct_failed(blk_get_stats(lu->qdev.conf.blk), &r->acct); | ||
1045 | + } else { | ||
1046 | + block_acct_done(blk_get_stats(lu->qdev.conf.blk), &r->acct); | ||
1047 | + } | ||
1048 | + scsi_dma_complete_noio(r, ret); | ||
1049 | + aio_context_release(blk_get_aio_context(lu->qdev.conf.blk)); | ||
1050 | +} | ||
1051 | + | ||
1052 | +static BlockAIOCB *scsi_dma_readv(int64_t offset, QEMUIOVector *iov, | ||
1053 | + BlockCompletionFunc *cb, void *cb_opaque, | ||
1054 | + void *opaque) | ||
1055 | +{ | ||
1056 | + UfsSCSIReq *r = opaque; | ||
1057 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
1058 | + return blk_aio_preadv(lu->qdev.conf.blk, offset, iov, 0, cb, cb_opaque); | ||
1059 | +} | ||
1060 | + | ||
1061 | +static void scsi_init_iovec(UfsSCSIReq *r, size_t size) | ||
1062 | +{ | ||
1063 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
1064 | + | ||
1065 | + if (!r->iov.iov_base) { | ||
1066 | + r->buflen = size; | ||
1067 | + r->iov.iov_base = blk_blockalign(lu->qdev.conf.blk, r->buflen); | ||
1068 | + } | ||
1069 | + r->iov.iov_len = MIN(r->sector_count * BDRV_SECTOR_SIZE, r->buflen); | ||
1070 | + qemu_iovec_init_external(&r->qiov, &r->iov, 1); | ||
1071 | +} | ||
1072 | + | ||
1073 | +static void scsi_read_complete_noio(UfsSCSIReq *r, int ret) | ||
1074 | +{ | ||
1075 | + uint32_t n; | ||
1076 | + | ||
1077 | + assert(r->req.aiocb == NULL); | ||
1078 | + if (ufs_scsi_req_check_error(r, ret, false)) { | ||
1079 | + goto done; | ||
1080 | + } | ||
1081 | + | ||
1082 | + n = r->qiov.size / BDRV_SECTOR_SIZE; | ||
1083 | + r->sector += n; | ||
1084 | + r->sector_count -= n; | ||
1085 | + scsi_req_data(&r->req, r->qiov.size); | ||
1086 | + | ||
1087 | +done: | ||
1088 | + scsi_req_unref(&r->req); | ||
1089 | +} | ||
1090 | + | ||
1091 | +static void scsi_read_complete(void *opaque, int ret) | ||
1092 | +{ | ||
1093 | + UfsSCSIReq *r = (UfsSCSIReq *)opaque; | ||
1094 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
1095 | + | ||
1096 | + assert(r->req.aiocb != NULL); | ||
1097 | + r->req.aiocb = NULL; | ||
1098 | + trace_ufs_scsi_read_data_count(r->sector_count); | ||
1099 | + aio_context_acquire(blk_get_aio_context(lu->qdev.conf.blk)); | ||
1100 | + if (ret < 0) { | ||
1101 | + block_acct_failed(blk_get_stats(lu->qdev.conf.blk), &r->acct); | ||
1102 | + } else { | ||
1103 | + block_acct_done(blk_get_stats(lu->qdev.conf.blk), &r->acct); | ||
1104 | + trace_ufs_scsi_read_complete(r->req.tag, r->qiov.size); | ||
1105 | + } | ||
1106 | + scsi_read_complete_noio(r, ret); | ||
1107 | + aio_context_release(blk_get_aio_context(lu->qdev.conf.blk)); | ||
1108 | +} | ||
1109 | + | ||
1110 | +/* Actually issue a read to the block device. */ | ||
1111 | +static void scsi_do_read(UfsSCSIReq *r, int ret) | ||
1112 | +{ | ||
1113 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
1114 | + | ||
1115 | + assert(r->req.aiocb == NULL); | ||
1116 | + if (ufs_scsi_req_check_error(r, ret, false)) { | ||
1117 | + goto done; | ||
1118 | + } | ||
1119 | + | ||
1120 | + /* The request is used as the AIO opaque value, so add a ref. */ | ||
1121 | + scsi_req_ref(&r->req); | ||
1122 | + | ||
1123 | + if (r->req.sg) { | ||
1124 | + dma_acct_start(lu->qdev.conf.blk, &r->acct, r->req.sg, BLOCK_ACCT_READ); | ||
1125 | + r->req.residual -= r->req.sg->size; | ||
1126 | + r->req.aiocb = dma_blk_io( | ||
1127 | + blk_get_aio_context(lu->qdev.conf.blk), r->req.sg, | ||
1128 | + r->sector << BDRV_SECTOR_BITS, BDRV_SECTOR_SIZE, scsi_dma_readv, r, | ||
1129 | + scsi_dma_complete, r, DMA_DIRECTION_FROM_DEVICE); | ||
1130 | + } else { | ||
1131 | + scsi_init_iovec(r, SCSI_DMA_BUF_SIZE); | ||
1132 | + block_acct_start(blk_get_stats(lu->qdev.conf.blk), &r->acct, | ||
1133 | + r->qiov.size, BLOCK_ACCT_READ); | ||
1134 | + r->req.aiocb = scsi_dma_readv(r->sector << BDRV_SECTOR_BITS, &r->qiov, | ||
1135 | + scsi_read_complete, r, r); | ||
1136 | + } | ||
1137 | + | ||
1138 | +done: | ||
1139 | + scsi_req_unref(&r->req); | ||
1140 | +} | ||
1141 | + | ||
1142 | +static void scsi_do_read_cb(void *opaque, int ret) | ||
1143 | +{ | ||
1144 | + UfsSCSIReq *r = (UfsSCSIReq *)opaque; | ||
1145 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
1146 | + | ||
1147 | + assert(r->req.aiocb != NULL); | ||
1148 | + r->req.aiocb = NULL; | ||
1149 | + | ||
1150 | + aio_context_acquire(blk_get_aio_context(lu->qdev.conf.blk)); | ||
1151 | + if (ret < 0) { | ||
1152 | + block_acct_failed(blk_get_stats(lu->qdev.conf.blk), &r->acct); | ||
1153 | + } else { | ||
1154 | + block_acct_done(blk_get_stats(lu->qdev.conf.blk), &r->acct); | ||
1155 | + } | ||
1156 | + scsi_do_read(opaque, ret); | ||
1157 | + aio_context_release(blk_get_aio_context(lu->qdev.conf.blk)); | ||
1158 | +} | ||
1159 | + | ||
1160 | +/* Read more data from scsi device into buffer. */ | ||
1161 | +static void scsi_read_data(SCSIRequest *req) | ||
1162 | +{ | ||
1163 | + UfsSCSIReq *r = DO_UPCAST(UfsSCSIReq, req, req); | ||
1164 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
1165 | + bool first; | ||
1166 | + | ||
1167 | + trace_ufs_scsi_read_data_count(r->sector_count); | ||
1168 | + if (r->sector_count == 0) { | ||
1169 | + /* This also clears the sense buffer for REQUEST SENSE. */ | ||
1170 | + scsi_req_complete(&r->req, GOOD); | ||
1171 | + return; | ||
1172 | + } | ||
1173 | + | ||
1174 | + /* No data transfer may already be in progress */ | ||
1175 | + assert(r->req.aiocb == NULL); | ||
1176 | + | ||
1177 | + /* The request is used as the AIO opaque value, so add a ref. */ | ||
1178 | + scsi_req_ref(&r->req); | ||
1179 | + if (r->req.cmd.mode == SCSI_XFER_TO_DEV) { | ||
1180 | + trace_ufs_scsi_read_data_invalid(); | ||
1181 | + scsi_read_complete_noio(r, -EINVAL); | ||
1182 | + return; | ||
1183 | + } | ||
1184 | + | ||
1185 | + if (!blk_is_available(req->dev->conf.blk)) { | ||
1186 | + scsi_read_complete_noio(r, -ENOMEDIUM); | ||
1187 | + return; | ||
1188 | + } | ||
1189 | + | ||
1190 | + first = !r->started; | ||
1191 | + r->started = true; | ||
1192 | + if (first && r->need_fua_emulation) { | ||
1193 | + block_acct_start(blk_get_stats(lu->qdev.conf.blk), &r->acct, 0, | ||
1194 | + BLOCK_ACCT_FLUSH); | ||
1195 | + r->req.aiocb = blk_aio_flush(lu->qdev.conf.blk, scsi_do_read_cb, r); | ||
1196 | + } else { | ||
1197 | + scsi_do_read(r, 0); | ||
1198 | + } | ||
1199 | +} | ||
1200 | + | ||
1201 | +static void scsi_write_complete_noio(UfsSCSIReq *r, int ret) | ||
1202 | +{ | ||
1203 | + uint32_t n; | ||
1204 | + | ||
1205 | + assert(r->req.aiocb == NULL); | ||
1206 | + if (ufs_scsi_req_check_error(r, ret, false)) { | ||
1207 | + goto done; | ||
1208 | + } | ||
1209 | + | ||
1210 | + n = r->qiov.size / BDRV_SECTOR_SIZE; | ||
1211 | + r->sector += n; | ||
1212 | + r->sector_count -= n; | ||
1213 | + if (r->sector_count == 0) { | ||
1214 | + scsi_write_do_fua(r); | ||
1215 | + return; | ||
1216 | + } else { | ||
1217 | + scsi_init_iovec(r, SCSI_DMA_BUF_SIZE); | ||
1218 | + trace_ufs_scsi_write_complete_noio(r->req.tag, r->qiov.size); | ||
1219 | + scsi_req_data(&r->req, r->qiov.size); | ||
1220 | + } | ||
1221 | + | ||
1222 | +done: | ||
1223 | + scsi_req_unref(&r->req); | ||
1224 | +} | ||
1225 | + | ||
1226 | +static void scsi_write_complete(void *opaque, int ret) | ||
1227 | +{ | ||
1228 | + UfsSCSIReq *r = (UfsSCSIReq *)opaque; | ||
1229 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
1230 | + | ||
1231 | + assert(r->req.aiocb != NULL); | ||
1232 | + r->req.aiocb = NULL; | ||
1233 | + | ||
1234 | + aio_context_acquire(blk_get_aio_context(lu->qdev.conf.blk)); | ||
1235 | + if (ret < 0) { | ||
1236 | + block_acct_failed(blk_get_stats(lu->qdev.conf.blk), &r->acct); | ||
1237 | + } else { | ||
1238 | + block_acct_done(blk_get_stats(lu->qdev.conf.blk), &r->acct); | ||
1239 | + } | ||
1240 | + scsi_write_complete_noio(r, ret); | ||
1241 | + aio_context_release(blk_get_aio_context(lu->qdev.conf.blk)); | ||
1242 | +} | ||
1243 | + | ||
1244 | +static BlockAIOCB *scsi_dma_writev(int64_t offset, QEMUIOVector *iov, | ||
1245 | + BlockCompletionFunc *cb, void *cb_opaque, | ||
1246 | + void *opaque) | ||
1247 | +{ | ||
1248 | + UfsSCSIReq *r = opaque; | ||
1249 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
1250 | + return blk_aio_pwritev(lu->qdev.conf.blk, offset, iov, 0, cb, cb_opaque); | ||
1251 | +} | ||
1252 | + | ||
1253 | +static void scsi_write_data(SCSIRequest *req) | ||
1254 | +{ | ||
1255 | + UfsSCSIReq *r = DO_UPCAST(UfsSCSIReq, req, req); | ||
1256 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, r->req.dev); | ||
1257 | + | ||
1258 | + /* No data transfer may already be in progress */ | ||
1259 | + assert(r->req.aiocb == NULL); | ||
1260 | + | ||
1261 | + /* The request is used as the AIO opaque value, so add a ref. */ | ||
1262 | + scsi_req_ref(&r->req); | ||
1263 | + if (r->req.cmd.mode != SCSI_XFER_TO_DEV) { | ||
1264 | + trace_ufs_scsi_write_data_invalid(); | ||
1265 | + scsi_write_complete_noio(r, -EINVAL); | ||
1266 | + return; | ||
1267 | + } | ||
1268 | + | ||
1269 | + if (!r->req.sg && !r->qiov.size) { | ||
1270 | + /* Called for the first time. Ask the driver to send us more data. */ | ||
1271 | + r->started = true; | ||
1272 | + scsi_write_complete_noio(r, 0); | ||
1273 | + return; | ||
1274 | + } | ||
1275 | + if (!blk_is_available(req->dev->conf.blk)) { | ||
1276 | + scsi_write_complete_noio(r, -ENOMEDIUM); | ||
1277 | + return; | ||
1278 | + } | ||
1279 | + | ||
1280 | + if (r->req.sg) { | ||
1281 | + dma_acct_start(lu->qdev.conf.blk, &r->acct, r->req.sg, | ||
1282 | + BLOCK_ACCT_WRITE); | ||
1283 | + r->req.residual -= r->req.sg->size; | ||
1284 | + r->req.aiocb = dma_blk_io( | ||
1285 | + blk_get_aio_context(lu->qdev.conf.blk), r->req.sg, | ||
1286 | + r->sector << BDRV_SECTOR_BITS, BDRV_SECTOR_SIZE, scsi_dma_writev, r, | ||
1287 | + scsi_dma_complete, r, DMA_DIRECTION_TO_DEVICE); | ||
1288 | + } else { | ||
1289 | + block_acct_start(blk_get_stats(lu->qdev.conf.blk), &r->acct, | ||
1290 | + r->qiov.size, BLOCK_ACCT_WRITE); | ||
1291 | + r->req.aiocb = scsi_dma_writev(r->sector << BDRV_SECTOR_BITS, &r->qiov, | ||
1292 | + scsi_write_complete, r, r); | ||
1293 | + } | ||
1294 | +} | ||
1295 | + | ||
1296 | +static const SCSIReqOps ufs_scsi_emulate_reqops = { | ||
1297 | + .size = sizeof(UfsSCSIReq), | ||
1298 | + .free_req = ufs_scsi_free_request, | ||
1299 | + .send_command = ufs_scsi_emulate_command, | ||
1300 | + .read_data = ufs_scsi_emulate_read_data, | ||
1301 | + .write_data = ufs_scsi_emulate_write_data, | ||
1302 | + .get_buf = ufs_scsi_get_buf, | ||
1303 | +}; | ||
1304 | + | ||
1305 | +static const SCSIReqOps ufs_scsi_dma_reqops = { | ||
1306 | + .size = sizeof(UfsSCSIReq), | ||
1307 | + .free_req = ufs_scsi_free_request, | ||
1308 | + .send_command = ufs_scsi_dma_command, | ||
1309 | + .read_data = scsi_read_data, | ||
1310 | + .write_data = scsi_write_data, | ||
1311 | + .get_buf = ufs_scsi_get_buf, | ||
1312 | +}; | ||
1313 | + | ||
1314 | +/* | ||
1315 | + * Following commands are not yet supported | ||
1316 | + * PRE_FETCH(10), | ||
1317 | + * UNMAP, | ||
1318 | + * WRITE_BUFFER, READ_BUFFER, | ||
1319 | + * SECURITY_PROTOCOL_IN, SECURITY_PROTOCOL_OUT | ||
1320 | + */ | ||
1321 | +static const SCSIReqOps *const ufs_scsi_reqops_dispatch[256] = { | ||
1322 | + [TEST_UNIT_READY] = &ufs_scsi_emulate_reqops, | ||
1323 | + [INQUIRY] = &ufs_scsi_emulate_reqops, | ||
1324 | + [MODE_SENSE_10] = &ufs_scsi_emulate_reqops, | ||
1325 | + [START_STOP] = &ufs_scsi_emulate_reqops, | ||
1326 | + [READ_CAPACITY_10] = &ufs_scsi_emulate_reqops, | ||
1327 | + [REQUEST_SENSE] = &ufs_scsi_emulate_reqops, | ||
1328 | + [SYNCHRONIZE_CACHE] = &ufs_scsi_emulate_reqops, | ||
1329 | + [MODE_SELECT_10] = &ufs_scsi_emulate_reqops, | ||
1330 | + [VERIFY_10] = &ufs_scsi_emulate_reqops, | ||
1331 | + [FORMAT_UNIT] = &ufs_scsi_emulate_reqops, | ||
1332 | + [SERVICE_ACTION_IN_16] = &ufs_scsi_emulate_reqops, | ||
1333 | + [SEND_DIAGNOSTIC] = &ufs_scsi_emulate_reqops, | ||
1334 | + | ||
1335 | + [READ_6] = &ufs_scsi_dma_reqops, | ||
1336 | + [READ_10] = &ufs_scsi_dma_reqops, | ||
1337 | + [WRITE_6] = &ufs_scsi_dma_reqops, | ||
1338 | + [WRITE_10] = &ufs_scsi_dma_reqops, | ||
1339 | +}; | ||
1340 | + | ||
1341 | +static SCSIRequest *scsi_new_request(SCSIDevice *dev, uint32_t tag, | ||
1342 | + uint32_t lun, uint8_t *buf, | ||
1343 | + void *hba_private) | ||
1344 | +{ | ||
1345 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, dev); | ||
1346 | + SCSIRequest *req; | ||
1347 | + const SCSIReqOps *ops; | ||
1348 | + uint8_t command; | ||
1349 | + | ||
1350 | + command = buf[0]; | ||
1351 | + ops = ufs_scsi_reqops_dispatch[command]; | ||
1352 | + if (!ops) { | ||
1353 | + ops = &ufs_scsi_emulate_reqops; | ||
1354 | + } | ||
1355 | + req = scsi_req_alloc(ops, &lu->qdev, tag, lun, hba_private); | ||
1356 | + | ||
1357 | + return req; | ||
1358 | +} | ||
1359 | + | ||
1360 | +static Property ufs_lu_props[] = { | ||
1361 | + DEFINE_PROP_DRIVE("drive", UfsLu, qdev.conf.blk), | ||
1362 | + DEFINE_PROP_END_OF_LIST(), | ||
1363 | +}; | ||
1364 | + | ||
1365 | +static bool ufs_lu_brdv_init(UfsLu *lu, Error **errp) | ||
1366 | +{ | ||
1367 | + SCSIDevice *dev = &lu->qdev; | ||
1368 | + bool read_only; | ||
1369 | + | ||
1370 | + if (!lu->qdev.conf.blk) { | ||
1371 | + error_setg(errp, "drive property not set"); | ||
1372 | + return false; | ||
1373 | + } | ||
1374 | + | ||
1375 | + if (!blkconf_blocksizes(&lu->qdev.conf, errp)) { | ||
1376 | + return false; | ||
1377 | + } | ||
1378 | + | ||
1379 | + if (blk_get_aio_context(lu->qdev.conf.blk) != qemu_get_aio_context() && | ||
1380 | + !lu->qdev.hba_supports_iothread) { | ||
1381 | + error_setg(errp, "HBA does not support iothreads"); | ||
1382 | + return false; | ||
1383 | + } | ||
1384 | + | ||
1385 | + read_only = !blk_supports_write_perm(lu->qdev.conf.blk); | ||
1386 | + | ||
1387 | + if (!blkconf_apply_backend_options(&dev->conf, read_only, | ||
1388 | + dev->type == TYPE_DISK, errp)) { | ||
1389 | + return false; | ||
1390 | + } | ||
1391 | + | ||
1392 | + if (blk_is_sg(lu->qdev.conf.blk)) { | ||
1393 | + error_setg(errp, "unwanted /dev/sg*"); | ||
1394 | + return false; | ||
1395 | + } | ||
1396 | + | ||
1397 | + blk_iostatus_enable(lu->qdev.conf.blk); | ||
1398 | + return true; | ||
1399 | +} | ||
1400 | + | ||
1401 | +static bool ufs_add_lu(UfsHc *u, UfsLu *lu, Error **errp) | ||
1402 | +{ | ||
1403 | + BlockBackend *blk = lu->qdev.conf.blk; | ||
1404 | + int64_t brdv_len = blk_getlength(blk); | ||
1405 | + uint64_t raw_dev_cap = | ||
1406 | + be64_to_cpu(u->geometry_desc.total_raw_device_capacity); | ||
1407 | + | ||
1408 | + if (u->device_desc.number_lu >= UFS_MAX_LUS) { | ||
1409 | + error_setg(errp, "ufs host controller has too many logical units."); | ||
1410 | + return false; | ||
1411 | + } | ||
1412 | + | ||
1413 | + if (u->lus[lu->lun] != NULL) { | ||
1414 | + error_setg(errp, "ufs logical unit %d already exists.", lu->lun); | ||
1415 | + return false; | ||
1416 | + } | ||
1417 | + | ||
1418 | + u->lus[lu->lun] = lu; | ||
1419 | + u->device_desc.number_lu++; | ||
1420 | + raw_dev_cap += (brdv_len >> UFS_GEOMETRY_CAPACITY_SHIFT); | ||
1421 | + u->geometry_desc.total_raw_device_capacity = cpu_to_be64(raw_dev_cap); | ||
1422 | + return true; | ||
1423 | +} | ||
1424 | + | ||
1425 | +static inline uint8_t ufs_log2(uint64_t input) | ||
1426 | +{ | ||
1427 | + int log = 0; | ||
1428 | + while (input >>= 1) { | ||
1429 | + log++; | ||
1430 | + } | ||
1431 | + return log; | ||
1432 | +} | ||
1433 | + | ||
1434 | +static void ufs_init_lu(UfsLu *lu) | ||
1435 | +{ | ||
1436 | + BlockBackend *blk = lu->qdev.conf.blk; | ||
1437 | + int64_t brdv_len = blk_getlength(blk); | ||
1438 | + | ||
1439 | + lu->lun = lu->qdev.lun; | ||
1440 | + memset(&lu->unit_desc, 0, sizeof(lu->unit_desc)); | ||
1441 | + lu->unit_desc.length = sizeof(UnitDescriptor); | ||
1442 | + lu->unit_desc.descriptor_idn = UFS_QUERY_DESC_IDN_UNIT; | ||
1443 | + lu->unit_desc.lu_enable = 0x01; | ||
1444 | + lu->unit_desc.logical_block_size = ufs_log2(lu->qdev.blocksize); | ||
1445 | + lu->unit_desc.unit_index = lu->qdev.lun; | ||
1446 | + lu->unit_desc.logical_block_count = | ||
1447 | + cpu_to_be64(brdv_len / (1 << lu->unit_desc.logical_block_size)); | ||
1448 | +} | ||
1449 | + | ||
1450 | +static bool ufs_lu_check_constraints(UfsLu *lu, Error **errp) | ||
1451 | +{ | ||
1452 | + if (!lu->qdev.conf.blk) { | ||
1453 | + error_setg(errp, "drive property not set"); | ||
1454 | + return false; | ||
1455 | + } | ||
1456 | + | ||
1457 | + if (lu->qdev.channel != 0) { | ||
1458 | + error_setg(errp, "ufs logical unit does not support channel"); | ||
1459 | + return false; | ||
1460 | + } | ||
1461 | + | ||
1462 | + if (lu->qdev.lun >= UFS_MAX_LUS) { | ||
1463 | + error_setg(errp, "lun must be between 1 and %d", UFS_MAX_LUS - 1); | ||
1464 | + return false; | ||
1465 | + } | ||
1466 | + | ||
1467 | + return true; | ||
1468 | +} | ||
1469 | + | ||
1470 | +static void ufs_lu_realize(SCSIDevice *dev, Error **errp) | ||
1471 | +{ | ||
1472 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, dev); | ||
1473 | + BusState *s = qdev_get_parent_bus(&dev->qdev); | ||
1474 | + UfsHc *u = UFS(s->parent); | ||
1475 | + AioContext *ctx = NULL; | ||
1476 | + uint64_t nb_sectors, nb_blocks; | ||
1477 | + | ||
1478 | + if (!ufs_lu_check_constraints(lu, errp)) { | ||
1479 | + return; | ||
1480 | + } | ||
1481 | + | ||
1482 | + if (lu->qdev.conf.blk) { | ||
1483 | + ctx = blk_get_aio_context(lu->qdev.conf.blk); | ||
1484 | + aio_context_acquire(ctx); | ||
1485 | + if (!blkconf_blocksizes(&lu->qdev.conf, errp)) { | ||
1486 | + goto out; | ||
1487 | + } | ||
1488 | + } | ||
1489 | + lu->qdev.blocksize = UFS_BLOCK_SIZE; | ||
1490 | + blk_get_geometry(lu->qdev.conf.blk, &nb_sectors); | ||
1491 | + nb_blocks = nb_sectors / (lu->qdev.blocksize / BDRV_SECTOR_SIZE); | ||
1492 | + if (nb_blocks > UINT32_MAX) { | ||
1493 | + nb_blocks = UINT32_MAX; | ||
1494 | + } | ||
1495 | + lu->qdev.max_lba = nb_blocks; | ||
1496 | + lu->qdev.type = TYPE_DISK; | ||
1497 | + | ||
1498 | + ufs_init_lu(lu); | ||
1499 | + if (!ufs_add_lu(u, lu, errp)) { | ||
1500 | + goto out; | ||
1501 | + } | ||
1502 | + | ||
1503 | + ufs_lu_brdv_init(lu, errp); | ||
1504 | +out: | ||
1505 | + if (ctx) { | ||
1506 | + aio_context_release(ctx); | ||
1507 | + } | ||
1508 | +} | ||
1509 | + | ||
1510 | +static void ufs_lu_unrealize(SCSIDevice *dev) | ||
1511 | +{ | ||
1512 | + UfsLu *lu = DO_UPCAST(UfsLu, qdev, dev); | ||
1513 | + | ||
1514 | + blk_drain(lu->qdev.conf.blk); | ||
1515 | +} | ||
1516 | + | ||
1517 | +static void ufs_wlu_realize(DeviceState *qdev, Error **errp) | ||
1518 | +{ | ||
1519 | + UfsWLu *wlu = UFSWLU(qdev); | ||
1520 | + SCSIDevice *dev = &wlu->qdev; | ||
1521 | + | ||
1522 | + if (!is_wlun(dev->lun)) { | ||
1523 | + error_setg(errp, "not well-known logical unit number"); | ||
1524 | + return; | ||
1525 | + } | ||
1526 | + | ||
1527 | + QTAILQ_INIT(&dev->requests); | ||
1528 | +} | ||
1529 | + | ||
1530 | +static void ufs_lu_class_init(ObjectClass *oc, void *data) | ||
1531 | +{ | ||
1532 | + DeviceClass *dc = DEVICE_CLASS(oc); | ||
1533 | + SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(oc); | ||
1534 | + | ||
1535 | + sc->realize = ufs_lu_realize; | ||
1536 | + sc->unrealize = ufs_lu_unrealize; | ||
1537 | + sc->alloc_req = scsi_new_request; | ||
1538 | + dc->bus_type = TYPE_UFS_BUS; | ||
1539 | + device_class_set_props(dc, ufs_lu_props); | ||
1540 | + dc->desc = "Virtual UFS logical unit"; | ||
1541 | +} | ||
1542 | + | ||
1543 | +static void ufs_wlu_class_init(ObjectClass *oc, void *data) | ||
1544 | +{ | ||
1545 | + DeviceClass *dc = DEVICE_CLASS(oc); | ||
1546 | + SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(oc); | ||
1547 | + | ||
1548 | + /* | ||
1549 | + * The realize() function of TYPE_SCSI_DEVICE causes a segmentation fault | ||
1550 | + * if a block drive does not exist. Define a new realize function for | ||
1551 | + * well-known LUs that do not have a block drive. | ||
1552 | + */ | ||
1553 | + dc->realize = ufs_wlu_realize; | ||
1554 | + sc->alloc_req = scsi_new_request; | ||
1555 | + dc->bus_type = TYPE_UFS_BUS; | ||
1556 | + dc->desc = "Virtual UFS well-known logical unit"; | ||
1557 | +} | ||
1558 | + | ||
1559 | +static const TypeInfo ufs_lu_info = { | ||
1560 | + .name = TYPE_UFS_LU, | ||
1561 | + .parent = TYPE_SCSI_DEVICE, | ||
1562 | + .class_init = ufs_lu_class_init, | ||
1563 | + .instance_size = sizeof(UfsLu), | ||
1564 | +}; | ||
1565 | + | ||
1566 | +static const TypeInfo ufs_wlu_info = { | ||
1567 | + .name = TYPE_UFS_WLU, | ||
1568 | + .parent = TYPE_SCSI_DEVICE, | ||
1569 | + .class_init = ufs_wlu_class_init, | ||
1570 | + .instance_size = sizeof(UfsWLu), | ||
1571 | +}; | ||
1572 | + | ||
1573 | +static void ufs_lu_register_types(void) | ||
1574 | +{ | ||
1575 | + type_register_static(&ufs_lu_info); | ||
1576 | + type_register_static(&ufs_wlu_info); | ||
1577 | +} | ||
1578 | + | ||
1579 | +type_init(ufs_lu_register_types) | ||
1580 | diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c | ||
1581 | index XXXXXXX..XXXXXXX 100644 | ||
1582 | --- a/hw/ufs/ufs.c | ||
1583 | +++ b/hw/ufs/ufs.c | ||
1584 | @@ -XXX,XX +XXX,XX @@ | ||
1585 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
1586 | */ | ||
1587 | |||
1588 | +/** | ||
1589 | + * Reference Specs: https://www.jedec.org/, 3.1 | ||
1590 | + * | ||
1591 | + * Usage | ||
1592 | + * ----- | ||
1593 | + * | ||
1594 | + * Add options: | ||
1595 | + * -drive file=<file>,if=none,id=<drive_id> | ||
1596 | + * -device ufs,serial=<serial>,id=<bus_name>, \ | ||
1597 | + * nutrs=<N[optional]>,nutmrs=<N[optional]> | ||
1598 | + * -device ufs-lu,drive=<drive_id>,bus=<bus_name> | ||
1599 | + */ | ||
1600 | + | ||
1601 | #include "qemu/osdep.h" | ||
1602 | #include "qapi/error.h" | ||
1603 | #include "migration/vmstate.h" | ||
1604 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps ufs_mmio_ops = { | ||
1605 | }, | ||
1606 | }; | ||
1607 | |||
1608 | +static QEMUSGList *ufs_get_sg_list(SCSIRequest *scsi_req) | ||
1609 | +{ | ||
1610 | + UfsRequest *req = scsi_req->hba_private; | ||
1611 | + return req->sg; | ||
1612 | +} | ||
1613 | + | ||
1614 | +static void ufs_build_upiu_sense_data(UfsRequest *req, SCSIRequest *scsi_req) | ||
1615 | +{ | ||
1616 | + req->rsp_upiu.sr.sense_data_len = cpu_to_be16(scsi_req->sense_len); | ||
1617 | + assert(scsi_req->sense_len <= SCSI_SENSE_LEN); | ||
1618 | + memcpy(req->rsp_upiu.sr.sense_data, scsi_req->sense, scsi_req->sense_len); | ||
1619 | +} | ||
1620 | + | ||
1621 | static void ufs_build_upiu_header(UfsRequest *req, uint8_t trans_type, | ||
1622 | uint8_t flags, uint8_t response, | ||
1623 | uint8_t scsi_status, | ||
1624 | @@ -XXX,XX +XXX,XX @@ static void ufs_build_upiu_header(UfsRequest *req, uint8_t trans_type, | ||
1625 | req->rsp_upiu.header.data_segment_length = cpu_to_be16(data_segment_length); | ||
1626 | } | ||
1627 | |||
1628 | +static void ufs_scsi_command_complete(SCSIRequest *scsi_req, size_t resid) | ||
1629 | +{ | ||
1630 | + UfsRequest *req = scsi_req->hba_private; | ||
1631 | + int16_t status = scsi_req->status; | ||
1632 | + uint32_t expected_len = be32_to_cpu(req->req_upiu.sc.exp_data_transfer_len); | ||
1633 | + uint32_t transfered_len = scsi_req->cmd.xfer - resid; | ||
1634 | + uint8_t flags = 0, response = UFS_COMMAND_RESULT_SUCESS; | ||
1635 | + uint16_t data_segment_length; | ||
1636 | + | ||
1637 | + if (expected_len > transfered_len) { | ||
1638 | + req->rsp_upiu.sr.residual_transfer_count = | ||
1639 | + cpu_to_be32(expected_len - transfered_len); | ||
1640 | + flags |= UFS_UPIU_FLAG_UNDERFLOW; | ||
1641 | + } else if (expected_len < transfered_len) { | ||
1642 | + req->rsp_upiu.sr.residual_transfer_count = | ||
1643 | + cpu_to_be32(transfered_len - expected_len); | ||
1644 | + flags |= UFS_UPIU_FLAG_OVERFLOW; | ||
1645 | + } | ||
1646 | + | ||
1647 | + if (status != 0) { | ||
1648 | + ufs_build_upiu_sense_data(req, scsi_req); | ||
1649 | + response = UFS_COMMAND_RESULT_FAIL; | ||
1650 | + } | ||
1651 | + | ||
1652 | + data_segment_length = cpu_to_be16(scsi_req->sense_len + | ||
1653 | + sizeof(req->rsp_upiu.sr.sense_data_len)); | ||
1654 | + ufs_build_upiu_header(req, UFS_UPIU_TRANSACTION_RESPONSE, flags, response, | ||
1655 | + status, data_segment_length); | ||
1656 | + | ||
1657 | + ufs_complete_req(req, UFS_REQUEST_SUCCESS); | ||
1658 | + | ||
1659 | + scsi_req->hba_private = NULL; | ||
1660 | + scsi_req_unref(scsi_req); | ||
1661 | +} | ||
1662 | + | ||
1663 | +static const struct SCSIBusInfo ufs_scsi_info = { | ||
1664 | + .tcq = true, | ||
1665 | + .max_target = 0, | ||
1666 | + .max_lun = UFS_MAX_LUS, | ||
1667 | + .max_channel = 0, | ||
1668 | + | ||
1669 | + .get_sg_list = ufs_get_sg_list, | ||
1670 | + .complete = ufs_scsi_command_complete, | ||
1671 | +}; | ||
1672 | + | ||
1673 | +static UfsReqResult ufs_exec_scsi_cmd(UfsRequest *req) | ||
1674 | +{ | ||
1675 | + UfsHc *u = req->hc; | ||
1676 | + uint8_t lun = req->req_upiu.header.lun; | ||
1677 | + uint8_t task_tag = req->req_upiu.header.task_tag; | ||
1678 | + SCSIDevice *dev = NULL; | ||
1679 | + | ||
1680 | + trace_ufs_exec_scsi_cmd(req->slot, lun, req->req_upiu.sc.cdb[0]); | ||
1681 | + | ||
1682 | + if (!is_wlun(lun)) { | ||
1683 | + if (lun >= u->device_desc.number_lu) { | ||
1684 | + trace_ufs_err_scsi_cmd_invalid_lun(lun); | ||
1685 | + return UFS_REQUEST_FAIL; | ||
1686 | + } else if (u->lus[lun] == NULL) { | ||
1687 | + trace_ufs_err_scsi_cmd_invalid_lun(lun); | ||
1688 | + return UFS_REQUEST_FAIL; | ||
1689 | + } | ||
1690 | + } | ||
1691 | + | ||
1692 | + switch (lun) { | ||
1693 | + case UFS_UPIU_REPORT_LUNS_WLUN: | ||
1694 | + dev = &u->report_wlu->qdev; | ||
1695 | + break; | ||
1696 | + case UFS_UPIU_UFS_DEVICE_WLUN: | ||
1697 | + dev = &u->dev_wlu->qdev; | ||
1698 | + break; | ||
1699 | + case UFS_UPIU_BOOT_WLUN: | ||
1700 | + dev = &u->boot_wlu->qdev; | ||
1701 | + break; | ||
1702 | + case UFS_UPIU_RPMB_WLUN: | ||
1703 | + dev = &u->rpmb_wlu->qdev; | ||
1704 | + break; | ||
1705 | + default: | ||
1706 | + dev = &u->lus[lun]->qdev; | ||
1707 | + } | ||
1708 | + | ||
1709 | + SCSIRequest *scsi_req = scsi_req_new( | ||
1710 | + dev, task_tag, lun, req->req_upiu.sc.cdb, UFS_CDB_SIZE, req); | ||
1711 | + | ||
1712 | + uint32_t len = scsi_req_enqueue(scsi_req); | ||
1713 | + if (len) { | ||
1714 | + scsi_req_continue(scsi_req); | ||
1715 | + } | ||
1716 | + | ||
1717 | + return UFS_REQUEST_NO_COMPLETE; | ||
1718 | +} | ||
1719 | + | ||
1720 | static UfsReqResult ufs_exec_nop_cmd(UfsRequest *req) | ||
28 | { | 1721 | { |
29 | BDRVQcow2State *s = bs->opaque; | 1722 | trace_ufs_exec_nop_cmd(req->slot); |
30 | - bool found; | 1723 | @@ -XXX,XX +XXX,XX @@ static const RpmbUnitDescriptor rpmb_unit_desc = { |
31 | - Qcow2BitmapList *bm_list; | 1724 | |
32 | + BdrvDirtyBitmap *bitmap; | 1725 | static QueryRespCode ufs_read_unit_desc(UfsRequest *req) |
33 | + uint64_t bitmap_directory_size = 0; | 1726 | { |
34 | + uint32_t nb_bitmaps = 0; | 1727 | + UfsHc *u = req->hc; |
35 | + | 1728 | uint8_t lun = req->req_upiu.qr.index; |
36 | + if (bdrv_find_dirty_bitmap(bs, name)) { | 1729 | |
37 | + error_setg(errp, "Bitmap already exists: %s", name); | 1730 | - if (lun != UFS_UPIU_RPMB_WLUN && lun > UFS_MAX_LUS) { |
1731 | + if (lun != UFS_UPIU_RPMB_WLUN && | ||
1732 | + (lun > UFS_MAX_LUS || u->lus[lun] == NULL)) { | ||
1733 | trace_ufs_err_query_invalid_index(req->req_upiu.qr.opcode, lun); | ||
1734 | return UFS_QUERY_RESULT_INVALID_INDEX; | ||
1735 | } | ||
1736 | @@ -XXX,XX +XXX,XX @@ static QueryRespCode ufs_read_unit_desc(UfsRequest *req) | ||
1737 | if (lun == UFS_UPIU_RPMB_WLUN) { | ||
1738 | memcpy(&req->rsp_upiu.qr.data, &rpmb_unit_desc, rpmb_unit_desc.length); | ||
1739 | } else { | ||
1740 | - /* unit descriptor is not yet supported */ | ||
1741 | - return UFS_QUERY_RESULT_INVALID_INDEX; | ||
1742 | + memcpy(&req->rsp_upiu.qr.data, &u->lus[lun]->unit_desc, | ||
1743 | + sizeof(u->lus[lun]->unit_desc)); | ||
1744 | } | ||
1745 | |||
1746 | return UFS_QUERY_RESULT_SUCCESS; | ||
1747 | @@ -XXX,XX +XXX,XX @@ static void ufs_exec_req(UfsRequest *req) | ||
1748 | req_result = ufs_exec_nop_cmd(req); | ||
1749 | break; | ||
1750 | case UFS_UPIU_TRANSACTION_COMMAND: | ||
1751 | - /* Not yet implemented */ | ||
1752 | - req_result = UFS_REQUEST_FAIL; | ||
1753 | + req_result = ufs_exec_scsi_cmd(req); | ||
1754 | break; | ||
1755 | case UFS_UPIU_TRANSACTION_QUERY_REQ: | ||
1756 | req_result = ufs_exec_query_cmd(req); | ||
1757 | @@ -XXX,XX +XXX,XX @@ static void ufs_exec_req(UfsRequest *req) | ||
1758 | req_result = UFS_REQUEST_FAIL; | ||
1759 | } | ||
1760 | |||
1761 | - ufs_complete_req(req, req_result); | ||
1762 | + /* | ||
1763 | + * The ufs_complete_req for scsi commands is handled by the | ||
1764 | + * ufs_scsi_command_complete() callback function. Therefore, to avoid | ||
1765 | + * duplicate processing, ufs_complete_req() is not called for scsi commands. | ||
1766 | + */ | ||
1767 | + if (req_result != UFS_REQUEST_NO_COMPLETE) { | ||
1768 | + ufs_complete_req(req, req_result); | ||
1769 | + } | ||
1770 | } | ||
1771 | |||
1772 | static void ufs_process_req(void *opaque) | ||
1773 | @@ -XXX,XX +XXX,XX @@ static void ufs_init_hc(UfsHc *u) | ||
1774 | u->flags.permanently_disable_fw_update = 1; | ||
1775 | } | ||
1776 | |||
1777 | +static bool ufs_init_wlu(UfsHc *u, UfsWLu **wlu, uint8_t wlun, Error **errp) | ||
1778 | +{ | ||
1779 | + UfsWLu *new_wlu = UFSWLU(qdev_new(TYPE_UFS_WLU)); | ||
1780 | + | ||
1781 | + qdev_prop_set_uint32(DEVICE(new_wlu), "lun", wlun); | ||
1782 | + | ||
1783 | + /* | ||
1784 | + * The well-known lu shares the same bus as the normal lu. If the well-known | ||
1785 | + * lu writes the same channel value as the normal lu, the report will be | ||
1786 | + * made not only for the normal lu but also for the well-known lu at | ||
1787 | + * REPORT_LUN time. To prevent this, the channel value of normal lu is fixed | ||
1788 | + * to 0 and the channel value of well-known lu is fixed to 1. | ||
1789 | + */ | ||
1790 | + qdev_prop_set_uint32(DEVICE(new_wlu), "channel", 1); | ||
1791 | + if (!qdev_realize_and_unref(DEVICE(new_wlu), BUS(&u->bus), errp)) { | ||
38 | + return false; | 1792 | + return false; |
39 | + } | 1793 | + } |
40 | 1794 | + | |
41 | if (s->qcow_version < 3) { | 1795 | + *wlu = new_wlu; |
42 | /* Without autoclear_features, we would always have to assume | 1796 | + return true; |
43 | @@ -XXX,XX +XXX,XX @@ bool coroutine_fn qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs, | 1797 | +} |
44 | goto fail; | 1798 | + |
1799 | static void ufs_realize(PCIDevice *pci_dev, Error **errp) | ||
1800 | { | ||
1801 | UfsHc *u = UFS(pci_dev); | ||
1802 | @@ -XXX,XX +XXX,XX @@ static void ufs_realize(PCIDevice *pci_dev, Error **errp) | ||
1803 | return; | ||
45 | } | 1804 | } |
46 | 1805 | ||
47 | - if (s->nb_bitmaps == 0) { | 1806 | + qbus_init(&u->bus, sizeof(UfsBus), TYPE_UFS_BUS, &pci_dev->qdev, |
48 | - return true; | 1807 | + u->parent_obj.qdev.id); |
49 | + FOR_EACH_DIRTY_BITMAP(bs, bitmap) { | 1808 | + u->bus.parent_bus.info = &ufs_scsi_info; |
50 | + if (bdrv_dirty_bitmap_get_persistence(bitmap)) { | 1809 | + |
51 | + nb_bitmaps++; | 1810 | ufs_init_state(u); |
52 | + bitmap_directory_size += | 1811 | ufs_init_hc(u); |
53 | + calc_dir_entry_size(strlen(bdrv_dirty_bitmap_name(bitmap)), 0); | 1812 | ufs_init_pci(u, pci_dev); |
54 | + } | 1813 | + |
55 | } | 1814 | + if (!ufs_init_wlu(u, &u->report_wlu, UFS_UPIU_REPORT_LUNS_WLUN, errp)) { |
56 | + nb_bitmaps++; | 1815 | + return; |
57 | + bitmap_directory_size += calc_dir_entry_size(strlen(name), 0); | 1816 | + } |
58 | 1817 | + | |
59 | - if (s->nb_bitmaps >= QCOW2_MAX_BITMAPS) { | 1818 | + if (!ufs_init_wlu(u, &u->dev_wlu, UFS_UPIU_UFS_DEVICE_WLUN, errp)) { |
60 | + if (nb_bitmaps > QCOW2_MAX_BITMAPS) { | 1819 | + return; |
61 | error_setg(errp, | 1820 | + } |
62 | "Maximum number of persistent bitmaps is already reached"); | 1821 | + |
63 | goto fail; | 1822 | + if (!ufs_init_wlu(u, &u->boot_wlu, UFS_UPIU_BOOT_WLUN, errp)) { |
64 | } | 1823 | + return; |
65 | 1824 | + } | |
66 | - if (s->bitmap_directory_size + calc_dir_entry_size(strlen(name), 0) > | 1825 | + |
67 | - QCOW2_MAX_BITMAP_DIRECTORY_SIZE) | 1826 | + if (!ufs_init_wlu(u, &u->rpmb_wlu, UFS_UPIU_RPMB_WLUN, errp)) { |
68 | - { | 1827 | + return; |
69 | + if (bitmap_directory_size > QCOW2_MAX_BITMAP_DIRECTORY_SIZE) { | 1828 | + } |
70 | error_setg(errp, "Not enough space in the bitmap directory"); | 1829 | } |
71 | goto fail; | 1830 | |
72 | } | 1831 | static void ufs_exit(PCIDevice *pci_dev) |
73 | 1832 | { | |
74 | - qemu_co_mutex_lock(&s->lock); | 1833 | UfsHc *u = UFS(pci_dev); |
75 | - bm_list = bitmap_list_load(bs, s->bitmap_directory_offset, | 1834 | |
76 | - s->bitmap_directory_size, errp); | 1835 | + if (u->dev_wlu) { |
77 | - qemu_co_mutex_unlock(&s->lock); | 1836 | + object_unref(OBJECT(u->dev_wlu)); |
78 | - if (bm_list == NULL) { | 1837 | + u->dev_wlu = NULL; |
79 | - goto fail; | 1838 | + } |
80 | - } | 1839 | + |
81 | - | 1840 | + if (u->report_wlu) { |
82 | - found = find_bitmap_by_name(bm_list, name); | 1841 | + object_unref(OBJECT(u->report_wlu)); |
83 | - bitmap_list_free(bm_list); | 1842 | + u->report_wlu = NULL; |
84 | - if (found) { | 1843 | + } |
85 | - error_setg(errp, "Bitmap with the same name is already stored"); | 1844 | + |
86 | - goto fail; | 1845 | + if (u->rpmb_wlu) { |
87 | - } | 1846 | + object_unref(OBJECT(u->rpmb_wlu)); |
88 | - | 1847 | + u->rpmb_wlu = NULL; |
89 | return true; | 1848 | + } |
90 | 1849 | + | |
91 | fail: | 1850 | + if (u->boot_wlu) { |
1851 | + object_unref(OBJECT(u->boot_wlu)); | ||
1852 | + u->boot_wlu = NULL; | ||
1853 | + } | ||
1854 | + | ||
1855 | qemu_bh_delete(u->doorbell_bh); | ||
1856 | qemu_bh_delete(u->complete_bh); | ||
1857 | |||
1858 | @@ -XXX,XX +XXX,XX @@ static void ufs_class_init(ObjectClass *oc, void *data) | ||
1859 | dc->vmsd = &ufs_vmstate; | ||
1860 | } | ||
1861 | |||
1862 | +static bool ufs_bus_check_address(BusState *qbus, DeviceState *qdev, | ||
1863 | + Error **errp) | ||
1864 | +{ | ||
1865 | + SCSIDevice *dev = SCSI_DEVICE(qdev); | ||
1866 | + UfsBusClass *ubc = UFS_BUS_GET_CLASS(qbus); | ||
1867 | + UfsHc *u = UFS(qbus->parent); | ||
1868 | + | ||
1869 | + if (strcmp(object_get_typename(OBJECT(dev)), TYPE_UFS_WLU) == 0) { | ||
1870 | + if (dev->lun != UFS_UPIU_REPORT_LUNS_WLUN && | ||
1871 | + dev->lun != UFS_UPIU_UFS_DEVICE_WLUN && | ||
1872 | + dev->lun != UFS_UPIU_BOOT_WLUN && dev->lun != UFS_UPIU_RPMB_WLUN) { | ||
1873 | + error_setg(errp, "bad well-known lun: %d", dev->lun); | ||
1874 | + return false; | ||
1875 | + } | ||
1876 | + | ||
1877 | + if ((dev->lun == UFS_UPIU_REPORT_LUNS_WLUN && u->report_wlu != NULL) || | ||
1878 | + (dev->lun == UFS_UPIU_UFS_DEVICE_WLUN && u->dev_wlu != NULL) || | ||
1879 | + (dev->lun == UFS_UPIU_BOOT_WLUN && u->boot_wlu != NULL) || | ||
1880 | + (dev->lun == UFS_UPIU_RPMB_WLUN && u->rpmb_wlu != NULL)) { | ||
1881 | + error_setg(errp, "well-known lun %d already exists", dev->lun); | ||
1882 | + return false; | ||
1883 | + } | ||
1884 | + | ||
1885 | + return true; | ||
1886 | + } | ||
1887 | + | ||
1888 | + if (strcmp(object_get_typename(OBJECT(dev)), TYPE_UFS_LU) != 0) { | ||
1889 | + error_setg(errp, "%s cannot be connected to ufs-bus", | ||
1890 | + object_get_typename(OBJECT(dev))); | ||
1891 | + return false; | ||
1892 | + } | ||
1893 | + | ||
1894 | + return ubc->parent_check_address(qbus, qdev, errp); | ||
1895 | +} | ||
1896 | + | ||
1897 | +static void ufs_bus_class_init(ObjectClass *class, void *data) | ||
1898 | +{ | ||
1899 | + BusClass *bc = BUS_CLASS(class); | ||
1900 | + UfsBusClass *ubc = UFS_BUS_CLASS(class); | ||
1901 | + ubc->parent_check_address = bc->check_address; | ||
1902 | + bc->check_address = ufs_bus_check_address; | ||
1903 | +} | ||
1904 | + | ||
1905 | static const TypeInfo ufs_info = { | ||
1906 | .name = TYPE_UFS, | ||
1907 | .parent = TYPE_PCI_DEVICE, | ||
1908 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo ufs_info = { | ||
1909 | .interfaces = (InterfaceInfo[]){ { INTERFACE_PCIE_DEVICE }, {} }, | ||
1910 | }; | ||
1911 | |||
1912 | +static const TypeInfo ufs_bus_info = { | ||
1913 | + .name = TYPE_UFS_BUS, | ||
1914 | + .parent = TYPE_SCSI_BUS, | ||
1915 | + .class_init = ufs_bus_class_init, | ||
1916 | + .class_size = sizeof(UfsBusClass), | ||
1917 | + .instance_size = sizeof(UfsBus), | ||
1918 | +}; | ||
1919 | + | ||
1920 | static void ufs_register_types(void) | ||
1921 | { | ||
1922 | type_register_static(&ufs_info); | ||
1923 | + type_register_static(&ufs_bus_info); | ||
1924 | } | ||
1925 | |||
1926 | type_init(ufs_register_types) | ||
1927 | diff --git a/hw/ufs/meson.build b/hw/ufs/meson.build | ||
1928 | index XXXXXXX..XXXXXXX 100644 | ||
1929 | --- a/hw/ufs/meson.build | ||
1930 | +++ b/hw/ufs/meson.build | ||
1931 | @@ -1 +1 @@ | ||
1932 | -system_ss.add(when: 'CONFIG_UFS_PCI', if_true: files('ufs.c')) | ||
1933 | +system_ss.add(when: 'CONFIG_UFS_PCI', if_true: files('ufs.c', 'lu.c')) | ||
1934 | diff --git a/hw/ufs/trace-events b/hw/ufs/trace-events | ||
1935 | index XXXXXXX..XXXXXXX 100644 | ||
1936 | --- a/hw/ufs/trace-events | ||
1937 | +++ b/hw/ufs/trace-events | ||
1938 | @@ -XXX,XX +XXX,XX @@ ufs_exec_scsi_cmd(uint32_t slot, uint8_t lun, uint8_t opcode) "slot %"PRIu32", l | ||
1939 | ufs_exec_query_cmd(uint32_t slot, uint8_t opcode) "slot %"PRIu32", opcode 0x%"PRIx8"" | ||
1940 | ufs_process_uiccmd(uint32_t uiccmd, uint32_t ucmdarg1, uint32_t ucmdarg2, uint32_t ucmdarg3) "uiccmd 0x%"PRIx32", ucmdarg1 0x%"PRIx32", ucmdarg2 0x%"PRIx32", ucmdarg3 0x%"PRIx32"" | ||
1941 | |||
1942 | +# lu.c | ||
1943 | +ufs_scsi_check_condition(uint32_t tag, uint8_t key, uint8_t asc, uint8_t ascq) "Command complete tag=0x%x sense=%d/%d/%d" | ||
1944 | +ufs_scsi_read_complete(uint32_t tag, size_t size) "Data ready tag=0x%x len=%zd" | ||
1945 | +ufs_scsi_read_data_count(uint32_t sector_count) "Read sector_count=%d" | ||
1946 | +ufs_scsi_read_data_invalid(void) "Data transfer direction invalid" | ||
1947 | +ufs_scsi_write_complete_noio(uint32_t tag, size_t size) "Write complete tag=0x%x more=%zd" | ||
1948 | +ufs_scsi_write_data_invalid(void) "Data transfer direction invalid" | ||
1949 | +ufs_scsi_emulate_vpd_page_00(size_t xfer) "Inquiry EVPD[Supported pages] buffer size %zd" | ||
1950 | +ufs_scsi_emulate_vpd_page_80_not_supported(void) "Inquiry EVPD[Serial number] not supported" | ||
1951 | +ufs_scsi_emulate_vpd_page_80(size_t xfer) "Inquiry EVPD[Serial number] buffer size %zd" | ||
1952 | +ufs_scsi_emulate_vpd_page_87(size_t xfer) "Inquiry EVPD[Mode Page Policy] buffer size %zd" | ||
1953 | +ufs_scsi_emulate_mode_sense(int cmd, int page, size_t xfer, int control) "Mode Sense(%d) (page %d, xfer %zd, page_control %d)" | ||
1954 | +ufs_scsi_emulate_read_data(int buflen) "Read buf_len=%d" | ||
1955 | +ufs_scsi_emulate_write_data(int buflen) "Write buf_len=%d" | ||
1956 | +ufs_scsi_emulate_command_START_STOP(void) "START STOP UNIT" | ||
1957 | +ufs_scsi_emulate_command_FORMAT_UNIT(void) "FORMAT UNIT" | ||
1958 | +ufs_scsi_emulate_command_SEND_DIAGNOSTIC(void) "SEND DIAGNOSTIC" | ||
1959 | +ufs_scsi_emulate_command_SAI_16(void) "SAI READ CAPACITY(16)" | ||
1960 | +ufs_scsi_emulate_command_SAI_unsupported(void) "Unsupported Service Action In" | ||
1961 | +ufs_scsi_emulate_command_MODE_SELECT_10(size_t xfer) "Mode Select(10) (len %zd)" | ||
1962 | +ufs_scsi_emulate_command_VERIFY(int bytchk) "Verify (bytchk %d)" | ||
1963 | +ufs_scsi_emulate_command_UNKNOWN(int cmd, const char *name) "Unknown SCSI command (0x%2.2x=%s)" | ||
1964 | +ufs_scsi_dma_command_READ(uint64_t lba, uint32_t len) "Read (block %" PRIu64 ", count %u)" | ||
1965 | +ufs_scsi_dma_command_WRITE(uint64_t lba, int len) "Write (block %" PRIu64 ", count %u)" | ||
1966 | + | ||
1967 | # error condition | ||
1968 | ufs_err_dma_read_utrd(uint32_t slot, uint64_t addr) "failed to read utrd. UTRLDBR slot %"PRIu32", UTRD dma addr %"PRIu64"" | ||
1969 | ufs_err_dma_read_req_upiu(uint32_t slot, uint64_t addr) "failed to read req upiu. UTRLDBR slot %"PRIu32", request upiu addr %"PRIu64"" | ||
92 | -- | 1970 | -- |
93 | 2.24.1 | 1971 | 2.41.0 |
94 | |||
95 | 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 | Print the feature fields as a set of bits so that filtering is easier. | ||
2 | 1 | ||
3 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
4 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
5 | Message-id: 20191107163708.833192-4-mreitz@redhat.com | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
7 | --- | ||
8 | tests/qemu-iotests/031.out | 36 +++++++++---------- | ||
9 | tests/qemu-iotests/036.out | 18 +++++----- | ||
10 | tests/qemu-iotests/039.out | 22 ++++++------ | ||
11 | tests/qemu-iotests/060.out | 20 +++++------ | ||
12 | tests/qemu-iotests/061.out | 72 ++++++++++++++++++------------------- | ||
13 | tests/qemu-iotests/137.out | 2 +- | ||
14 | tests/qemu-iotests/qcow2.py | 18 +++++++--- | ||
15 | 7 files changed, 99 insertions(+), 89 deletions(-) | ||
16 | |||
17 | diff --git a/tests/qemu-iotests/031.out b/tests/qemu-iotests/031.out | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/tests/qemu-iotests/031.out | ||
20 | +++ b/tests/qemu-iotests/031.out | ||
21 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
22 | refcount_table_clusters 1 | ||
23 | nb_snapshots 0 | ||
24 | snapshot_offset 0x0 | ||
25 | -incompatible_features 0x0 | ||
26 | -compatible_features 0x0 | ||
27 | -autoclear_features 0x0 | ||
28 | +incompatible_features [] | ||
29 | +compatible_features [] | ||
30 | +autoclear_features [] | ||
31 | refcount_order 4 | ||
32 | header_length 72 | ||
33 | |||
34 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
35 | refcount_table_clusters 1 | ||
36 | nb_snapshots 0 | ||
37 | snapshot_offset 0x0 | ||
38 | -incompatible_features 0x0 | ||
39 | -compatible_features 0x0 | ||
40 | -autoclear_features 0x0 | ||
41 | +incompatible_features [] | ||
42 | +compatible_features [] | ||
43 | +autoclear_features [] | ||
44 | refcount_order 4 | ||
45 | header_length 72 | ||
46 | |||
47 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
48 | refcount_table_clusters 1 | ||
49 | nb_snapshots 0 | ||
50 | snapshot_offset 0x0 | ||
51 | -incompatible_features 0x0 | ||
52 | -compatible_features 0x0 | ||
53 | -autoclear_features 0x0 | ||
54 | +incompatible_features [] | ||
55 | +compatible_features [] | ||
56 | +autoclear_features [] | ||
57 | refcount_order 4 | ||
58 | header_length 72 | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
61 | refcount_table_clusters 1 | ||
62 | nb_snapshots 0 | ||
63 | snapshot_offset 0x0 | ||
64 | -incompatible_features 0x0 | ||
65 | -compatible_features 0x0 | ||
66 | -autoclear_features 0x0 | ||
67 | +incompatible_features [] | ||
68 | +compatible_features [] | ||
69 | +autoclear_features [] | ||
70 | refcount_order 4 | ||
71 | header_length 104 | ||
72 | |||
73 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
74 | refcount_table_clusters 1 | ||
75 | nb_snapshots 0 | ||
76 | snapshot_offset 0x0 | ||
77 | -incompatible_features 0x0 | ||
78 | -compatible_features 0x0 | ||
79 | -autoclear_features 0x0 | ||
80 | +incompatible_features [] | ||
81 | +compatible_features [] | ||
82 | +autoclear_features [] | ||
83 | refcount_order 4 | ||
84 | header_length 104 | ||
85 | |||
86 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
87 | refcount_table_clusters 1 | ||
88 | nb_snapshots 0 | ||
89 | snapshot_offset 0x0 | ||
90 | -incompatible_features 0x0 | ||
91 | -compatible_features 0x0 | ||
92 | -autoclear_features 0x0 | ||
93 | +incompatible_features [] | ||
94 | +compatible_features [] | ||
95 | +autoclear_features [] | ||
96 | refcount_order 4 | ||
97 | header_length 104 | ||
98 | |||
99 | diff --git a/tests/qemu-iotests/036.out b/tests/qemu-iotests/036.out | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/tests/qemu-iotests/036.out | ||
102 | +++ b/tests/qemu-iotests/036.out | ||
103 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
104 | refcount_table_clusters 1 | ||
105 | nb_snapshots 0 | ||
106 | snapshot_offset 0x0 | ||
107 | -incompatible_features 0x8000000000000000 | ||
108 | -compatible_features 0x0 | ||
109 | -autoclear_features 0x0 | ||
110 | +incompatible_features [63] | ||
111 | +compatible_features [] | ||
112 | +autoclear_features [] | ||
113 | refcount_order 4 | ||
114 | header_length 104 | ||
115 | |||
116 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
117 | refcount_table_clusters 1 | ||
118 | nb_snapshots 0 | ||
119 | snapshot_offset 0x0 | ||
120 | -incompatible_features 0x0 | ||
121 | -compatible_features 0x0 | ||
122 | -autoclear_features 0x8000000000000000 | ||
123 | +incompatible_features [] | ||
124 | +compatible_features [] | ||
125 | +autoclear_features [63] | ||
126 | refcount_order 4 | ||
127 | header_length 104 | ||
128 | |||
129 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
130 | refcount_table_clusters 1 | ||
131 | nb_snapshots 0 | ||
132 | snapshot_offset 0x0 | ||
133 | -incompatible_features 0x0 | ||
134 | -compatible_features 0x0 | ||
135 | -autoclear_features 0x0 | ||
136 | +incompatible_features [] | ||
137 | +compatible_features [] | ||
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 | ||
144 | --- a/tests/qemu-iotests/039.out | ||
145 | +++ b/tests/qemu-iotests/039.out | ||
146 | @@ -XXX,XX +XXX,XX @@ QA output created by 039 | ||
147 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
148 | wrote 512/512 bytes at offset 0 | ||
149 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
150 | -incompatible_features 0x0 | ||
151 | +incompatible_features [] | ||
152 | No errors were found on the image. | ||
153 | |||
154 | == Creating a dirty image file == | ||
155 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
156 | wrote 512/512 bytes at offset 0 | ||
157 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
158 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | ||
159 | -incompatible_features 0x1 | ||
160 | +incompatible_features [0] | ||
161 | ERROR cluster 5 refcount=0 reference=1 | ||
162 | ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 | ||
163 | |||
164 | @@ -XXX,XX +XXX,XX @@ Data may be corrupted, or further writes to the image may corrupt it. | ||
165 | == Read-only access must still work == | ||
166 | read 512/512 bytes at offset 0 | ||
167 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
168 | -incompatible_features 0x1 | ||
169 | +incompatible_features [0] | ||
170 | |||
171 | == Repairing the image file must succeed == | ||
172 | ERROR cluster 5 refcount=0 reference=1 | ||
173 | @@ -XXX,XX +XXX,XX @@ The following inconsistencies were found and repaired: | ||
174 | |||
175 | Double checking the fixed image now... | ||
176 | No errors were found on the image. | ||
177 | -incompatible_features 0x0 | ||
178 | +incompatible_features [] | ||
179 | |||
180 | == Data should still be accessible after repair == | ||
181 | read 512/512 bytes at offset 0 | ||
182 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
183 | wrote 512/512 bytes at offset 0 | ||
184 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
185 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | ||
186 | -incompatible_features 0x1 | ||
187 | +incompatible_features [0] | ||
188 | ERROR cluster 5 refcount=0 reference=1 | ||
189 | Rebuilding refcount structure | ||
190 | Repairing cluster 1 refcount=1 reference=0 | ||
191 | Repairing cluster 2 refcount=1 reference=0 | ||
192 | wrote 512/512 bytes at offset 0 | ||
193 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
194 | -incompatible_features 0x0 | ||
195 | +incompatible_features [] | ||
196 | |||
197 | == Creating an image file with lazy_refcounts=off == | ||
198 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
199 | wrote 512/512 bytes at offset 0 | ||
200 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
201 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | ||
202 | -incompatible_features 0x0 | ||
203 | +incompatible_features [] | ||
204 | No errors were found on the image. | ||
205 | |||
206 | == Committing to a backing file with lazy_refcounts=on == | ||
207 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/ | ||
208 | wrote 512/512 bytes at offset 0 | ||
209 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
210 | Image committed. | ||
211 | -incompatible_features 0x0 | ||
212 | -incompatible_features 0x0 | ||
213 | +incompatible_features [] | ||
214 | +incompatible_features [] | ||
215 | No errors were found on the image. | ||
216 | No errors were found on the image. | ||
217 | |||
218 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
219 | wrote 512/512 bytes at offset 0 | ||
220 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
221 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | ||
222 | -incompatible_features 0x1 | ||
223 | +incompatible_features [0] | ||
224 | ERROR cluster 5 refcount=0 reference=1 | ||
225 | ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 | ||
226 | |||
227 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
228 | wrote 512/512 bytes at offset 0 | ||
229 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
230 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | ||
231 | -incompatible_features 0x0 | ||
232 | +incompatible_features [] | ||
233 | No errors were found on the image. | ||
234 | *** 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 | ||
305 | index XXXXXXX..XXXXXXX 100644 | ||
306 | --- a/tests/qemu-iotests/061.out | ||
307 | +++ b/tests/qemu-iotests/061.out | ||
308 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
309 | refcount_table_clusters 1 | ||
310 | nb_snapshots 0 | ||
311 | snapshot_offset 0x0 | ||
312 | -incompatible_features 0x0 | ||
313 | -compatible_features 0x1 | ||
314 | -autoclear_features 0x0 | ||
315 | +incompatible_features [] | ||
316 | +compatible_features [0] | ||
317 | +autoclear_features [] | ||
318 | refcount_order 4 | ||
319 | header_length 104 | ||
320 | |||
321 | @@ -XXX,XX +XXX,XX @@ refcount_table_offset 0x10000 | ||
322 | refcount_table_clusters 1 | ||
323 | nb_snapshots 0 | ||
324 | snapshot_offset 0x0 | ||
325 | -incompatible_features 0x0 | ||
326 | -compatible_features 0x0 | ||
327 | -autoclear_features 0x0 | ||
328 | +incompatible_features [] | ||
329 | +compatible_features [] | ||
330 | +autoclear_features [] | ||
331 | refcount_order 4 | ||
332 | header_length 72 | ||
333 | |||
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 | ||
466 | --- a/tests/qemu-iotests/137.out | ||
467 | +++ b/tests/qemu-iotests/137.out | ||
468 | @@ -XXX,XX +XXX,XX @@ qemu-io: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are | ||
469 | wrote 512/512 bytes at offset 0 | ||
470 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
471 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | ||
472 | -incompatible_features 0x0 | ||
473 | +incompatible_features [] | ||
474 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
475 | wrote 65536/65536 bytes at offset 0 | ||
476 | 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 | ||
478 | index XXXXXXX..XXXXXXX 100755 | ||
479 | --- a/tests/qemu-iotests/qcow2.py | ||
480 | +++ b/tests/qemu-iotests/qcow2.py | ||
481 | @@ -XXX,XX +XXX,XX @@ class QcowHeader: | ||
482 | [ uint64_t, '%#x', 'snapshot_offset' ], | ||
483 | |||
484 | # Version 3 header fields | ||
485 | - [ uint64_t, '%#x', 'incompatible_features' ], | ||
486 | - [ uint64_t, '%#x', 'compatible_features' ], | ||
487 | - [ uint64_t, '%#x', 'autoclear_features' ], | ||
488 | + [ uint64_t, 'mask', 'incompatible_features' ], | ||
489 | + [ uint64_t, 'mask', 'compatible_features' ], | ||
490 | + [ uint64_t, 'mask', 'autoclear_features' ], | ||
491 | [ uint32_t, '%d', 'refcount_order' ], | ||
492 | [ uint32_t, '%d', 'header_length' ], | ||
493 | ]; | ||
494 | @@ -XXX,XX +XXX,XX @@ class QcowHeader: | ||
495 | |||
496 | def dump(self): | ||
497 | for f in QcowHeader.fields: | ||
498 | - print("%-25s" % f[2], f[1] % self.__dict__[f[2]]) | ||
499 | + value = self.__dict__[f[2]] | ||
500 | + if f[1] == 'mask': | ||
501 | + bits = [] | ||
502 | + for bit in range(64): | ||
503 | + if value & (1 << bit): | ||
504 | + bits.append(bit) | ||
505 | + value_str = str(bits) | ||
506 | + else: | ||
507 | + value_str = f[1] % value | ||
508 | + | ||
509 | + print("%-25s" % f[2], value_str) | ||
510 | print("") | ||
511 | |||
512 | def dump_extensions(self): | ||
513 | -- | ||
514 | 2.24.1 | ||
515 | |||
516 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
2 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
3 | Message-id: 20191107163708.833192-5-mreitz@redhat.com | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
5 | --- | ||
6 | tests/qemu-iotests/common.filter | 24 ++++++++++++++++++++++++ | ||
7 | 1 file changed, 24 insertions(+) | ||
8 | 1 | ||
9 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/tests/qemu-iotests/common.filter | ||
12 | +++ b/tests/qemu-iotests/common.filter | ||
13 | @@ -XXX,XX +XXX,XX @@ _filter_qmp_empty_return() | ||
14 | grep -v '{"return": {}}' | ||
15 | } | ||
16 | |||
17 | +_filter_json_filename() | ||
18 | +{ | ||
19 | + $PYTHON -c 'import sys | ||
20 | +result, *fnames = sys.stdin.read().split("json:{") | ||
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 | + | ||
32 | + # json:{} filenames may be nested; filter out everything from | ||
33 | + # inside the outermost one | ||
34 | + if depth == 0: | ||
35 | + chr_i += 1 # First character past the filename | ||
36 | + result += "json:{ /* filtered */ }" + fname[chr_i:] | ||
37 | + | ||
38 | +sys.stdout.write(result)' | ||
39 | +} | ||
40 | + | ||
41 | # make sure this script returns success | ||
42 | true | ||
43 | -- | ||
44 | 2.24.1 | ||
45 | |||
46 | 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 |
Deleted patch | |||
---|---|---|---|
1 | Some tests require compat=1.1 and thus set IMGOPTS='compat=1.1' | ||
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 | 1 | ||
6 | This makes the tests heed user-specified $IMGOPTS. Some do not work | ||
7 | with all image options, though, so we need to disable them accordingly. | ||
8 | |||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | Reviewed-by: Maxim Levitsky <mlevitsky@redhat.com> | ||
11 | Message-id: 20191107163708.833192-7-mreitz@redhat.com | ||
12 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
13 | --- | ||
14 | tests/qemu-iotests/036 | 3 +-- | ||
15 | tests/qemu-iotests/060 | 4 ++-- | ||
16 | tests/qemu-iotests/062 | 3 ++- | ||
17 | tests/qemu-iotests/066 | 3 ++- | ||
18 | tests/qemu-iotests/068 | 3 ++- | ||
19 | tests/qemu-iotests/098 | 4 ++-- | ||
20 | 6 files changed, 11 insertions(+), 9 deletions(-) | ||
21 | |||
22 | diff --git a/tests/qemu-iotests/036 b/tests/qemu-iotests/036 | ||
23 | index XXXXXXX..XXXXXXX 100755 | ||
24 | --- a/tests/qemu-iotests/036 | ||
25 | +++ b/tests/qemu-iotests/036 | ||
26 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
27 | # This tests qcow2-specific low-level functionality | ||
28 | _supported_fmt qcow2 | ||
29 | _supported_proto file | ||
30 | - | ||
31 | # Only qcow2v3 and later supports feature bits | ||
32 | -IMGOPTS="compat=1.1" | ||
33 | +_unsupported_imgopts 'compat=0.10' | ||
34 | |||
35 | echo | ||
36 | echo === Image with unknown incompatible feature bit === | ||
37 | diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 | ||
38 | index XXXXXXX..XXXXXXX 100755 | ||
39 | --- a/tests/qemu-iotests/060 | ||
40 | +++ b/tests/qemu-iotests/060 | ||
41 | @@ -XXX,XX +XXX,XX @@ _filter_io_error() | ||
42 | _supported_fmt qcow2 | ||
43 | _supported_proto file | ||
44 | _supported_os Linux | ||
45 | +# These tests only work for compat=1.1 images with refcount_bits=16 | ||
46 | +_unsupported_imgopts 'compat=0.10' 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
47 | |||
48 | # The repair process will create a large file - so check for availability first | ||
49 | _require_large_file 64G | ||
50 | @@ -XXX,XX +XXX,XX @@ l1_offset=196608 # 0x30000 (XXX: just an assumption) | ||
51 | l2_offset=262144 # 0x40000 (XXX: just an assumption) | ||
52 | l2_offset_after_snapshot=524288 # 0x80000 (XXX: just an assumption) | ||
53 | |||
54 | -IMGOPTS="compat=1.1" | ||
55 | - | ||
56 | OPEN_RW="open -o overlap-check=all $TEST_IMG" | ||
57 | # Overlap checks are done before write operations only, therefore opening an | ||
58 | # image read-only makes the overlap-check option irrelevant | ||
59 | diff --git a/tests/qemu-iotests/062 b/tests/qemu-iotests/062 | ||
60 | index XXXXXXX..XXXXXXX 100755 | ||
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 | |||
120 | -- | ||
121 | 2.24.1 | ||
122 | |||
123 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | IMGOPTS can never be empty for qcow2, because the check scripts adds | ||
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 | 1 | ||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
6 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
7 | Message-id: 20191107163708.833192-8-mreitz@redhat.com | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | --- | ||
10 | tests/qemu-iotests/050 | 4 ---- | ||
11 | 1 file changed, 4 deletions(-) | ||
12 | |||
13 | diff --git a/tests/qemu-iotests/050 b/tests/qemu-iotests/050 | ||
14 | index XXXXXXX..XXXXXXX 100755 | ||
15 | --- a/tests/qemu-iotests/050 | ||
16 | +++ b/tests/qemu-iotests/050 | ||
17 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
18 | _supported_fmt qcow2 qed | ||
19 | _supported_proto file | ||
20 | |||
21 | -if test "$IMGFMT" = qcow2 && test $IMGOPTS = ""; then | ||
22 | - IMGOPTS=compat=1.1 | ||
23 | -fi | ||
24 | - | ||
25 | echo | ||
26 | echo "== Creating images ==" | ||
27 | |||
28 | -- | ||
29 | 2.24.1 | ||
30 | |||
31 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This will allow us to add more options than just -b. | ||
2 | 1 | ||
3 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
4 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
5 | Message-id: 20191107163708.833192-9-mreitz@redhat.com | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
7 | --- | ||
8 | tests/qemu-iotests/common.rc | 28 ++++++++++++++++++++-------- | ||
9 | 1 file changed, 20 insertions(+), 8 deletions(-) | ||
10 | |||
11 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/tests/qemu-iotests/common.rc | ||
14 | +++ b/tests/qemu-iotests/common.rc | ||
15 | @@ -XXX,XX +XXX,XX @@ _make_test_img() | ||
16 | # extra qemu-img options can be added by tests | ||
17 | # at least one argument (the image size) needs to be added | ||
18 | local extra_img_options="" | ||
19 | - local image_size=$* | ||
20 | local optstr="" | ||
21 | local img_name="" | ||
22 | local use_backing=0 | ||
23 | local backing_file="" | ||
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 | |||
70 | -- | ||
71 | 2.24.1 | ||
72 | |||
73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Blindly overriding IMGOPTS is suboptimal as this discards user-specified | ||
2 | options. Whatever options the test needs should simply be appended. | ||
3 | 1 | ||
4 | Some tests do this (with IMGOPTS=$(_optstr_add "$IMGOPTS" "...")), but | ||
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 | |||
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
14 | 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 | --- | ||
18 | tests/qemu-iotests/common.rc | 13 +++++++++++++ | ||
19 | 1 file changed, 13 insertions(+) | ||
20 | |||
21 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/tests/qemu-iotests/common.rc | ||
24 | +++ b/tests/qemu-iotests/common.rc | ||
25 | @@ -XXX,XX +XXX,XX @@ _make_test_img() | ||
26 | local use_backing=0 | ||
27 | local backing_file="" | ||
28 | local object_options="" | ||
29 | + local opts_param=false | ||
30 | local misc_params=() | ||
31 | |||
32 | if [ -n "$TEST_IMG_FILE" ]; then | ||
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 | + | ||
52 | + --no-opts) | ||
53 | + optstr="" | ||
54 | + ;; | ||
55 | + | ||
56 | *) | ||
57 | misc_params=("${misc_params[@]}" "$param") | ||
58 | ;; | ||
59 | -- | ||
60 | 2.24.1 | ||
61 | |||
62 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | It did not matter before, but now that _make_test_img understands -o, we | ||
2 | should use it properly here. | ||
3 | 1 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
5 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
6 | Message-id: 20191107163708.833192-11-mreitz@redhat.com | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
8 | --- | ||
9 | tests/qemu-iotests/051 | 2 +- | ||
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 | ||
13 | index XXXXXXX..XXXXXXX 100755 | ||
14 | --- a/tests/qemu-iotests/051 | ||
15 | +++ b/tests/qemu-iotests/051 | ||
16 | @@ -XXX,XX +XXX,XX @@ echo | ||
17 | echo === With version 2 images enabling lazy refcounts must fail === | ||
18 | echo | ||
19 | |||
20 | -_make_test_img -ocompat=0.10 $size | ||
21 | +_make_test_img -o compat=0.10 $size | ||
22 | |||
23 | run_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=on | ||
24 | run_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=off | ||
25 | -- | ||
26 | 2.24.1 | ||
27 | |||
28 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Tests should not overwrite all user-supplied image options, but only add | ||
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 | 1 | ||
5 | For some tests, there is no functional change because they already only | ||
6 | appended options to IMGOPTS. For these, this patch is just a | ||
7 | simplification. | ||
8 | |||
9 | For others, this is a change, so they now heed user-specified $IMGOPTS. | ||
10 | Some of those tests do not work with all image options, though, so we | ||
11 | need to disable them accordingly. | ||
12 | |||
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
14 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
15 | Message-id: 20191107163708.833192-12-mreitz@redhat.com | ||
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
17 | --- | ||
18 | tests/qemu-iotests/031 | 9 ++++--- | ||
19 | tests/qemu-iotests/039 | 24 ++++++------------ | ||
20 | tests/qemu-iotests/059 | 18 ++++++------- | ||
21 | tests/qemu-iotests/060 | 6 ++--- | ||
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 | |||
42 | diff --git a/tests/qemu-iotests/031 b/tests/qemu-iotests/031 | ||
43 | index XXXXXXX..XXXXXXX 100755 | ||
44 | --- a/tests/qemu-iotests/031 | ||
45 | +++ b/tests/qemu-iotests/031 | ||
46 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
47 | # This tests qcow2-specific low-level functionality | ||
48 | _supported_fmt qcow2 | ||
49 | _supported_proto file | ||
50 | +# We want to test compat=0.10, which does not support refcount widths | ||
51 | +# other than 16 | ||
52 | +_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
53 | |||
54 | CLUSTER_SIZE=65536 | ||
55 | |||
56 | # qcow2.py output depends on the exact options used, so override the command | ||
57 | # line here as an exception | ||
58 | -for IMGOPTS in "compat=0.10" "compat=1.1"; do | ||
59 | +for compat in "compat=0.10" "compat=1.1"; do | ||
60 | |||
61 | echo | ||
62 | - echo ===== Testing with -o $IMGOPTS ===== | ||
63 | + echo ===== Testing with -o $compat ===== | ||
64 | echo | ||
65 | echo === Create image with unknown header extension === | ||
66 | echo | ||
67 | - _make_test_img 64M | ||
68 | + _make_test_img -o $compat 64M | ||
69 | $PYTHON qcow2.py "$TEST_IMG" add-header-ext 0x12345678 "This is a test header extension" | ||
70 | $PYTHON qcow2.py "$TEST_IMG" dump-header | ||
71 | _check_test_img | ||
72 | diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 | ||
73 | index XXXXXXX..XXXXXXX 100755 | ||
74 | --- a/tests/qemu-iotests/039 | ||
75 | +++ b/tests/qemu-iotests/039 | ||
76 | @@ -XXX,XX +XXX,XX @@ size=128M | ||
77 | echo | ||
78 | echo "== Checking that image is clean on shutdown ==" | ||
79 | |||
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 | ||
665 | index XXXXXXX..XXXXXXX 100755 | ||
666 | --- a/tests/qemu-iotests/125 | ||
667 | +++ b/tests/qemu-iotests/125 | ||
668 | @@ -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 | ||
716 | |||
717 | diff --git a/tests/qemu-iotests/190 b/tests/qemu-iotests/190 | ||
718 | index XXXXXXX..XXXXXXX 100755 | ||
719 | --- a/tests/qemu-iotests/190 | ||
720 | +++ b/tests/qemu-iotests/190 | ||
721 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
722 | echo "== Huge file ==" | ||
723 | echo | ||
724 | |||
725 | -IMGOPTS='cluster_size=2M' _make_test_img 2T | ||
726 | +_make_test_img -o 'cluster_size=2M' 2T | ||
727 | |||
728 | $QEMU_IMG measure -O raw -f qcow2 "$TEST_IMG" | ||
729 | $QEMU_IMG measure -O qcow2 -o cluster_size=64k -f qcow2 "$TEST_IMG" | ||
730 | diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 | ||
731 | index XXXXXXX..XXXXXXX 100755 | ||
732 | --- a/tests/qemu-iotests/191 | ||
733 | +++ b/tests/qemu-iotests/191 | ||
734 | @@ -XXX,XX +XXX,XX @@ echo === Preparing and starting VM === | ||
735 | echo | ||
736 | |||
737 | TEST_IMG="${TEST_IMG}.base" _make_test_img $size | ||
738 | -IMGOPTS=$(_optstr_add "$IMGOPTS" "backing_fmt=$IMGFMT") \ | ||
739 | - TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base" | ||
740 | +TEST_IMG="${TEST_IMG}.mid" _make_test_img -o "backing_fmt=$IMGFMT" -b "${TEST_IMG}.base" | ||
741 | _make_test_img -b "${TEST_IMG}.mid" | ||
742 | TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid" | ||
743 | |||
744 | diff --git a/tests/qemu-iotests/220 b/tests/qemu-iotests/220 | ||
745 | index XXXXXXX..XXXXXXX 100755 | ||
746 | --- a/tests/qemu-iotests/220 | ||
747 | +++ b/tests/qemu-iotests/220 | ||
748 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
749 | _supported_fmt qcow2 | ||
750 | _supported_proto file | ||
751 | _supported_os Linux | ||
752 | +# To use a different refcount width but 16 bits we need compat=1.1 | ||
753 | +_unsupported_imgopts 'compat=0.10' | ||
754 | |||
755 | echo "== Creating huge file ==" | ||
756 | |||
757 | @@ -XXX,XX +XXX,XX @@ echo "== Creating huge file ==" | ||
758 | # of a HUGE (but very sparse) file. tmpfs works, ext4 does not. | ||
759 | _require_large_file 513T | ||
760 | |||
761 | -IMGOPTS='cluster_size=2M,refcount_bits=1' _make_test_img 513T | ||
762 | +_make_test_img -o 'cluster_size=2M,refcount_bits=1' 513T | ||
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 | -- | ||
874 | 2.24.1 | ||
875 | |||
876 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
2 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
3 | Message-id: 20191107163708.833192-13-mreitz@redhat.com | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
5 | --- | ||
6 | tests/qemu-iotests/071 | 4 ++-- | ||
7 | tests/qemu-iotests/174 | 2 +- | ||
8 | tests/qemu-iotests/178 | 4 ++-- | ||
9 | tests/qemu-iotests/197 | 4 ++-- | ||
10 | tests/qemu-iotests/215 | 4 ++-- | ||
11 | 5 files changed, 9 insertions(+), 9 deletions(-) | ||
12 | 1 | ||
13 | diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 | ||
14 | index XXXXXXX..XXXXXXX 100755 | ||
15 | --- a/tests/qemu-iotests/071 | ||
16 | +++ b/tests/qemu-iotests/071 | ||
17 | @@ -XXX,XX +XXX,XX @@ echo | ||
18 | echo "=== Testing blkverify through filename ===" | ||
19 | echo | ||
20 | |||
21 | -TEST_IMG="$TEST_IMG.base" IMGOPTS="" IMGFMT="raw" _make_test_img $IMG_SIZE |\ | ||
22 | +TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\ | ||
23 | _filter_imgfmt | ||
24 | _make_test_img $IMG_SIZE | ||
25 | $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \ | ||
26 | @@ -XXX,XX +XXX,XX @@ echo | ||
27 | echo "=== Testing blkverify through file blockref ===" | ||
28 | echo | ||
29 | |||
30 | -TEST_IMG="$TEST_IMG.base" IMGOPTS="" IMGFMT="raw" _make_test_img $IMG_SIZE |\ | ||
31 | +TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\ | ||
32 | _filter_imgfmt | ||
33 | _make_test_img $IMG_SIZE | ||
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" \ | ||
35 | diff --git a/tests/qemu-iotests/174 b/tests/qemu-iotests/174 | ||
36 | index XXXXXXX..XXXXXXX 100755 | ||
37 | --- a/tests/qemu-iotests/174 | ||
38 | +++ b/tests/qemu-iotests/174 | ||
39 | @@ -XXX,XX +XXX,XX @@ _unsupported_fmt raw | ||
40 | |||
41 | |||
42 | size=256K | ||
43 | -IMGFMT=raw IMGKEYSECRET= IMGOPTS= _make_test_img $size | _filter_imgfmt | ||
44 | +IMGFMT=raw IMGKEYSECRET= _make_test_img --no-opts $size | _filter_imgfmt | ||
45 | |||
46 | echo | ||
47 | echo "== reading wrong format should fail ==" | ||
48 | diff --git a/tests/qemu-iotests/178 b/tests/qemu-iotests/178 | ||
49 | index XXXXXXX..XXXXXXX 100755 | ||
50 | --- a/tests/qemu-iotests/178 | ||
51 | +++ b/tests/qemu-iotests/178 | ||
52 | @@ -XXX,XX +XXX,XX @@ $QEMU_IMG measure -O foo "$TEST_IMG" # unknown image file format | ||
53 | |||
54 | make_test_img_with_fmt() { | ||
55 | # Shadow global variables within this function | ||
56 | - local IMGFMT="$1" IMGOPTS="" | ||
57 | - _make_test_img "$2" | ||
58 | + local IMGFMT="$1" | ||
59 | + _make_test_img --no-opts "$2" | ||
60 | } | ||
61 | |||
62 | qemu_io_with_fmt() { | ||
63 | diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197 | ||
64 | index XXXXXXX..XXXXXXX 100755 | ||
65 | --- a/tests/qemu-iotests/197 | ||
66 | +++ b/tests/qemu-iotests/197 | ||
67 | @@ -XXX,XX +XXX,XX @@ if [ "$IMGFMT" = "vpc" ]; then | ||
68 | fi | ||
69 | _make_test_img 4G | ||
70 | $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io | ||
71 | -IMGPROTO=file IMGFMT=qcow2 IMGOPTS= TEST_IMG_FILE="$TEST_WRAP" \ | ||
72 | - _make_test_img -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create | ||
73 | +IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \ | ||
74 | + _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create | ||
75 | $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io | ||
76 | |||
77 | # Ensure that a read of two clusters, but where one is already allocated, | ||
78 | diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215 | ||
79 | index XXXXXXX..XXXXXXX 100755 | ||
80 | --- a/tests/qemu-iotests/215 | ||
81 | +++ b/tests/qemu-iotests/215 | ||
82 | @@ -XXX,XX +XXX,XX @@ if [ "$IMGFMT" = "vpc" ]; then | ||
83 | fi | ||
84 | _make_test_img 4G | ||
85 | $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io | ||
86 | -IMGPROTO=file IMGFMT=qcow2 IMGOPTS= TEST_IMG_FILE="$TEST_WRAP" \ | ||
87 | - _make_test_img -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create | ||
88 | +IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \ | ||
89 | + _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create | ||
90 | $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io | ||
91 | |||
92 | # Ensure that a read of two clusters, but where one is already allocated, | ||
93 | -- | ||
94 | 2.24.1 | ||
95 | |||
96 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Overwriting IMGOPTS means ignoring all user-supplied options, which is | ||
2 | not what we want. Replace the current IMGOPTS use by a new BACKING_FILE | ||
3 | variable. | ||
4 | 1 | ||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
6 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
7 | Message-id: 20191107163708.833192-14-mreitz@redhat.com | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | --- | ||
10 | tests/qemu-iotests/267 | 12 ++++++++---- | ||
11 | 1 file changed, 8 insertions(+), 4 deletions(-) | ||
12 | |||
13 | diff --git a/tests/qemu-iotests/267 b/tests/qemu-iotests/267 | ||
14 | index XXXXXXX..XXXXXXX 100755 | ||
15 | --- a/tests/qemu-iotests/267 | ||
16 | +++ b/tests/qemu-iotests/267 | ||
17 | @@ -XXX,XX +XXX,XX @@ size=128M | ||
18 | |||
19 | run_test() | ||
20 | { | ||
21 | - _make_test_img $size | ||
22 | + if [ -n "$BACKING_FILE" ]; then | ||
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 | } | ||
29 | |||
30 | @@ -XXX,XX +XXX,XX @@ echo | ||
31 | |||
32 | TEST_IMG="$TEST_IMG.base" _make_test_img $size | ||
33 | |||
34 | -IMGOPTS="backing_file=$TEST_IMG.base" \ | ||
35 | +BACKING_FILE="$TEST_IMG.base" \ | ||
36 | run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ | ||
37 | -blockdev driver=file,filename="$TEST_IMG",node-name=file \ | ||
38 | -blockdev driver=$IMGFMT,file=file,backing=backing-file,node-name=fmt | ||
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 | -- | ||
55 | 2.24.1 | ||
56 | |||
57 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Use _make_test_img whenever possible. This way, we will not ignore | ||
2 | user-specified image options. | ||
3 | 1 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
5 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
6 | Message-id: 20191107163708.833192-15-mreitz@redhat.com | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
8 | --- | ||
9 | tests/qemu-iotests/094 | 2 +- | ||
10 | tests/qemu-iotests/111 | 3 +-- | ||
11 | tests/qemu-iotests/123 | 2 +- | ||
12 | tests/qemu-iotests/153 | 2 +- | ||
13 | tests/qemu-iotests/200 | 4 ++-- | ||
14 | 5 files changed, 6 insertions(+), 7 deletions(-) | ||
15 | |||
16 | diff --git a/tests/qemu-iotests/094 b/tests/qemu-iotests/094 | ||
17 | index XXXXXXX..XXXXXXX 100755 | ||
18 | --- a/tests/qemu-iotests/094 | ||
19 | +++ b/tests/qemu-iotests/094 | ||
20 | @@ -XXX,XX +XXX,XX @@ _supported_proto nbd | ||
21 | _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" | ||
22 | |||
23 | _make_test_img 64M | ||
24 | -$QEMU_IMG create -f $IMGFMT "$TEST_DIR/source.$IMGFMT" 64M | _filter_img_create | ||
25 | +TEST_IMG_FILE="$TEST_DIR/source.$IMGFMT" IMGPROTO=file _make_test_img 64M | ||
26 | |||
27 | _launch_qemu -drive if=none,id=src,file="$TEST_DIR/source.$IMGFMT",format=raw \ | ||
28 | -nodefaults | ||
29 | diff --git a/tests/qemu-iotests/111 b/tests/qemu-iotests/111 | ||
30 | index XXXXXXX..XXXXXXX 100755 | ||
31 | --- a/tests/qemu-iotests/111 | ||
32 | +++ b/tests/qemu-iotests/111 | ||
33 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qed qcow qcow2 vmdk | ||
34 | _supported_proto file | ||
35 | _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" | ||
36 | |||
37 | -$QEMU_IMG create -f $IMGFMT -b "$TEST_IMG.inexistent" "$TEST_IMG" 2>&1 \ | ||
38 | - | _filter_testdir | _filter_imgfmt | ||
39 | +_make_test_img -b "$TEST_IMG.inexistent" | ||
40 | |||
41 | # success, all done | ||
42 | echo '*** done' | ||
43 | diff --git a/tests/qemu-iotests/123 b/tests/qemu-iotests/123 | ||
44 | index XXXXXXX..XXXXXXX 100755 | ||
45 | --- a/tests/qemu-iotests/123 | ||
46 | +++ b/tests/qemu-iotests/123 | ||
47 | @@ -XXX,XX +XXX,XX @@ _supported_os Linux | ||
48 | SRC_IMG="$TEST_DIR/source.$IMGFMT" | ||
49 | |||
50 | _make_test_img 1M | ||
51 | -$QEMU_IMG create -f $IMGFMT "$SRC_IMG" 1M | _filter_img_create | ||
52 | +TEST_IMG_FILE=$SRC_IMG IMGPROTO=file _make_test_img 1M | ||
53 | |||
54 | $QEMU_IO -c 'write -P 42 0 1M' "$SRC_IMG" | _filter_qemu_io | ||
55 | |||
56 | diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153 | ||
57 | index XXXXXXX..XXXXXXX 100755 | ||
58 | --- a/tests/qemu-iotests/153 | ||
59 | +++ b/tests/qemu-iotests/153 | ||
60 | @@ -XXX,XX +XXX,XX @@ for opts1 in "" "read-only=on" "read-only=on,force-share=on"; do | ||
61 | |||
62 | echo | ||
63 | echo "== Creating test image ==" | ||
64 | - $QEMU_IMG create -f $IMGFMT "${TEST_IMG}" -b ${TEST_IMG}.base | _filter_img_create | ||
65 | + _make_test_img -b "${TEST_IMG}.base" | ||
66 | |||
67 | echo | ||
68 | echo "== Launching QEMU, opts: '$opts1' ==" | ||
69 | diff --git a/tests/qemu-iotests/200 b/tests/qemu-iotests/200 | ||
70 | index XXXXXXX..XXXXXXX 100755 | ||
71 | --- a/tests/qemu-iotests/200 | ||
72 | +++ b/tests/qemu-iotests/200 | ||
73 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
74 | BACKING_IMG="${TEST_DIR}/backing.img" | ||
75 | TEST_IMG="${TEST_DIR}/test.img" | ||
76 | |||
77 | -${QEMU_IMG} create -f $IMGFMT "${BACKING_IMG}" 512M | _filter_img_create | ||
78 | -${QEMU_IMG} create -f $IMGFMT -F $IMGFMT "${TEST_IMG}" -b "${BACKING_IMG}" 512M | _filter_img_create | ||
79 | +TEST_IMG="$BACKING_IMG" _make_test_img 512M | ||
80 | +_make_test_img -F $IMGFMT -b "$BACKING_IMG" 512M | ||
81 | |||
82 | ${QEMU_IO} -c "write -P 0xa5 512 300M" "${BACKING_IMG}" | _filter_qemu_io | ||
83 | |||
84 | -- | ||
85 | 2.24.1 | ||
86 | |||
87 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Just rm will not delete external data files. Use _rm_test_img every | ||
2 | time we delete a test image. | ||
3 | 1 | ||
4 | (In the process, clean up the indentation of every _cleanup() this patch | ||
5 | touches.) | ||
6 | |||
7 | ((Also, use quotes consistently. I am happy to see unquoted instances | ||
8 | like "rm -rf $TEST_DIR/..." go.)) | ||
9 | |||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
11 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
12 | Message-id: 20191107163708.833192-16-mreitz@redhat.com | ||
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
14 | --- | ||
15 | tests/qemu-iotests/019 | 6 +++--- | ||
16 | tests/qemu-iotests/020 | 6 +++--- | ||
17 | tests/qemu-iotests/024 | 10 +++++----- | ||
18 | tests/qemu-iotests/028 | 2 +- | ||
19 | tests/qemu-iotests/029 | 2 +- | ||
20 | tests/qemu-iotests/043 | 4 +++- | ||
21 | tests/qemu-iotests/048 | 2 +- | ||
22 | tests/qemu-iotests/050 | 4 ++-- | ||
23 | tests/qemu-iotests/053 | 4 ++-- | ||
24 | tests/qemu-iotests/058 | 2 +- | ||
25 | tests/qemu-iotests/059 | 2 +- | ||
26 | tests/qemu-iotests/061 | 2 +- | ||
27 | tests/qemu-iotests/063 | 6 ++++-- | ||
28 | tests/qemu-iotests/069 | 2 +- | ||
29 | tests/qemu-iotests/074 | 2 +- | ||
30 | tests/qemu-iotests/080 | 2 +- | ||
31 | tests/qemu-iotests/081 | 6 +++--- | ||
32 | tests/qemu-iotests/085 | 9 ++++++--- | ||
33 | tests/qemu-iotests/088 | 2 +- | ||
34 | tests/qemu-iotests/092 | 2 +- | ||
35 | tests/qemu-iotests/094 | 2 +- | ||
36 | tests/qemu-iotests/095 | 5 +++-- | ||
37 | tests/qemu-iotests/099 | 7 ++++--- | ||
38 | tests/qemu-iotests/109 | 4 ++-- | ||
39 | tests/qemu-iotests/110 | 4 ++-- | ||
40 | tests/qemu-iotests/122 | 6 ++++-- | ||
41 | tests/qemu-iotests/123 | 2 +- | ||
42 | tests/qemu-iotests/141 | 4 +++- | ||
43 | tests/qemu-iotests/142 | 2 +- | ||
44 | tests/qemu-iotests/144 | 4 +++- | ||
45 | tests/qemu-iotests/153 | 10 +++------- | ||
46 | tests/qemu-iotests/156 | 8 ++++++-- | ||
47 | tests/qemu-iotests/159 | 2 +- | ||
48 | tests/qemu-iotests/160 | 3 ++- | ||
49 | tests/qemu-iotests/161 | 4 ++-- | ||
50 | tests/qemu-iotests/170 | 2 +- | ||
51 | tests/qemu-iotests/172 | 6 +++--- | ||
52 | tests/qemu-iotests/173 | 3 ++- | ||
53 | tests/qemu-iotests/178 | 2 +- | ||
54 | tests/qemu-iotests/182 | 2 +- | ||
55 | tests/qemu-iotests/183 | 2 +- | ||
56 | tests/qemu-iotests/185 | 4 ++-- | ||
57 | tests/qemu-iotests/187 | 6 +++--- | ||
58 | tests/qemu-iotests/190 | 2 +- | ||
59 | tests/qemu-iotests/191 | 6 +++--- | ||
60 | tests/qemu-iotests/195 | 2 +- | ||
61 | tests/qemu-iotests/197 | 2 +- | ||
62 | tests/qemu-iotests/200 | 3 ++- | ||
63 | tests/qemu-iotests/215 | 2 +- | ||
64 | tests/qemu-iotests/225 | 2 +- | ||
65 | tests/qemu-iotests/229 | 3 ++- | ||
66 | tests/qemu-iotests/232 | 4 +++- | ||
67 | tests/qemu-iotests/243 | 2 +- | ||
68 | tests/qemu-iotests/244 | 4 ++-- | ||
69 | tests/qemu-iotests/247 | 4 +++- | ||
70 | tests/qemu-iotests/249 | 4 ++-- | ||
71 | tests/qemu-iotests/252 | 2 +- | ||
72 | 57 files changed, 118 insertions(+), 95 deletions(-) | ||
73 | |||
74 | diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019 | ||
75 | index XXXXXXX..XXXXXXX 100755 | ||
76 | --- a/tests/qemu-iotests/019 | ||
77 | +++ b/tests/qemu-iotests/019 | ||
78 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
79 | |||
80 | _cleanup() | ||
81 | { | ||
82 | - _cleanup_test_img | ||
83 | - rm -f "$TEST_IMG.base" | ||
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 | } | ||
89 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
90 | |||
91 | diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020 | ||
92 | index XXXXXXX..XXXXXXX 100755 | ||
93 | --- a/tests/qemu-iotests/020 | ||
94 | +++ b/tests/qemu-iotests/020 | ||
95 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
96 | |||
97 | _cleanup() | ||
98 | { | ||
99 | - _cleanup_test_img | ||
100 | - rm -f "$TEST_IMG.base" | ||
101 | - rm -f "$TEST_IMG.orig" | ||
102 | + _cleanup_test_img | ||
103 | + _rm_test_img "$TEST_IMG.base" | ||
104 | + _rm_test_img "$TEST_IMG.orig" | ||
105 | } | ||
106 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
107 | |||
108 | diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024 | ||
109 | index XXXXXXX..XXXXXXX 100755 | ||
110 | --- a/tests/qemu-iotests/024 | ||
111 | +++ b/tests/qemu-iotests/024 | ||
112 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
113 | _cleanup() | ||
114 | { | ||
115 | _cleanup_test_img | ||
116 | - rm -f "$TEST_DIR/t.$IMGFMT.base_old" | ||
117 | - rm -f "$TEST_DIR/t.$IMGFMT.base_new" | ||
118 | + _rm_test_img "$TEST_DIR/t.$IMGFMT.base_old" | ||
119 | + _rm_test_img "$TEST_DIR/t.$IMGFMT.base_new" | ||
120 | |||
121 | - rm -f "$TEST_DIR/subdir/t.$IMGFMT" | ||
122 | - rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_old" | ||
123 | - rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_new" | ||
124 | + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT" | ||
125 | + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_old" | ||
126 | + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_new" | ||
127 | rmdir "$TEST_DIR/subdir" 2> /dev/null | ||
128 | } | ||
129 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
130 | diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028 | ||
131 | index XXXXXXX..XXXXXXX 100755 | ||
132 | --- a/tests/qemu-iotests/028 | ||
133 | +++ b/tests/qemu-iotests/028 | ||
134 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
135 | _cleanup() | ||
136 | { | ||
137 | _cleanup_qemu | ||
138 | - rm -f "${TEST_IMG}.copy" | ||
139 | + _rm_test_img "${TEST_IMG}.copy" | ||
140 | _cleanup_test_img | ||
141 | } | ||
142 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
143 | diff --git a/tests/qemu-iotests/029 b/tests/qemu-iotests/029 | ||
144 | index XXXXXXX..XXXXXXX 100755 | ||
145 | --- a/tests/qemu-iotests/029 | ||
146 | +++ b/tests/qemu-iotests/029 | ||
147 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
148 | |||
149 | _cleanup() | ||
150 | { | ||
151 | - rm -f $TEST_IMG.snap | ||
152 | + _rm_test_img "$TEST_IMG.snap" | ||
153 | _cleanup_test_img | ||
154 | } | ||
155 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
156 | diff --git a/tests/qemu-iotests/043 b/tests/qemu-iotests/043 | ||
157 | index XXXXXXX..XXXXXXX 100755 | ||
158 | --- a/tests/qemu-iotests/043 | ||
159 | +++ b/tests/qemu-iotests/043 | ||
160 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
161 | _cleanup() | ||
162 | { | ||
163 | _cleanup_test_img | ||
164 | - rm -f "$TEST_IMG".[123].base | ||
165 | + for img in "$TEST_IMG".[123].base; do | ||
166 | + _rm_test_img "$img" | ||
167 | + done | ||
168 | } | ||
169 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
170 | |||
171 | diff --git a/tests/qemu-iotests/048 b/tests/qemu-iotests/048 | ||
172 | index XXXXXXX..XXXXXXX 100755 | ||
173 | --- a/tests/qemu-iotests/048 | ||
174 | +++ b/tests/qemu-iotests/048 | ||
175 | @@ -XXX,XX +XXX,XX @@ _cleanup() | ||
176 | { | ||
177 | echo "Cleanup" | ||
178 | _cleanup_test_img | ||
179 | - rm "${TEST_IMG_FILE2}" | ||
180 | + _rm_test_img "${TEST_IMG_FILE2}" | ||
181 | } | ||
182 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
183 | |||
184 | diff --git a/tests/qemu-iotests/050 b/tests/qemu-iotests/050 | ||
185 | index XXXXXXX..XXXXXXX 100755 | ||
186 | --- a/tests/qemu-iotests/050 | ||
187 | +++ b/tests/qemu-iotests/050 | ||
188 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
189 | _cleanup() | ||
190 | { | ||
191 | _cleanup_test_img | ||
192 | - rm -f "$TEST_IMG.old" | ||
193 | - rm -f "$TEST_IMG.new" | ||
194 | + _rm_test_img "$TEST_IMG.old" | ||
195 | + _rm_test_img "$TEST_IMG.new" | ||
196 | } | ||
197 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
198 | |||
199 | diff --git a/tests/qemu-iotests/053 b/tests/qemu-iotests/053 | ||
200 | index XXXXXXX..XXXXXXX 100755 | ||
201 | --- a/tests/qemu-iotests/053 | ||
202 | +++ b/tests/qemu-iotests/053 | ||
203 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
204 | |||
205 | _cleanup() | ||
206 | { | ||
207 | - rm -f "$TEST_IMG.orig" | ||
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 | |||
930 | -- | ||
931 | 2.24.1 | ||
932 | |||
933 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This will not work with external data files, so try to get tests working | ||
2 | without it as far as possible. | ||
3 | 1 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
5 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
6 | Message-id: 20191107163708.833192-17-mreitz@redhat.com | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
8 | --- | ||
9 | tests/qemu-iotests/063 | 12 ++++-------- | ||
10 | tests/qemu-iotests/063.out | 3 ++- | ||
11 | tests/qemu-iotests/085 | 9 +++------ | ||
12 | tests/qemu-iotests/085.out | 8 ++++---- | ||
13 | 4 files changed, 13 insertions(+), 19 deletions(-) | ||
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 | ||
52 | --- a/tests/qemu-iotests/063.out | ||
53 | +++ b/tests/qemu-iotests/063.out | ||
54 | @@ -XXX,XX +XXX,XX @@ QA output created by 063 | ||
55 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304 | ||
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 | } | ||
81 | |||
82 | @@ -XXX,XX +XXX,XX @@ blockdev_snapshot() | ||
83 | |||
84 | size=128M | ||
85 | |||
86 | -_make_test_img $size | ||
87 | -mv "${TEST_IMG}" "${TEST_IMG}.1" | ||
88 | -_make_test_img $size | ||
89 | -mv "${TEST_IMG}" "${TEST_IMG}.2" | ||
90 | +TEST_IMG="$TEST_IMG.1" _make_test_img $size | ||
91 | +TEST_IMG="$TEST_IMG.2" _make_test_img $size | ||
92 | |||
93 | echo | ||
94 | echo === Running QEMU === | ||
95 | diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/tests/qemu-iotests/085.out | ||
98 | +++ b/tests/qemu-iotests/085.out | ||
99 | @@ -XXX,XX +XXX,XX @@ | ||
100 | QA output created by 085 | ||
101 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
102 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
103 | +Formatting 'TEST_DIR/t.IMGFMT.1', fmt=IMGFMT size=134217728 | ||
104 | +Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=134217728 | ||
105 | |||
106 | === Running QEMU === | ||
107 | |||
108 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_fil | ||
109 | |||
110 | === Create a couple of snapshots using blockdev-snapshot === | ||
111 | |||
112 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT | ||
113 | +Formatting 'TEST_DIR/11-snapshot-v0.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT | ||
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' } } } | ||
115 | {"return": {}} | ||
116 | { 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay':'snap_11' } } | ||
117 | {"return": {}} | ||
118 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT | ||
119 | +Formatting 'TEST_DIR/12-snapshot-v0.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT | ||
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' } } } | ||
121 | {"return": {}} | ||
122 | { 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay':'snap_12' } } | ||
123 | -- | ||
124 | 2.24.1 | ||
125 | |||
126 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The image end offset as reported by qemu-img check is different when | ||
2 | using an external data file; we do not care about its value here, so we | ||
3 | can just filter it. Incidentally, common.rc already has _check_test_img | ||
4 | for us which does exactly that. | ||
5 | 1 | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
7 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
8 | Message-id: 20191107163708.833192-18-mreitz@redhat.com | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | --- | ||
11 | tests/qemu-iotests/091 | 2 +- | ||
12 | tests/qemu-iotests/091.out | 2 -- | ||
13 | 2 files changed, 1 insertion(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091 | ||
16 | index XXXXXXX..XXXXXXX 100755 | ||
17 | --- a/tests/qemu-iotests/091 | ||
18 | +++ b/tests/qemu-iotests/091 | ||
19 | @@ -XXX,XX +XXX,XX @@ echo "Check image pattern" | ||
20 | ${QEMU_IO} -c "read -P 0x22 0 4M" "${TEST_IMG}" | _filter_testdir | _filter_qemu_io | ||
21 | |||
22 | echo "Running 'qemu-img check -r all \$TEST_IMG'" | ||
23 | -"${QEMU_IMG}" check -r all "${TEST_IMG}" 2>&1 | _filter_testdir | _filter_qemu | ||
24 | +_check_test_img -r all | ||
25 | |||
26 | echo "*** done" | ||
27 | rm -f $seq.full | ||
28 | diff --git a/tests/qemu-iotests/091.out b/tests/qemu-iotests/091.out | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/tests/qemu-iotests/091.out | ||
31 | +++ b/tests/qemu-iotests/091.out | ||
32 | @@ -XXX,XX +XXX,XX @@ read 4194304/4194304 bytes at offset 0 | ||
33 | 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
34 | Running 'qemu-img check -r all $TEST_IMG' | ||
35 | No errors were found on the image. | ||
36 | -80/16384 = 0.49% allocated, 0.00% fragmented, 0.00% compressed clusters | ||
37 | -Image end offset: 5570560 | ||
38 | *** done | ||
39 | -- | ||
40 | 2.24.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The only difference is that the json:{} filename of the image looks | ||
2 | different. We actually do not care about that filename in this test, we | ||
3 | are only interested in (1) that there is a json:{} filename, and (2) | ||
4 | whether the backing filename can be constructed. | ||
5 | 1 | ||
6 | So just filter out the json:{} data, thus making this test pass both | ||
7 | with and without data_file. | ||
8 | |||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
11 | Message-id: 20191107163708.833192-19-mreitz@redhat.com | ||
12 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
13 | --- | ||
14 | tests/qemu-iotests/110 | 7 +++++-- | ||
15 | tests/qemu-iotests/110.out | 4 ++-- | ||
16 | 2 files changed, 7 insertions(+), 4 deletions(-) | ||
17 | |||
18 | diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 | ||
19 | index XXXXXXX..XXXXXXX 100755 | ||
20 | --- a/tests/qemu-iotests/110 | ||
21 | +++ b/tests/qemu-iotests/110 | ||
22 | @@ -XXX,XX +XXX,XX @@ echo | ||
23 | # Across blkdebug without a config file, you cannot reconstruct filenames, so | ||
24 | # qemu is incapable of knowing the directory of the top image from the filename | ||
25 | # alone. However, using bdrv_dirname(), it should still work. | ||
26 | +# (Filter out the json:{} filename so this test works with external data files) | ||
27 | TEST_IMG="json:{ | ||
28 | 'driver': '$IMGFMT', | ||
29 | 'file': { | ||
30 | @@ -XXX,XX +XXX,XX @@ TEST_IMG="json:{ | ||
31 | } | ||
32 | ] | ||
33 | } | ||
34 | -}" _img_info | _filter_img_info | grep -v 'backing file format' | ||
35 | +}" _img_info | _filter_img_info | grep -v 'backing file format' \ | ||
36 | + | _filter_json_filename | ||
37 | |||
38 | echo | ||
39 | echo '=== Backing name is always relative to the backed image ===' | ||
40 | @@ -XXX,XX +XXX,XX @@ TEST_IMG="json:{ | ||
41 | } | ||
42 | ] | ||
43 | } | ||
44 | -}" _img_info | _filter_img_info | grep -v 'backing file format' | ||
45 | +}" _img_info | _filter_img_info | grep -v 'backing file format' \ | ||
46 | + | _filter_json_filename | ||
47 | |||
48 | |||
49 | # success, all done | ||
50 | diff --git a/tests/qemu-iotests/110.out b/tests/qemu-iotests/110.out | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/tests/qemu-iotests/110.out | ||
53 | +++ b/tests/qemu-iotests/110.out | ||
54 | @@ -XXX,XX +XXX,XX @@ backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base) | ||
55 | |||
56 | === Non-reconstructable filename === | ||
57 | |||
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}} | ||
59 | +image: json:{ /* filtered */ } | ||
60 | file format: IMGFMT | ||
61 | virtual size: 64 MiB (67108864 bytes) | ||
62 | backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base) | ||
63 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=t.IMGFMT.b | ||
64 | |||
65 | === Nodes without a common directory === | ||
66 | |||
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}} | ||
68 | +image: json:{ /* filtered */ } | ||
69 | file format: IMGFMT | ||
70 | virtual size: 64 MiB (67108864 bytes) | ||
71 | backing file: t.IMGFMT.base (cannot determine actual path) | ||
72 | -- | ||
73 | 2.24.1 | ||
74 | |||
75 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | When using an external data file, there are no refcounts for data | ||
2 | clusters. We thus have to adjust the corruption test in this patch to | ||
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 | 1 | ||
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 | |||
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
14 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
15 | Message-id: 20191107163708.833192-20-mreitz@redhat.com | ||
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
17 | --- | ||
18 | tests/qemu-iotests/137 | 15 +++++++++++---- | ||
19 | tests/qemu-iotests/137.out | 6 ++---- | ||
20 | 2 files changed, 13 insertions(+), 8 deletions(-) | ||
21 | |||
22 | diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 | ||
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 | ||
54 | --- a/tests/qemu-iotests/137.out | ||
55 | +++ b/tests/qemu-iotests/137.out | ||
56 | @@ -XXX,XX +XXX,XX @@ qemu-io: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are | ||
57 | wrote 512/512 bytes at offset 0 | ||
58 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
59 | ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) | ||
60 | -incompatible_features [] | ||
61 | +OK: Dirty bit not set | ||
62 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
63 | -wrote 65536/65536 bytes at offset 0 | ||
64 | -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
65 | qemu-io: Parameter 'lazy-refcounts' expects 'on' or 'off' | ||
66 | -qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with qcow2_header); further corruption events will be suppressed | ||
67 | +qcow2: Marking image as corrupt: Preventing invalid allocation of L2 table at offset 0; further corruption events will be suppressed | ||
68 | write failed: Input/output error | ||
69 | *** done | ||
70 | -- | ||
71 | 2.24.1 | ||
72 | |||
73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We do not care about the json:{} filenames here, so we can just filter | ||
2 | them out and thus make the test work both with and without external data | ||
3 | files. | ||
4 | 1 | ||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
6 | Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
7 | Message-id: 20191107163708.833192-21-mreitz@redhat.com | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | --- | ||
10 | tests/qemu-iotests/198 | 6 ++++-- | ||
11 | tests/qemu-iotests/198.out | 4 ++-- | ||
12 | 2 files changed, 6 insertions(+), 4 deletions(-) | ||
13 | |||
14 | diff --git a/tests/qemu-iotests/198 b/tests/qemu-iotests/198 | ||
15 | index XXXXXXX..XXXXXXX 100755 | ||
16 | --- a/tests/qemu-iotests/198 | ||
17 | +++ b/tests/qemu-iotests/198 | ||
18 | @@ -XXX,XX +XXX,XX @@ echo | ||
19 | echo "== checking image base ==" | ||
20 | $QEMU_IMG info --image-opts $IMGSPECBASE | _filter_img_info --format-specific \ | ||
21 | | sed -e "/^disk size:/ D" -e '/refcount bits:/ D' -e '/compat:/ D' \ | ||
22 | - -e '/lazy refcounts:/ D' -e '/corrupt:/ D' | ||
23 | + -e '/lazy refcounts:/ D' -e '/corrupt:/ D' -e '/^\s*data file/ D' \ | ||
24 | + | _filter_json_filename | ||
25 | |||
26 | echo | ||
27 | echo "== checking image layer ==" | ||
28 | $QEMU_IMG info --image-opts $IMGSPECLAYER | _filter_img_info --format-specific \ | ||
29 | | sed -e "/^disk size:/ D" -e '/refcount bits:/ D' -e '/compat:/ D' \ | ||
30 | - -e '/lazy refcounts:/ D' -e '/corrupt:/ D' | ||
31 | + -e '/lazy refcounts:/ D' -e '/corrupt:/ D' -e '/^\s*data file/ D' \ | ||
32 | + | _filter_json_filename | ||
33 | |||
34 | |||
35 | # success, all done | ||
36 | diff --git a/tests/qemu-iotests/198.out b/tests/qemu-iotests/198.out | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/tests/qemu-iotests/198.out | ||
39 | +++ b/tests/qemu-iotests/198.out | ||
40 | @@ -XXX,XX +XXX,XX @@ read 16777216/16777216 bytes at offset 0 | ||
41 | 16 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
42 | |||
43 | == checking image base == | ||
44 | -image: json:{"encrypt.key-secret": "sec0", "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}} | ||
45 | +image: json:{ /* filtered */ } | ||
46 | file format: IMGFMT | ||
47 | virtual size: 16 MiB (16777216 bytes) | ||
48 | Format specific information: | ||
49 | @@ -XXX,XX +XXX,XX @@ Format specific information: | ||
50 | master key iters: 1024 | ||
51 | |||
52 | == checking image layer == | ||
53 | -image: json:{"encrypt.key-secret": "sec1", "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}} | ||
54 | +image: json:{ /* filtered */ } | ||
55 | file format: IMGFMT | ||
56 | virtual size: 16 MiB (16777216 bytes) | ||
57 | backing file: TEST_DIR/t.IMGFMT.base | ||
58 | -- | ||
59 | 2.24.1 | ||
60 | |||
61 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
2 | Message-id: 20191107163708.833192-22-mreitz@redhat.com | ||
3 | [mreitz: Also disable 273] | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
5 | --- | ||
6 | tests/qemu-iotests/007 | 5 +++-- | ||
7 | tests/qemu-iotests/014 | 2 ++ | ||
8 | tests/qemu-iotests/015 | 5 +++-- | ||
9 | tests/qemu-iotests/026 | 5 ++++- | ||
10 | tests/qemu-iotests/029 | 5 +++-- | ||
11 | tests/qemu-iotests/031 | 6 +++--- | ||
12 | tests/qemu-iotests/036 | 5 +++-- | ||
13 | tests/qemu-iotests/039 | 3 +++ | ||
14 | tests/qemu-iotests/046 | 2 ++ | ||
15 | tests/qemu-iotests/048 | 2 ++ | ||
16 | tests/qemu-iotests/051 | 5 +++-- | ||
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 | 1 | ||
52 | diff --git a/tests/qemu-iotests/007 b/tests/qemu-iotests/007 | ||
53 | index XXXXXXX..XXXXXXX 100755 | ||
54 | --- a/tests/qemu-iotests/007 | ||
55 | +++ b/tests/qemu-iotests/007 | ||
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 | ||
73 | _supported_fmt qcow2 | ||
74 | _supported_proto file | ||
75 | _supported_os Linux | ||
76 | +# Compression and snapshots do not work with external data files | ||
77 | +_unsupported_imgopts data_file | ||
78 | |||
79 | TEST_OFFSETS="0 4294967296" | ||
80 | TEST_OPS="writev read write readv" | ||
81 | diff --git a/tests/qemu-iotests/015 b/tests/qemu-iotests/015 | ||
82 | index XXXXXXX..XXXXXXX 100755 | ||
83 | --- a/tests/qemu-iotests/015 | ||
84 | +++ b/tests/qemu-iotests/015 | ||
85 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
86 | # actually any format that supports snapshots | ||
87 | _supported_fmt qcow2 | ||
88 | _supported_proto generic | ||
89 | -# Internal snapshots are (currently) impossible with refcount_bits=1 | ||
90 | -_unsupported_imgopts 'refcount_bits=1[^0-9]' | ||
91 | +# Internal snapshots are (currently) impossible with refcount_bits=1, | ||
92 | +# and generally impossible with external data files | ||
93 | +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file | ||
94 | |||
95 | echo | ||
96 | echo "creating image" | ||
97 | diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 | ||
98 | index XXXXXXX..XXXXXXX 100755 | ||
99 | --- a/tests/qemu-iotests/026 | ||
100 | +++ b/tests/qemu-iotests/026 | ||
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 | ||
118 | _supported_fmt qcow2 | ||
119 | _supported_proto generic | ||
120 | _unsupported_proto vxhs | ||
121 | -# Internal snapshots are (currently) impossible with refcount_bits=1 | ||
122 | -_unsupported_imgopts 'refcount_bits=1[^0-9]' | ||
123 | +# Internal snapshots are (currently) impossible with refcount_bits=1, | ||
124 | +# and generally impossible with external data files | ||
125 | +_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file | ||
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 | ||
131 | --- a/tests/qemu-iotests/031 | ||
132 | +++ b/tests/qemu-iotests/031 | ||
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 | ||
273 | _supported_fmt qcow2 | ||
274 | _supported_proto generic | ||
275 | # We need zero clusters and snapshots | ||
276 | -_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' | ||
277 | +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' data_file | ||
278 | |||
279 | IMG_SIZE=64M | ||
280 | |||
281 | diff --git a/tests/qemu-iotests/066 b/tests/qemu-iotests/066 | ||
282 | index XXXXXXX..XXXXXXX 100755 | ||
283 | --- a/tests/qemu-iotests/066 | ||
284 | +++ b/tests/qemu-iotests/066 | ||
285 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
286 | _supported_fmt qcow2 | ||
287 | _supported_proto generic | ||
288 | # We need zero clusters and snapshots | ||
289 | -_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' | ||
290 | +# (TODO: Consider splitting the snapshot part into a separate test | ||
291 | +# file, so this one runs with refcount_bits=1 and data_file) | ||
292 | +_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' data_file | ||
293 | |||
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 | ||
298 | --- a/tests/qemu-iotests/067 | ||
299 | +++ b/tests/qemu-iotests/067 | ||
300 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
301 | |||
302 | _supported_fmt qcow2 | ||
303 | _supported_proto file | ||
304 | -# Because anything other than 16 would change the output of query-block | ||
305 | -_unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | ||
306 | +# Because anything other than 16 would change the output of query-block, | ||
307 | +# and external data files would change the output of | ||
308 | +# query-named-block-nodes | ||
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 | ||
315 | --- a/tests/qemu-iotests/068 | ||
316 | +++ b/tests/qemu-iotests/068 | ||
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 | ||
348 | _supported_fmt qcow2 | ||
349 | _supported_proto generic | ||
350 | _unsupported_proto vxhs | ||
351 | +# External data files do not support compressed clusters | ||
352 | +# (TODO: Consider writing a version for external data files that does | ||
353 | +# not test compressed clusters) | ||
354 | +_unsupported_imgopts data_file | ||
355 | |||
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 | ||
360 | --- a/tests/qemu-iotests/074 | ||
361 | +++ b/tests/qemu-iotests/074 | ||
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 | ||
487 | _supported_fmt qcow2 | ||
488 | _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 | ||
503 | +# Refcount structures are used much differently with external data | ||
504 | +# files | ||
505 | +_unsupported_imgopts data_file | ||
506 | |||
507 | echo | ||
508 | echo '=== New refcount structures may not conflict with existing structures ===' | ||
509 | diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138 | ||
510 | index XXXXXXX..XXXXXXX 100755 | ||
511 | --- a/tests/qemu-iotests/138 | ||
512 | +++ b/tests/qemu-iotests/138 | ||
513 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
514 | _supported_fmt qcow2 | ||
515 | _supported_proto file | ||
516 | _supported_os Linux | ||
517 | +# With an external data file, data clusters are not refcounted | ||
518 | +# (and so qemu-img check does not check their refcount) | ||
519 | +_unsupported_imgopts data_file | ||
520 | |||
521 | echo | ||
522 | echo '=== Check on an image with a multiple of 2^32 clusters ===' | ||
523 | diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156 | ||
524 | index XXXXXXX..XXXXXXX 100755 | ||
525 | --- a/tests/qemu-iotests/156 | ||
526 | +++ b/tests/qemu-iotests/156 | ||
527 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
528 | _supported_fmt qcow2 qed | ||
529 | _supported_proto generic | ||
530 | _unsupported_proto vxhs | ||
531 | +# Copying files around with cp does not work with external data files | ||
532 | +_unsupported_imgopts data_file | ||
533 | |||
534 | # Create source disk | ||
535 | TEST_IMG="$TEST_IMG.backing" _make_test_img 1M | ||
536 | diff --git a/tests/qemu-iotests/176 b/tests/qemu-iotests/176 | ||
537 | index XXXXXXX..XXXXXXX 100755 | ||
538 | --- a/tests/qemu-iotests/176 | ||
539 | +++ b/tests/qemu-iotests/176 | ||
540 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
541 | _supported_fmt qcow2 | ||
542 | _supported_proto file | ||
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 | -- | ||
719 | 2.24.1 | ||
720 | |||
721 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The problem with allowing the data_file option is that you want to use a | ||
2 | different data file per image used in the test. Therefore, we need to | ||
3 | allow patterns like -o data_file='$TEST_IMG.data_file'. | ||
4 | 1 | ||
5 | Then, we need to filter it out from qemu-img map, qemu-img create, and | ||
6 | remove the data file in _rm_test_img. | ||
7 | |||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | 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 | --- | ||
13 | tests/qemu-iotests/common.filter | 23 +++++++++++++++++++++-- | ||
14 | tests/qemu-iotests/common.rc | 22 +++++++++++++++++++++- | ||
15 | 2 files changed, 42 insertions(+), 3 deletions(-) | ||
16 | |||
17 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/tests/qemu-iotests/common.filter | ||
20 | +++ b/tests/qemu-iotests/common.filter | ||
21 | @@ -XXX,XX +XXX,XX @@ _filter_actual_image_size() | ||
22 | # replace driver-specific options in the "Formatting..." line | ||
23 | _filter_img_create() | ||
24 | { | ||
25 | - $SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ | ||
26 | + data_file_filter=() | ||
27 | + if data_file=$(_get_data_file "$TEST_IMG"); then | ||
28 | + data_file_filter=(-e "s# data_file=$data_file##") | ||
29 | + fi | ||
30 | + | ||
31 | + $SED "${data_file_filter[@]}" \ | ||
32 | + -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ | ||
33 | -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ | ||
34 | -e "s#$TEST_DIR#TEST_DIR#g" \ | ||
35 | -e "s#$SOCK_DIR#SOCK_DIR#g" \ | ||
36 | @@ -XXX,XX +XXX,XX @@ _filter_img_info() | ||
37 | # human and json output | ||
38 | _filter_qemu_img_map() | ||
39 | { | ||
40 | + # Assuming the data_file value in $IMGOPTS contains a '$TEST_IMG', | ||
41 | + # create a filter that replaces the data file name by $TEST_IMG. | ||
42 | + # Example: | ||
43 | + # In $IMGOPTS: 'data_file=$TEST_IMG.data_file' | ||
44 | + # Then data_file_pattern == '\(.*\).data_file' | ||
45 | + # And data_file_filter == -e 's#\(.*\).data_file#\1# | ||
46 | + data_file_filter=() | ||
47 | + if data_file_pattern=$(_get_data_file '\\(.*\\)'); then | ||
48 | + data_file_filter=(-e "s#$data_file_pattern#\\1#") | ||
49 | + fi | ||
50 | + | ||
51 | $SED -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \ | ||
52 | -e 's/"offset": [0-9]\+/"offset": OFFSET/g' \ | ||
53 | - -e 's/Mapped to *//' | _filter_testdir | _filter_imgfmt | ||
54 | + -e 's/Mapped to *//' \ | ||
55 | + "${data_file_filter[@]}" \ | ||
56 | + | _filter_testdir | _filter_imgfmt | ||
57 | } | ||
58 | |||
59 | _filter_nbd() | ||
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 | -- | ||
108 | 2.24.1 | ||
109 | |||
110 | diff view generated by jsdifflib |
1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | 1 | From: Jeuk Kim <jeuk20.kim@samsung.com> |
---|---|---|---|
2 | 2 | ||
3 | QEMU currently supports writing compressed data of the size equal to | 3 | This patch includes the following tests |
4 | one cluster. This patch allows writing QCOW2 compressed data that | 4 | Test mmio read |
5 | exceed one cluster. Now, we split buffered data into separate clusters | 5 | Test ufs device initialization and ufs-lu recognition |
6 | and write them compressed using the block/aio_task API. | 6 | Test I/O (Performs a write followed by a read to verify) |
7 | 7 | ||
8 | Suggested-by: Pavel Butsykin <pbutsykin@virtuozzo.com> | 8 | Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com> |
9 | Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 9 | Acked-by: Thomas Huth <thuth@redhat.com> |
10 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | 10 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
11 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 11 | Message-id: 9e9207f54505e9ba30931849f949ff6f474ac333.1693980783.git.jeuk20.kim@gmail.com |
12 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 12 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
13 | Message-id: 1575288906-551879-3-git-send-email-andrey.shinkevich@virtuozzo.com | ||
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
15 | --- | 13 | --- |
16 | block/qcow2.c | 102 +++++++++++++++++++++++++++++++++++++------------- | 14 | MAINTAINERS | 1 + |
17 | 1 file changed, 75 insertions(+), 27 deletions(-) | 15 | tests/qtest/ufs-test.c | 587 ++++++++++++++++++++++++++++++++++++++++ |
16 | tests/qtest/meson.build | 1 + | ||
17 | 3 files changed, 589 insertions(+) | ||
18 | create mode 100644 tests/qtest/ufs-test.c | ||
18 | 19 | ||
19 | diff --git a/block/qcow2.c b/block/qcow2.c | 20 | diff --git a/MAINTAINERS b/MAINTAINERS |
20 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/block/qcow2.c | 22 | --- a/MAINTAINERS |
22 | +++ b/block/qcow2.c | 23 | +++ b/MAINTAINERS |
23 | @@ -XXX,XX +XXX,XX @@ fail: | 24 | @@ -XXX,XX +XXX,XX @@ M: Jeuk Kim <jeuk20.kim@samsung.com> |
24 | return ret; | 25 | S: Supported |
25 | } | 26 | F: hw/ufs/* |
26 | 27 | F: include/block/ufs.h | |
27 | -/* XXX: put compressed sectors first, then all the cluster aligned | 28 | +F: tests/qtest/ufs-test.c |
28 | - tables to avoid losing bytes in alignment */ | 29 | |
29 | static coroutine_fn int | 30 | megasas |
30 | -qcow2_co_pwritev_compressed_part(BlockDriverState *bs, | 31 | M: Hannes Reinecke <hare@suse.com> |
31 | +qcow2_co_pwritev_compressed_task(BlockDriverState *bs, | 32 | diff --git a/tests/qtest/ufs-test.c b/tests/qtest/ufs-test.c |
32 | uint64_t offset, uint64_t bytes, | 33 | new file mode 100644 |
33 | QEMUIOVector *qiov, size_t qiov_offset) | 34 | index XXXXXXX..XXXXXXX |
34 | { | 35 | --- /dev/null |
35 | @@ -XXX,XX +XXX,XX @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs, | 36 | +++ b/tests/qtest/ufs-test.c |
36 | uint8_t *buf, *out_buf; | 37 | @@ -XXX,XX +XXX,XX @@ |
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 | +{ | ||
77 | + Qcow2AioTask *t = container_of(task, Qcow2AioTask, task); | ||
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 | +/* | 38 | +/* |
86 | + * XXX: put compressed sectors first, then all the cluster aligned | 39 | + * QTest testcase for UFS |
87 | + * tables to avoid losing bytes in alignment | 40 | + * |
41 | + * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved. | ||
42 | + * | ||
43 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
88 | + */ | 44 | + */ |
89 | +static coroutine_fn int | 45 | + |
90 | +qcow2_co_pwritev_compressed_part(BlockDriverState *bs, | 46 | +#include "qemu/osdep.h" |
91 | + uint64_t offset, uint64_t bytes, | 47 | +#include "qemu/module.h" |
92 | + QEMUIOVector *qiov, size_t qiov_offset) | 48 | +#include "qemu/units.h" |
93 | +{ | 49 | +#include "libqtest.h" |
94 | + BDRVQcow2State *s = bs->opaque; | 50 | +#include "libqos/qgraph.h" |
95 | + AioTaskPool *aio = NULL; | 51 | +#include "libqos/pci.h" |
96 | + int ret = 0; | 52 | +#include "scsi/constants.h" |
97 | + | 53 | +#include "include/block/ufs.h" |
98 | + if (has_data_file(bs)) { | 54 | + |
99 | + return -ENOTSUP; | 55 | +/* Test images sizes in Bytes */ |
56 | +#define TEST_IMAGE_SIZE (64 * 1024 * 1024) | ||
57 | +/* Timeout for various operations, in seconds. */ | ||
58 | +#define TIMEOUT_SECONDS 10 | ||
59 | +/* Maximum PRD entry count */ | ||
60 | +#define MAX_PRD_ENTRY_COUNT 10 | ||
61 | +#define PRD_ENTRY_DATA_SIZE 4096 | ||
62 | +/* Constants to build upiu */ | ||
63 | +#define UTP_COMMAND_DESCRIPTOR_SIZE 4096 | ||
64 | +#define UTP_RESPONSE_UPIU_OFFSET 1024 | ||
65 | +#define UTP_PRDT_UPIU_OFFSET 2048 | ||
66 | + | ||
67 | +typedef struct QUfs QUfs; | ||
68 | + | ||
69 | +struct QUfs { | ||
70 | + QOSGraphObject obj; | ||
71 | + QPCIDevice dev; | ||
72 | + QPCIBar bar; | ||
73 | + | ||
74 | + uint64_t utrlba; | ||
75 | + uint64_t utmrlba; | ||
76 | + uint64_t cmd_desc_addr; | ||
77 | + uint64_t data_buffer_addr; | ||
78 | + | ||
79 | + bool enabled; | ||
80 | +}; | ||
81 | + | ||
82 | +static inline uint32_t ufs_rreg(QUfs *ufs, size_t offset) | ||
83 | +{ | ||
84 | + return qpci_io_readl(&ufs->dev, ufs->bar, offset); | ||
85 | +} | ||
86 | + | ||
87 | +static inline void ufs_wreg(QUfs *ufs, size_t offset, uint32_t value) | ||
88 | +{ | ||
89 | + qpci_io_writel(&ufs->dev, ufs->bar, offset, value); | ||
90 | +} | ||
91 | + | ||
92 | +static void ufs_wait_for_irq(QUfs *ufs) | ||
93 | +{ | ||
94 | + uint64_t end_time; | ||
95 | + uint32_t is; | ||
96 | + /* Wait for device to reset as the linux driver does. */ | ||
97 | + end_time = g_get_monotonic_time() + TIMEOUT_SECONDS * G_TIME_SPAN_SECOND; | ||
98 | + do { | ||
99 | + qtest_clock_step(ufs->dev.bus->qts, 100); | ||
100 | + is = ufs_rreg(ufs, A_IS); | ||
101 | + } while (is == 0 && g_get_monotonic_time() < end_time); | ||
102 | +} | ||
103 | + | ||
104 | +static UtpTransferReqDesc ufs_build_req_utrd(uint64_t cmd_desc_addr, | ||
105 | + uint8_t slot, | ||
106 | + uint32_t data_direction, | ||
107 | + uint16_t prd_table_length) | ||
108 | +{ | ||
109 | + UtpTransferReqDesc req = { 0 }; | ||
110 | + uint64_t command_desc_base_addr = | ||
111 | + cmd_desc_addr + slot * UTP_COMMAND_DESCRIPTOR_SIZE; | ||
112 | + | ||
113 | + req.header.dword_0 = | ||
114 | + cpu_to_le32(1 << 28 | data_direction | UFS_UTP_REQ_DESC_INT_CMD); | ||
115 | + req.header.dword_2 = cpu_to_le32(UFS_OCS_INVALID_COMMAND_STATUS); | ||
116 | + | ||
117 | + req.command_desc_base_addr_hi = cpu_to_le32(command_desc_base_addr >> 32); | ||
118 | + req.command_desc_base_addr_lo = | ||
119 | + cpu_to_le32(command_desc_base_addr & 0xffffffff); | ||
120 | + req.response_upiu_offset = | ||
121 | + cpu_to_le16(UTP_RESPONSE_UPIU_OFFSET / sizeof(uint32_t)); | ||
122 | + req.response_upiu_length = cpu_to_le16(sizeof(UtpUpiuRsp)); | ||
123 | + req.prd_table_offset = cpu_to_le16(UTP_PRDT_UPIU_OFFSET / sizeof(uint32_t)); | ||
124 | + req.prd_table_length = cpu_to_le16(prd_table_length); | ||
125 | + return req; | ||
126 | +} | ||
127 | + | ||
128 | +static void ufs_send_nop_out(QUfs *ufs, uint8_t slot, | ||
129 | + UtpTransferReqDesc *utrd_out, UtpUpiuRsp *rsp_out) | ||
130 | +{ | ||
131 | + /* Build up utp transfer request descriptor */ | ||
132 | + UtpTransferReqDesc utrd = ufs_build_req_utrd(ufs->cmd_desc_addr, slot, | ||
133 | + UFS_UTP_NO_DATA_TRANSFER, 0); | ||
134 | + uint64_t utrd_addr = ufs->utrlba + slot * sizeof(UtpTransferReqDesc); | ||
135 | + uint64_t req_upiu_addr = | ||
136 | + ufs->cmd_desc_addr + slot * UTP_COMMAND_DESCRIPTOR_SIZE; | ||
137 | + uint64_t rsp_upiu_addr = req_upiu_addr + UTP_RESPONSE_UPIU_OFFSET; | ||
138 | + qtest_memwrite(ufs->dev.bus->qts, utrd_addr, &utrd, sizeof(utrd)); | ||
139 | + | ||
140 | + /* Build up request upiu */ | ||
141 | + UtpUpiuReq req_upiu = { 0 }; | ||
142 | + req_upiu.header.trans_type = UFS_UPIU_TRANSACTION_NOP_OUT; | ||
143 | + req_upiu.header.task_tag = slot; | ||
144 | + qtest_memwrite(ufs->dev.bus->qts, req_upiu_addr, &req_upiu, | ||
145 | + sizeof(req_upiu)); | ||
146 | + | ||
147 | + /* Ring Doorbell */ | ||
148 | + ufs_wreg(ufs, A_UTRLDBR, 1); | ||
149 | + ufs_wait_for_irq(ufs); | ||
150 | + g_assert_true(FIELD_EX32(ufs_rreg(ufs, A_IS), IS, UTRCS)); | ||
151 | + ufs_wreg(ufs, A_IS, FIELD_DP32(0, IS, UTRCS, 1)); | ||
152 | + | ||
153 | + qtest_memread(ufs->dev.bus->qts, utrd_addr, utrd_out, sizeof(*utrd_out)); | ||
154 | + qtest_memread(ufs->dev.bus->qts, rsp_upiu_addr, rsp_out, sizeof(*rsp_out)); | ||
155 | +} | ||
156 | + | ||
157 | +static void ufs_send_query(QUfs *ufs, uint8_t slot, uint8_t query_function, | ||
158 | + uint8_t query_opcode, uint8_t idn, uint8_t index, | ||
159 | + UtpTransferReqDesc *utrd_out, UtpUpiuRsp *rsp_out) | ||
160 | +{ | ||
161 | + /* Build up utp transfer request descriptor */ | ||
162 | + UtpTransferReqDesc utrd = ufs_build_req_utrd(ufs->cmd_desc_addr, slot, | ||
163 | + UFS_UTP_NO_DATA_TRANSFER, 0); | ||
164 | + uint64_t utrd_addr = ufs->utrlba + slot * sizeof(UtpTransferReqDesc); | ||
165 | + uint64_t req_upiu_addr = | ||
166 | + ufs->cmd_desc_addr + slot * UTP_COMMAND_DESCRIPTOR_SIZE; | ||
167 | + uint64_t rsp_upiu_addr = req_upiu_addr + UTP_RESPONSE_UPIU_OFFSET; | ||
168 | + qtest_memwrite(ufs->dev.bus->qts, utrd_addr, &utrd, sizeof(utrd)); | ||
169 | + | ||
170 | + /* Build up request upiu */ | ||
171 | + UtpUpiuReq req_upiu = { 0 }; | ||
172 | + req_upiu.header.trans_type = UFS_UPIU_TRANSACTION_QUERY_REQ; | ||
173 | + req_upiu.header.query_func = query_function; | ||
174 | + req_upiu.header.task_tag = slot; | ||
175 | + /* | ||
176 | + * QEMU UFS does not currently support Write descriptor and Write attribute, | ||
177 | + * so the value of data_segment_length is always 0. | ||
178 | + */ | ||
179 | + req_upiu.header.data_segment_length = 0; | ||
180 | + req_upiu.qr.opcode = query_opcode; | ||
181 | + req_upiu.qr.idn = idn; | ||
182 | + req_upiu.qr.index = index; | ||
183 | + qtest_memwrite(ufs->dev.bus->qts, req_upiu_addr, &req_upiu, | ||
184 | + sizeof(req_upiu)); | ||
185 | + | ||
186 | + /* Ring Doorbell */ | ||
187 | + ufs_wreg(ufs, A_UTRLDBR, 1); | ||
188 | + ufs_wait_for_irq(ufs); | ||
189 | + g_assert_true(FIELD_EX32(ufs_rreg(ufs, A_IS), IS, UTRCS)); | ||
190 | + ufs_wreg(ufs, A_IS, FIELD_DP32(0, IS, UTRCS, 1)); | ||
191 | + | ||
192 | + qtest_memread(ufs->dev.bus->qts, utrd_addr, utrd_out, sizeof(*utrd_out)); | ||
193 | + qtest_memread(ufs->dev.bus->qts, rsp_upiu_addr, rsp_out, sizeof(*rsp_out)); | ||
194 | +} | ||
195 | + | ||
196 | +static void ufs_send_scsi_command(QUfs *ufs, uint8_t slot, uint8_t lun, | ||
197 | + const uint8_t *cdb, const uint8_t *data_in, | ||
198 | + size_t data_in_len, uint8_t *data_out, | ||
199 | + size_t data_out_len, | ||
200 | + UtpTransferReqDesc *utrd_out, | ||
201 | + UtpUpiuRsp *rsp_out) | ||
202 | + | ||
203 | +{ | ||
204 | + /* Build up PRDT */ | ||
205 | + UfshcdSgEntry entries[MAX_PRD_ENTRY_COUNT] = { | ||
206 | + 0, | ||
207 | + }; | ||
208 | + uint8_t flags; | ||
209 | + uint16_t prd_table_length, i; | ||
210 | + uint32_t data_direction, data_len; | ||
211 | + uint64_t req_upiu_addr = | ||
212 | + ufs->cmd_desc_addr + slot * UTP_COMMAND_DESCRIPTOR_SIZE; | ||
213 | + uint64_t prdt_addr = req_upiu_addr + UTP_PRDT_UPIU_OFFSET; | ||
214 | + | ||
215 | + g_assert_true(data_in_len < MAX_PRD_ENTRY_COUNT * PRD_ENTRY_DATA_SIZE); | ||
216 | + g_assert_true(data_out_len < MAX_PRD_ENTRY_COUNT * PRD_ENTRY_DATA_SIZE); | ||
217 | + if (data_in_len > 0) { | ||
218 | + g_assert_nonnull(data_in); | ||
219 | + data_direction = UFS_UTP_HOST_TO_DEVICE; | ||
220 | + data_len = data_in_len; | ||
221 | + flags = UFS_UPIU_CMD_FLAGS_WRITE; | ||
222 | + } else if (data_out_len > 0) { | ||
223 | + g_assert_nonnull(data_out); | ||
224 | + data_direction = UFS_UTP_DEVICE_TO_HOST; | ||
225 | + data_len = data_out_len; | ||
226 | + flags = UFS_UPIU_CMD_FLAGS_READ; | ||
227 | + } else { | ||
228 | + data_direction = UFS_UTP_NO_DATA_TRANSFER; | ||
229 | + data_len = 0; | ||
230 | + flags = UFS_UPIU_CMD_FLAGS_NONE; | ||
100 | + } | 231 | + } |
101 | + | 232 | + prd_table_length = DIV_ROUND_UP(data_len, PRD_ENTRY_DATA_SIZE); |
102 | + if (bytes == 0) { | 233 | + |
103 | + /* | 234 | + qtest_memset(ufs->dev.bus->qts, ufs->data_buffer_addr, 0, |
104 | + * align end of file to a sector boundary to ease reading with | 235 | + MAX_PRD_ENTRY_COUNT * PRD_ENTRY_DATA_SIZE); |
105 | + * sector based I/Os | 236 | + if (data_in_len) { |
106 | + */ | 237 | + qtest_memwrite(ufs->dev.bus->qts, ufs->data_buffer_addr, data_in, |
107 | + int64_t len = bdrv_getlength(bs->file->bs); | 238 | + data_in_len); |
108 | + if (len < 0) { | 239 | + } |
109 | + return len; | 240 | + |
241 | + for (i = 0; i < prd_table_length; i++) { | ||
242 | + entries[i].addr = | ||
243 | + cpu_to_le64(ufs->data_buffer_addr + i * sizeof(UfshcdSgEntry)); | ||
244 | + if (i + 1 != prd_table_length) { | ||
245 | + entries[i].size = cpu_to_le32(PRD_ENTRY_DATA_SIZE - 1); | ||
246 | + } else { | ||
247 | + entries[i].size = cpu_to_le32( | ||
248 | + data_len - (PRD_ENTRY_DATA_SIZE * (prd_table_length - 1)) - 1); | ||
110 | + } | 249 | + } |
111 | + return bdrv_co_truncate(bs->file, len, false, PREALLOC_MODE_OFF, NULL); | ||
112 | + } | 250 | + } |
113 | + | 251 | + qtest_memwrite(ufs->dev.bus->qts, prdt_addr, entries, |
114 | + if (offset_into_cluster(s, offset)) { | 252 | + prd_table_length * sizeof(UfshcdSgEntry)); |
115 | + return -EINVAL; | 253 | + |
254 | + /* Build up utp transfer request descriptor */ | ||
255 | + UtpTransferReqDesc utrd = ufs_build_req_utrd( | ||
256 | + ufs->cmd_desc_addr, slot, data_direction, prd_table_length); | ||
257 | + uint64_t utrd_addr = ufs->utrlba + slot * sizeof(UtpTransferReqDesc); | ||
258 | + uint64_t rsp_upiu_addr = req_upiu_addr + UTP_RESPONSE_UPIU_OFFSET; | ||
259 | + qtest_memwrite(ufs->dev.bus->qts, utrd_addr, &utrd, sizeof(utrd)); | ||
260 | + | ||
261 | + /* Build up request upiu */ | ||
262 | + UtpUpiuReq req_upiu = { 0 }; | ||
263 | + req_upiu.header.trans_type = UFS_UPIU_TRANSACTION_COMMAND; | ||
264 | + req_upiu.header.flags = flags; | ||
265 | + req_upiu.header.lun = lun; | ||
266 | + req_upiu.header.task_tag = slot; | ||
267 | + req_upiu.sc.exp_data_transfer_len = cpu_to_be32(data_len); | ||
268 | + memcpy(req_upiu.sc.cdb, cdb, UFS_CDB_SIZE); | ||
269 | + qtest_memwrite(ufs->dev.bus->qts, req_upiu_addr, &req_upiu, | ||
270 | + sizeof(req_upiu)); | ||
271 | + | ||
272 | + /* Ring Doorbell */ | ||
273 | + ufs_wreg(ufs, A_UTRLDBR, 1); | ||
274 | + ufs_wait_for_irq(ufs); | ||
275 | + g_assert_true(FIELD_EX32(ufs_rreg(ufs, A_IS), IS, UTRCS)); | ||
276 | + ufs_wreg(ufs, A_IS, FIELD_DP32(0, IS, UTRCS, 1)); | ||
277 | + | ||
278 | + qtest_memread(ufs->dev.bus->qts, utrd_addr, utrd_out, sizeof(*utrd_out)); | ||
279 | + qtest_memread(ufs->dev.bus->qts, rsp_upiu_addr, rsp_out, sizeof(*rsp_out)); | ||
280 | + if (data_out_len) { | ||
281 | + qtest_memread(ufs->dev.bus->qts, ufs->data_buffer_addr, data_out, | ||
282 | + data_out_len); | ||
116 | + } | 283 | + } |
117 | + | 284 | +} |
118 | + while (bytes && aio_task_pool_status(aio) == 0) { | 285 | + |
119 | + uint64_t chunk_size = MIN(bytes, s->cluster_size); | 286 | +/** |
120 | + | 287 | + * Initialize Ufs host controller and logical unit. |
121 | + if (!aio && chunk_size != bytes) { | 288 | + * After running this function, you can make a transfer request to the UFS. |
122 | + aio = aio_task_pool_new(QCOW2_MAX_WORKERS); | 289 | + */ |
123 | + } | 290 | +static void ufs_init(QUfs *ufs, QGuestAllocator *alloc) |
124 | + | 291 | +{ |
125 | + ret = qcow2_add_task(bs, aio, qcow2_co_pwritev_compressed_task_entry, | 292 | + uint64_t end_time; |
126 | + 0, 0, offset, chunk_size, qiov, qiov_offset, NULL); | 293 | + uint32_t nutrs, nutmrs; |
127 | + if (ret < 0) { | 294 | + uint32_t hcs, is, ucmdarg2, cap; |
128 | + break; | 295 | + uint32_t hce = 0, ie = 0; |
129 | + } | 296 | + UtpTransferReqDesc utrd; |
130 | + qiov_offset += chunk_size; | 297 | + UtpUpiuRsp rsp_upiu; |
131 | + offset += chunk_size; | 298 | + |
132 | + bytes -= chunk_size; | 299 | + ufs->bar = qpci_iomap(&ufs->dev, 0, NULL); |
300 | + qpci_device_enable(&ufs->dev); | ||
301 | + | ||
302 | + /* Start host controller initialization */ | ||
303 | + hce = FIELD_DP32(hce, HCE, HCE, 1); | ||
304 | + ufs_wreg(ufs, A_HCE, hce); | ||
305 | + | ||
306 | + /* Wait for device to reset */ | ||
307 | + end_time = g_get_monotonic_time() + TIMEOUT_SECONDS * G_TIME_SPAN_SECOND; | ||
308 | + do { | ||
309 | + qtest_clock_step(ufs->dev.bus->qts, 100); | ||
310 | + hce = FIELD_EX32(ufs_rreg(ufs, A_HCE), HCE, HCE); | ||
311 | + } while (hce == 0 && g_get_monotonic_time() < end_time); | ||
312 | + g_assert_cmpuint(hce, ==, 1); | ||
313 | + | ||
314 | + /* Enable interrupt */ | ||
315 | + ie = FIELD_DP32(ie, IE, UCCE, 1); | ||
316 | + ie = FIELD_DP32(ie, IE, UHESE, 1); | ||
317 | + ie = FIELD_DP32(ie, IE, UHXSE, 1); | ||
318 | + ie = FIELD_DP32(ie, IE, UPMSE, 1); | ||
319 | + ufs_wreg(ufs, A_IE, ie); | ||
320 | + | ||
321 | + /* Send DME_LINK_STARTUP uic command */ | ||
322 | + hcs = ufs_rreg(ufs, A_HCS); | ||
323 | + g_assert_true(FIELD_EX32(hcs, HCS, UCRDY)); | ||
324 | + | ||
325 | + ufs_wreg(ufs, A_UCMDARG1, 0); | ||
326 | + ufs_wreg(ufs, A_UCMDARG2, 0); | ||
327 | + ufs_wreg(ufs, A_UCMDARG3, 0); | ||
328 | + ufs_wreg(ufs, A_UICCMD, UFS_UIC_CMD_DME_LINK_STARTUP); | ||
329 | + | ||
330 | + is = ufs_rreg(ufs, A_IS); | ||
331 | + g_assert_true(FIELD_EX32(is, IS, UCCS)); | ||
332 | + ufs_wreg(ufs, A_IS, FIELD_DP32(0, IS, UCCS, 1)); | ||
333 | + | ||
334 | + ucmdarg2 = ufs_rreg(ufs, A_UCMDARG2); | ||
335 | + g_assert_cmpuint(ucmdarg2, ==, 0); | ||
336 | + is = ufs_rreg(ufs, A_IS); | ||
337 | + g_assert_cmpuint(is, ==, 0); | ||
338 | + hcs = ufs_rreg(ufs, A_HCS); | ||
339 | + g_assert_true(FIELD_EX32(hcs, HCS, DP)); | ||
340 | + g_assert_true(FIELD_EX32(hcs, HCS, UTRLRDY)); | ||
341 | + g_assert_true(FIELD_EX32(hcs, HCS, UTMRLRDY)); | ||
342 | + g_assert_true(FIELD_EX32(hcs, HCS, UCRDY)); | ||
343 | + | ||
344 | + /* Enable all interrupt functions */ | ||
345 | + ie = FIELD_DP32(ie, IE, UTRCE, 1); | ||
346 | + ie = FIELD_DP32(ie, IE, UEE, 1); | ||
347 | + ie = FIELD_DP32(ie, IE, UPMSE, 1); | ||
348 | + ie = FIELD_DP32(ie, IE, UHXSE, 1); | ||
349 | + ie = FIELD_DP32(ie, IE, UHESE, 1); | ||
350 | + ie = FIELD_DP32(ie, IE, UTMRCE, 1); | ||
351 | + ie = FIELD_DP32(ie, IE, UCCE, 1); | ||
352 | + ie = FIELD_DP32(ie, IE, DFEE, 1); | ||
353 | + ie = FIELD_DP32(ie, IE, HCFEE, 1); | ||
354 | + ie = FIELD_DP32(ie, IE, SBFEE, 1); | ||
355 | + ie = FIELD_DP32(ie, IE, CEFEE, 1); | ||
356 | + ufs_wreg(ufs, A_IE, ie); | ||
357 | + ufs_wreg(ufs, A_UTRIACR, 0); | ||
358 | + | ||
359 | + /* Enable tranfer request and task management request */ | ||
360 | + cap = ufs_rreg(ufs, A_CAP); | ||
361 | + nutrs = FIELD_EX32(cap, CAP, NUTRS) + 1; | ||
362 | + nutmrs = FIELD_EX32(cap, CAP, NUTMRS) + 1; | ||
363 | + ufs->cmd_desc_addr = | ||
364 | + guest_alloc(alloc, nutrs * UTP_COMMAND_DESCRIPTOR_SIZE); | ||
365 | + ufs->data_buffer_addr = | ||
366 | + guest_alloc(alloc, MAX_PRD_ENTRY_COUNT * PRD_ENTRY_DATA_SIZE); | ||
367 | + ufs->utrlba = guest_alloc(alloc, nutrs * sizeof(UtpTransferReqDesc)); | ||
368 | + ufs->utmrlba = guest_alloc(alloc, nutmrs * sizeof(UtpTaskReqDesc)); | ||
369 | + | ||
370 | + ufs_wreg(ufs, A_UTRLBA, ufs->utrlba & 0xffffffff); | ||
371 | + ufs_wreg(ufs, A_UTRLBAU, ufs->utrlba >> 32); | ||
372 | + ufs_wreg(ufs, A_UTMRLBA, ufs->utmrlba & 0xffffffff); | ||
373 | + ufs_wreg(ufs, A_UTMRLBAU, ufs->utmrlba >> 32); | ||
374 | + ufs_wreg(ufs, A_UTRLRSR, 1); | ||
375 | + ufs_wreg(ufs, A_UTMRLRSR, 1); | ||
376 | + | ||
377 | + /* Send nop out to test transfer request */ | ||
378 | + ufs_send_nop_out(ufs, 0, &utrd, &rsp_upiu); | ||
379 | + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS); | ||
380 | + | ||
381 | + /* Set fDeviceInit flag via query request */ | ||
382 | + ufs_send_query(ufs, 0, UFS_UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST, | ||
383 | + UFS_UPIU_QUERY_OPCODE_SET_FLAG, | ||
384 | + UFS_QUERY_FLAG_IDN_FDEVICEINIT, 0, &utrd, &rsp_upiu); | ||
385 | + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS); | ||
386 | + | ||
387 | + /* Wait for device to reset */ | ||
388 | + end_time = g_get_monotonic_time() + TIMEOUT_SECONDS * G_TIME_SPAN_SECOND; | ||
389 | + do { | ||
390 | + qtest_clock_step(ufs->dev.bus->qts, 100); | ||
391 | + ufs_send_query(ufs, 0, UFS_UPIU_QUERY_FUNC_STANDARD_READ_REQUEST, | ||
392 | + UFS_UPIU_QUERY_OPCODE_READ_FLAG, | ||
393 | + UFS_QUERY_FLAG_IDN_FDEVICEINIT, 0, &utrd, &rsp_upiu); | ||
394 | + } while (be32_to_cpu(rsp_upiu.qr.value) != 0 && | ||
395 | + g_get_monotonic_time() < end_time); | ||
396 | + g_assert_cmpuint(be32_to_cpu(rsp_upiu.qr.value), ==, 0); | ||
397 | + | ||
398 | + ufs->enabled = true; | ||
399 | +} | ||
400 | + | ||
401 | +static void ufs_exit(QUfs *ufs, QGuestAllocator *alloc) | ||
402 | +{ | ||
403 | + if (ufs->enabled) { | ||
404 | + guest_free(alloc, ufs->utrlba); | ||
405 | + guest_free(alloc, ufs->utmrlba); | ||
406 | + guest_free(alloc, ufs->cmd_desc_addr); | ||
407 | + guest_free(alloc, ufs->data_buffer_addr); | ||
133 | + } | 408 | + } |
134 | + | 409 | + |
135 | + if (aio) { | 410 | + qpci_iounmap(&ufs->dev, ufs->bar); |
136 | + aio_task_pool_wait_all(aio); | 411 | +} |
137 | + if (ret == 0) { | 412 | + |
138 | + ret = aio_task_pool_status(aio); | 413 | +static void *ufs_get_driver(void *obj, const char *interface) |
139 | + } | 414 | +{ |
140 | + g_free(aio); | 415 | + QUfs *ufs = obj; |
416 | + | ||
417 | + if (!g_strcmp0(interface, "pci-device")) { | ||
418 | + return &ufs->dev; | ||
141 | + } | 419 | + } |
142 | + | 420 | + |
143 | + return ret; | 421 | + fprintf(stderr, "%s not present in ufs\n", interface); |
144 | +} | 422 | + g_assert_not_reached(); |
145 | + | 423 | +} |
146 | static int coroutine_fn | 424 | + |
147 | qcow2_co_preadv_compressed(BlockDriverState *bs, | 425 | +static void *ufs_create(void *pci_bus, QGuestAllocator *alloc, void *addr) |
148 | uint64_t file_cluster_offset, | 426 | +{ |
427 | + QUfs *ufs = g_new0(QUfs, 1); | ||
428 | + QPCIBus *bus = pci_bus; | ||
429 | + | ||
430 | + qpci_device_init(&ufs->dev, bus, addr); | ||
431 | + ufs->obj.get_driver = ufs_get_driver; | ||
432 | + | ||
433 | + return &ufs->obj; | ||
434 | +} | ||
435 | + | ||
436 | +static void ufstest_reg_read(void *obj, void *data, QGuestAllocator *alloc) | ||
437 | +{ | ||
438 | + QUfs *ufs = obj; | ||
439 | + uint32_t cap; | ||
440 | + | ||
441 | + ufs->bar = qpci_iomap(&ufs->dev, 0, NULL); | ||
442 | + qpci_device_enable(&ufs->dev); | ||
443 | + | ||
444 | + cap = ufs_rreg(ufs, A_CAP); | ||
445 | + g_assert_cmpuint(FIELD_EX32(cap, CAP, NUTRS), ==, 31); | ||
446 | + g_assert_cmpuint(FIELD_EX32(cap, CAP, NUTMRS), ==, 7); | ||
447 | + g_assert_cmpuint(FIELD_EX32(cap, CAP, 64AS), ==, 1); | ||
448 | + | ||
449 | + qpci_iounmap(&ufs->dev, ufs->bar); | ||
450 | +} | ||
451 | + | ||
452 | +static void ufstest_init(void *obj, void *data, QGuestAllocator *alloc) | ||
453 | +{ | ||
454 | + QUfs *ufs = obj; | ||
455 | + | ||
456 | + uint8_t buf[4096] = { 0 }; | ||
457 | + const uint8_t report_luns_cdb[UFS_CDB_SIZE] = { | ||
458 | + /* allocation length 4096 */ | ||
459 | + REPORT_LUNS, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
460 | + 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 | ||
461 | + }; | ||
462 | + const uint8_t test_unit_ready_cdb[UFS_CDB_SIZE] = { | ||
463 | + TEST_UNIT_READY, | ||
464 | + }; | ||
465 | + UtpTransferReqDesc utrd; | ||
466 | + UtpUpiuRsp rsp_upiu; | ||
467 | + | ||
468 | + ufs_init(ufs, alloc); | ||
469 | + | ||
470 | + /* Check REPORT_LUNS */ | ||
471 | + ufs_send_scsi_command(ufs, 0, 0, report_luns_cdb, NULL, 0, buf, sizeof(buf), | ||
472 | + &utrd, &rsp_upiu); | ||
473 | + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS); | ||
474 | + g_assert_cmpuint(rsp_upiu.header.scsi_status, ==, GOOD); | ||
475 | + /* LUN LIST LENGTH should be 8, in big endian */ | ||
476 | + g_assert_cmpuint(buf[3], ==, 8); | ||
477 | + /* There is one logical unit whose lun is 0 */ | ||
478 | + g_assert_cmpuint(buf[9], ==, 0); | ||
479 | + | ||
480 | + /* Check TEST_UNIT_READY */ | ||
481 | + ufs_send_scsi_command(ufs, 0, 0, test_unit_ready_cdb, NULL, 0, NULL, 0, | ||
482 | + &utrd, &rsp_upiu); | ||
483 | + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS); | ||
484 | + g_assert_cmpuint(rsp_upiu.header.scsi_status, ==, GOOD); | ||
485 | + | ||
486 | + ufs_exit(ufs, alloc); | ||
487 | +} | ||
488 | + | ||
489 | +static void ufstest_read_write(void *obj, void *data, QGuestAllocator *alloc) | ||
490 | +{ | ||
491 | + QUfs *ufs = obj; | ||
492 | + uint8_t read_buf[4096] = { 0 }; | ||
493 | + uint8_t write_buf[4096] = { 0 }; | ||
494 | + const uint8_t read_capacity_cdb[UFS_CDB_SIZE] = { | ||
495 | + /* allocation length 4096 */ | ||
496 | + SERVICE_ACTION_IN_16, | ||
497 | + SAI_READ_CAPACITY_16, | ||
498 | + 0x00, | ||
499 | + 0x00, | ||
500 | + 0x00, | ||
501 | + 0x00, | ||
502 | + 0x00, | ||
503 | + 0x00, | ||
504 | + 0x00, | ||
505 | + 0x00, | ||
506 | + 0x00, | ||
507 | + 0x00, | ||
508 | + 0x10, | ||
509 | + 0x00, | ||
510 | + 0x00, | ||
511 | + 0x00 | ||
512 | + }; | ||
513 | + const uint8_t read_cdb[UFS_CDB_SIZE] = { | ||
514 | + /* READ(10) to LBA 0, transfer length 1 */ | ||
515 | + READ_10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 | ||
516 | + }; | ||
517 | + const uint8_t write_cdb[UFS_CDB_SIZE] = { | ||
518 | + /* WRITE(10) to LBA 0, transfer length 1 */ | ||
519 | + WRITE_10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 | ||
520 | + }; | ||
521 | + uint32_t block_size; | ||
522 | + UtpTransferReqDesc utrd; | ||
523 | + UtpUpiuRsp rsp_upiu; | ||
524 | + | ||
525 | + ufs_init(ufs, alloc); | ||
526 | + | ||
527 | + /* Read capacity */ | ||
528 | + ufs_send_scsi_command(ufs, 0, 1, read_capacity_cdb, NULL, 0, read_buf, | ||
529 | + sizeof(read_buf), &utrd, &rsp_upiu); | ||
530 | + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS); | ||
531 | + g_assert_cmpuint(rsp_upiu.header.scsi_status, ==, | ||
532 | + UFS_COMMAND_RESULT_SUCESS); | ||
533 | + block_size = ldl_be_p(&read_buf[8]); | ||
534 | + g_assert_cmpuint(block_size, ==, 4096); | ||
535 | + | ||
536 | + /* Write data */ | ||
537 | + memset(write_buf, rand() % 255 + 1, block_size); | ||
538 | + ufs_send_scsi_command(ufs, 0, 1, write_cdb, write_buf, block_size, NULL, 0, | ||
539 | + &utrd, &rsp_upiu); | ||
540 | + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS); | ||
541 | + g_assert_cmpuint(rsp_upiu.header.scsi_status, ==, | ||
542 | + UFS_COMMAND_RESULT_SUCESS); | ||
543 | + | ||
544 | + /* Read data and verify */ | ||
545 | + ufs_send_scsi_command(ufs, 0, 1, read_cdb, NULL, 0, read_buf, block_size, | ||
546 | + &utrd, &rsp_upiu); | ||
547 | + g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS); | ||
548 | + g_assert_cmpuint(rsp_upiu.header.scsi_status, ==, | ||
549 | + UFS_COMMAND_RESULT_SUCESS); | ||
550 | + g_assert_cmpint(memcmp(read_buf, write_buf, block_size), ==, 0); | ||
551 | + | ||
552 | + ufs_exit(ufs, alloc); | ||
553 | +} | ||
554 | + | ||
555 | +static void drive_destroy(void *path) | ||
556 | +{ | ||
557 | + unlink(path); | ||
558 | + g_free(path); | ||
559 | + qos_invalidate_command_line(); | ||
560 | +} | ||
561 | + | ||
562 | +static char *drive_create(void) | ||
563 | +{ | ||
564 | + int fd, ret; | ||
565 | + char *t_path; | ||
566 | + | ||
567 | + /* Create a temporary raw image */ | ||
568 | + fd = g_file_open_tmp("qtest-ufs.XXXXXX", &t_path, NULL); | ||
569 | + g_assert_cmpint(fd, >=, 0); | ||
570 | + ret = ftruncate(fd, TEST_IMAGE_SIZE); | ||
571 | + g_assert_cmpint(ret, ==, 0); | ||
572 | + close(fd); | ||
573 | + | ||
574 | + g_test_queue_destroy(drive_destroy, t_path); | ||
575 | + return t_path; | ||
576 | +} | ||
577 | + | ||
578 | +static void *ufs_blk_test_setup(GString *cmd_line, void *arg) | ||
579 | +{ | ||
580 | + char *tmp_path = drive_create(); | ||
581 | + | ||
582 | + g_string_append_printf(cmd_line, | ||
583 | + " -blockdev file,filename=%s,node-name=drv1 " | ||
584 | + "-device ufs-lu,bus=ufs0,drive=drv1,lun=1 ", | ||
585 | + tmp_path); | ||
586 | + | ||
587 | + return arg; | ||
588 | +} | ||
589 | + | ||
590 | +static void ufs_register_nodes(void) | ||
591 | +{ | ||
592 | + const char *arch; | ||
593 | + QOSGraphEdgeOptions edge_opts = { | ||
594 | + .before_cmd_line = "-blockdev null-co,node-name=drv0,read-zeroes=on", | ||
595 | + .after_cmd_line = "-device ufs-lu,bus=ufs0,drive=drv0,lun=0", | ||
596 | + .extra_device_opts = "addr=04.0,id=ufs0,nutrs=32,nutmrs=8" | ||
597 | + }; | ||
598 | + | ||
599 | + QOSGraphTestOptions io_test_opts = { | ||
600 | + .before = ufs_blk_test_setup, | ||
601 | + }; | ||
602 | + | ||
603 | + add_qpci_address(&edge_opts, &(QPCIAddress){ .devfn = QPCI_DEVFN(4, 0) }); | ||
604 | + | ||
605 | + qos_node_create_driver("ufs", ufs_create); | ||
606 | + qos_node_consumes("ufs", "pci-bus", &edge_opts); | ||
607 | + qos_node_produces("ufs", "pci-device"); | ||
608 | + | ||
609 | + qos_add_test("reg-read", "ufs", ufstest_reg_read, NULL); | ||
610 | + | ||
611 | + /* | ||
612 | + * Check architecture | ||
613 | + * TODO: Enable ufs io tests for ppc64 | ||
614 | + */ | ||
615 | + arch = qtest_get_arch(); | ||
616 | + if (!strcmp(arch, "ppc64")) { | ||
617 | + g_test_message("Skipping ufs io tests for ppc64"); | ||
618 | + return; | ||
619 | + } | ||
620 | + qos_add_test("init", "ufs", ufstest_init, NULL); | ||
621 | + qos_add_test("read-write", "ufs", ufstest_read_write, &io_test_opts); | ||
622 | +} | ||
623 | + | ||
624 | +libqos_init(ufs_register_nodes); | ||
625 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
626 | index XXXXXXX..XXXXXXX 100644 | ||
627 | --- a/tests/qtest/meson.build | ||
628 | +++ b/tests/qtest/meson.build | ||
629 | @@ -XXX,XX +XXX,XX @@ qos_test_ss.add( | ||
630 | 'virtio-iommu-test.c', | ||
631 | 'vmxnet3-test.c', | ||
632 | 'igb-test.c', | ||
633 | + 'ufs-test.c', | ||
634 | ) | ||
635 | |||
636 | if config_all_devices.has_key('CONFIG_VIRTIO_SERIAL') | ||
149 | -- | 637 | -- |
150 | 2.24.1 | 638 | 2.41.0 |
151 | |||
152 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | ||
2 | 1 | ||
3 | Add the case to the iotest #214 that checks possibility of writing | ||
4 | compressed data of more than one cluster size. The test case involves | ||
5 | the compress filter driver showing a sample usage of that. | ||
6 | |||
7 | Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | ||
8 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
9 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
10 | Message-id: 1575288906-551879-4-git-send-email-andrey.shinkevich@virtuozzo.com | ||
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
12 | --- | ||
13 | tests/qemu-iotests/214 | 43 ++++++++++++++++++++++++++++++++++++++ | ||
14 | tests/qemu-iotests/214.out | 14 +++++++++++++ | ||
15 | 2 files changed, 57 insertions(+) | ||
16 | |||
17 | diff --git a/tests/qemu-iotests/214 b/tests/qemu-iotests/214 | ||
18 | index XXXXXXX..XXXXXXX 100755 | ||
19 | --- a/tests/qemu-iotests/214 | ||
20 | +++ b/tests/qemu-iotests/214 | ||
21 | @@ -XXX,XX +XXX,XX @@ _check_test_img -r all | ||
22 | $QEMU_IO -c "read -P 0x11 0 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir | ||
23 | $QEMU_IO -c "read -P 0x22 4M 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir | ||
24 | |||
25 | +echo | ||
26 | +echo "=== Write compressed data of multiple clusters ===" | ||
27 | +echo | ||
28 | +cluster_size=0x10000 | ||
29 | +_make_test_img 2M -o cluster_size=$cluster_size | ||
30 | + | ||
31 | +echo "Write uncompressed data:" | ||
32 | +let data_size="8 * $cluster_size" | ||
33 | +$QEMU_IO -c "write -P 0xaa 0 $data_size" "$TEST_IMG" \ | ||
34 | + 2>&1 | _filter_qemu_io | _filter_testdir | ||
35 | +sizeA=$($QEMU_IMG info --output=json "$TEST_IMG" | | ||
36 | + sed -n '/"actual-size":/ s/[^0-9]//gp') | ||
37 | + | ||
38 | +_make_test_img 2M -o cluster_size=$cluster_size | ||
39 | +echo "Write compressed data:" | ||
40 | +let data_size="3 * $cluster_size + $cluster_size / 2" | ||
41 | +# Set compress on. That will align the written data | ||
42 | +# by the cluster size and will write them compressed. | ||
43 | +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT \ | ||
44 | +$QEMU_IO -c "write -P 0xbb 0 $data_size" --image-opts \ | ||
45 | + "driver=compress,file.driver=$IMGFMT,file.file.driver=file,file.file.filename=$TEST_IMG" \ | ||
46 | + 2>&1 | _filter_qemu_io | _filter_testdir | ||
47 | + | ||
48 | +let offset="4 * $cluster_size + $cluster_size / 4" | ||
49 | +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT \ | ||
50 | +$QEMU_IO -c "write -P 0xcc $offset $data_size" "json:{\ | ||
51 | + 'driver': 'compress', | ||
52 | + 'file': {'driver': '$IMGFMT', | ||
53 | + 'file': {'driver': 'file', | ||
54 | + 'filename': '$TEST_IMG'}}}" | \ | ||
55 | + _filter_qemu_io | _filter_testdir | ||
56 | + | ||
57 | +sizeB=$($QEMU_IMG info --output=json "$TEST_IMG" | | ||
58 | + sed -n '/"actual-size":/ s/[^0-9]//gp') | ||
59 | + | ||
60 | +if [ $sizeA -le $sizeB ] | ||
61 | +then | ||
62 | + echo "Compression ERROR" | ||
63 | +fi | ||
64 | + | ||
65 | +$QEMU_IMG check --output=json "$TEST_IMG" | | ||
66 | + sed -n 's/,$//; /"compressed-clusters":/ s/^ *//p' | ||
67 | + | ||
68 | # success, all done | ||
69 | echo '*** done' | ||
70 | rm -f $seq.full | ||
71 | diff --git a/tests/qemu-iotests/214.out b/tests/qemu-iotests/214.out | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/tests/qemu-iotests/214.out | ||
74 | +++ b/tests/qemu-iotests/214.out | ||
75 | @@ -XXX,XX +XXX,XX @@ read 4194304/4194304 bytes at offset 0 | ||
76 | 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
77 | read 4194304/4194304 bytes at offset 4194304 | ||
78 | 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
79 | + | ||
80 | +=== Write compressed data of multiple clusters === | ||
81 | + | ||
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 | -- | ||
95 | 2.24.1 | ||
96 | |||
97 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Commit 6f6e1698a6 desugarized "-machine accel=" to a list | ||
4 | of "-accel" options. Since now "-machine accel" and "-accel" | ||
5 | became incompatible, update the iotests to the new format. | ||
6 | |||
7 | Error reported here: | ||
8 | https://gitlab.com/qemu-project/qemu/-/jobs/385801004#L3400 | ||
9 | |||
10 | Reported-by: GitLab CI | ||
11 | Fixes: 6f6e1698a6 (vl: configure accelerators from -accel options) | ||
12 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
13 | Message-id: 20200106130951.29873-1-philmd@redhat.com | ||
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
15 | --- | ||
16 | tests/qemu-iotests/235 | 2 +- | ||
17 | tests/qemu-iotests/check | 6 +++--- | ||
18 | 2 files changed, 4 insertions(+), 4 deletions(-) | ||
19 | |||
20 | diff --git a/tests/qemu-iotests/235 b/tests/qemu-iotests/235 | ||
21 | index XXXXXXX..XXXXXXX 100755 | ||
22 | --- a/tests/qemu-iotests/235 | ||
23 | +++ b/tests/qemu-iotests/235 | ||
24 | @@ -XXX,XX +XXX,XX @@ qemu_img_create('-f', iotests.imgfmt, '-o', 'preallocation=metadata', disk, | ||
25 | str(size)) | ||
26 | |||
27 | vm = QEMUMachine(iotests.qemu_prog) | ||
28 | -vm.add_args('-machine', 'accel=kvm:tcg') | ||
29 | +vm.add_args('-accel', 'kvm', '-accel', 'tcg') | ||
30 | if iotests.qemu_default_machine == 's390-ccw-virtio': | ||
31 | vm.add_args('-no-shutdown') | ||
32 | vm.add_args('-drive', 'id=src,file=' + disk) | ||
33 | diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check | ||
34 | index XXXXXXX..XXXXXXX 100755 | ||
35 | --- a/tests/qemu-iotests/check | ||
36 | +++ b/tests/qemu-iotests/check | ||
37 | @@ -XXX,XX +XXX,XX @@ export QEMU_PROG="$(type -p "$QEMU_PROG")" | ||
38 | |||
39 | case "$QEMU_PROG" in | ||
40 | *qemu-system-arm|*qemu-system-aarch64) | ||
41 | - export QEMU_OPTIONS="-nodefaults -display none -machine virt,accel=qtest" | ||
42 | + export QEMU_OPTIONS="-nodefaults -display none -machine virt -accel qtest" | ||
43 | ;; | ||
44 | *qemu-system-tricore) | ||
45 | - export QEMU_OPTIONS="-nodefaults -display none -machine tricore_testboard,accel=qtest" | ||
46 | + export QEMU_OPTIONS="-nodefaults -display none -machine tricore_testboard -accel qtest" | ||
47 | ;; | ||
48 | *) | ||
49 | - export QEMU_OPTIONS="-nodefaults -display none -machine accel=qtest" | ||
50 | + export QEMU_OPTIONS="-nodefaults -display none -accel qtest" | ||
51 | ;; | ||
52 | esac | ||
53 | |||
54 | -- | ||
55 | 2.24.1 | ||
56 | |||
57 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | When dropping backup-top, we need to drain the node before freeing the | ||
2 | BlockCopyState. Otherwise, requests may still be in flight and then the | ||
3 | assertion in shres_destroy() will fail. | ||
4 | 1 | ||
5 | (This becomes visible in intermittent failure of 056.) | ||
6 | |||
7 | Cc: qemu-stable@nongnu.org | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | Message-id: 20191219182638.104621-1-mreitz@redhat.com | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
11 | --- | ||
12 | block/backup-top.c | 4 ++-- | ||
13 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/block/backup-top.c b/block/backup-top.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/block/backup-top.c | ||
18 | +++ b/block/backup-top.c | ||
19 | @@ -XXX,XX +XXX,XX @@ void bdrv_backup_top_drop(BlockDriverState *bs) | ||
20 | BDRVBackupTopState *s = bs->opaque; | ||
21 | AioContext *aio_context = bdrv_get_aio_context(bs); | ||
22 | |||
23 | - block_copy_state_free(s->bcs); | ||
24 | - | ||
25 | aio_context_acquire(aio_context); | ||
26 | |||
27 | bdrv_drained_begin(bs); | ||
28 | |||
29 | + block_copy_state_free(s->bcs); | ||
30 | + | ||
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 | -- | ||
35 | 2.24.1 | ||
36 | |||
37 | diff view generated by jsdifflib |