vm/dispvm: fix DispVM cleanup
First unregister the domain from collection, and only then call remove_from_disk(). Removing it from collection prevent further calls being made to it. Or if anything else keep a reference to it (for example as a netvm), then abort the operation. Additionally this makes it unnecessary to take startup lock when cleaning it up in tests.
This commit is contained in:
parent
e1f65bdf7b
commit
5be003d539
@ -789,13 +789,6 @@ class SystemTestCase(QubesTestCase):
|
||||
vmname = vm.name
|
||||
app = vm.app
|
||||
|
||||
# avoid race with DispVM.auto_cleanup=True
|
||||
try:
|
||||
self.loop.run_until_complete(
|
||||
asyncio.wait_for(vm.startup_lock.acquire(), 10))
|
||||
except asyncio.TimeoutError:
|
||||
pass
|
||||
|
||||
try:
|
||||
# XXX .is_running() may throw libvirtError if undefined
|
||||
if vm.is_running():
|
||||
|
@ -142,8 +142,8 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
|
||||
def _auto_cleanup(self):
|
||||
'''Do auto cleanup if enabled'''
|
||||
if self.auto_cleanup and self in self.app.domains:
|
||||
yield from self.remove_from_disk()
|
||||
del self.app.domains[self]
|
||||
yield from self.remove_from_disk()
|
||||
self.app.save()
|
||||
|
||||
@classmethod
|
||||
@ -193,8 +193,8 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
|
||||
pass
|
||||
# if auto_cleanup is set, this will be done automatically
|
||||
if not self.auto_cleanup:
|
||||
yield from self.remove_from_disk()
|
||||
del self.app.domains[self]
|
||||
yield from self.remove_from_disk()
|
||||
self.app.save()
|
||||
|
||||
@asyncio.coroutine
|
||||
|
Loading…
Reference in New Issue
Block a user