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 1195155 - libvirtd crashes after chardev hotplug crashes qemu
Summary: libvirtd crashes after chardev hotplug crashes qemu
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: x86_64
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 1186765
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-02-23 09:36 UTC by Jan Kurik
Modified: 2015-03-05 14:10 UTC (History)
14 users (show)

Fixed In Version: libvirt-1.2.8-16.el7_1.1
Doc Type: Bug Fix
Doc Text:
When attaching a character device, libvirt did not correctly check the status of the domain after the libvirtd daemon exited the monitor operation. As a consequence, freed data from the domain definition could be accessed even when the domain had terminated unexpectedly, which caused libvirtd to crash as well. Now, libvirtd verifies that the domain is online before accessing its definition, which prevents libvirtd from crashing in the described situation.
Clone Of: 1186765
Environment:
Last Closed: 2015-03-05 14:10:05 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:0625 0 normal SHIPPED_LIVE libvirt bug fix update 2015-03-05 18:40:56 UTC

Description Jan Kurik 2015-02-23 09:36:10 UTC
This bug has been copied from bug #1186765 and has been proposed
to be backported to 7.1 z-stream (EUS).

Comment 8 Luyao Huang 2015-02-26 05:04:28 UTC
Verify this bug with libvirt-1.2.8-16.el7_1.1 and qemu-kvm-rhev-2.1.2-23.el7.x86_64 (because i noticed there is a really libvirtd crashed after qemu crashed when do hotplug chardev, please see bug 1192775):

1.run libvirtd in valgrind:

# valgrind --leak-check=full libvirtd
==30538== Memcheck, a memory error detector
==30538== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==30538== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==30538== Command: libvirtd

2.in another terminal hotplug a virtio console than hotplug a qemu-agent:
# cat lxcconsole.xml 
  <console type='pty'>
      <target type='virtio'/>
    </console>
# cat agent.xml 
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/r6.agent'/>
      <target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
      <alias name='channel1'/>
      <address type='virtio-serial' controller='0' bus='0' port='8'/>
    </channel>

# virsh attach-device test3 lxcconsole.xml 
Device attached successfully

# virsh attach-device test3 agent.xml 
error: Failed to attach device from agent.xml
error: operation failed: domain is no longer running

3. check the first terminal , no invalid read/free/write, and libvirtd still live.
...

Domain test3 started

Device attached successfully

error: Failed to attach device from agent.xml
error: Unable to read from monitor: Connection reset by peer

Domain test3 started

Device attached successfully

error: Failed to attach device from agent.xml
error: operation failed: domain is no longer running

...

4. use a script do this, after 1 hours, libvirtd still live.



Also test this with gdb:

1.# cat lxcconsole.xml
  <console type='pty'>
      <target type='virtio' port='1'/>
    </console>

2. use gdb attach libvirtd set breakpoint at qemuDomainAttachChrDevice

3. # virsh attach-device test3 lxcconsole.xml

4.open another terminal kill qemu (after qemuDomainObjEnterMonitor)

# kill -11 4711

5.
(gdb) 
1532	    qemuDomainObjEnterMonitor(driver, vm);
(gdb) 
1533	    if (qemuMonitorAttachCharDev(priv->mon, charAlias, &chr->source) < 0) {
(gdb) 
1538	    if (devstr && qemuMonitorAddDevice(priv->mon, devstr) < 0) {
(gdb) n
1540	        qemuMonitorDetachCharDev(priv->mon, charAlias);
(gdb) n
1541	        ignore_value(qemuDomainObjExitMonitor(driver, vm));
(gdb) n
1550	    virDomainAuditChardev(vm, NULL, chr, "attach", ret == 0);
(gdb) n
1505	                              virDomainObjPtr vm,
(gdb) c
Continuing.

6. libvirtd not crashed and output a error in client side.

# virsh attach-device test3 lxcconsole.xml
error: Failed to attach device from lxcconsole.xml
error: operation failed: domain is no longer running

Comment 10 errata-xmlrpc 2015-03-05 14:10:05 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://rhn.redhat.com/errata/RHBA-2015-0625.html


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