From f324f4eef8a480a16b073db196eb38c4f5068eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 18 Apr 2014 01:35:12 +0200 Subject: [PATCH] core: verify template compatibility when adding new VM It is done in Qubes Manager, but do it at lower level - especially for qvm-create tool. --- core/qubes.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/qubes.py b/core/qubes.py index b8833d64..898b3ba2 100755 --- a/core/qubes.py +++ b/core/qubes.py @@ -249,7 +249,13 @@ class QubesVmCollection(dict): raise ValueError("Unknown VM type: %s" % vm_type) qid = self.get_new_unused_qid() - vm = QubesVmClasses[vm_type](qid=qid, collection=self, **kwargs) + vm_cls = QubesVmClasses[vm_type] + if 'template' in kwargs: + if not vm_cls.is_template_compatible(kwargs['template']): + raise QubesException("Template not compatible with selected " + "VM type") + + vm = vm_cls(qid=qid, collection=self, **kwargs) if not self.verify_new_vm(vm): raise QubesException("Wrong VM description!") self[vm.qid] = vm