]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: Fix deadlock across fork() in QEMU driver
authorMarc Hartmayer <mhartmay@linux.vnet.ibm.com>
Tue, 21 Feb 2017 12:11:00 +0000 (13:11 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 21 Feb 2017 14:47:32 +0000 (15:47 +0100)
commite22de286b11350ab03064ae8a9387fd906fef3df
treec9d02c489ef13faf69e7b94e01e21aebfb341a9a
parent6304277534b3bd569861ae64f522898b66417adc
qemu: Fix deadlock across fork() in QEMU driver

The functions in virCommand() after fork() must be careful with regard
to accessing any mutexes that may have been locked by other threads in
the parent process. It is possible that another thread in the parent
process holds the lock for the virQEMUDriver while fork() is called.
This leads to a deadlock in the child process when
'virQEMUDriverGetConfig(driver)' is called and therefore the handshake
never completes between the child and the parent process. Ultimately
the virDomainObjectPtr will never be unlocked.

It gets much worse if the other thread of the parent process, that
holds the lock for the virQEMUDriver, tries to lock the already locked
virDomainObject. This leads to a completely unresponsive libvirtd.

It's possible to reproduce this case with calling 'virsh start XXX'
and 'virsh managedsave XXX' in a tight loop for multiple domains.

This commit fixes the deadlock in the same way as it is described in
commit 61b52d2e3813cc8c9ff3ab67f232bd0c65f7318d.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/qemu/qemu_process.c