4ec855
From ee7b9d7867634d052f2c695fcebf68f585fe59c0 Mon Sep 17 00:00:00 2001
4ec855
From: Kevin Wolf <kwolf@redhat.com>
4ec855
Date: Wed, 14 Aug 2019 08:42:27 +0100
4ec855
Subject: [PATCH 04/10] block: Fix AioContext switch for drained node
4ec855
4ec855
RH-Author: Kevin Wolf <kwolf@redhat.com>
4ec855
Message-id: <20190814084229.6458-4-kwolf@redhat.com>
4ec855
Patchwork-id: 89969
4ec855
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 3/5] block: Fix AioContext switch for drained node
4ec855
Bugzilla: 1716349
4ec855
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4ec855
RH-Acked-by: Max Reitz <mreitz@redhat.com>
4ec855
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4ec855
4ec855
When a drained node changes its AioContext, we need to move its
4ec855
aio_disable_external() to the new context, too.
4ec855
4ec855
Without this fix, drain_end will try to reenable the new context, which
4ec855
has never been disabled, so an assertion failure is triggered.
4ec855
4ec855
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4ec855
Reviewed-by: Eric Blake <eblake@redhat.com>
4ec855
(cherry picked from commit e64f25f30b80a71bd4e409ed518c39eeb5905166)
4ec855
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4ec855
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
4ec855
---
4ec855
 block.c | 7 +++++++
4ec855
 1 file changed, 7 insertions(+)
4ec855
4ec855
diff --git a/block.c b/block.c
4ec855
index 82b16df..9d9b8a9 100644
4ec855
--- a/block.c
4ec855
+++ b/block.c
4ec855
@@ -4948,6 +4948,9 @@ void bdrv_detach_aio_context(BlockDriverState *bs)
4ec855
         bdrv_detach_aio_context(child->bs);
4ec855
     }
4ec855
 
4ec855
+    if (bs->quiesce_counter) {
4ec855
+        aio_enable_external(bs->aio_context);
4ec855
+    }
4ec855
     bs->aio_context = NULL;
4ec855
 }
4ec855
 
4ec855
@@ -4961,6 +4964,10 @@ void bdrv_attach_aio_context(BlockDriverState *bs,
4ec855
         return;
4ec855
     }
4ec855
 
4ec855
+    if (bs->quiesce_counter) {
4ec855
+        aio_disable_external(new_context);
4ec855
+    }
4ec855
+
4ec855
     bs->aio_context = new_context;
4ec855
 
4ec855
     QLIST_FOREACH(child, &bs->children, next) {
4ec855
-- 
4ec855
1.8.3.1
4ec855