yeahuh / rpms / qemu-kvm

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