From 595d983659200e0ea75c5f9370a3d39c92174508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 17 May 2017 01:37:11 +0200 Subject: [PATCH] storage: make verify() asyncio aware --- qubes/storage/__init__.py | 12 ++++++++++-- qubes/vm/qubesvm.py | 3 +-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index eb41ef3d..96697792 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -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 diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index b81690f3..96bca7d1 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -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