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

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