add support for linux stubdoms

(cherry picked from commit e14ac1500a05162b3c07a5f44b4f0223f43fe90c)
This commit is contained in:
HW42 2017-05-04 20:48:27 +02:00 committed by Marek Marczykowski-Górecki
parent eaf5c27b27
commit f7094bec4f
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 36 additions and 4 deletions

View File

@ -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:

View File

@ -112,17 +112,32 @@
{% if vm.hvm %}
<emulator
type="stubdom"
{% if vm.netvm %}
{% if vm.features.get('linux-stubdom', False) %}
type="stubdom-linux"
{% else %}
type="stubdom"
{% endif %}
{% if vm.netvm and not vm.features.get('linux-stubdom', False) %}
cmdline="-net lwip,client_ip={{ vm.ip -}}
,server_ip={{ vm.dns[1] -}}
,dns={{ vm.netvm.gateway -}}
,gw={{ vm.netvm.gateway -}}
,netmask={{ vm.netmask }}"
{% endif %}
{% if vm.stubdom_mem %}
memory="{{ vm.stubdom_mem * 1024 -}}"
{% endif %}
/>
<input type="tablet" bus="usb"/>
<video type="vga"/>
{% if vm.features.get('linux-stubdom', False) %}
<video type="cirrus"/>
{% else %}
<video type="vga"/>
{% endif %}
{% if vm.features.get('linux-stubdom', False) %}
{# TODO only add qubes gui if gui-agent is not installed in HVM #}
<graphics type="qubes"/>
{% endif %}
{% else %}
<console type="pty">
<target type="xen" port="0"/>