Libvirt provides a portable, long term stable C API for managing the virtualization technologies provided by many operating systems. It includes support for QEMU, KVM, Xen, LXC, bhyve, Virtuozzo, VMware vCenter and ESX, VMware Desktop, Hyper-V, VirtualBox and the POWER Hypervisor.
Go to file
Laine Stump b8a56f12f5 nwfilter: fix crash during filter define when lxc driver failed startup
The meat of this patch is just moving the calls to
virNWFilterRegisterCallbackDriver from each hypervisor's "register"
function into its "initialize" function. The rest is just code
movement to allow that, and a new virNWFilterUnRegisterCallbackDriver
function to undo what the register function does.

The long explanation:

There is an array in nwfilter called callbackDrvArray that has
pointers to a table of functions for each hypervisor driver that are
called by nwfilter. One of those function pointers is to a function
that will lock the hypervisor driver. Entries are added to the table
by calling each driver's "register" function, which happens quite
early in libvirtd's startup.

Sometime later, each driver's "initialize" function is called. This
function allocates a driver object and stores a pointer to it in a
static variable that was previously initialized to NULL. (and here's
the important part...) If the "initialize" function fails, the driver
object is freed, and that pointer set back to NULL (but the entry in
nwfilter's callbackDrvArray is still there).

When the "lock the driver" function mentioned above is called, it
assumes that the driver was successfully loaded, so it blindly tries
to call virMutexLock on "driver->lock".

BUT, if the initialize never happened, or if it failed, "driver" is
NULL. And it just happens that "lock" is always the first field in
driver so it is also NULL.

Boom.

To fix this, the call to virNWFilterRegisterCallbackDriver for each
driver shouldn't be called until the end of its (*already guaranteed
successful*) "initialize" function, not during its "register" function
(which is currently the case). This implies that there should also be
a virNWFilterUnregisterCallbackDriver() function that is called in a
driver's "shutdown" function (although in practice, that function is
currently never called).
2012-08-09 23:28:00 -04:00
.gnulib@dbd914496c build: update to latest gnulib, for secure tarball 2012-07-26 07:50:59 -06:00
build-aux Remove tabs from all perl files & enforce this 2012-07-30 13:09:57 +01:00
daemon Turn virNetServer* into virObject instances 2012-08-07 11:47:55 +01:00
docs Added timestamps to storage volumes 2012-08-02 17:14:17 -06:00
examples examples: Update strings for event details 2012-08-09 15:34:47 +02:00
gnulib build: fix fresh checkout on RHEL5 2012-04-19 17:11:43 -06:00
include parallels: add driver skeleton 2012-08-01 11:44:26 +08:00
m4 Added timestamps to storage volumes 2012-08-02 17:14:17 -06:00
po esx: Implement network driver 2012-08-09 22:31:47 +02:00
python python: Don't generate bodies for close callback functions 2012-07-30 15:38:07 +02:00
src nwfilter: fix crash during filter define when lxc driver failed startup 2012-08-09 23:28:00 -04:00
tests build: fix PROBE() usage of intptr_t 2012-08-09 15:40:42 -06:00
tools virsh: Use vshPrint instead of printf 2012-08-06 12:35:42 +08:00
.dir-locals.el maint: let emacs avoid tabs in rng files 2011-08-13 08:56:26 -06:00
.gitignore Rewrite virAtomic APIs using GLib's atomic ops code 2012-08-02 11:50:59 +01:00
.gitmodules
.mailmap build: fix author of previous commit 2012-08-09 15:39:34 -06:00
AUTHORS Fix errno check, prevent spurious errors under heavy load 2012-08-08 15:50:58 -06:00
autobuild.sh Switch automated builds to use Mingw64 toolchain instead of Mingw32 2012-06-25 10:41:10 +01:00
autogen.sh Allow NOCONFIGURE=1 to make autogen.sh skip ./configure 2012-06-25 10:41:10 +01:00
bootstrap maint: regenerate bootstrap 2012-07-27 09:34:04 -06:00
bootstrap.conf Added timestamps to storage volumes 2012-08-02 17:14:17 -06:00
cfg.mk Turn virNetClient* into virObject instances 2012-08-07 11:47:55 +01:00
ChangeLog-old virterror.c: Fix several spelling mistakes 2012-02-03 11:32:51 -07:00
configure.ac build: add stubs so mdns code can be unconditionally compiled 2012-08-02 13:35:21 -06:00
COPYING.LIB
HACKING docs: Improve patch submission guidelines 2012-07-16 11:05:12 +02:00
libvirt.pc.in build: silence warning from autoconf 2012-05-30 09:22:02 -06:00
libvirt.spec.in spec: Remove extra () with return statement 2012-08-01 13:09:57 +02:00
Makefile.am Switch automated builds to use Mingw64 toolchain instead of Mingw32 2012-06-25 10:41:10 +01:00
Makefile.nonreentrant Ban use of all inet_* functions 2010-10-22 11:59:23 +01:00
mingw-libvirt.spec.in parallels: add driver skeleton 2012-08-01 11:44:26 +08:00
README
README-hacking maint: relax git minimum version 2010-02-24 14:29:27 -05:00
TODO Update todo list file to point at bugzilla/website 2010-10-13 16:45:26 +01:00

         LibVirt : simple API for virtualization

  Libvirt is a C toolkit to interact with the virtualization capabilities
of recent versions of Linux (and other OSes). It is free software
available under the GNU Lesser General Public License. Virtualization of
the Linux Operating System means the ability to run multiple instances of
Operating Systems concurrently on a single hardware system where the basic
resources are driven by a Linux instance. The library aim at providing
long term stable C API initially for the Xen paravirtualization but
should be able to integrate other virtualization mechanisms if needed.

Daniel Veillard <veillard@redhat.com>