pve-qemu-qoup/debian/patches/pve/0040-pvebackup_complete_cb-avoid-poll-loop-if-already-ins.patch
Thomas Lamprecht 22ff24871d various small pve backup co-routine related fixes
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-30 16:03:56 +01:00

44 lines
1.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dietmar Maurer <dietmar@proxmox.com>
Date: Wed, 30 Oct 2019 12:15:46 +0100
Subject: [PATCH] pvebackup_complete_cb: avoid poll loop if already inside
coroutine
---
blockdev.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 421240fbb8..e889bd13d5 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3169,6 +3169,8 @@ static void coroutine_fn block_on_coroutine_wrapper(void *opaque)
static void block_on_coroutine_fn(CoroutineEntry *entry, void *entry_arg)
{
+ assert(!qemu_in_coroutine());
+
AioContext *ctx = qemu_get_current_aio_context();
BlockOnCoroutineWrapper wrapper = {
.finished = false,
@@ -3352,13 +3354,17 @@ static void coroutine_fn pvebackup_co_complete_cb(void *opaque)
static void pvebackup_complete_cb(void *opaque, int ret)
{
- // This always called from the main loop
+ // This can be called from the main loop, or from a coroutine
PVEBackupCompeteCallbackData cb_data = {
.di = opaque,
.result = ret,
};
- block_on_coroutine_fn(pvebackup_co_complete_cb, &cb_data);
+ if (qemu_in_coroutine()) {
+ pvebackup_co_complete_cb(&cb_data);
+ } else {
+ block_on_coroutine_fn(pvebackup_co_complete_cb, &cb_data);
+ }
}
static void coroutine_fn pvebackup_co_cancel(void *opaque)