dispvm: don't load separate Qubes() instance when handling DispVM

This will not work in qubesd, where there is one and only Qubes()
instance.
This commit is contained in:
Marek Marczykowski-Górecki 2017-03-20 22:18:10 +01:00
parent 3bc4ec1e98
commit e4e92b06af
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -123,7 +123,7 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
'''Create a new instance from given AppVM
:param qubes.vm.appvm.AppVM appvm: template from which the VM should \
be created (could also be name or qid)
be created
:returns: new disposable vm
*kwargs* are passed to the newly created VM
@ -133,12 +133,10 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
>>> dispvm.run_service('qubes.VMShell', input='firefox')
>>> dispvm.cleanup()
This method modifies :file:`qubes.xml` file. In fact, the newly created
vm belongs to other :py:class:`qubes.Qubes` instance than the *app*.
This method modifies :file:`qubes.xml` file.
The qube returned is not started.
'''
store = appvm.app.store if isinstance(appvm, qubes.vm.BaseVM) else None
app = qubes.Qubes(store)
app = appvm.app
dispvm = app.add_new_vm(
cls,
dispid=app.domains.get_new_unused_dispid(),
@ -156,15 +154,12 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
'''Clean up after the DispVM
This stops the disposable qube and removes it from the store.
This method modifies :file:`qubes.xml` file.
'''
app = qubes.Qubes(self.app.store)
self = app.domains[self.uuid]
try:
self.force_shutdown()
except qubes.exc.QubesVMNotStartedError:
pass
self.remove_from_disk()
del app.domains[self]
app.save()
del self.app.domains[self]
self.app.save()