Now QEMU can understand type directly from the job itself, type is redundant.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@yandex-team.ru> --- blockjob.c | 2 +- docs/about/deprecated.rst | 6 ++++++ job-qmp.c | 17 +++++++++++++++++ qapi/block-core.json | 10 ++++++++-- stubs/meson.build | 1 + stubs/qapi-jobchangeoptions-mapper.c | 8 ++++++++ 6 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 stubs/qapi-jobchangeoptions-mapper.c diff --git a/blockjob.c b/blockjob.c index 788cb1e07d..33c40e7d25 100644 --- a/blockjob.c +++ b/blockjob.c @@ -319,7 +319,7 @@ void block_job_change_locked(BlockJob *job, JobChangeOptions *opts, GLOBAL_STATE_CODE(); - if (job_type(&job->job) != opts->type) { + if (opts->has_type && job_type(&job->job) != opts->type) { error_setg(errp, "Job '%s' is '%s' job, not '%s'", job->job.id, job_type_str(&job->job), JobType_str(opts->type)); return; diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index dfd681cd02..64981e5e4a 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -142,6 +142,12 @@ accepted incorrect commands will return an error. Users should make sure that all arguments passed to ``device_add`` are consistent with the documented property types. + +``block-job-change`` argument ``type`` (since 9.1) +'''''''''''''''''''''''''''''''''''''''''''''''''' + +QEMU can get job type from the job itself (by @id), @type field is redundant. + QEMU Machine Protocol (QMP) events ---------------------------------- diff --git a/job-qmp.c b/job-qmp.c index 9e26fa899f..c486df9579 100644 --- a/job-qmp.c +++ b/job-qmp.c @@ -26,6 +26,8 @@ #include "qemu/osdep.h" #include "qemu/job.h" #include "qapi/qapi-commands-job.h" +#include "qapi/qapi-types-block-core.h" +#include "qapi/qapi-visit-block-core.h" #include "qapi/error.h" #include "trace/trace-root.h" @@ -186,3 +188,18 @@ JobInfoList *qmp_query_jobs(Error **errp) return head; } + +bool JobChangeOptions_mapper(JobChangeOptions *opts, JobType *out, Error **errp) +{ + Job *job; + + JOB_LOCK_GUARD(); + + job = find_job_locked(opts->id, errp); + if (!job) { + return false; + } + + *out = job_type(job); + return true; +} diff --git a/qapi/block-core.json b/qapi/block-core.json index 6041e7bd8f..3d890dfcd0 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3082,11 +3082,17 @@ # # @type: The job type # +# Features: +# +# @deprecated: Members @type is deprecated. Qemu can get type from +# the job itself, @type is redundant. +# # Since: 8.2 ## { 'union': 'JobChangeOptions', - 'base': { 'id': 'str', 'type': 'JobType' }, - 'discriminator': 'type', + 'base': { 'id': 'str', + '*type': { 'type': 'JobType', 'features': ['deprecated'] } }, + 'discriminator': 'JobType', 'data': { 'mirror': 'JobChangeOptionsMirror' } } ## diff --git a/stubs/meson.build b/stubs/meson.build index 0bf25e6ca5..e480400a6c 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -31,6 +31,7 @@ stub_ss.add(files('module-opts.c')) stub_ss.add(files('monitor.c')) stub_ss.add(files('monitor-core.c')) stub_ss.add(files('physmem.c')) +stub_ss.add(files('qapi-jobchangeoptions-mapper.c')) stub_ss.add(files('qemu-timer-notify-cb.c')) stub_ss.add(files('memory_device.c')) stub_ss.add(files('qmp-command-available.c')) diff --git a/stubs/qapi-jobchangeoptions-mapper.c b/stubs/qapi-jobchangeoptions-mapper.c new file mode 100644 index 0000000000..e4acfd91b3 --- /dev/null +++ b/stubs/qapi-jobchangeoptions-mapper.c @@ -0,0 +1,8 @@ +#include "qemu/osdep.h" +#include "qapi/qapi-visit-block-core.h" +#include "qapi/qapi-types-job.h" + +bool JobChangeOptions_mapper(JobChangeOptions *opts, JobType *out, Error **errp) +{ + g_assert_not_reached(); +} -- 2.34.1