From f7094bec4f95749f66a0bd9de322edbc3792f16a Mon Sep 17 00:00:00 2001 From: HW42 Date: Thu, 4 May 2017 20:48:27 +0200 Subject: [PATCH] add support for linux stubdoms (cherry picked from commit e14ac1500a05162b3c07a5f44b4f0223f43fe90c) --- qubes/vm/qubesvm.py | 19 ++++++++++++++++++- templates/libvirt/xen.xml | 21 ++++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 28649f14..af4e1b41 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -409,6 +409,11 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): doc='''Maximum amount of memory available for this VM (for the purpose of the memory balancer).''') + stubdom_mem = qubes.property('stubdom_mem', type=int, + setter=_setter_positive_int, + default=None, + doc='Memory ammount allocated for the stubdom') + internal = qubes.property('internal', default=False, type=bool, setter=qubes.property.bool, doc='''Internal VM (not shown in qubes-manager, don't create appmenus @@ -1136,7 +1141,19 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): return if mem_required is None: - mem_required = int(self.memory) * 1024 * 1024 + if self.hvm: + if self.stubdom_mem: + stubdom_mem = self.stubdom_mem + else: + if self.features.get('linux-stubdom', False): + stubdom_mem = 128 # from libxl_create.c + else: + stubdom_mem = 28 # from libxl_create.c + stubdom_mem += 16 # video ram + else: + stubdom_mem = 0 + + mem_required = int(self.memory + stubdom_mem) * 1024 * 1024 qmemman_client = qubes.qmemman.client.QMemmanClient() try: diff --git a/templates/libvirt/xen.xml b/templates/libvirt/xen.xml index c6480cac..84ae0b07 100644 --- a/templates/libvirt/xen.xml +++ b/templates/libvirt/xen.xml @@ -112,17 +112,32 @@ {% if vm.hvm %} -