vm/dispvm: cleanup DispVM also on failed startup
If dispvm.auto_cleanup is set, cleanup it also after failed startup (like not enough memory). Fixes QubesOS/qubes-issues#3045
This commit is contained in:
parent
7c6b04677f
commit
e38e227503
@ -137,7 +137,7 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
|
|||||||
'''
|
'''
|
||||||
with (yield from self.startup_lock):
|
with (yield from self.startup_lock):
|
||||||
yield from self.storage.stop()
|
yield from self.storage.stop()
|
||||||
if self.auto_cleanup:
|
if self.auto_cleanup and self in self.app.domains:
|
||||||
yield from self.remove_from_disk()
|
yield from self.remove_from_disk()
|
||||||
del self.app.domains[self]
|
del self.app.domains[self]
|
||||||
self.app.save()
|
self.app.save()
|
||||||
@ -197,6 +197,7 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
|
|||||||
def start(self, **kwargs):
|
def start(self, **kwargs):
|
||||||
# pylint: disable=arguments-differ
|
# pylint: disable=arguments-differ
|
||||||
|
|
||||||
|
try:
|
||||||
# sanity check, if template_for_dispvm got changed in the meantime
|
# sanity check, if template_for_dispvm got changed in the meantime
|
||||||
if not self.template.template_for_dispvms:
|
if not self.template.template_for_dispvms:
|
||||||
raise qubes.exc.QubesException(
|
raise qubes.exc.QubesException(
|
||||||
@ -204,3 +205,11 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
|
|||||||
'template_for_dispvms=True'.format(self.template.name))
|
'template_for_dispvms=True'.format(self.template.name))
|
||||||
|
|
||||||
yield from super(DispVM, self).start(**kwargs)
|
yield from super(DispVM, self).start(**kwargs)
|
||||||
|
except:
|
||||||
|
# cleanup also on failed startup; there is potential race with
|
||||||
|
# self.on_domain_shutdown_coro, so check if wasn't already removed
|
||||||
|
if self.auto_cleanup and self in self.app.domains:
|
||||||
|
yield from self.remove_from_disk()
|
||||||
|
del self.app.domains[self]
|
||||||
|
self.app.save()
|
||||||
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user