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