From 4f15153c864d6c9503f4dd5f95944ab5b98152ed Mon Sep 17 00:00:00 2001
From: Stefan Hajnoczi <stefanha@redhat.com>
Date: Wed, 17 Jan 2018 10:24:33 +0100
Subject: [PATCH 2/2] mirror: Fix inconsistent backing AioContext for after
 mirroring

RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: <20180117102433.16728-2-stefanha@redhat.com>
Patchwork-id: 78656
O-Subject: [RHV-7.4.z qemu-kvm-rhev PATCH 1/1] mirror: Fix inconsistent backing AioContext for after mirroring
Bugzilla: 1535125
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
RH-Acked-by: Fam Zheng <fzheng@redhat.com>

From: "sochin.jiang" <sochin.jiang@huawei.com>

mirror_complete opens the backing chain, which should have the same
AioContext as the top when using iothreads. Make the code guarantee
this, which fixes a failed assertion in bdrv_attach_child.

Signed-off-by: sochin.jiang <sochin.jiang@huawei.com>
Message-id: 1498475064-39816-1-git-send-email-sochin.jiang@huawei.com
[mreitz: Reworded commit message]
Signed-off-by: Max Reitz <mreitz@redhat.com>
(cherry picked from commit 5ce6bfe255091d532ec4555d0ede816294cb1703)
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 block.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block.c b/block.c
index 49f94d1..f3b2c27 100644
--- a/block.c
+++ b/block.c
@@ -2087,6 +2087,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options,
         ret = -EINVAL;
         goto free_exit;
     }
+    bdrv_set_aio_context(backing_hd, bdrv_get_aio_context(bs));
 
     /* Hook up the backing file link; drop our reference, bs owns the
      * backing_hd reference now */
-- 
1.8.3.1

