[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 22/33] blockjob: Split block_job_event_pending()
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [RFC PATCH 22/33] blockjob: Split block_job_event_pending() |
Date: |
Tue, 24 Apr 2018 17:25:04 +0200 |
block_job_event_pending() doesn't only send a QMP event, but it also
transitions to the PENDING state. Split the function so that we get one
part only sending the event (like other block_job_event_* functions) and
another part than does the state transition.
Signed-off-by: Kevin Wolf <address@hidden>
---
blockjob.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/blockjob.c b/blockjob.c
index 62f4a87744..c49cfdf130 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -38,7 +38,7 @@
static void block_job_event_cancelled(BlockJob *job);
static void block_job_event_completed(BlockJob *job, const char *msg);
-static int block_job_event_pending(BlockJob *job);
+static void block_job_event_pending(BlockJob *job);
/* Transactional group of block jobs */
struct BlockJobTxn {
@@ -501,6 +501,15 @@ static void block_job_do_finalize(BlockJob *job)
}
}
+static int block_job_transition_to_pending(BlockJob *job)
+{
+ job_state_transition(&job->job, JOB_STATUS_PENDING);
+ if (!job->job.auto_finalize) {
+ block_job_event_pending(job);
+ }
+ return 0;
+}
+
static void block_job_completed_txn_success(BlockJob *job)
{
BlockJobTxn *txn = job->txn;
@@ -519,7 +528,7 @@ static void block_job_completed_txn_success(BlockJob *job)
assert(other_job->ret == 0);
}
- block_job_txn_apply(txn, block_job_event_pending, false);
+ block_job_txn_apply(txn, block_job_transition_to_pending, false);
/* If no jobs need manual finalization, automatically do so */
if (block_job_txn_apply(txn, block_job_needs_finalize, false) == 0) {
@@ -732,15 +741,15 @@ static void block_job_event_completed(BlockJob *job,
const char *msg)
&error_abort);
}
-static int block_job_event_pending(BlockJob *job)
+static void block_job_event_pending(BlockJob *job)
{
- job_state_transition(&job->job, JOB_STATUS_PENDING);
- if (!job->job.auto_finalize && !block_job_is_internal(job)) {
- qapi_event_send_block_job_pending(job_type(&job->job),
- job->job.id,
- &error_abort);
+ if (block_job_is_internal(job)) {
+ return;
}
- return 0;
+
+ qapi_event_send_block_job_pending(job_type(&job->job),
+ job->job.id,
+ &error_abort);
}
/*
--
2.13.6
- [Qemu-devel] [RFC PATCH 08/33] job: Rename BlockJobType into JobType, (continued)
- [Qemu-devel] [RFC PATCH 08/33] job: Rename BlockJobType into JobType, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 10/33] job: Add job_delete(), Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 09/33] job: Add JobDriver.job_type, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 11/33] job: Maintain a list of all jobs, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 15/33] job: Add Job.aio_context, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 07/33] job: Create Job, JobDriver and job_create(), Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 13/33] job: Add reference counting, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 14/33] job: Move cancelled to Job, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 12/33] job: Move state transitions to Job, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 16/33] job: Move defer_to_main_loop to Job, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 22/33] blockjob: Split block_job_event_pending(),
Kevin Wolf <=
- [Qemu-devel] [RFC PATCH 21/33] job: Move BlockJobCreateFlags to Job, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 18/33] job: Add job_sleep_ns(), Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 20/33] job: Replace BlockJob.completed with job_is_completed(), Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 23/33] job: Add job_event_*(), Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 19/33] job: Move pause/resume functions to Job, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 25/33] job: Convert block_job_cancel_async() to Job, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 24/33] job: Move single job finalisation to Job, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 26/33] job: Add job_drain(), Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 28/33] job: Move job_finish_sync() to Job, Kevin Wolf, 2018/04/24
- [Qemu-devel] [RFC PATCH 27/33] job: Move .complete callback to Job, Kevin Wolf, 2018/04/24