From 5eea4737259688872fd249b794da62a2f154dfbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 16 Jun 2016 16:58:15 +0200 Subject: [PATCH] core2migration: add a skeleton for dispvm_netvm migration QubesOS/qubes-issues#2075 --- qubes/core2migration.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/qubes/core2migration.py b/qubes/core2migration.py index 3816525c..9f93391e 100644 --- a/qubes/core2migration.py +++ b/qubes/core2migration.py @@ -110,7 +110,40 @@ class Core2Qubes(qubes.Qubes): else: vm.netvm = int(netvm_qid) - # TODO: dispvm_netvm + def set_dispvm_netvm_dependency(self, element): + kwargs = {} + attr_list = ("qid", "uses_default_netvm", "netvm_qid") + + for attribute in attr_list: + kwargs[attribute] = element.get(attribute) + + vm = self.domains[int(kwargs["qid"])] + + if element.get("uses_default_dispvm_netvm") is None: + uses_default_dispvm_netvm = True + else: + uses_default_dispvm_netvm = ( + True if element.get("uses_default_dispvm_netvm") == "True" + else False) + if not uses_default_dispvm_netvm: + dispvm_netvm_qid = element.get("dispvm_netvm_qid") + if dispvm_netvm_qid is None or dispvm_netvm_qid == "none": + dispvm_netvm = None + else: + dispvm_netvm = self.domains[int(dispvm_netvm_qid)] + else: + dispvm_netvm = vm.netvm + + if dispvm_netvm: + dispvm_tpl_name = 'disp-{}'.format(dispvm_netvm.name) + else: + dispvm_tpl_name = 'disp-no-netvm' + + if dispvm_tpl_name not in self.domains: + vm = self.add_new_vm(qubes.vm.appvm.AppVM, + name=dispvm_tpl_name) + # TODO: add support for #2075 + # TODO: set qrexec policy based on dispvm_netvm value def import_core2_vm(self, element): vm_class_name = element.tag