--- /dev/null
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Dietmar Maurer <dietmar@proxmox.com>
+Date: Mon, 21 Oct 2019 11:51:57 +0200
+Subject: [PATCH] PVE bug fix #1071 - vma-writer.c: use correct AioContext
+
+Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
+---
+ vma-writer.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/vma-writer.c b/vma-writer.c
+index fd9567634d..b163fa2d3a 100644
+--- a/vma-writer.c
++++ b/vma-writer.c
+@@ -199,12 +199,14 @@ int vma_writer_register_stream(VmaWriter *vmaw, const char *devname,
+ return n;
+ }
+
+-static void vma_co_continue_write(void *opaque)
++static void coroutine_fn yield_until_fd_writable(int fd)
+ {
+- VmaWriter *vmaw = opaque;
+-
+- DPRINTF("vma_co_continue_write\n");
+- qemu_coroutine_enter(vmaw->co_writer);
++ assert(qemu_in_coroutine());
++ AioContext *ctx = qemu_get_current_aio_context();
++ aio_set_fd_handler(ctx, fd, false, NULL, (IOHandler *)qemu_coroutine_enter,
++ NULL, qemu_coroutine_self());
++ qemu_coroutine_yield();
++ aio_set_fd_handler(ctx, fd, false, NULL, NULL, NULL, NULL);
+ }
+
+ static ssize_t coroutine_fn
+@@ -224,14 +226,12 @@ vma_queue_write(VmaWriter *vmaw, const void *buf, size_t bytes)
+ vmaw->co_writer = qemu_coroutine_self();
+
+ while (done < bytes) {
+- aio_set_fd_handler(qemu_get_aio_context(), vmaw->fd, false, NULL, vma_co_continue_write, NULL, vmaw);
+- qemu_coroutine_yield();
+- aio_set_fd_handler(qemu_get_aio_context(), vmaw->fd, false, NULL, NULL, NULL, NULL);
+ if (vmaw->status < 0) {
+ DPRINTF("vma_queue_write detected canceled backup\n");
+ done = -1;
+ break;
+ }
++ yield_until_fd_writable(vmaw->fd);
+ ret = write(vmaw->fd, buf + done, bytes - done);
+ if (ret > 0) {
+ done += ret;
+--
+2.20.1