From f4528296b5d51486bbc1ea821078d7765a45a25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 27 Feb 2019 06:00:38 +0100 Subject: [PATCH] vm: allow StandaloneVM to be a DVM template Fixes QubesOS/qubes-issues#4670 --- qubes/vm/dispvm.py | 8 +++++++- qubes/vm/standalonevm.py | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/qubes/vm/dispvm.py b/qubes/vm/dispvm.py index d26079a2..1d3d0704 100644 --- a/qubes/vm/dispvm.py +++ b/qubes/vm/dispvm.py @@ -26,12 +26,18 @@ import qubes.vm.qubesvm import qubes.vm.appvm import qubes.config +def _setter_template(self, prop, value): + if not getattr(value, 'template_for_dispvms', False): + raise qubes.exc.QubesPropertyValueError(self, prop, value, + 'template for DispVM must have template_for_dispvms=True') + return value + class DispVM(qubes.vm.qubesvm.QubesVM): '''Disposable VM''' template = qubes.VMProperty('template', load_stage=4, - vmclass=qubes.vm.appvm.AppVM, + setter=_setter_template, doc='AppVM, on which this DispVM is based.') dispid = qubes.property('dispid', type=int, write_once=True, diff --git a/qubes/vm/standalonevm.py b/qubes/vm/standalonevm.py index 2175ac72..aec3f45d 100644 --- a/qubes/vm/standalonevm.py +++ b/qubes/vm/standalonevm.py @@ -19,10 +19,12 @@ # import qubes.events +import qubes.vm.mix.dvmtemplate import qubes.vm.qubesvm import qubes.config -class StandaloneVM(qubes.vm.qubesvm.QubesVM): +class StandaloneVM(qubes.vm.mix.dvmtemplate.DVMTemplateMixin, + qubes.vm.qubesvm.QubesVM): '''Standalone Application VM''' def __init__(self, *args, **kwargs):