Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 1195155 - libvirtd crashes after chardev hotplug crashes qemu
libvirtd crashes after chardev hotplug crashes qemu
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.1
x86_64 Linux
high Severity high
: rc
: ---
Assigned To: Ján Tomko
Virtualization Bugs
: Upstream, ZStream
Depends On: 1186765
Blocks:
  Show dependency treegraph
 
Reported: 2015-02-23 04:36 EST by Jan Kurik
Modified: 2015-03-05 09:10 EST (History)
14 users (show)

See Also:
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.
Story Points: ---
Clone Of: 1186765
Environment:
Last Closed: 2015-03-05 09:10:05 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:0625 normal SHIPPED_LIVE libvirt bug fix update 2015-03-05 13:40:56 EST

  None (edit)
Description Jan Kurik 2015-02-23 04:36:10 EST
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 00:04:28 EST
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 09:10:05 EST
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.