Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1065225

Summary: QMP socket breaks on unexpected close
Product: Red Hat Enterprise Linux 7 Reporter: Amit Shah <amit.shah>
Component: qemu-kvmAssignee: Amit Shah <amit.shah>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 7.0CC: acathrow, amit.shah, bsarathy, chayang, cloud, hhuang, juzhang, konishchev, mazhang, mkenneth, qzhang, sluo, ukar, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-1.5.3-48.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1060024 Environment:
Last Closed: 2014-06-13 12:42:55 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:
Bug Depends On: 1060024    
Bug Blocks:    

Description Amit Shah 2014-02-14 07:23:07 UTC
RHEL7 clone.  QE, please try to reproduce using the script in the original bug.

+++ This bug was initially created as a clone of Bug #1060024 +++

QMP socket breaking script

Description of problem:

If you connect to QMP socket and immediately close it there is a big change to break QMP socket and get hung QEMU process consuming CPU on 100%. 


Version-Release number of selected component:

qemu-kvm-0.12.1.2-2.415.el6_5.3.x86_64


Steps to Reproduce:

1. Run QEMU:
   # /usr/libexec/qemu-kvm -qmp unix:/tmp/qmp,server,nowait

2. Run the attached script (specify path to qemu-kvm sources to include provided example of Python qmp module):
   # python break_qmp.py PATH/TO/QEMU/SOURCES /tmp/qmp 

You will get the following output (after one or several connects using socket you will hand on connection to QMP socket):
> Connecting to QMP...
> OK
> Connecting using socket...
> OK
> Connecting to QMP...

QEMU will burn the CPU.


Additional info:

qemu-kvm-0.12.1.2-2.355.el6_4.9:2.x86_64 doesn't have this bug.

--- Additional comment from Amit Shah on 2014-02-14 12:46:08 IST ---

We need to backport the following commit from upstream.  I've confirmed it fixes the problem.

commit 056f49ff2cf645dc484956b00b65a3aa18a1a9a3
Author: Stratos Psomadakis <psomas>
Date:   Mon Jan 27 12:30:15 2014 +0200

    monitor: Cleanup mon->outbuf on write error
    
    In case monitor_flush() fails to write the contents of mon->outbuf to
    the output device, mon->outbuf is not cleaned up properly. Check the
    return code of the qemu_chr_fe_write() function and cleanup the outbuf
    if it fails.
    
    References: http://lists.nongnu.org/archive/html/qemu-devel/2014-01/msg02890.html

Comment 1 Qunfang Zhang 2014-02-14 08:28:26 UTC
Hi, Amit

On rhel7 host (qemu-kvm-1.5.3-47.el7.x86_64), the python script shows:
# python break_qmp.py  qemu-kvm/ /tmp/qmp 
Connecting to QMP...
OK
Connecting using socket...
OK
Connecting to QMP...
Traceback (most recent call last):
  File "break_qmp.py", line 13, in <module>
    c.connect()
  File "qemu-kvm/QMP/qmp.py", line 76, in connect
    raise QMPCapabilitiesError
qmp.QMPCapabilitiesError

But it works on rhel6 bug 1060024. Could you give a help on the above issue? 


Thanks,
Qunfang

