diff mbox series

[23/42] blockjob: Split block_job_event_pending()

Message ID 20180509162637.15575-24-kwolf@redhat.com
State New
Headers show
Series Generic background jobs | expand

Commit Message

Kevin Wolf May 9, 2018, 4:26 p.m. UTC
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 <kwolf@redhat.com>
---
 blockjob.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

Comments

Max Reitz May 14, 2018, 5:56 p.m. UTC | #1
On 2018-05-09 18:26, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
>  blockjob.c | 27 ++++++++++++++++++---------
>  1 file changed, 18 insertions(+), 9 deletions(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>
Eric Blake May 16, 2018, 7:15 p.m. UTC | #2
On 05/09/2018 11:26 AM, Kevin Wolf wrote:
> 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.

s/than/that/

> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>   blockjob.c | 27 ++++++++++++++++++---------
>   1 file changed, 18 insertions(+), 9 deletions(-)
>
diff mbox series

Patch

diff --git a/blockjob.c b/blockjob.c
index 4cfedbe791..de9a789e29 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) {
@@ -734,15 +743,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);
 }
 
 /*