Go to file
Marek Marczykowski-Górecki 2c1629da04
vm: call after-shutdown cleanup also from vm.kill and vm.shutdown
Cleaning up after domain shutdown (domain-stopped and domain-shutdown
events) relies on libvirt events which may be unreliable in some cases
(events may be processed with some delay, of if libvirt was restarted in
the meantime, may not happen at all). So, instead of ensuring only
proper ordering between shutdown cleanup and next startup, also trigger
the cleanup when we know for sure domain isn't running:
 - at vm.kill() - after libvirt confirms domain was destroyed
 - at vm.shutdown(wait=True) - after successful shutdown
 - at vm.remove_from_disk() - after ensuring it isn't running but just
 before actually removing it

This fixes various race conditions:
 - qvm-kill && qvm-remove: remove could happen before shutdown cleanup
 was done and storage driver would be confused about that
 - qvm-shutdown --wait && qvm-clone: clone could happen before new content was
 commited to the original volume, making the copy of previous VM state
(and probably more)

Previously it wasn't such a big issue on default configuration, because
LVM driver was fully synchronous, effectively blocking the whole qubesd
for the time the cleanup happened.

To avoid code duplication, factor out _ensure_shutdown_handled function
calling actual cleanup (and possibly canceling one called with libvirt
event). Note that now, "Duplicated stopped event from libvirt received!"
warning may happen in normal circumstances, not only because of some
bug.

It is very important that post-shutdown cleanup happen when domain is
not running. To ensure that, take startup_lock and under it 1) ensure
its halted and only then 2) execute the cleanup. This isn't necessary
when removing it from disk, because its already removed from the
collection at that time, which also avoids other calls to it (see also
"vm/dispvm: fix DispVM cleanup" commit).
Actually, taking the startup_lock in remove_from_disk function would
cause a deadlock in DispVM auto cleanup code:
 - vm.kill (or other trigger for the cleanup)
   - vm.startup_lock acquire   <====
     - vm._ensure_shutdown_handled
       - domain-shutdown event
         - vm._auto_cleanup (in DispVM class)
           - vm.remove_from_disk
             - cannot take vm.startup_lock again
2018-10-26 23:54:08 +02:00
ci Fix issues found by pylint 2.0 2018-07-15 23:51:15 +02:00
contrib events: add support for async event handlers 2017-07-04 13:04:22 +02:00
doc doc: document features, qvm-features-request and services 2018-10-23 16:53:35 +02:00
etc Replace pool config parsing logic 2016-04-25 07:16:37 +02:00
linux Handle qubes.skip_autostart option on kernel command line 2018-09-16 05:22:30 +02:00
qubes vm: call after-shutdown cleanup also from vm.kill and vm.shutdown 2018-10-26 23:54:08 +02:00
qubes-rpc Add qubes.GetDate proxy service 2018-03-03 03:50:58 +01:00
qubes-rpc-policy comments 2018-08-08 09:38:45 +00:00
qubespolicy qubespolicy: ease testing by calling str(target) only once 2018-09-01 19:51:03 +02:00
qvm-tools add missing /sbin/ to hwclock call (so it will work as cronjob) 2018-09-10 17:24:35 +02:00
relaxng Change license to LGPL v2.1+ 2017-10-12 00:11:50 +02:00
rpm_spec tests: migrate qvm-block tests to core3 2018-10-10 00:44:15 +02:00
templates Switch to new PVH config variant 2018-01-24 02:48:00 +01:00
test-packages Fix starting VM with kernel=None 2017-12-14 23:26:52 +01:00
tests tests: migrate qvm-block tests to core3 2018-10-10 00:44:15 +02:00
.coveragerc add config for coverage.py 2015-10-12 16:40:46 +02:00
.gitignore run-tests: Script for running tests in repo 2016-04-20 13:54:56 +02:00
.pylintrc Remove obsolete options from .pylintrc 2016-07-21 12:21:00 +02:00
.travis.yml travis: flag codecov.io uploads with 'unittests' flag 2017-06-02 12:31:07 +02:00
installer.wxs windows/installer: configurable destination directory 2014-11-19 12:50:31 +01:00
LICENSE Change license to LGPL v2.1+ 2017-10-12 00:11:50 +02:00
Makefile tests: delete orphaned Makefile 2018-09-11 23:50:27 +00:00
Makefile.builder rpm: integrate -doc package into main one 2017-05-12 18:43:35 +02:00
README.md Update readme 2017-10-16 04:16:23 +02:00
run-tests tests: rearrage LVM thin tests to run at least some in devel env 2017-05-12 18:10:17 +02:00
setup.cfg Add yapf configuration to setup.cfg 2016-07-21 12:11:34 +02:00
setup.py Update windows-related feature requests 2018-07-16 22:02:58 +02:00
version version 4.0.32 2018-10-14 06:05:04 +02:00

Qubes core, version 3

Build Status

This is master branch of the Qubes OS core.

API documentation is available: https://dev.qubes-os.org/projects/core-admin/en/latest/.