libvirt/src
Eric Blake 83e4c77547 cgroup: be robust against cgroup movement races
https://bugzilla.redhat.com/show_bug.cgi?id=965169 documents a
problem starting domains when cgroups are enabled; I was able
to reliably reproduce the race about 5% of the time when I added
hooks to domain startup by 3 seconds (as that seemed to be about
the length of time that qemu created and then closed a temporary
thread, probably related to aio handling of initially opening
a disk image).  The problem has existed since we introduced
virCgroupMoveTask in commit 9102829 (v0.10.0).

There are some inherent TOCTTOU races when moving tasks between
kernel cgroups, precisely because threads can be created or
completed in the window between when we read a thread id from the
source and when we write to the destination.  As the goal of
virCgroupMoveTask is merely to move ALL tasks into the new
cgroup, it is sufficient to iterate until no more threads are
being created in the old group, and ignoring any threads that
die before we can move them.

It would be nicer to start the threads in the right cgroup to
begin with, but by default, all child threads are created in
the same cgroup as their parent, and we don't want vcpu child
threads in the emulator cgroup, so I don't see any good way
of avoiding the move.  It would also be nice if the kernel were
to implement something like rename() as a way to atomically move
a group of threads from one cgroup to another, instead of forcing
a window where we have to read and parse the source, then format
and write back into the destination.

* src/util/vircgroup.c (virCgroupAddTaskStrController): Ignore
ESRCH, because a thread ended between read and write attempts.
(virCgroupMoveTask): Loop until all threads have moved.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-21 11:33:56 -06:00
..
conf src/conf: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
cpu
esx esx: Replace almost all esxVI_String_DeepCopyValue vith VIR_STRDUP 2013-05-21 00:19:37 +02:00
hyperv
interface src/interface: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
libxl src/libxl: Remove the whitespace before ';' 2013-05-21 23:41:43 +08:00
locking src/locking: Remove the whitespace before ";" 2013-05-21 23:41:45 +08:00
lxc src/lxc: Remove the whitespace before ";" 2013-05-21 23:41:45 +08:00
network src/network: Remove the whitespace before ';' 2013-05-21 23:41:43 +08:00
node_device src/node_device: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
nwfilter src/nwfilter: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
openvz src/openvz: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
parallels src/parallels: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
phyp src/phyp: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
qemu src/qemu: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
remote src/remote: Remove the whitespace before ";" 2013-05-21 23:41:45 +08:00
rpc src/rpc: Remove the whitespace before ";" 2013-05-21 23:41:45 +08:00
secret
security src/security: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
storage src/storage: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
test src/test: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
uml src/uml: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
util cgroup: be robust against cgroup movement races 2013-05-21 11:33:56 -06:00
vbox src/vbox: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
vmware src/vmware: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
vmx util: move virFile* functions from virutil.c to virfile.c 2013-05-10 13:09:30 -04:00
xen src/xen: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
xenapi
xenxs src/xenxs: Remove the whitespace before ';' 2013-05-21 23:41:44 +08:00
check-driverimpls.pl Skip virNWFilterTechDriver when validating API naming 2013-05-09 17:09:59 +01:00
check-drivername.pl
check-symfile.pl maint: use LGPL correctly 2013-05-20 14:03:48 -06:00
check-symsorting.pl maint: use LGPL correctly 2013-05-20 14:03:48 -06:00
datatypes.c datatypes: fix virGetStoragePool's comment 2013-05-16 16:26:21 +02:00
datatypes.h
driver.c
driver.h maint: use LGPL correctly 2013-05-20 14:03:48 -06:00
dtrace2systemtap.pl
fdstream.c Allow the iohelper path to be customized by test programs 2013-05-10 19:57:18 +01:00
fdstream.h Allow the iohelper path to be customized by test programs 2013-05-10 19:57:18 +01:00
gnutls_1_0_compat.h
internal.h maint: use LGPL correctly 2013-05-20 14:03:48 -06:00
libvirt_atomic.syms
libvirt_daemon.syms
libvirt_driver_modules.syms
libvirt_esx.syms
libvirt_gnutls.syms
libvirt_internal.h
libvirt_libssh2.syms
libvirt_linux.syms
libvirt_lxc.syms
libvirt_openvz.syms
libvirt_private.syms Convert Xen domain lookup driver methods to use virDomainDefPtr 2013-05-21 16:11:38 +01:00
libvirt_probes.d
libvirt_public.syms Add a virGetLastErrorMessage() function 2013-05-10 19:57:18 +01:00
libvirt_qemu_probes.d
libvirt_qemu.syms
libvirt_sasl.syms
libvirt_vmx.syms
libvirt_xenxs.syms
libvirt-lxc.c src/*.[ch]: Remove the whitespace before ";" 2013-05-21 23:41:45 +08:00
libvirt-qemu.c
libvirt.c src/*.[ch]: Remove the whitespace before ";" 2013-05-21 23:41:45 +08:00
libvirt.conf
lxc_protocol-structs
Makefile.am maint: use LGPL correctly 2013-05-20 14:03:48 -06:00
nodeinfo.c src/*.[ch]: Remove the whitespace before ";" 2013-05-21 23:41:45 +08:00
nodeinfo.h
qemu_protocol-structs
README
remote_protocol-structs
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