[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 05/10] mirror: implement mirror_change method
From: |
Fiona Ebner |
Subject: |
[PATCH v2 05/10] mirror: implement mirror_change method |
Date: |
Mon, 9 Oct 2023 11:46:14 +0200 |
which allows switching the @copy-mode from 'background' to
'write-blocking'.
This is useful for management applications, so they can start out in
background mode to avoid limiting guest write speed and switch to
active mode when certain criteria are fulfilled.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
Changes in v2:
* update QEMU version in QAPI
* update indentation in QAPI (like in a937b6aa73 ("qapi: Reformat
doc comments to conform to current conventions"))
* drop drained section and disable dirty bitmap call. It's already
disabled, because the bitmap is now attached to the filter and
set in bdrv_mirror_top_do_write(). See the earlier patch
"block/mirror: move dirty bitmap to filter"
block/mirror.c | 22 ++++++++++++++++++++++
qapi/block-core.json | 13 ++++++++++++-
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/block/mirror.c b/block/mirror.c
index b84de56734..83aa4176c2 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1246,6 +1246,27 @@ static bool commit_active_cancel(Job *job, bool force)
return force || !job_is_ready(job);
}
+static void mirror_change(BlockJob *job, BlockJobChangeOptions *opts,
+ Error **errp)
+{
+ MirrorBlockJob *s = container_of(job, MirrorBlockJob, common);
+ BlockJobChangeOptionsMirror *change_opts = &opts->u.mirror;
+
+ if (s->copy_mode == change_opts->copy_mode) {
+ return;
+ }
+
+ if (s->copy_mode == MIRROR_COPY_MODE_WRITE_BLOCKING) {
+ error_setg(errp, "Cannot switch away from copy mode 'write-blocking'");
+ return;
+ }
+
+ assert(s->copy_mode == MIRROR_COPY_MODE_BACKGROUND &&
+ change_opts->copy_mode == MIRROR_COPY_MODE_WRITE_BLOCKING);
+
+ s->copy_mode = MIRROR_COPY_MODE_WRITE_BLOCKING;
+}
+
static const BlockJobDriver mirror_job_driver = {
.job_driver = {
.instance_size = sizeof(MirrorBlockJob),
@@ -1260,6 +1281,7 @@ static const BlockJobDriver mirror_job_driver = {
.cancel = mirror_cancel,
},
.drained_poll = mirror_drained_poll,
+ .change = mirror_change,
};
static const BlockJobDriver commit_active_job_driver = {
diff --git a/qapi/block-core.json b/qapi/block-core.json
index c6f31a9399..01427c259a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3044,6 +3044,17 @@
{ 'command': 'block-job-finalize', 'data': { 'id': 'str' },
'allow-preconfig': true }
+##
+# @BlockJobChangeOptionsMirror:
+#
+# @copy-mode: Switch to this copy mode. Currenlty, only the switch
+# from 'background' to 'write-blocking' is implemented.
+#
+# Since: 8.2
+##
+{ 'struct': 'BlockJobChangeOptionsMirror',
+ 'data': { 'copy-mode' : 'MirrorCopyMode' } }
+
##
# @BlockJobChangeOptions:
#
@@ -3058,7 +3069,7 @@
{ 'union': 'BlockJobChangeOptions',
'base': { 'id': 'str', 'type': 'JobType' },
'discriminator': 'type',
- 'data': {} }
+ 'data': { 'mirror': 'BlockJobChangeOptionsMirror' } }
##
# @block-job-change:
--
2.39.2
- Re: [PATCH v2 01/10] blockjob: introduce block-job-change QMP command, (continued)
- [PATCH v2 03/10] block/mirror: move dirty bitmap to filter, Fiona Ebner, 2023/10/09
- [PATCH v2 04/10] block/mirror: determine copy_to_target only once, Fiona Ebner, 2023/10/09
- [PATCH v2 09/10] mirror: return mirror-specific information upon query, Fiona Ebner, 2023/10/09
- [PATCH v2 08/10] blockjob: query driver-specific info via a new 'query' driver method, Fiona Ebner, 2023/10/09
- [PATCH v2 07/10] qapi/block-core: turn BlockJobInfo into a union, Fiona Ebner, 2023/10/09
- [PATCH v2 05/10] mirror: implement mirror_change method,
Fiona Ebner <=
- [PATCH v2 10/10] iotests: adapt test output for new mirror query property, Fiona Ebner, 2023/10/09
- [PATCH v2 06/10] qapi/block-core: use JobType for BlockJobInfo's type, Fiona Ebner, 2023/10/09
- Re: [PATCH v2 00/10] mirror: allow switching from background to active mode, Vladimir Sementsov-Ogievskiy, 2023/10/10