]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0035-mirror-move-some-checks-to-qmp.patch
clean up pve/ patches by squashing patches of patches
[pve-qemu.git] / debian / patches / pve / 0035-mirror-move-some-checks-to-qmp.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= <f.gruenbichler@proxmox.com>
3 Date: Mon, 6 Apr 2020 12:17:08 +0200
4 Subject: [PATCH] mirror: move some checks to qmp
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 and assert the passing conditions in block/mirror.c. while incremental
10 mode was never available for drive-mirror, it makes the interface more
11 uniform w.r.t. backup block jobs.
12
13 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
14 ---
15 block/mirror.c | 28 +++------------
16 blockdev.c | 29 +++++++++++++++
17 tests/qemu-iotests/384.out | 72 +++++++++++++++++++-------------------
18 3 files changed, 70 insertions(+), 59 deletions(-)
19
20 diff --git a/block/mirror.c b/block/mirror.c
21 index e6140cf018..3a08239a78 100644
22 --- a/block/mirror.c
23 +++ b/block/mirror.c
24 @@ -1592,31 +1592,13 @@ static BlockJob *mirror_start_job(
25 Error *local_err = NULL;
26 int ret;
27
28 - if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
29 - error_setg(errp, "Sync mode '%s' not supported",
30 - MirrorSyncMode_str(sync_mode));
31 - return NULL;
32 - } else if (sync_mode == MIRROR_SYNC_MODE_BITMAP) {
33 - if (!bitmap) {
34 - error_setg(errp, "Must provide a valid bitmap name for '%s'"
35 - " sync mode",
36 - MirrorSyncMode_str(sync_mode));
37 - return NULL;
38 - }
39 - } else if (bitmap) {
40 - error_setg(errp,
41 - "sync mode '%s' is not compatible with bitmaps",
42 - MirrorSyncMode_str(sync_mode));
43 - return NULL;
44 - }
45 + /* QMP interface protects us from these cases */
46 + assert(sync_mode != MIRROR_SYNC_MODE_INCREMENTAL);
47 + assert((bitmap && sync_mode == MIRROR_SYNC_MODE_BITMAP) ||
48 + (!bitmap && sync_mode != MIRROR_SYNC_MODE_BITMAP));
49 + assert(!(bitmap && granularity));
50
51 if (bitmap) {
52 - if (granularity) {
53 - error_setg(errp, "granularity (%d)"
54 - "cannot be specified when a bitmap is provided",
55 - granularity);
56 - return NULL;
57 - }
58 granularity = bdrv_dirty_bitmap_granularity(bitmap);
59
60 if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
61 diff --git a/blockdev.c b/blockdev.c
62 index 827f004069..e2f826ca62 100644
63 --- a/blockdev.c
64 +++ b/blockdev.c
65 @@ -3009,7 +3009,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
66 sync = MIRROR_SYNC_MODE_FULL;
67 }
68
69 + if ((sync == MIRROR_SYNC_MODE_BITMAP) ||
70 + (sync == MIRROR_SYNC_MODE_INCREMENTAL)) {
71 + /* done before desugaring 'incremental' to print the right message */
72 + if (!has_bitmap) {
73 + error_setg(errp, "Must provide a valid bitmap name for "
74 + "'%s' sync mode", MirrorSyncMode_str(sync));
75 + return;
76 + }
77 + }
78 +
79 + if (sync == MIRROR_SYNC_MODE_INCREMENTAL) {
80 + if (has_bitmap_mode &&
81 + bitmap_mode != BITMAP_SYNC_MODE_ON_SUCCESS) {
82 + error_setg(errp, "Bitmap sync mode must be '%s' "
83 + "when using sync mode '%s'",
84 + BitmapSyncMode_str(BITMAP_SYNC_MODE_ON_SUCCESS),
85 + MirrorSyncMode_str(sync));
86 + return;
87 + }
88 + has_bitmap_mode = true;
89 + sync = MIRROR_SYNC_MODE_BITMAP;
90 + bitmap_mode = BITMAP_SYNC_MODE_ON_SUCCESS;
91 + }
92 +
93 if (has_bitmap) {
94 + if (sync != MIRROR_SYNC_MODE_BITMAP) {
95 + error_setg(errp, "Sync mode '%s' not supported with bitmap.",
96 + MirrorSyncMode_str(sync));
97 + return;
98 + }
99 if (granularity) {
100 error_setg(errp, "Granularity and bitmap cannot both be set");
101 return;
102 diff --git a/tests/qemu-iotests/384.out b/tests/qemu-iotests/384.out
103 index 9b7408b6d6..06a2e29058 100644
104 --- a/tests/qemu-iotests/384.out
105 +++ b/tests/qemu-iotests/384.out
106 @@ -2681,45 +2681,45 @@ qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" ==> Identical, OK!
107 -- Sync mode incremental tests --
108
109 {"execute": "blockdev-mirror", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
110 -{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
111 +{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'incremental' sync mode"}}
112
113 {"execute": "blockdev-mirror", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
114 -{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
115 +{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'incremental' sync mode"}}
116
117 {"execute": "blockdev-mirror", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
118 -{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
119 +{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'incremental' sync mode"}}
120
121 {"execute": "blockdev-mirror", "arguments": {"device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
122 -{"error": {"class": "GenericError", "desc": "Sync mode 'incremental' not supported"}}
123 +{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'incremental' sync mode"}}
124
125 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
126 {"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
127
128 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
129 -{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
130 +{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be 'on-success' when using sync mode 'incremental'"}}
131
132 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
133 -{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
134 +{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be 'on-success' when using sync mode 'incremental'"}}
135
136 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
137 -{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
138 +{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
139
140 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
141 -{"error": {"class": "GenericError", "desc": "Sync mode 'incremental' not supported"}}
142 +{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be 'on-success' when using sync mode 'incremental'"}}
143
144 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
145 -{"error": {"class": "GenericError", "desc": "Sync mode 'incremental' not supported"}}
146 +{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be 'on-success' when using sync mode 'incremental'"}}
147
148 -- Sync mode bitmap tests --
149
150 {"execute": "blockdev-mirror", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "bitmap", "target": "mirror_target"}}
151 -{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
152 +{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'bitmap' sync mode"}}
153
154 {"execute": "blockdev-mirror", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "bitmap", "target": "mirror_target"}}
155 -{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
156 +{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'bitmap' sync mode"}}
157
158 {"execute": "blockdev-mirror", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "bitmap", "target": "mirror_target"}}
159 -{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
160 +{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'bitmap' sync mode"}}
161
162 {"execute": "blockdev-mirror", "arguments": {"device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "bitmap", "target": "mirror_target"}}
163 {"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'bitmap' sync mode"}}
164 @@ -2751,28 +2751,28 @@ qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" ==> Identical, OK!
165 {"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
166
167 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "full", "target": "mirror_target"}}
168 -{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
169 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
170
171 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "full", "target": "mirror_target"}}
172 -{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
173 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
174
175 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "full", "target": "mirror_target"}}
176 -{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
177 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
178
179 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "full", "target": "mirror_target"}}
180 -{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
181 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
182
183 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "full", "target": "mirror_target"}}
184 -{"error": {"class": "GenericError", "desc": "sync mode 'full' is not compatible with bitmaps"}}
185 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
186
187 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "full", "target": "mirror_target"}}
188 -{"error": {"class": "GenericError", "desc": "sync mode 'full' is not compatible with bitmaps"}}
189 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
190
191 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "full", "target": "mirror_target"}}
192 -{"error": {"class": "GenericError", "desc": "sync mode 'full' is not compatible with bitmaps"}}
193 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
194
195 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "full", "target": "mirror_target"}}
196 -{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
197 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
198
199 -- Sync mode top tests --
200
201 @@ -2786,28 +2786,28 @@ qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" ==> Identical, OK!
202 {"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
203
204 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "top", "target": "mirror_target"}}
205 -{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
206 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
207
208 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "top", "target": "mirror_target"}}
209 -{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
210 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
211
212 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "top", "target": "mirror_target"}}
213 -{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
214 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
215
216 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "top", "target": "mirror_target"}}
217 -{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
218 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
219
220 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "top", "target": "mirror_target"}}
221 -{"error": {"class": "GenericError", "desc": "sync mode 'full' is not compatible with bitmaps"}}
222 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
223
224 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "top", "target": "mirror_target"}}
225 -{"error": {"class": "GenericError", "desc": "sync mode 'full' is not compatible with bitmaps"}}
226 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
227
228 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "top", "target": "mirror_target"}}
229 -{"error": {"class": "GenericError", "desc": "sync mode 'full' is not compatible with bitmaps"}}
230 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
231
232 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "top", "target": "mirror_target"}}
233 -{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
234 +{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
235
236 -- Sync mode none tests --
237
238 @@ -2821,26 +2821,26 @@ qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" ==> Identical, OK!
239 {"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
240
241 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "none", "target": "mirror_target"}}
242 -{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
243 +{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
244
245 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "none", "target": "mirror_target"}}
246 -{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
247 +{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
248
249 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "none", "target": "mirror_target"}}
250 -{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
251 +{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
252
253 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "none", "target": "mirror_target"}}
254 -{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
255 +{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
256
257 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "none", "target": "mirror_target"}}
258 -{"error": {"class": "GenericError", "desc": "sync mode 'none' is not compatible with bitmaps"}}
259 +{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
260
261 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "always", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "none", "target": "mirror_target"}}
262 -{"error": {"class": "GenericError", "desc": "sync mode 'none' is not compatible with bitmaps"}}
263 +{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
264
265 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "bitmap-mode": "never", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "none", "target": "mirror_target"}}
266 -{"error": {"class": "GenericError", "desc": "sync mode 'none' is not compatible with bitmaps"}}
267 +{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
268
269 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "none", "target": "mirror_target"}}
270 -{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
271 +{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
272