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