tests: release qubes.xml lock while killing VMs
Otherwise hotplug scripts may deadlock on qvm-template-commit and consequently do not release loop and device-mapper devices. Which means also not releasing disk space for underlying images. Fixes QubesOS/qubes-issues#1458
This commit is contained in:
parent
624c94b9d6
commit
3e79ff6a37
@ -219,10 +219,16 @@ class SystemTestsMixin(object):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(SystemTestsMixin, self).tearDown()
|
super(SystemTestsMixin, self).tearDown()
|
||||||
|
|
||||||
|
# release the lock, because we have no way to check whether it was
|
||||||
|
# read or write lock
|
||||||
try:
|
try:
|
||||||
self.qc.lock_db_for_writing()
|
self.qc.unlock_db()
|
||||||
except qubes.qubes.QubesException:
|
except qubes.qubes.QubesException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
self.kill_test_vms()
|
||||||
|
|
||||||
|
self.qc.lock_db_for_writing()
|
||||||
self.qc.load()
|
self.qc.load()
|
||||||
|
|
||||||
self.remove_test_vms()
|
self.remove_test_vms()
|
||||||
@ -242,6 +248,18 @@ class SystemTestsMixin(object):
|
|||||||
self.qc.lock_db_for_writing()
|
self.qc.lock_db_for_writing()
|
||||||
self.qc.load()
|
self.qc.load()
|
||||||
|
|
||||||
|
def kill_test_vms(self):
|
||||||
|
# do not keep write lock while killing VMs, because that may cause a
|
||||||
|
# deadlock with disk hotplug scripts (namely qvm-template-commit
|
||||||
|
# called when shutting down TemplateVm)
|
||||||
|
self.qc.lock_db_for_reading()
|
||||||
|
self.qc.load()
|
||||||
|
self.qc.unlock_db()
|
||||||
|
for vm in self.qc.values():
|
||||||
|
if vm.name.startswith(VMPREFIX):
|
||||||
|
if vm.is_running():
|
||||||
|
vm.force_shutdown()
|
||||||
|
|
||||||
def _remove_vm_qubes(self, vm):
|
def _remove_vm_qubes(self, vm):
|
||||||
vmname = vm.name
|
vmname = vm.name
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user