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

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