Blame SOURCES/kvm-blockjob-Split-block_job_event_pending.patch

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