libvirt/src
Peter Krempa 8dce8b828c qemu: Fix deadlock when qemuDomainOpenConsole cleans up a connection
The new safe console handling introduced a possibility to deadlock the
qemu driver when a new console connection forcibly disconnects a
previous console stream that belongs to an already closed connection.

The virStreamFree function calls subsequently a the virReleaseConnect
function that tries to lock the driver while discarding the connection,
but the driver was already locked in qemuDomainOpenConsole.

Backtrace of the deadlocked thread:
0  0x00007f66e5aa7f14 in __lll_lock_wait () from /lib64/libpthread.so.0
1  0x00007f66e5aa3411 in _L_lock_500 () from /lib64/libpthread.so.0
2  0x00007f66e5aa322a in pthread_mutex_lock () from/lib64/libpthread.so.0
3  0x0000000000462bbd in qemudClose ()
4  0x00007f66e6e178eb in virReleaseConnect () from/usr/lib64/libvirt.so.0
5  0x00007f66e6e19c8c in virUnrefStream () from /usr/lib64/libvirt.so.0
6  0x00007f66e6e3d1de in virStreamFree () from /usr/lib64/libvirt.so.0
7  0x00007f66e6e09a5d in virConsoleHashEntryFree () from/usr/lib64/libvirt.so.0
8  0x00007f66e6db7282 in virHashRemoveEntry () from/usr/lib64/libvirt.so.0
9  0x00007f66e6e09c4e in virConsoleOpen () from /usr/lib64/libvirt.so.0
10 0x00000000004526e9 in qemuDomainOpenConsole ()
11 0x00007f66e6e421f1 in virDomainOpenConsole () from/usr/lib64/libvirt.so.0
12 0x00000000004361e4 in remoteDispatchDomainOpenConsoleHelper ()
13 0x00007f66e6e80375 in virNetServerProgramDispatch () from/usr/lib64/libvirt.so.0
14 0x00007f66e6e7ae11 in virNetServerHandleJob () from/usr/lib64/libvirt.so.0
15 0x00007f66e6da897d in virThreadPoolWorker () from/usr/lib64/libvirt.so.0
16 0x00007f66e6da7ff6 in virThreadHelper () from/usr/lib64/libvirt.so.0
17 0x00007f66e5aa0c5c in start_thread () from /lib64/libpthread.so.0
18 0x00007f66e57e7fcd in clone () from /lib64/libc.so.6

* src/qemu/qemu_driver.c: qemuDomainOpenConsole()
        -- unlock the qemu driver right after acquiring the domain
        object
