storage: make verify() asyncio aware

This commit is contained in:
Marek Marczykowski-Górecki 2017-05-17 01:37:11 +02:00
parent d57aef96e5
commit 595d983659
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 11 additions and 4 deletions

View File

@ -431,6 +431,7 @@ class Storage(object):
pool = self.get_pool(volume)
volumes[name] = pool.rename(volume, old_name, new_name)
@asyncio.coroutine
def verify(self):
'''Verify that the storage is sane.
@ -440,8 +441,13 @@ class Storage(object):
raise qubes.exc.QubesVMError(
self.vm,
'VM directory does not exist: {}'.format(self.vm.dir_path))
futures = []
for volume in self.vm.volumes.values():
self.get_pool(volume).verify(volume)
ret = self.get_pool(volume).verify(volume)
if asyncio.iscoroutine(ret):
futures.append(ret)
if futures:
yield from asyncio.wait(futures)
self.vm.fire_event('domain-verify-files')
return True
@ -677,7 +683,9 @@ class Pool(object):
This can be implemented as a coroutine.'''
def verify(self, volume):
''' Verifies the volume. '''
''' Verifies the volume.
This can be implemented as a coroutine.'''
raise self._not_implemented("verify")
@property

View File

@ -854,8 +854,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
self.fire_event_pre('domain-pre-start', preparing_dvm=preparing_dvm,
start_guid=start_guid, mem_required=mem_required)
yield from asyncio.get_event_loop().run_in_executor(None,
self.storage.verify)
yield from self.storage.verify()
if self.netvm is not None:
# pylint: disable = no-member