vm/dispvm: convert DispVM related function to coroutines

Some functions used there (create_on_disk, remove_from_disk, kill) are
coroutines, so callers needs to be too.

Fixes QubesOS/qubes-issues#2896
This commit is contained in:
Marek Marczykowski-Górecki 2017-07-08 02:53:09 +02:00
parent 148d1cda78
commit c32f0db582
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 10 additions and 7 deletions

View File

@ -69,8 +69,7 @@ class QubesInternalAPI(qubes.api.AbstractQubesAPI):
def create_dispvm(self):
assert not self.arg
# TODO convert to coroutine
dispvm = qubes.vm.dispvm.DispVM.from_appvm(self.dest)
dispvm = yield from qubes.vm.dispvm.DispVM.from_appvm(self.dest)
return dispvm.name
@qubes.api.method('internal.vm.CleanupDispVM', no_payload=True)
@ -78,8 +77,7 @@ class QubesInternalAPI(qubes.api.AbstractQubesAPI):
def cleanup_dispvm(self):
assert not self.arg
# TODO convert to coroutine
self.dest.cleanup()
yield from self.dest.cleanup()
@qubes.api.method('internal.vm.volume.ImportEnd')
@asyncio.coroutine

View File

@ -23,6 +23,8 @@
import copy
import asyncio
import qubes.vm.qubesvm
import qubes.vm.appvm
import qubes.config
@ -116,6 +118,7 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
'Cannot change template of Disposable VM')
@classmethod
@asyncio.coroutine
def from_appvm(cls, appvm, **kwargs):
'''Create a new instance from given AppVM
@ -147,10 +150,11 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
proplist = [prop for prop in dispvm.property_list()
if prop.clone and prop.__name__ not in ['template']]
dispvm.clone_properties(app.domains[appvm], proplist=proplist)
dispvm.create_on_disk()
yield from dispvm.create_on_disk()
app.save()
return dispvm
@asyncio.coroutine
def cleanup(self):
'''Clean up after the DispVM
@ -158,9 +162,10 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
This method modifies :file:`qubes.xml` file.
'''
try:
self.force_shutdown()
# pylint: disable=not-an-iterable
yield from self.kill()
except qubes.exc.QubesVMNotStartedError:
pass
self.remove_from_disk()
yield from self.remove_from_disk()
del self.app.domains[self]
self.app.save()