(cherry picked from commit 3d3de46a67)
2012-04-16 12:41:28 +01:00
..
conf conf: Plug memory leaks on virDomainDiskDefParseXML 2012-04-16 12:39:38 +01:00
cpu Cleanup for a return statement in source files 2012-03-26 14:45:22 -06:00
esx Consistent style for usage of sizeof operator 2012-03-30 11:47:24 +01:00
hyperv Consistent style for usage of sizeof operator 2012-03-30 11:47:24 +01:00
interface Cleanup for a return statement in source files 2012-03-26 14:45:22 -06:00
libxl Consistent style for usage of sizeof operator 2012-03-30 11:47:24 +01:00
locking sanlock: Use STREQ_NULLABLE instead of STREQ on strings that may be null 2012-03-08 11:49:32 +01:00
lxc Consistent style for usage of sizeof operator 2012-03-30 11:47:24 +01:00
network Attach vm-id to Open vSwitch interfaces. 2012-03-08 14:44:15 -05:00
node_device build: avoid s390 compiler warnings 2012-04-16 12:41:10 +01:00
nwfilter Cleanup for a return statement in source files 2012-03-26 14:45:22 -06:00
openvz openvz: support vzctl 3.1 2012-04-16 12:39:32 +01:00
phyp Lookup auth credentials in config file before prompting 2012-03-23 13:24:07 +00:00
qemu qemu: Fix deadlock when qemuDomainOpenConsole cleans up a connection 2012-04-16 12:41:28 +01:00
remote Fix typo in previous patch 2012-03-30 12:44:28 +01:00
rpc Fix comment about GNUTLS initialization/cleanup 2012-04-16 12:40:48 +01:00
secret
security Consistent style for usage of sizeof operator 2012-03-30 11:47:24 +01:00
storage Consistent style for usage of sizeof operator 2012-03-30 11:47:24 +01:00
test Cleanup for a return statement in source files 2012-03-26 14:45:22 -06:00
uml UML: fix iteration over consoles 2012-04-16 12:40:28 +01:00
util snapshot: fix memory leak on error 2012-04-16 12:40:24 +01:00
vbox Consistent style for usage of sizeof operator 2012-03-30 11:47:24 +01:00
vmware build: use correct type for pid and similar types 2012-03-02 06:57:43 -07:00
vmx Centralize error reporting for URI parsing/formatting problems 2012-03-23 12:59:21 +00:00
xen Consistent style for usage of sizeof operator 2012-03-30 11:47:24 +01:00
xenapi Consistent style for usage of sizeof operator 2012-03-30 11:47:24 +01:00
xenxs xen config: No vfb in HVM guest configuration 2012-04-16 12:40:13 +01:00
datatypes.c Cleanup for a return statement in source files 2012-03-26 14:45:22 -06:00
datatypes.h Fixed URI parsing 2012-02-24 16:49:21 -07:00
driver.c
driver.h xml: use long long internally, to centralize overflow checks 2012-03-07 18:24:43 -07:00
dtrace2systemtap.pl
fdstream.c fdstream: Add internal callback on stream close 2012-02-27 15:05:17 +01:00
fdstream.h fdstream: Add internal callback on stream close 2012-02-27 15:05:17 +01:00
gnutls_1_0_compat.h
internal.h Consistent style for usage of sizeof operator 2012-03-30 11:47:24 +01:00
libvirt_daemon.syms
libvirt_dbus.syms
libvirt_driver_modules.syms
libvirt_internal.h
libvirt_linux.syms Add linuxNodeInfoCPUPopulate to src/libvirt_linux.syms 2012-04-16 12:39:08 +01:00
libvirt_network.syms
libvirt_nwfilter.syms
libvirt_private.syms Support clock=variable relative to localtime 2012-04-02 09:08:31 -06:00
libvirt_public.syms Introduce virDomainPMWakeup API 2012-02-27 11:43:59 +01:00
libvirt_qemu.syms
libvirt_sasl.syms
libvirt_vmx.syms
libvirt_xenxs.syms
libvirt-qemu.c build: use correct type for pid and similar types 2012-03-02 06:57:43 -07:00
libvirt.c build: fix mingw ssize_t, syntax check 2012-03-30 11:10:54 -06:00
libvirt.conf Allow overriding default URI in config file 2012-03-15 11:20:17 +00:00
Makefile.am Add helper API for finding auth file path 2012-03-23 13:24:07 +00:00
nodeinfo.c build: avoid s390 compiler warnings 2012-04-16 12:41:10 +01:00
nodeinfo.h add nodeGetCPUmap() for getting available CPU IDs in a cpumap. 2012-03-06 21:54:48 -07:00
probes.d build: use correct type for pid and similar types 2012-03-02 06:57:43 -07:00
qemu_protocol-structs build: use correct type for pid and similar types 2012-03-02 06:57:43 -07:00
README
remote_protocol-structs build: fix incorrect enum declaration 2012-03-23 14:29:00 -06:00
virkeepaliveprotocol-structs
virnetprotocol-structs

       libvirt library code README
       ===========================

The directory provides the bulk of the libvirt codebase. Everything
except for the libvirtd daemon and client tools. The build uses a
large number of libtool convenience libraries - one for each child
directory, and then links them together for the final libvirt.so,
although some bits get linked directly to libvirtd daemon instead.

The files directly in this directory are supporting the public API
entry points & data structures.

There are two core shared modules to be aware of:

 * util/  - a collection of shared APIs that can be used by any
            code. This directory is always in the include path
            for all things built

 * conf/  - APIs for parsing / manipulating all the official XML
            files used by the public API. This directory is only
            in the include path for driver implementation modules

 * vmx/   - VMware VMX config handling (used by esx/ and vmware/)


Then there are the hypervisor implementations:

 * esx/          - VMware ESX and GSX support using vSphere API over SOAP
 * hyperv/       - Microsoft Hyper-V support using WinRM
 * lxc/          - Linux Native Containers
 * openvz/       - OpenVZ containers using cli tools
 * phyp/         - IBM Power Hypervisor using CLI tools over SSH
 * qemu/         - QEMU / KVM using qemu CLI/monitor
 * remote/       - Generic libvirt native RPC client
 * test/         - A "mock" driver for testing
 * uml/          - User Mode Linux
 * vbox/         - Virtual Box using native API
 * vmware/       - VMware Workstation and Player using the vmrun tool
 * xen/          - Xen using hypercalls, XenD SEXPR & XenStore
 * xenapi/       - Xen using libxenserver


Finally some secondary drivers that are shared for several HVs.
Currently these are used by LXC, OpenVZ, QEMU, UML and Xen drivers.
The ESX, Hyper-V, Power Hypervisor, Remote, Test & VirtualBox drivers all
implement the secondary drivers directly

 * cpu/          - CPU feature management
 * interface/    - Host network interface management
 * network/      - Virtual NAT networking
 * nwfilter/     - Network traffic filtering rules
 * node_device/  - Host device enumeration
 * secret/       - Secret management
 * security/     - Mandatory access control drivers
 * storage/      - Storage management drivers


Since both the hypervisor and secondary drivers can be built as
dlopen()able modules, it is *FORBIDDEN* to have build dependencies
between these directories. Drivers are only allowed to depend on
the public API, and the internal APIs in the util/ and conf/
directories