@@ -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;
@@ -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
----------------------------------
@@ -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;
+}
@@ -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' } }
##
@@ -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'))
new file mode 100644
@@ -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();
+}
Now QEMU can understand type directly from the job itself, type is redundant. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@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