Bug 1122992

Summary: Full mirroring with smaller backing file causes qemu to hang
Product: Red Hat Enterprise Linux 6 Reporter: Kevin Wolf <kwolf>
Component: qemu-kvmAssignee: Kevin Wolf <kwolf>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.5CC: bsarathy, chayang, juli, juzhang, michen, mkenneth, qzhang, rbalakri, shu, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.436.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-14 07:02:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Kevin Wolf 2014-07-24 14:30:22 UTC
The following sequence of commands makes qemu hang in an endless loop. Ctrl-C
doesn't help any more, I needed SIGKILL to get rid of the qemu process.

$ qemu-img create -f qcow2 /tmp/backing.qcow2 4M
Formatting '/tmp/backing.qcow2', fmt=qcow2 size=4194304 encryption=off cluster_size=65536
$ qemu-img create -f qcow2 -b /tmp/backing.qcow2 /tmp/test.qcow2 16M
Formatting '/tmp/test.qcow2', fmt=qcow2 size=16777216 backing_file='/tmp/backing.qcow2' encryption=off cluster_size=65536
$ x86_64-softmmu/qemu-system-x86_64 -hda /tmp/test.qcow2 -monitor stdio
QEMU 0.12.1 monitor - type 'help' for more information
(qemu) __com.redhat_drive-mirror -f ide0-hd0 /tmp/copy.qcow2
Formatting '/tmp/copy.qcow2', fmt=qcow2 size=16777216 encryption=off cluster_size=65536
[hangs]

The hang occurs in mirror_run(): is_any_allocated() returns with n = 0 after
the end of the backing file, so the dirty bitmap initialisation doesn't make any
progress.

Found while backporting qemu-iotests case 041 to RHEL 6.

Comment 2 Jun Li 2014-07-28 09:54:59 UTC
Reproduce:
Version of the components:
qemu-kvm-rhev-0.12.1.2-2.431.el6.x86_64

Steps:
1,
# qemu-img create -f qcow2 /tmp/backing.qcow2 4M
Formatting '/tmp/backing.qcow2', fmt=qcow2 size=4194304 encryption=off cluster_size=65536 
2,
# qemu-img create -f qcow2 -b /tmp/backing.qcow2 /tmp/test.qcow2 16M
Formatting '/tmp/test.qcow2', fmt=qcow2 size=16777216 backing_file='/tmp/backing.qcow2' encryption=off cluster_size=65536 
3,
# /usr/libexec/qemu-kvm -hda /tmp/test.qcow2 -monitor stdio 
(qemu) __com.redhat_drive-mirror -f ide0-hd0 /tmp/copy.qcow2
Formatting '/tmp/copy.qcow2', fmt=qcow2 size=16777216 encryption=off cluster_size=65536 

Results:
After step3, qemu-kvm hang.

# gdb -p `pidof qemu-kvm`
(gdb) bt
#0  0x00007f1e36f44891 in qemu_in_coroutine ()
    at /usr/src/debug/qemu-kvm-0.12.1.2/coroutine-ucontext.c:227
#1  0x00007f1e36f44570 in qemu_co_mutex_unlock (mutex=0x7f1e38c0da88)
    at /usr/src/debug/qemu-kvm-0.12.1.2/qemu-coroutine-lock.c:126
#2  0x00007f1e36f56c6d in qcow2_co_get_block_status (bs=<value optimized out>, 
    sector_num=8192, nb_sectors=<value optimized out>, pnum=0x7f1e36e40f88)
    at /usr/src/debug/qemu-kvm-0.12.1.2/block/qcow2.c:485
#3  0x00007f1e36f386e4 in bdrv_co_get_block_status (
    opaque=<value optimized out>)
    at /usr/src/debug/qemu-kvm-0.12.1.2/block.c:2815
#4  bdrv_get_block_status_co_entry (opaque=<value optimized out>)
    at /usr/src/debug/qemu-kvm-0.12.1.2/block.c:2845
#5  0x00007f1e36f39778 in bdrv_get_block_status (bs=<value optimized out>, 
    sector_num=<value optimized out>, nb_sectors=<value optimized out>, 
    pnum=<value optimized out>)
    at /usr/src/debug/qemu-kvm-0.12.1.2/block.c:2869
#6  0x00007f1e36f39799 in bdrv_is_allocated (bs=<value optimized out>, 
    sector_num=<value optimized out>, nb_sectors=<value optimized out>, 
    pnum=<value optimized out>)
    at /usr/src/debug/qemu-kvm-0.12.1.2/block.c:2883
#7  0x00007f1e36f66e0b in is_any_allocated (opaque=0x7f1e38f490a0)
    at /usr/src/debug/qemu-kvm-0.12.1.2/block/mirror.c:88
#8  mirror_run (opaque=0x7f1e38f490a0)
---Type <return> to continue, or q <return> to quit---
    at /usr/src/debug/qemu-kvm-0.12.1.2/block/mirror.c:133
#9  0x00007f1e36f4498b in coroutine_trampoline (i0=<value optimized out>, 
    i1=<value optimized out>)
    at /usr/src/debug/qemu-kvm-0.12.1.2/coroutine-ucontext.c:129
#10 0x00007f1e33997be0 in ?? () from /lib64/libc.so.6
#11 0x00007fffa77d7660 in ?? ()
#12 0x0000000000000000 in ?? ()

Comment 3 Jeff Nelson 2014-08-07 19:49:37 UTC
Fix included in qemu-kvm-0.12.1.2-2.436.el6

Comment 5 Jun Li 2014-08-12 05:24:01 UTC
Verify this bz as followings:
Version of the components:
qemu-kvm-rhev-0.12.1.2-2.436.el6.x86_64
Steps:
1,
# qemu-img create -f qcow2 /tmp/backing.qcow2 4M
Formatting '/tmp/backing.qcow2', fmt=qcow2 size=4194304 encryption=off cluster_size=65536 
2,
# qemu-img create -f qcow2 -b /tmp/backing.qcow2 /tmp/test.qcow2 16M
Formatting '/tmp/test.qcow2', fmt=qcow2 size=16777216 backing_file='/tmp/backing.qcow2' encryption=off cluster_size=65536 
3,
# /usr/libexec/qemu-kvm -hda /tmp/test.qcow2 -monitor stdio 
VNC server running on `::1:5900'
QEMU 0.12.1 monitor - type 'help' for more information
(qemu) __com.redhat_drive-mirror -f ide0-hd0 /tmp/copy.qcow2
Formatting '/tmp/copy.qcow2', fmt=qcow2 size=16777216 encryption=off cluster_size=65536 
(qemu) info status 
VM status: running

Results:
After step3, qemu-kvm works well.
(qemu) info status 
VM status: running

Based on comment #2 and above show, this bz has been verified.

Comment 7 errata-xmlrpc 2014-10-14 07:02:58 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.

http://rhn.redhat.com/errata/RHBA-2014-1490.html