Message ID | 20240626110124.374336-4-vsementsov@yandex-team.ru (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | introduce job-change qmp command | expand |
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes: > We are going to add more parameters to change. We want to make possible > to change only one or any subset of available options. So all the > options should be optional. > > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> > --- > block/mirror.c | 4 ++++ > qapi/block-core.json | 3 ++- > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/block/mirror.c b/block/mirror.c > index 2816bb1042..60e8d83e4f 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -1272,6 +1272,10 @@ static void mirror_change(BlockJob *job, JobChangeOptions *opts, > > GLOBAL_STATE_CODE(); > > + if (!change_opts->has_copy_mode) { > + return; > + } > + > if (qatomic_read(&s->copy_mode) == change_opts->copy_mode) { > return; > } > diff --git a/qapi/block-core.json b/qapi/block-core.json > index 4ec5632596..660c7f4a48 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -3071,11 +3071,12 @@ > # > # @copy-mode: Switch to this copy mode. Currently, only the switch > # from 'background' to 'write-blocking' is implemented. > +# If absent, copy mode remains the same. (optional since 9.1) > # > # Since: 8.2 > ## > { 'struct': 'JobChangeOptionsMirror', > - 'data': { 'copy-mode' : 'MirrorCopyMode' } } > + 'data': { '*copy-mode' : 'MirrorCopyMode' } } > > ## > # @JobChangeOptions: Acked-by: Markus Armbruster <armbru@redhat.com>
diff --git a/block/mirror.c b/block/mirror.c index 2816bb1042..60e8d83e4f 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1272,6 +1272,10 @@ static void mirror_change(BlockJob *job, JobChangeOptions *opts, GLOBAL_STATE_CODE(); + if (!change_opts->has_copy_mode) { + return; + } + if (qatomic_read(&s->copy_mode) == change_opts->copy_mode) { return; } diff --git a/qapi/block-core.json b/qapi/block-core.json index 4ec5632596..660c7f4a48 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3071,11 +3071,12 @@ # # @copy-mode: Switch to this copy mode. Currently, only the switch # from 'background' to 'write-blocking' is implemented. +# If absent, copy mode remains the same. (optional since 9.1) # # Since: 8.2 ## { 'struct': 'JobChangeOptionsMirror', - 'data': { 'copy-mode' : 'MirrorCopyMode' } } + 'data': { '*copy-mode' : 'MirrorCopyMode' } } ## # @JobChangeOptions:
We are going to add more parameters to change. We want to make possible to change only one or any subset of available options. So all the options should be optional. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> --- block/mirror.c | 4 ++++ qapi/block-core.json | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-)