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.
This commit is contained in:
parent
113fe3391d
commit
f324f4eef8
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user