thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
432cb7
From b21fa5ecd9acf2b91839a2915fb4bb39dac4c803 Mon Sep 17 00:00:00 2001
432cb7
From: Kevin Wolf <kwolf@redhat.com>
432cb7
Date: Thu, 3 Feb 2022 15:05:33 +0100
432cb7
Subject: [PATCH 2/5] block: Lock AioContext for drain_end in blockdev-reopen
432cb7
432cb7
RH-Author: Kevin Wolf <kwolf@redhat.com>
432cb7
RH-MergeRequest: 142: block: Lock AioContext for drain_end in blockdev-reopen
432cb7
RH-Commit: [1/2] 98de3b5987f88ea6b4b503f623d6c4475574e037
432cb7
RH-Bugzilla: 2067118
432cb7
RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
432cb7
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
432cb7
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
432cb7
432cb7
bdrv_subtree_drained_end() requires the caller to hold the AioContext
432cb7
lock for the drained node. Not doing this for nodes outside of the main
432cb7
AioContext leads to crashes when AIO_WAIT_WHILE() needs to wait and
432cb7
tries to temporarily release the lock.
432cb7
432cb7
Fixes: 3908b7a8994fa5ef7a89aa58cd5a02fc58141592
432cb7
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2046659
432cb7
Reported-by: Qing Wang <qinwang@redhat.com>
432cb7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
432cb7
Message-Id: <20220203140534.36522-2-kwolf@redhat.com>
432cb7
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
432cb7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
432cb7
(cherry picked from commit aba8205be0707b9d108e32254e186ba88107a869)
432cb7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
432cb7
---
432cb7
 blockdev.c | 11 ++++++++++-
432cb7
 1 file changed, 10 insertions(+), 1 deletion(-)
432cb7
432cb7
diff --git a/blockdev.c b/blockdev.c
432cb7
index b35072644e..565f6a81fd 100644
432cb7
--- a/blockdev.c
432cb7
+++ b/blockdev.c
432cb7
@@ -3562,6 +3562,7 @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
432cb7
 {
432cb7
     BlockReopenQueue *queue = NULL;
432cb7
     GSList *drained = NULL;
432cb7
+    GSList *p;
432cb7
 
432cb7
     /* Add each one of the BDS that we want to reopen to the queue */
432cb7
     for (; reopen_list != NULL; reopen_list = reopen_list->next) {
432cb7
@@ -3611,7 +3612,15 @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
432cb7
 
432cb7
 fail:
432cb7
     bdrv_reopen_queue_free(queue);
432cb7
-    g_slist_free_full(drained, (GDestroyNotify) bdrv_subtree_drained_end);
432cb7
+    for (p = drained; p; p = p->next) {
432cb7
+        BlockDriverState *bs = p->data;
432cb7
+        AioContext *ctx = bdrv_get_aio_context(bs);
432cb7
+
432cb7
+        aio_context_acquire(ctx);
432cb7
+        bdrv_subtree_drained_end(bs);
432cb7
+        aio_context_release(ctx);
432cb7
+    }
432cb7
+    g_slist_free(drained);
432cb7
 }
432cb7
 
432cb7
 void qmp_blockdev_del(const char *node_name, Error **errp)
432cb7
-- 
432cb7
2.27.0
432cb7