Comment 3 Amit Shah 2014-02-14 08:32:32 UTC
(In reply to Qunfang Zhang from comment #1)
> Hi, Amit
> 
> On rhel7 host (qemu-kvm-1.5.3-47.el7.x86_64), the python script shows:
> # python break_qmp.py  qemu-kvm/ /tmp/qmp 
> Connecting to QMP...
> OK
> Connecting using socket...
> OK
> Connecting to QMP...
> Traceback (most recent call last):
>   File "break_qmp.py", line 13, in <module>
>     c.connect()
>   File "qemu-kvm/QMP/qmp.py", line 76, in connect
>     raise QMPCapabilitiesError
> qmp.QMPCapabilitiesError
> 
> But it works on rhel6 bug 1060024. Could you give a help on the above issue? 

The expected result is thta this traceback doesn't happen, and the connecting...OK sequences keep happening in a loop.  Please try the brew build.

For RHEL6, the python script doesn't quit, but instead just freezes, and if you see 'top' output, qemu uses 100% cpu.  With the fix, RHEL6 too will just continue connecting and disconnecting in a loop.

Comment 4 Sibiao Luo 2014-02-14 08:38:06 UTC
(In reply to Amit Shah from comment #3)
> (In reply to Qunfang Zhang from comment #1)
> > Hi, Amit
> > 
> > On rhel7 host (qemu-kvm-1.5.3-47.el7.x86_64), the python script shows:
> > # python break_qmp.py  qemu-kvm/ /tmp/qmp 
> > Connecting to QMP...
> > OK
> > Connecting using socket...
> > OK
> > Connecting to QMP...
> > Traceback (most recent call last):
> >   File "break_qmp.py", line 13, in <module>
> >     c.connect()
> >   File "qemu-kvm/QMP/qmp.py", line 76, in connect
> >     raise QMPCapabilitiesError
> > qmp.QMPCapabilitiesError
> > 
> > But it works on rhel6 bug 1060024. Could you give a help on the above issue? 
> 
> The expected result is thta this traceback doesn't happen, and the
> connecting...OK sequences keep happening in a loop.  Please try the brew
> build.
> 
> For RHEL6, the python script doesn't quit, but instead just freezes, and if
> you see 'top' output, qemu uses 100% cpu.  With the fix, RHEL6 too will just
> continue connecting and disconnecting in a loop.

Tried your build also meet the same problem as comment #3.
# uname -r && rpm -q qemu-kvm
3.10.0-86.el7.x86_64
qemu-kvm-1.5.3-45.el7.bz1065225.x86_64

# python break_qmp.py /home/qemu-kvm /tmp/qmp 
Connecting to QMP...
OK
Connecting using socket...
OK
Connecting to QMP...
Traceback (most recent call last):
  File "break_qmp.py", line 13, in <module>
    c.connect()
  File "/home/qemu-kvm/QMP/qmp.py", line 87, in connect
    return self.__negotiate_capabilities()
  File "/home/qemu-kvm/QMP/qmp.py", line 59, in __negotiate_capabilities
    raise QMPCapabilitiesError
qmp.QMPCapabilitiesError

Comment 5 Amit Shah 2014-02-14 09:28:41 UTC
(In reply to Sibiao Luo from comment #4)
> Tried your build also meet the same problem as comment #3.

Can you try multiple times?  Do you get the same result each time?

Comment 6 Sibiao Luo 2014-02-14 09:32:23 UTC
(In reply to Amit Shah from comment #5)
> (In reply to Sibiao Luo from comment #4)
> > Tried your build also meet the same problem as comment #3.
> 
> Can you try multiple times?  Do you get the same result each time?
sure, each time can hit it.

Comment 7 Amit Shah 2014-02-14 10:17:04 UTC
Strange.  In my testing, with the patch, I don't see any problems and the script continues to run, whereas without the patch, the script aborts quickly.

Comment 8 Miroslav Rezanina 2014-02-17 09:38:49 UTC
Fix included in qemu-kvm-1.5.3-48.el7

Comment 10 mazhang 2014-02-25 03:12:35 UTC
Reproduce this bug with qemu-kvm-1.5.3-41.el7.x86_64.

[root@m1 ~]# python break_qmp.py /root/source/qemu-kvm /tmp/qmp 
Connecting to QMP...
OK
Connecting using socket...
OK
Connecting to QMP...
Traceback (most recent call last):
  File "break_qmp.py", line 13, in <module>
    c.connect()
  File "/root/source/qemu-kvm/QMP/qmp.py", line 87, in connect
    return self.__negotiate_capabilities()
  File "/root/source/qemu-kvm/QMP/qmp.py", line 59, in __negotiate_capabilities
    raise QMPCapabilitiesError
qmp.QMPCapabilitiesError


Update qemu-kvm and re-test this bug.

Host:
qemu-kvm-debuginfo-1.5.3-49.el7.x86_64
qemu-img-1.5.3-49.el7.x86_64
libvirt-daemon-driver-qemu-1.1.1-22.el7.x86_64
qemu-kvm-common-1.5.3-49.el7.x86_64
qemu-kvm-tools-1.5.3-49.el7.x86_64
qemu-kvm-1.5.3-49.el7.x86_64

Steps:
# /usr/libexec/qemu-kvm -qmp unix:/tmp/qmp,server,nowait
VNC server running on `::1:5900'

Result:
1. Continue output following:
Connecting using socket...
OK
Connecting to QMP...
OK
Connecting using socket...
OK
Connecting to QMP...
OK
Connecting using socket...
OK
Connecting to QMP...
OK
Connecting using socket...
OK

2. qemu-kvm uses 70~80% cpu.

This bug has been fixed.

Comment 12 Ludek Smid 2014-06-13 12:42:55 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.