Blame SOURCES/kvm-tests-test-blockjob-remove-exit-callback.patch

357786
From b7db3ff5fc3664af536364f8274ed4826566b1dd Mon Sep 17 00:00:00 2001
357786
From: John Snow <jsnow@redhat.com>
357786
Date: Mon, 10 Sep 2018 18:17:56 +0200
357786
Subject: [PATCH 18/25] tests/test-blockjob: remove exit callback
357786
357786
RH-Author: John Snow <jsnow@redhat.com>
357786
Message-id: <20180910181803.11781-19-jsnow@redhat.com>
357786
Patchwork-id: 82108
357786
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 18/25] tests/test-blockjob: remove exit callback
357786
Bugzilla: 1626061
357786
RH-Acked-by: Max Reitz <mreitz@redhat.com>
357786
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
357786
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
357786
357786
We remove the exit callback and the completed boolean along with it.
357786
We can simulate it just fine by waiting for the job to defer to the
357786
main loop, and then giving it one final kick to get the main loop
357786
portion to run.
357786
357786
Signed-off-by: John Snow <jsnow@redhat.com>
357786
Reviewed-by: Max Reitz <mreitz@redhat.com>
357786
Message-id: 20180906130225.5118-10-jsnow@redhat.com
357786
Reviewed-by: Jeff Cody <jcody@redhat.com>
357786
Signed-off-by: Max Reitz <mreitz@redhat.com>
357786
(cherry picked from commit c0345e9d3bd2f3672d481be7514b9ad181878921)
357786
Signed-off-by: John Snow <jsnow@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 tests/test-blockjob.c | 16 ++++++----------
357786
 1 file changed, 6 insertions(+), 10 deletions(-)
357786
357786
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
357786
index 8e8b680..de4c1c2 100644
357786
--- a/tests/test-blockjob.c
357786
+++ b/tests/test-blockjob.c
357786
@@ -160,15 +160,8 @@ typedef struct CancelJob {
357786
     BlockBackend *blk;
357786
     bool should_converge;
357786
     bool should_complete;
357786
-    bool completed;
357786
 } CancelJob;
357786
 
357786
-static void cancel_job_exit(Job *job)
357786
-{
357786
-    CancelJob *s = container_of(job, CancelJob, common.job);
357786
-    s->completed = true;
357786
-}
357786
-
357786
 static void cancel_job_complete(Job *job, Error **errp)
357786
 {
357786
     CancelJob *s = container_of(job, CancelJob, common.job);
357786
@@ -201,7 +194,6 @@ static const BlockJobDriver test_cancel_driver = {
357786
         .user_resume   = block_job_user_resume,
357786
         .drain         = block_job_drain,
357786
         .run           = cancel_job_run,
357786
-        .exit          = cancel_job_exit,
357786
         .complete      = cancel_job_complete,
357786
     },
357786
 };
357786
@@ -335,9 +327,11 @@ static void test_cancel_pending(void)
357786
 
357786
     job_complete(job, &error_abort);
357786
     job_enter(job);
357786
-    while (!s->completed) {
357786
+    while (!job->deferred_to_main_loop) {
357786
         aio_poll(qemu_get_aio_context(), true);
357786
     }
357786
+    assert(job->status == JOB_STATUS_READY);
357786
+    aio_poll(qemu_get_aio_context(), true);
357786
     assert(job->status == JOB_STATUS_PENDING);
357786
 
357786
     cancel_common(s);
357786
@@ -359,9 +353,11 @@ static void test_cancel_concluded(void)
357786
 
357786
     job_complete(job, &error_abort);
357786
     job_enter(job);
357786
-    while (!s->completed) {
357786
+    while (!job->deferred_to_main_loop) {
357786
         aio_poll(qemu_get_aio_context(), true);
357786
     }
357786
+    assert(job->status == JOB_STATUS_READY);
357786
+    aio_poll(qemu_get_aio_context(), true);
357786
     assert(job->status == JOB_STATUS_PENDING);
357786
 
357786
     job_finalize(job, &error_abort);
357786
-- 
357786
1.8.3.1
357786