]> git.proxmox.com Git - mirror_qemu.git/commitdiff
vl: Drain before (block) job cancel when quitting
authorMax Reitz <mreitz@redhat.com>
Wed, 12 Jun 2019 22:08:38 +0000 (00:08 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 19 Jul 2019 13:17:54 +0000 (15:17 +0200)
If the main loop cancels all block jobs while the block layer is not
drained, this cancelling may not happen instantaneously.  We can start a
drained section before vm_shutdown(), which entails another
bdrv_drain_all(); this nested bdrv_drain_all() will thus be a no-op,
basically.

We do not have to end the drained section, because we actually do not
want any requests to happen from this point on.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
vl.c

diff --git a/vl.c b/vl.c
index a5808f9a0200ddae5cc692b08203007dab749921..53335a54704ac1d2e17b36626ad6a8b4649295cf 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -4480,6 +4480,17 @@ int main(int argc, char **argv, char **envp)
      */
     migration_shutdown();
 
+    /*
+     * We must cancel all block jobs while the block layer is drained,
+     * or cancelling will be affected by throttling and thus may block
+     * for an extended period of time.
+     * vm_shutdown() will bdrv_drain_all(), so we may as well include
+     * it in the drained section.
+     * We do not need to end this section, because we do not want any
+     * requests happening from here on anyway.
+     */
+    bdrv_drain_all_begin();
+
     /* No more vcpu or device emulation activity beyond this point */
     vm_shutdown();