qubesvm: make vm.create_on_disk cleanup after failed attempt
Don't leave half-created VM - it will make harder to retry.
This commit is contained in:
		
							parent
							
								
									2a25db7eb7
								
							
						
					
					
						commit
						ef031d6f0d
					
				@ -1257,7 +1257,16 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
 | 
			
		||||
                                                      pools)
 | 
			
		||||
            self.storage = qubes.storage.Storage(self)
 | 
			
		||||
 | 
			
		||||
        try:
 | 
			
		||||
            yield from self.storage.create()
 | 
			
		||||
        except:
 | 
			
		||||
            try:
 | 
			
		||||
                yield from self.storage.remove()
 | 
			
		||||
                os.rmdir(self.dir_path)
 | 
			
		||||
            except:  # pylint: disable=bare-except
 | 
			
		||||
                self.log.exception('failed to cleanup {} after failed VM '
 | 
			
		||||
                                   'creation'.format(self.dir_path))
 | 
			
		||||
            raise
 | 
			
		||||
 | 
			
		||||
        self.log.info('Creating icon symlink: {} -> {}'.format(
 | 
			
		||||
            self.icon_path, self.label.icon_path))
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user