pve-qemu-qoup/debian/patches/pve/0040-pvebackup_complete_cb-avoid-poll-loop-if-already-ins.patch
Stefan Reiter be901f6656 Update and rebase to QEMU 4.1
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-11-21 07:58:57 +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 66f2711185..083ada6c8e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3189,6 +3189,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,
@@ -3372,13 +3374,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)