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

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