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,10 +197,19 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
 | 
				
			|||||||
    def start(self, **kwargs):
 | 
					    def start(self, **kwargs):
 | 
				
			||||||
        # pylint: disable=arguments-differ
 | 
					        # pylint: disable=arguments-differ
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # sanity check, if template_for_dispvm got changed in the meantime
 | 
					        try:
 | 
				
			||||||
        if not self.template.template_for_dispvms:
 | 
					            # sanity check, if template_for_dispvm got changed in the meantime
 | 
				
			||||||
            raise qubes.exc.QubesException(
 | 
					            if not self.template.template_for_dispvms:
 | 
				
			||||||
                'template for DispVM ({}) needs to have '
 | 
					                raise qubes.exc.QubesException(
 | 
				
			||||||
                'template_for_dispvms=True'.format(self.template.name))
 | 
					                    'template for DispVM ({}) needs to have '
 | 
				
			||||||
 | 
					                    '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