@@ -1251,10 +1251,9 @@ static bool commit_active_cancel(Job *job, bool force)
return force || !job_is_ready(job);
}
-static void mirror_change(BlockJob *job, JobChangeOptions *opts,
- Error **errp)
+static void mirror_change(Job *job, JobChangeOptions *opts, Error **errp)
{
- MirrorBlockJob *s = container_of(job, MirrorBlockJob, common);
+ MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job);
JobChangeOptionsMirror *change_opts = &opts->u.mirror;
MirrorCopyMode current;
@@ -1310,9 +1309,9 @@ static const BlockJobDriver mirror_job_driver = {
.pause = mirror_pause,
.complete = mirror_complete,
.cancel = mirror_cancel,
+ .change = mirror_change,
},
.drained_poll = mirror_drained_poll,
- .change = mirror_change,
.query = mirror_query,
};
@@ -3256,7 +3256,7 @@ void qmp_block_job_change(JobChangeOptions *opts, Error **errp)
return;
}
- block_job_change_locked(job, opts, errp);
+ job_change_locked(&job->job, opts, errp);
}
void qmp_change_backing_file(const char *device,
@@ -312,32 +312,6 @@ static bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
return block_job_set_speed_locked(job, speed, errp);
}
-void block_job_change_locked(BlockJob *job, JobChangeOptions *opts,
- Error **errp)
-{
- const BlockJobDriver *drv = block_job_driver(job);
-
- GLOBAL_STATE_CODE();
-
- 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;
- }
-
- if (job_apply_verb_locked(&job->job, JOB_VERB_CHANGE, errp)) {
- return;
- }
-
- if (drv->change) {
- job_unlock();
- drv->change(job, opts, errp);
- job_lock();
- } else {
- error_setg(errp, "Job type does not support change");
- }
-}
-
void block_job_ratelimit_processed_bytes(BlockJob *job, uint64_t n)
{
IO_CODE();
@@ -173,17 +173,6 @@ bool block_job_has_bdrv(BlockJob *job, BlockDriverState *bs);
*/
bool block_job_set_speed_locked(BlockJob *job, int64_t speed, Error **errp);
-/**
- * block_job_change_locked:
- * @job: The job to change.
- * @opts: The new options.
- * @errp: Error object.
- *
- * Change the job according to opts.
- */
-void block_job_change_locked(BlockJob *job, JobChangeOptions *opts,
- Error **errp);
-
/**
* block_job_query_locked:
* @job: The job to get information about.
@@ -68,13 +68,6 @@ struct BlockJobDriver {
void (*set_speed)(BlockJob *job, int64_t speed);
- /*
- * Change the @job's options according to @opts.
- *
- * Note that this can already be called before the job coroutine is running.
- */
- void (*change)(BlockJob *job, JobChangeOptions *opts, Error **errp);
-
/*
* Query information specific to this kind of block job.
*/
@@ -27,6 +27,7 @@
#define JOB_H
#include "qapi/qapi-types-job.h"
+#include "qapi/qapi-types-block-core.h"
#include "qemu/queue.h"
#include "qemu/progress_meter.h"
#include "qemu/coroutine.h"
@@ -307,6 +308,12 @@ struct JobDriver {
*/
bool (*cancel)(Job *job, bool force);
+ /**
+ * Change the @job's options according to @opts.
+ *
+ * Note that this can already be called before the job coroutine is running.
+ */
+ void (*change)(Job *job, JobChangeOptions *opts, Error **errp);
/**
* Called when the job is freed.
@@ -705,6 +712,11 @@ void job_finalize_locked(Job *job, Error **errp);
*/
void job_dismiss_locked(Job **job, Error **errp);
+/**
+ * Change the job according to opts.
+ */
+void job_change_locked(Job *job, JobChangeOptions *opts, Error **errp);
+
/**
* Synchronously finishes the given @job. If @finish is given, it is called to
* trigger completion or cancellation of the job.
@@ -28,6 +28,7 @@
#include "qapi/qapi-commands-job.h"
#include "qapi/qapi-types-block-core.h"
#include "qapi/qapi-visit-block-core.h"
+#include "qapi/qapi-commands-block-core.h"
#include "qapi/error.h"
#include "trace/trace-root.h"
@@ -1262,3 +1262,26 @@ int job_finish_sync_locked(Job *job,
job_unref_locked(job);
return ret;
}
+
+void job_change_locked(Job *job, JobChangeOptions *opts, Error **errp)
+{
+ GLOBAL_STATE_CODE();
+
+ if (opts->has_type && job_type(job) != opts->type) {
+ error_setg(errp, "Job '%s' is '%s' job, not '%s'", job->id,
+ job_type_str(job), JobType_str(opts->type));
+ return;
+ }
+
+ if (job_apply_verb_locked(job, JOB_VERB_CHANGE, errp)) {
+ return;
+ }
+
+ if (job->driver->change) {
+ job_unlock();
+ job->driver->change(job, opts, errp);
+ job_lock();
+ } else {
+ error_setg(errp, "Job type does not support change");
+ }
+}
Like for other block-job-* APIs we want have the actual functionality in job layer and make block-job-change to be a deprecated duplication of job-change in the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> --- block/mirror.c | 7 +++---- blockdev.c | 2 +- blockjob.c | 26 -------------------------- include/block/blockjob.h | 11 ----------- include/block/blockjob_int.h | 7 ------- include/qemu/job.h | 12 ++++++++++++ job-qmp.c | 1 + job.c | 23 +++++++++++++++++++++++ 8 files changed, 40 insertions(+), 49 deletions(-)