Bug 1534491 - Mirror jobs for drives with iothreads make QEMU to abort with "block.c:1895: bdrv_attach_child: Assertion `bdrv_get_aio_context(parent_bs) == bdrv_get_aio_context(child_bs)' failed."
Summary: Mirror jobs for drives with iothreads make QEMU to abort with "block.c:1895: ...
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev
Version: 7.4
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: Stefan Hajnoczi
QA Contact: Qianqian Zhu
URL:
Whiteboard:
Keywords: ZStream
Depends On:
Blocks: 1535125
TreeView+ depends on / blocked
 
Reported: 2018-01-15 11:17 UTC by Sergio Lopez
Modified: 2018-04-11 00:58 UTC (History)
13 users (show)

(edit)
Clone Of:
: 1535125 (view as bug list)
(edit)
Last Closed: 2018-04-11 00:58:52 UTC


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:1104 normal SHIPPED_LIVE Important: qemu-kvm-rhev security, bug fix, and enhancement update 2018-04-10 22:54:38 UTC
Red Hat Knowledge Base (Solution) 3317791 None None None 2018-01-15 20:33 UTC

Description Sergio Lopez 2018-01-15 11:17:30 UTC
Description of problem:

 * Preparing the images

# qemu-img create -f raw base.img 1g
# qemu-img create -f qcow2 -o backing_file=base.img top1.qcow2
# qemu-img create -f qcow2 -o backing_file=base.img top2.qcow2


 * Running with iothreads

# /usr/libexec/qemu-kvm -m 1g -drive if=none,file=top1.qcow2,format=qcow2,id=drive0 -object iothread,id=iothread0 -device virtio-blk-pci,iothread=iothread0,drive=drive0 -monitor stdio 
QEMU 2.9.0 monitor - type 'help' for more information
(qemu) drive_mirror -n drive0 top2.qcow2
(qemu) info block-jobs
Type mirror, device drive0: Completed 0 of 0 bytes, speed limit 0 bytes/s
(qemu) block_job_complete drive0
qemu-kvm: block.c:1895: bdrv_attach_child: Assertion `bdrv_get_aio_context(parent_bs) == bdrv_get_aio_context(child_bs)' failed.
Aborted (core dumped)


 * Running without iothreads

# /usr/libexec/qemu-kvm -m 1g -drive if=none,file=top1.qcow2,format=qcow2,id=drive0 -device virtio-blk-pci,drive=drive0 -monitor stdio
QEMU 2.9.0 monitor - type 'help' for more information
(qemu) drive_mirror -n drive0 top2.qcow2
(qemu) info block-jobs
Type mirror, device drive0: Completed 0 of 0 bytes, speed limit 0 bytes/s
(qemu) block_job_complete drive0
(qemu) info block-jobs
No active jobs


Version-Release number of selected component (if applicable):

qemu-kvm-rhev-2.9.0-16.el7_4.13.x86_64


How reproducible:

Always


Additional info:

This has been fixed in upstream by this oneliner:

<snip>
[slopezpa@dritchie qemu]$ git show 5ce6bfe255091d532ec4555d0ede816294cb1703
commit 5ce6bfe255091d532ec4555d0ede816294cb1703
Author: sochin.jiang <sochin.jiang@huawei.com>
Date:   Mon Jun 26 19:04:24 2017 +0800

    mirror: Fix inconsistent backing AioContext for after mirroring
    
    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>

diff --git a/block.c b/block.c
index edfa6b7a2c..b9e5114a27 100644
--- a/block.c
+++ b/block.c
@@ -2185,6 +2185,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 */
</snip>


Please consider backporting this. Thanks.

Comment 4 Qianqian Zhu 2018-01-16 02:54:46 UTC
Reproduced on qemu-kvm-rhev-10:2.9.0-14.el7.x86_64 with steps in comment 0.

If mirror source file is base, wont trigger the core dump, the source file must be a snapshot for this issue.

Same steps work well on qemu-kvm-rhev-2.10.0-16.el7.x86_64, so the latest version qemu should have already fixed this issue.

Comment 5 Ademar Reis 2018-01-16 11:35:36 UTC
(In reply to Qianqian Zhu from comment #4)
> Reproduced on qemu-kvm-rhev-10:2.9.0-14.el7.x86_64 with steps in comment 0.
> 
> If mirror source file is base, wont trigger the core dump, the source file
> must be a snapshot for this issue.
> 
> Same steps work well on qemu-kvm-rhev-2.10.0-16.el7.x86_64, so the latest
> version qemu should have already fixed this issue.

Indeed, I confirmed the upstream patch pointed in Comment #0 is included in qemu-2.10, changing BZ to MODIFIED.

Comment 8 Qianqian Zhu 2018-01-23 06:23:53 UTC
Move to VERIFIED per comment 4.

Comment 10 errata-xmlrpc 2018-04-11 00:58:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:1104


Note You need to log in before you can comment on or make changes to this bug.