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

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