]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: Cancel job in bdrv_close_all() callers
authorKevin Wolf <kwolf@redhat.com>
Wed, 16 May 2018 11:46:37 +0000 (13:46 +0200)
committerKevin Wolf <kwolf@redhat.com>
Wed, 23 May 2018 12:30:51 +0000 (14:30 +0200)
Now that we cancel all jobs and not only block jobs on shutdown, doing
that in bdrv_close_all() isn't really appropriate any more. Move the
job_cancel_sync_all() call to the callers, and only assert that there
are no job running in bdrv_close_all().

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
qemu-nbd.c
vl.c

diff --git a/block.c b/block.c
index d50b08c29b4bb76e5c2a7ead1c2a79450420df0a..501b64c8193f52d826ab55c10e9bcb248f90fbe2 100644 (file)
--- a/block.c
+++ b/block.c
@@ -3362,9 +3362,7 @@ static void bdrv_close(BlockDriverState *bs)
 
 void bdrv_close_all(void)
 {
-    /* TODO We do want to cancel all jobs instead of just block jobs on
-     * shutdown, but bdrv_close_all() isn't the right place any more. */
-    job_cancel_sync_all();
+    assert(job_next(NULL) == NULL);
     nbd_export_close_all();
 
     /* Drop references from requests still in flight, such as canceled block
index 0af0560ad1c65fa6d67b66e57e747849ce4f9979..51b9d38c72732c821cb4ee5bf362533406ce2494 100644 (file)
@@ -482,6 +482,12 @@ static const char *socket_activation_validate_opts(const char *device,
     return NULL;
 }
 
+static void qemu_nbd_shutdown(void)
+{
+    job_cancel_sync_all();
+    bdrv_close_all();
+}
+
 int main(int argc, char **argv)
 {
     BlockBackend *blk;
@@ -928,7 +934,7 @@ int main(int argc, char **argv)
         exit(EXIT_FAILURE);
     }
     bdrv_init();
-    atexit(bdrv_close_all);
+    atexit(qemu_nbd_shutdown);
 
     srcpath = argv[optind];
     if (imageOpts) {
diff --git a/vl.c b/vl.c
index d5836c65aec71bcc49548b8015f1ca7b643020c0..038d7f8042d338870cda3e6542734ca312c6e655 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -4683,6 +4683,7 @@ int main(int argc, char **argv, char **envp)
     /* No more vcpu or device emulation activity beyond this point */
     vm_shutdown();
 
+    job_cancel_sync_all();
     bdrv_close_all();
 
     res_free();