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 1378401 - qemu-attach should not hang when execute the 2nd time
Summary: qemu-attach should not hang when execute the 2nd time
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Jing Qi
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-22 10:54 UTC by yalzhang@redhat.com
Modified: 2017-08-01 23:57 UTC (History)
6 users (show)

Fixed In Version: libvirt-2.5.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-01 17:16:43 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2017:1846 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2017-08-01 18:02:50 UTC

Description yalzhang@redhat.com 2016-09-22 10:54:58 UTC
Description of problem:
qemu-attach will fail with 'JSON monitor is required' the 1st time and hang when execute the 2nd time

Version-Release number of selected component (if applicable):
libvirt-2.0.0-10.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. # qemu-img create /var/lib/libvirt/images/foo.img 1G

2. # /usr/libexec/qemu-kvm -cdrom /var/lib/libvirt/images/foo.img -monitor unix:/tmp/demo,server,nowait -name foo -uuid cece4f9f-dff0-575d-0e8e-01fe380f12ea &
[1] 7044
  # VNC server running on '::1;5900'

3.qemu-attach failed
# virsh qemu-attach 7044
error: Failed to attach to pid 7044
error: Operation not supported: JSON monitor is required
# virsh list --all
 Id    Name                           State
----------------------------------------------------

===> not connected

4. Run the qemu-attach command the 2nd time, it will hang. On another terminal, you will found the vm is already connected with "shut off" state
# virsh qemu-attach 7044  

===> it will hang
# virsh list
 Id    Name                           State
----------------------------------------------------
 4     foo                            shut off
# ps -aux | grep qemu-kvm
root      7044 18.4  0.5 591372 39536 pts/1    Sl   12:34   0:12 /usr/libexec/qemu-kvm -cdrom /var/lib/libvirt/images/foo.img -monitor unix:/tmp/demo,server,nowait -name foo -uuid cece4f9f-dff0-575d-0e8e-01fe380f12ea

5. Run the qemu-attach the 3rd time, it says the domain is already active
# virsh qemu-attach 7044
error: Failed to attach to pid 7044
error: Requested operation is not valid: domain 'foo' is already active

Actual results:
qemu-attach will fail with 'Json monitor required' when executed the 1st time and hang when executed the 2nd time.

Expected results:
The qemu-attach should not hang.

Additional info:
Downgrade to libvirt-2.0.0-6.el7.x86_64 on the same host, it works well.
# virsh qemu-attach 6636
Domain foo attached to pid 6636

Comment 2 Peter Krempa 2016-09-30 07:41:26 UTC
"JSON monitor is required" originates from my recent VCPU patches, which incorrectly require the JSON monitor in case of attaching to a qemu process.

Libvirt then doesn't properly clean up.

Comment 3 Peter Krempa 2016-10-05 06:59:48 UTC
commit 2c739866df5a820b2db280b36cd8b6fe00cfba58
Author: Peter Krempa <pkrempa>
Date:   Mon Oct 3 13:11:47 2016 +0200

    qemu: attach: Close monitor socket on connection failure
    
    If attaching to a qemu process fails after opening the monitor socket
    libvirt does not clean up the monitor. As the monitor also holds a
    reference to the domain object the qemu attach API basically leaks it.
    
    QEMU also does not interact on a second monitor connection and thus a
    further attempt to attach to it would lock up.
    
    Prevent libvirt from leaking the monitor by explicitly closing it.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1378401

commit 62135ff692044a0a7cac5ee91f2cb42463550052
Author: Peter Krempa <pkrempa>
Date:   Fri Sep 30 12:45:59 2016 +0200

    qemu: Don't strictly require JSON monitor for vCPU detection
    
    Attaching to a existing qemu process allows to get us into a situation
    when qemu is new enough to have JSON monitor and new vCPU hotplug but
    the json monitor is not used. The vCPU detection code would require it
    though. This broke attaching to qemu processes.
    
    Make the condition less strict and just skip the vCPU hotplug detection
    if JSON monitor is not available.
    
    Resolves one of the symptoms in:
    https://bugzilla.redhat.com/show_bug.cgi?id=1378401

Comment 5 Jing Qi 2017-01-03 05:22:05 UTC
Test passed with version libvirt-2.5.0-1.el7.x86_64 & qemu-kvm-rhev-2.6.0-28.el7.x86-64.

1. # qemu-img create /var/lib/libvirt/images/foo.img 1G

2. # /usr/libexec/qemu-kvm -cdrom /var/lib/libvirt/images/foo.img -monitor unix:/tmp/demo,server,nowait -name foo
 VNC server running on '::1;5900'

3.qemu-attach succeeded.
# virsh qemu-attach 5975
Domain foo attached to pid 5975

4. virsh list
Id   Name     State
----------------------------
1    foo      running

Comment 6 errata-xmlrpc 2017-08-01 17:16:43 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/RHEA-2017:1846

Comment 7 errata-xmlrpc 2017-08-01 23:57:38 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/RHEA-2017:1846


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