libvirt/src/qemu
Laine Stump 595e26c086 qemu: drop driver lock while trying to terminate qemu process
This patch is based on an earlier patch by Eric Blake which was never
committed:

https://www.redhat.com/archives/libvir-list/2011-November/msg00243.html

Aside from rebasing, this patch only drops the driver lock once (prior
to the first time the function sleeps), then leaves it dropped until
it returns (Eric's patch would drop and re-acquire the lock around
each call to sleep).

At the time Eric sent his patch, the response (from Dan Berrange) was
that, while it wasn't a good thing to be holding the driver lock while
sleeping, we really need to rethink locking wrt the driver object,
switching to a finer-grained approach that locks individual items
within the driver object separately to allow for greater concurrency.

This is a good plan, and at the time it made sense to not apply the
patch because there was no known bug related to the driver lock being
held in this function.

However, we now know that the length of the wait in qemuProcessKill is
sometimes too short to allow the qemu process to fully flush its disk
cache before SIGKILL is sent, so we need to lengthen the timeout (in
order to improve the situation with management applications until they
can be updated to use the new VIR_DOMAIN_DESTROY_GRACEFUL flag added
in commit 72f8a7f197). But, if we
lengthen the timeout, we also lengthen the amount of time that all
other threads in libvirtd are essentially blocked from doing anything
(since just about everything needs to acquire the driver lock, if only
for long enough to get a pointer to a domain).

The solution is to modify qemuProcessKill to drop the driver lock
while sleeping, as proposed in Eric's patch. Then we can increase the
timeout with a clear conscience, and thus at least lower the chances
that someone running with existing management software will suffer the
consequence's of qemu's disk cache not being flushed.

In the meantime, we still should work on Dan's proposal to make
locking within the driver object more fine grained.

(NB: although I couldn't find any instance where qemuProcessKill() was
called with no jobs active for the domain (or some other guarantee
that the current thread had at least one refcount on the domain
object), this patch still follows Eric's method of temporarily adding
a ref prior to unlocking the domain object, because I couldn't
convince myself 100% that this was the case.)
2012-02-15 13:57:10 -05:00
..
libvirtd_qemu.aug Add two new security label types 2012-02-02 17:44:37 -07:00
MIGRATION.txt qemu: Implement migration job phases 2011-07-27 08:45:09 -06:00
qemu_agent.c qemu: Implement DomainPMSuspendForDuration 2012-02-15 11:45:45 +01:00
qemu_agent.h qemu: Implement DomainPMSuspendForDuration 2012-02-15 11:45:45 +01:00
qemu_bridge_filter.c Remove conn parameter from virReportSystemError 2010-02-09 01:04:54 +01:00
qemu_bridge_filter.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
qemu_capabilities.c qemu: Set capabilities based on supported monitor commands 2012-02-15 11:37:39 +01:00
qemu_capabilities.h qemu: Set capabilities based on supported monitor commands 2012-02-15 11:37:39 +01:00
qemu_cgroup.c qemu: eliminate "Ignoring open failure" when using root-squash NFS 2012-02-03 16:47:43 -05:00
qemu_cgroup.h qemu: Implement period and quota tunable XML configuration and parsing 2011-07-21 17:11:12 +08:00
qemu_command.c Revert "qemu: add ibmvscsi controller model" 2012-02-13 21:37:03 +08:00
qemu_command.h tests: Teach qemuxml2argvtest about spapr-vio addresses 2012-01-13 16:08:22 -07:00
qemu_conf.c Add two new security label types 2012-02-02 17:44:37 -07:00
qemu_conf.h Add two new security label types 2012-02-02 17:44:37 -07:00
qemu_domain.c qemu: fix my typo at commit 74e034964c 2012-01-31 20:21:06 -07:00
qemu_domain.h QEMU guest agent support 2012-01-24 12:19:51 +01:00
qemu_driver.c qemu: drop driver lock while trying to terminate qemu process 2012-02-15 13:57:10 -05:00
qemu_driver.h Split all QEMU process mangement code into separate file 2011-02-17 12:48:55 +00:00
qemu_hostdev.c qemu: Introduce inactive PCI device list 2012-01-17 17:05:32 -07:00
qemu_hostdev.h qemu: Keep list of USB devices attached to domains 2011-12-24 18:12:04 +01:00
qemu_hotplug.c qemu: Refactor qemuMonitorGetBlockInfo 2012-01-27 13:07:56 +01:00
qemu_hotplug.h qemu: Don't drop hostdev config until security label restore 2011-12-16 11:53:03 +01:00
qemu_migration.c qemu: Fix seamless spice migration 2012-02-06 09:41:52 +01:00
qemu_migration.h Clarify semantics of virDomainMigrate2 2011-10-14 22:04:31 +02:00
qemu_monitor_json.c qemu: Set capabilities based on supported monitor commands 2012-02-15 11:37:39 +01:00
qemu_monitor_json.h qemu: Set capabilities based on supported monitor commands 2012-02-15 11:37:39 +01:00
qemu_monitor_text.c qemu: Implement virDomainGetDiskErrors 2012-02-01 10:54:15 +01:00
qemu_monitor_text.h qemu: Refactor qemuMonitorGetBlockInfo 2012-01-27 13:07:56 +01:00
qemu_monitor.c qemu: Set capabilities based on supported monitor commands 2012-02-15 11:37:39 +01:00
qemu_monitor.h qemu: Set capabilities based on supported monitor commands 2012-02-15 11:37:39 +01:00
qemu_process.c qemu: drop driver lock while trying to terminate qemu process 2012-02-15 13:57:10 -05:00
qemu_process.h qemu: drop driver lock while trying to terminate qemu process 2012-02-15 13:57:10 -05:00
qemu.conf Add two new security label types 2012-02-02 17:44:37 -07:00
test_libvirtd_qemu.aug qemu: Support for overriding NOFILE limit 2011-12-22 17:49:04 +01:00
THREADS.txt qemu: fix crash when mixing sync and async monitor jobs 2011-08-01 09:41:57 -06:00