]> 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 7.1.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>
059a9447
FG
15---
16 block/mirror.c | 28 +++------------
17 blockdev.c | 29 +++++++++++++++
83faa3fe 18 tests/qemu-iotests/384.out | 72 +++++++++++++++++++-------------------
059a9447
FG
19 3 files changed, 70 insertions(+), 59 deletions(-)
20
21diff --git a/block/mirror.c b/block/mirror.c
5b15e2ec 22index 8b3342f9ec..1d4ff0efad 100644
059a9447
FG
23--- a/block/mirror.c
24+++ b/block/mirror.c
dc9827a6 25@@ -1634,31 +1634,13 @@ static BlockJob *mirror_start_job(
8dca018b 26 uint64_t target_perms, target_shared_perms;
059a9447
FG
27 int ret;
28
29- if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
30- error_setg(errp, "Sync mode '%s' not supported",
31- MirrorSyncMode_str(sync_mode));
32- return NULL;
33- } else if (sync_mode == MIRROR_SYNC_MODE_BITMAP) {
34- if (!bitmap) {
35- error_setg(errp, "Must provide a valid bitmap name for '%s'"
36- " sync mode",
37- MirrorSyncMode_str(sync_mode));
38- return NULL;
39- }
40- } else if (bitmap) {
41- error_setg(errp,
42- "sync mode '%s' is not compatible with bitmaps",
43- MirrorSyncMode_str(sync_mode));
44- return NULL;
45- }
46+ /* QMP interface protects us from these cases */
47+ assert(sync_mode != MIRROR_SYNC_MODE_INCREMENTAL);
48+ assert((bitmap && sync_mode == MIRROR_SYNC_MODE_BITMAP) ||
49+ (!bitmap && sync_mode != MIRROR_SYNC_MODE_BITMAP));
50+ assert(!(bitmap && granularity));
51
52 if (bitmap) {
53- if (granularity) {
54- error_setg(errp, "granularity (%d)"
55- "cannot be specified when a bitmap is provided",
56- granularity);
57- return NULL;
58- }
59 granularity = bdrv_dirty_bitmap_granularity(bitmap);
60
61 if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
62diff --git a/blockdev.c b/blockdev.c
5b15e2ec 63index a57b0af2e7..ce62a9b439 100644
059a9447
FG
64--- a/blockdev.c
65+++ b/blockdev.c
dc9827a6 66@@ -3029,7 +3029,36 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
059a9447
FG
67 sync = MIRROR_SYNC_MODE_FULL;
68 }
69
70+ if ((sync == MIRROR_SYNC_MODE_BITMAP) ||
71+ (sync == MIRROR_SYNC_MODE_INCREMENTAL)) {
72+ /* done before desugaring 'incremental' to print the right message */
73+ if (!has_bitmap) {
74+ error_setg(errp, "Must provide a valid bitmap name for "
75+ "'%s' sync mode", MirrorSyncMode_str(sync));
76+ return;
77+ }
78+ }
79+
80+ if (sync == MIRROR_SYNC_MODE_INCREMENTAL) {
81+ if (has_bitmap_mode &&
82+ bitmap_mode != BITMAP_SYNC_MODE_ON_SUCCESS) {
83+ error_setg(errp, "Bitmap sync mode must be '%s' "
84+ "when using sync mode '%s'",
85+ BitmapSyncMode_str(BITMAP_SYNC_MODE_ON_SUCCESS),
86+ MirrorSyncMode_str(sync));
87+ return;
88+ }
89+ has_bitmap_mode = true;
90+ sync = MIRROR_SYNC_MODE_BITMAP;
91+ bitmap_mode = BITMAP_SYNC_MODE_ON_SUCCESS;
92+ }
93+
94 if (has_bitmap) {
95+ if (sync != MIRROR_SYNC_MODE_BITMAP) {
96+ error_setg(errp, "Sync mode '%s' not supported with bitmap.",
97+ MirrorSyncMode_str(sync));
98+ return;
99+ }
100 if (granularity) {
101 error_setg(errp, "Granularity and bitmap cannot both be set");
102 return;
83faa3fe 103diff --git a/tests/qemu-iotests/384.out b/tests/qemu-iotests/384.out
059a9447 104index 9b7408b6d6..06a2e29058 100644
83faa3fe
TL
105--- a/tests/qemu-iotests/384.out
106+++ b/tests/qemu-iotests/384.out
059a9447
FG
107@@ -2681,45 +2681,45 @@ qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" ==> Identical, OK!
108 -- Sync mode incremental tests --
109
110 {"execute": "blockdev-mirror", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
111-{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
112+{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'incremental' sync mode"}}
113
114 {"execute": "blockdev-mirror", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
115-{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
116+{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'incremental' sync mode"}}
117
118 {"execute": "blockdev-mirror", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
119-{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
120+{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'incremental' sync mode"}}
121
122 {"execute": "blockdev-mirror", "arguments": {"device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
123-{"error": {"class": "GenericError", "desc": "Sync mode 'incremental' not supported"}}
124+{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'incremental' sync mode"}}
125
126 {"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"}}
127 {"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
128
129 {"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"}}
130-{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
131+{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be 'on-success' when using sync mode 'incremental'"}}
132
133 {"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"}}
134-{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
135+{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be 'on-success' when using sync mode 'incremental'"}}
136
137 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "incremental", "target": "mirror_target"}}
138-{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
139+{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
140
141 {"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"}}
142-{"error": {"class": "GenericError", "desc": "Sync mode 'incremental' not supported"}}
143+{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be 'on-success' when using sync mode 'incremental'"}}
144
145 {"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"}}
146-{"error": {"class": "GenericError", "desc": "Sync mode 'incremental' not supported"}}
147+{"error": {"class": "GenericError", "desc": "Bitmap sync mode must be 'on-success' when using sync mode 'incremental'"}}
148
149 -- Sync mode bitmap tests --
150
151 {"execute": "blockdev-mirror", "arguments": {"bitmap-mode": "on-success", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "bitmap", "target": "mirror_target"}}
152-{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
153+{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'bitmap' sync mode"}}
154
155 {"execute": "blockdev-mirror", "arguments": {"bitmap-mode": "always", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "bitmap", "target": "mirror_target"}}
156-{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
157+{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'bitmap' sync mode"}}
158
159 {"execute": "blockdev-mirror", "arguments": {"bitmap-mode": "never", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "bitmap", "target": "mirror_target"}}
160-{"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
161+{"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'bitmap' sync mode"}}
162
163 {"execute": "blockdev-mirror", "arguments": {"device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "bitmap", "target": "mirror_target"}}
164 {"error": {"class": "GenericError", "desc": "Must provide a valid bitmap name for 'bitmap' sync mode"}}
165@@ -2751,28 +2751,28 @@ qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" ==> Identical, OK!
166 {"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
167
168 {"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"}}
169-{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
170+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
171
172 {"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"}}
173-{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
174+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
175
176 {"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"}}
177-{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
178+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
179
180 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "full", "target": "mirror_target"}}
181-{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
182+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
183
184 {"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"}}
185-{"error": {"class": "GenericError", "desc": "sync mode 'full' is not compatible with bitmaps"}}
186+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
187
188 {"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"}}
189-{"error": {"class": "GenericError", "desc": "sync mode 'full' is not compatible with bitmaps"}}
190+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
191
192 {"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"}}
193-{"error": {"class": "GenericError", "desc": "sync mode 'full' is not compatible with bitmaps"}}
194+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
195
196 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "full", "target": "mirror_target"}}
197-{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
198+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
199
200 -- Sync mode top tests --
201
202@@ -2786,28 +2786,28 @@ qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" ==> Identical, OK!
203 {"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
204
205 {"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"}}
206-{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
207+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
208
209 {"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"}}
210-{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
211+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
212
213 {"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"}}
214-{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
215+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
216
217 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "top", "target": "mirror_target"}}
218-{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
219+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
220
221 {"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"}}
222-{"error": {"class": "GenericError", "desc": "sync mode 'full' is not compatible with bitmaps"}}
223+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
224
225 {"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"}}
226-{"error": {"class": "GenericError", "desc": "sync mode 'full' is not compatible with bitmaps"}}
227+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
228
229 {"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"}}
230-{"error": {"class": "GenericError", "desc": "sync mode 'full' is not compatible with bitmaps"}}
231+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
232
233 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "top", "target": "mirror_target"}}
234-{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
235+{"error": {"class": "GenericError", "desc": "Sync mode 'full' not supported with bitmap."}}
236
237 -- Sync mode none tests --
238
239@@ -2821,26 +2821,26 @@ qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" ==> Identical, OK!
240 {"error": {"class": "GenericError", "desc": "Cannot specify bitmap sync mode without a bitmap"}}
241
242 {"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"}}
243-{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
244+{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
245
246 {"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"}}
247-{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
248+{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
249
250 {"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"}}
251-{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not found"}}
252+{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
253
254 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "none", "target": "mirror_target"}}
255-{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
256+{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
257
258 {"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"}}
259-{"error": {"class": "GenericError", "desc": "sync mode 'none' is not compatible with bitmaps"}}
260+{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
261
262 {"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"}}
263-{"error": {"class": "GenericError", "desc": "sync mode 'none' is not compatible with bitmaps"}}
264+{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
265
266 {"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"}}
267-{"error": {"class": "GenericError", "desc": "sync mode 'none' is not compatible with bitmaps"}}
268+{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
269
270 {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "device": "drive0", "filter-node-name": "mirror-top", "job-id": "api_job", "sync": "none", "target": "mirror_target"}}
271-{"error": {"class": "GenericError", "desc": "bitmap-mode must be specified if a bitmap is provided"}}
272+{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supported with bitmap."}}
273