]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: Fix locking in external_snapshot_prepare()
authorKevin Wolf <kwolf@redhat.com>
Wed, 7 Dec 2022 13:18:30 +0000 (14:18 +0100)
committerKevin Wolf <kwolf@redhat.com>
Thu, 15 Dec 2022 15:08:23 +0000 (16:08 +0100)
bdrv_img_create() polls internally (when calling bdrv_create(), which is
a co_wrapper), so it can't be called while holding the lock of any
AioContext except the current one without causing deadlocks. Drop the
lock around the call in external_snapshot_prepare().

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20221207131838.239125-11-kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
blockdev.c

diff --git a/block.c b/block.c
index 6191ac1f440c00d26bef6ff168362d077f6a6210..44d59362d680341f5ffc5e5f7cc944ada699a2f0 100644 (file)
--- a/block.c
+++ b/block.c
@@ -6924,6 +6924,10 @@ bool bdrv_op_blocker_is_empty(BlockDriverState *bs)
     return true;
 }
 
+/*
+ * Must not be called while holding the lock of an AioContext other than the
+ * current one.
+ */
 void bdrv_img_create(const char *filename, const char *fmt,
                      const char *base_filename, const char *base_fmt,
                      char *options, uint64_t img_size, int flags, bool quiet,
index d2f80b0386ffbc7a1c875250859d93806616e488..ebf952cd218e44caa6c63960e1b77544afd7d0f6 100644 (file)
@@ -1507,10 +1507,14 @@ static void external_snapshot_prepare(BlkActionState *common,
                 goto out;
             }
             bdrv_refresh_filename(state->old_bs);
+
+            aio_context_release(aio_context);
             bdrv_img_create(new_image_file, format,
                             state->old_bs->filename,
                             state->old_bs->drv->format_name,
                             NULL, size, flags, false, &local_err);
+            aio_context_acquire(aio_context);
+
             if (local_err) {
                 error_propagate(errp, local_err);
                 goto out;