Bug 1451849

Summary: qemu-img convert crashes on error
Product: Red Hat Enterprise Linux 7 Reporter: Kevin Wolf <kwolf>
Component: qemu-kvm-rhevAssignee: Kevin Wolf <kwolf>
Status: CLOSED ERRATA QA Contact: Ping Li <pingl>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: aliang, chayang, coli, juzhang, knoel, michen, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-rhev-2.9.0-7.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-02 04:38:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Kevin Wolf 2017-05-17 16:08:42 UTC
When an error occurs during qemu-img convert, several use-after-free errors can
happen which may cause qemu to crash. The problem has been fixed upstream with
commit b91127edd ('qemu-img: wait for convert coroutines to complete') and is
proposed for qemu-stable.

In my own testing, I could not quickly reproduce actual crashes, but using
valgrind I could see errors without the patch. For reproduction, I used a
blkdebug configuration file that would inject a write error after a while:

[inject-error]
event = "write_aio"
sector = "819200"
once = "on"

The test run was performed with a command line like this (note that using
blkdebug as the target requires that an image of the correct size is manually
created and -n is used):

$ valgrind qemu-img convert -npWO qcow2 $SOURCE blkdebug:/tmp/blkdebug.conf:/tmp/test.qcow2

Expected result:
No valgrind errors are reported:
==2576== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Actual result:
Valgrind does report errors:
==2657== ERROR SUMMARY: 8 errors from 2 contexts (suppressed: 0 from 0)

Comment 1 Miroslav Rezanina 2017-05-30 15:03:39 UTC
Fix included in qemu-kvm-rhev-2.9.0-7.el7

Comment 2 Ping Li 2017-06-01 14:03:11 UTC
Test steps:
#wget http://www.valgrind.org/downloads/valgrind-3.12.0.tar.bz2
#tar -jxvf valgrind-3.12.0.tar.bz2
#cd valgrind-3.12.0
#./autogen.sh
#./configure
#make && make install
# cat >> /home/blkdebug.cfg << eof
[inject-error]
event = "write_aio"
sector = "819200"
once = "on"
eof
#qemu-img create -f qcow2 /home/source.qcow2 1G
#qemu-img create -f qcow2 /home/target.qcow2 1G
#qemu-io -c 'write 0 1G' source.qcow2
#valgrind qemu-img convert -npWO qcow2 source.qcow2 blkdebug:/home/blkdebug.cfg:/home/target.qcow2


Reproduced the issue with below packages:
kernel-3.10.0-669.el7
qemu-kvm-rhev-2.9.0-5.el7
test result:
==4108== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

Verified the issue with below packages:
kernel-3.10.0-675.el7
qemu-kvm-rhev-2.9.0-7.el7
test result:
==28177== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Comment 3 CongLi 2017-06-02 02:08:18 UTC
Based on comment 2, set this bug to 'VERIFIED'.

Thanks.

Comment 5 errata-xmlrpc 2017-08-02 04:38:29 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-2017:2392