|
|
ae23c9 |
From 83f845c133441c92d87a0040f4b52c3e2654b995 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Date: Tue, 26 Jun 2018 09:48:26 +0200
|
|
|
ae23c9 |
Subject: [PATCH 118/268] job: Add job_dismiss()
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180626094856.6924-44-kwolf@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 81125
|
|
|
ae23c9 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 43/73] job: Add job_dismiss()
|
|
|
ae23c9 |
Bugzilla: 1513543
|
|
|
ae23c9 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
This moves block_job_dismiss() to the Job layer.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 5f9a6a08e8f65e01746d2485fc65a3a78e74865f)
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
blockdev.c | 10 ++++++----
|
|
|
ae23c9 |
blockjob.c | 13 -------------
|
|
|
ae23c9 |
include/block/blockjob.h | 9 ---------
|
|
|
ae23c9 |
include/qemu/job.h | 7 ++++++-
|
|
|
ae23c9 |
job.c | 15 ++++++++++++++-
|
|
|
ae23c9 |
tests/test-blockjob.c | 4 ++--
|
|
|
ae23c9 |
6 files changed, 28 insertions(+), 30 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
ae23c9 |
index c768e68..721dc9a 100644
|
|
|
ae23c9 |
--- a/blockdev.c
|
|
|
ae23c9 |
+++ b/blockdev.c
|
|
|
ae23c9 |
@@ -3916,14 +3916,16 @@ void qmp_block_job_finalize(const char *id, Error **errp)
|
|
|
ae23c9 |
void qmp_block_job_dismiss(const char *id, Error **errp)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
AioContext *aio_context;
|
|
|
ae23c9 |
- BlockJob *job = find_block_job(id, &aio_context, errp);
|
|
|
ae23c9 |
+ BlockJob *bjob = find_block_job(id, &aio_context, errp);
|
|
|
ae23c9 |
+ Job *job;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- if (!job) {
|
|
|
ae23c9 |
+ if (!bjob) {
|
|
|
ae23c9 |
return;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- trace_qmp_block_job_dismiss(job);
|
|
|
ae23c9 |
- block_job_dismiss(&job, errp);
|
|
|
ae23c9 |
+ trace_qmp_block_job_dismiss(bjob);
|
|
|
ae23c9 |
+ job = &bjob->job;
|
|
|
ae23c9 |
+ job_dismiss(&job, errp);
|
|
|
ae23c9 |
aio_context_release(aio_context);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/blockjob.c b/blockjob.c
|
|
|
ae23c9 |
index f146fe0..3ca009b 100644
|
|
|
ae23c9 |
--- a/blockjob.c
|
|
|
ae23c9 |
+++ b/blockjob.c
|
|
|
ae23c9 |
@@ -242,19 +242,6 @@ int64_t block_job_ratelimit_get_delay(BlockJob *job, uint64_t n)
|
|
|
ae23c9 |
return ratelimit_calculate_delay(&job->limit, n);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
-void block_job_dismiss(BlockJob **jobptr, Error **errp)
|
|
|
ae23c9 |
-{
|
|
|
ae23c9 |
- BlockJob *job = *jobptr;
|
|
|
ae23c9 |
- /* similarly to _complete, this is QMP-interface only. */
|
|
|
ae23c9 |
- assert(job->job.id);
|
|
|
ae23c9 |
- if (job_apply_verb(&job->job, JOB_VERB_DISMISS, errp)) {
|
|
|
ae23c9 |
- return;
|
|
|
ae23c9 |
- }
|
|
|
ae23c9 |
-
|
|
|
ae23c9 |
- job_do_dismiss(&job->job);
|
|
|
ae23c9 |
- *jobptr = NULL;
|
|
|
ae23c9 |
-}
|
|
|
ae23c9 |
-
|
|
|
ae23c9 |
void block_job_progress_update(BlockJob *job, uint64_t done)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
job->offset += done;
|
|
|
ae23c9 |
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
|
|
|
ae23c9 |
index e9ed7b8..5a81afc 100644
|
|
|
ae23c9 |
--- a/include/block/blockjob.h
|
|
|
ae23c9 |
+++ b/include/block/blockjob.h
|
|
|
ae23c9 |
@@ -141,15 +141,6 @@ void block_job_remove_all_bdrv(BlockJob *job);
|
|
|
ae23c9 |
void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/**
|
|
|
ae23c9 |
- * block_job_dismiss:
|
|
|
ae23c9 |
- * @job: The job to be dismissed.
|
|
|
ae23c9 |
- * @errp: Error object.
|
|
|
ae23c9 |
- *
|
|
|
ae23c9 |
- * Remove a concluded job from the query list.
|
|
|
ae23c9 |
- */
|
|
|
ae23c9 |
-void block_job_dismiss(BlockJob **job, Error **errp);
|
|
|
ae23c9 |
-
|
|
|
ae23c9 |
-/**
|
|
|
ae23c9 |
* block_job_progress_update:
|
|
|
ae23c9 |
* @job: The job that has made progress
|
|
|
ae23c9 |
* @done: How much progress the job made
|
|
|
ae23c9 |
diff --git a/include/qemu/job.h b/include/qemu/job.h
|
|
|
ae23c9 |
index 94900ec..1e8050c 100644
|
|
|
ae23c9 |
--- a/include/qemu/job.h
|
|
|
ae23c9 |
+++ b/include/qemu/job.h
|
|
|
ae23c9 |
@@ -487,6 +487,12 @@ int job_complete_sync(Job *job, Error **errp);
|
|
|
ae23c9 |
*/
|
|
|
ae23c9 |
void job_finalize(Job *job, Error **errp);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+/**
|
|
|
ae23c9 |
+ * Remove the concluded @job from the query list and resets the passed pointer
|
|
|
ae23c9 |
+ * to %NULL. Returns an error if the job is not actually concluded.
|
|
|
ae23c9 |
+ */
|
|
|
ae23c9 |
+void job_dismiss(Job **job, Error **errp);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
typedef void JobDeferToMainLoopFn(Job *job, void *opaque);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/**
|
|
|
ae23c9 |
@@ -515,6 +521,5 @@ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* TODO To be removed from the public interface */
|
|
|
ae23c9 |
void job_state_transition(Job *job, JobStatus s1);
|
|
|
ae23c9 |
-void job_do_dismiss(Job *job);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
#endif
|
|
|
ae23c9 |
diff --git a/job.c b/job.c
|
|
|
ae23c9 |
index eede680..7cd3602 100644
|
|
|
ae23c9 |
--- a/job.c
|
|
|
ae23c9 |
+++ b/job.c
|
|
|
ae23c9 |
@@ -568,7 +568,7 @@ void job_user_resume(Job *job, Error **errp)
|
|
|
ae23c9 |
job_resume(job);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
-void job_do_dismiss(Job *job)
|
|
|
ae23c9 |
+static void job_do_dismiss(Job *job)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
assert(job);
|
|
|
ae23c9 |
job->busy = false;
|
|
|
ae23c9 |
@@ -581,6 +581,19 @@ void job_do_dismiss(Job *job)
|
|
|
ae23c9 |
job_unref(job);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+void job_dismiss(Job **jobptr, Error **errp)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ Job *job = *jobptr;
|
|
|
ae23c9 |
+ /* similarly to _complete, this is QMP-interface only. */
|
|
|
ae23c9 |
+ assert(job->id);
|
|
|
ae23c9 |
+ if (job_apply_verb(job, JOB_VERB_DISMISS, errp)) {
|
|
|
ae23c9 |
+ return;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ job_do_dismiss(job);
|
|
|
ae23c9 |
+ *jobptr = NULL;
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
void job_early_fail(Job *job)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
assert(job->status == JOB_STATUS_CREATED);
|
|
|
ae23c9 |
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
|
|
|
ae23c9 |
index 46a7873..7131cab 100644
|
|
|
ae23c9 |
--- a/tests/test-blockjob.c
|
|
|
ae23c9 |
+++ b/tests/test-blockjob.c
|
|
|
ae23c9 |
@@ -233,8 +233,8 @@ static void cancel_common(CancelJob *s)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
job_cancel_sync(&job->job);
|
|
|
ae23c9 |
if (sts != JOB_STATUS_CREATED && sts != JOB_STATUS_CONCLUDED) {
|
|
|
ae23c9 |
- BlockJob *dummy = job;
|
|
|
ae23c9 |
- block_job_dismiss(&dummy, &error_abort);
|
|
|
ae23c9 |
+ Job *dummy = &job->job;
|
|
|
ae23c9 |
+ job_dismiss(&dummy, &error_abort);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
assert(job->job.status == JOB_STATUS_NULL);
|
|
|
ae23c9 |
job_unref(&job->job);
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|