Blame SOURCES/kvm-block-Cancel-job-in-bdrv_close_all-callers.patch

1bdc94
From 7ea7ac78a4d38bc1873df660406b25949515cf07 Mon Sep 17 00:00:00 2001
1bdc94
From: Kevin Wolf <kwolf@redhat.com>
1bdc94
Date: Tue, 26 Jun 2018 09:48:24 +0200
1bdc94
Subject: [PATCH 55/89] block: Cancel job in bdrv_close_all() callers
1bdc94
1bdc94
RH-Author: Kevin Wolf <kwolf@redhat.com>
1bdc94
Message-id: <20180626094856.6924-42-kwolf@redhat.com>
1bdc94
Patchwork-id: 81098
1bdc94
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 41/73] block: Cancel job in bdrv_close_all() callers
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
Now that we cancel all jobs and not only block jobs on shutdown, doing
1bdc94
that in bdrv_close_all() isn't really appropriate any more. Move the
1bdc94
job_cancel_sync_all() call to the callers, and only assert that there
1bdc94
are no job running in bdrv_close_all().
1bdc94
1bdc94
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
(cherry picked from commit b3b5299d58bce4366c647af40374e6b063f371eb)
1bdc94
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 block.c    | 4 +---
1bdc94
 qemu-nbd.c | 8 +++++++-
1bdc94
 vl.c       | 1 +
1bdc94
 3 files changed, 9 insertions(+), 4 deletions(-)
1bdc94
1bdc94
diff --git a/block.c b/block.c
1bdc94
index a83787f..afe30ca 100644
1bdc94
--- a/block.c
1bdc94
+++ b/block.c
1bdc94
@@ -3374,9 +3374,7 @@ static void bdrv_close(BlockDriverState *bs)
1bdc94
 
1bdc94
 void bdrv_close_all(void)
1bdc94
 {
1bdc94
-    /* TODO We do want to cancel all jobs instead of just block jobs on
1bdc94
-     * shutdown, but bdrv_close_all() isn't the right place any more. */
1bdc94
-    job_cancel_sync_all();
1bdc94
+    assert(job_next(NULL) == NULL);
1bdc94
     nbd_export_close_all();
1bdc94
 
1bdc94
     /* Drop references from requests still in flight, such as canceled block
1bdc94
diff --git a/qemu-nbd.c b/qemu-nbd.c
1bdc94
index 0af0560..51b9d38 100644
1bdc94
--- a/qemu-nbd.c
1bdc94
+++ b/qemu-nbd.c
1bdc94
@@ -482,6 +482,12 @@ static const char *socket_activation_validate_opts(const char *device,
1bdc94
     return NULL;
1bdc94
 }
1bdc94
 
1bdc94
+static void qemu_nbd_shutdown(void)
1bdc94
+{
1bdc94
+    job_cancel_sync_all();
1bdc94
+    bdrv_close_all();
1bdc94
+}
1bdc94
+
1bdc94
 int main(int argc, char **argv)
1bdc94
 {
1bdc94
     BlockBackend *blk;
1bdc94
@@ -928,7 +934,7 @@ int main(int argc, char **argv)
1bdc94
         exit(EXIT_FAILURE);
1bdc94
     }
1bdc94
     bdrv_init();
1bdc94
-    atexit(bdrv_close_all);
1bdc94
+    atexit(qemu_nbd_shutdown);
1bdc94
 
1bdc94
     srcpath = argv[optind];
1bdc94
     if (imageOpts) {
1bdc94
diff --git a/vl.c b/vl.c
1bdc94
index f3acab3..713f899 100644
1bdc94
--- a/vl.c
1bdc94
+++ b/vl.c
1bdc94
@@ -4772,6 +4772,7 @@ int main(int argc, char **argv, char **envp)
1bdc94
     /* No more vcpu or device emulation activity beyond this point */
1bdc94
     vm_shutdown();
1bdc94
 
1bdc94
+    job_cancel_sync_all();
1bdc94
     bdrv_close_all();
1bdc94
 
1bdc94
     res_free();
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94