Bug 1195155 - libvirtd crashes after chardev hotplug crashes qemu
Summary: libvirtd crashes after chardev hotplug crashes qemu
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: x86_64
OS: Linux
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
Depends On: 1186765
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
Last Closed: 2015-03-05 14:10:05 UTC
Target Upstream Version:

Attachments (Terms of Use)

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'/>
# 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'/>

# 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'/>

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

1532	    qemuDomainObjEnterMonitor(driver, vm);
1533	    if (qemuMonitorAttachCharDev(priv->mon, charAlias, &chr->source) < 0) {
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

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.


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