26ba25
From 6d0b0e3738595df279028c62682f033d941cc97c Mon Sep 17 00:00:00 2001
26ba25
From: Kevin Wolf <kwolf@redhat.com>
26ba25
Date: Tue, 26 Jun 2018 09:48:14 +0200
26ba25
Subject: [PATCH 106/268] blockjob: Split block_job_event_pending()
26ba25
26ba25
RH-Author: Kevin Wolf <kwolf@redhat.com>
26ba25
Message-id: <20180626094856.6924-32-kwolf@redhat.com>
26ba25
Patchwork-id: 81071
26ba25
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 31/73] blockjob: Split block_job_event_pending()
26ba25
Bugzilla: 1513543
26ba25
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
26ba25
RH-Acked-by: Max Reitz <mreitz@redhat.com>
26ba25
RH-Acked-by: Fam Zheng <famz@redhat.com>
26ba25
26ba25
block_job_event_pending() doesn't only send a QMP event, but it also
26ba25
transitions to the PENDING state. Split the function so that we get one
26ba25
part only sending the event (like other block_job_event_* functions) and
26ba25
another part that does the state transition.
26ba25
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Reviewed-by: Max Reitz <mreitz@redhat.com>
26ba25
(cherry picked from commit 5d4f376998bc6b01402b90634385b082b2eb5c5b)
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 blockjob.c | 27 ++++++++++++++++++---------
26ba25
 1 file changed, 18 insertions(+), 9 deletions(-)
26ba25
26ba25
diff --git a/blockjob.c b/blockjob.c
26ba25
index d9d8ff7..b4334fb 100644
26ba25
--- a/blockjob.c
26ba25
+++ b/blockjob.c
26ba25
@@ -38,7 +38,7 @@
26ba25
 
26ba25
 static void block_job_event_cancelled(BlockJob *job);
26ba25
 static void block_job_event_completed(BlockJob *job, const char *msg);
26ba25
-static int block_job_event_pending(BlockJob *job);
26ba25
+static void block_job_event_pending(BlockJob *job);
26ba25
 
26ba25
 /* Transactional group of block jobs */
26ba25
 struct BlockJobTxn {
26ba25
@@ -500,6 +500,15 @@ static void block_job_do_finalize(BlockJob *job)
26ba25
     }
26ba25
 }
26ba25
 
26ba25
+static int block_job_transition_to_pending(BlockJob *job)
26ba25
+{
26ba25
+    job_state_transition(&job->job, JOB_STATUS_PENDING);
26ba25
+    if (!job->job.auto_finalize) {
26ba25
+        block_job_event_pending(job);
26ba25
+    }
26ba25
+    return 0;
26ba25
+}
26ba25
+
26ba25
 static void block_job_completed_txn_success(BlockJob *job)
26ba25
 {
26ba25
     BlockJobTxn *txn = job->txn;
26ba25
@@ -518,7 +527,7 @@ static void block_job_completed_txn_success(BlockJob *job)
26ba25
         assert(other_job->ret == 0);
26ba25
     }
26ba25
 
26ba25
-    block_job_txn_apply(txn, block_job_event_pending, false);
26ba25
+    block_job_txn_apply(txn, block_job_transition_to_pending, false);
26ba25
 
26ba25
     /* If no jobs need manual finalization, automatically do so */
26ba25
     if (block_job_txn_apply(txn, block_job_needs_finalize, false) == 0) {
26ba25
@@ -733,15 +742,15 @@ static void block_job_event_completed(BlockJob *job, const char *msg)
26ba25
                                         &error_abort);
26ba25
 }
26ba25
 
26ba25
-static int block_job_event_pending(BlockJob *job)
26ba25
+static void block_job_event_pending(BlockJob *job)
26ba25
 {
26ba25
-    job_state_transition(&job->job, JOB_STATUS_PENDING);
26ba25
-    if (!job->job.auto_finalize && !block_job_is_internal(job)) {
26ba25
-        qapi_event_send_block_job_pending(job_type(&job->job),
26ba25
-                                          job->job.id,
26ba25
-                                          &error_abort);
26ba25
+    if (block_job_is_internal(job)) {
26ba25
+        return;
26ba25
     }
26ba25
-    return 0;
26ba25
+
26ba25
+    qapi_event_send_block_job_pending(job_type(&job->job),
26ba25
+                                      job->job.id,
26ba25
+                                      &error_abort);
26ba25
 }
26ba25
 
26ba25
 /*
26ba25
-- 
26ba25
1.8.3.1
26ba25