2016-03-02 12:17:29 +01:00
|
|
|
<domain type="xen">
|
2016-10-04 11:30:29 +02:00
|
|
|
{% block basic %}
|
2017-06-01 03:49:57 +02:00
|
|
|
<name>{{ vm.name }}</name>
|
2016-10-04 11:30:29 +02:00
|
|
|
<uuid>{{ vm.uuid }}</uuid>
|
2017-07-17 12:26:10 +02:00
|
|
|
{% if vm.virt_mode == 'hvm' and vm.devices['pci'].persistent() | list %}
|
2017-06-15 00:21:13 +02:00
|
|
|
<memory unit="MiB">{{ vm.memory }}</memory>
|
|
|
|
{% else %}
|
|
|
|
<memory unit="MiB">{{ vm.maxmem }}</memory>
|
|
|
|
{% endif %}
|
2016-10-04 11:30:29 +02:00
|
|
|
<currentMemory unit="MiB">{{ vm.memory }}</currentMemory>
|
|
|
|
<vcpu placement="static">{{ vm.vcpus }}</vcpu>
|
|
|
|
{% endblock %}
|
2017-07-03 23:25:43 +02:00
|
|
|
{% block cpu %}
|
2017-10-02 22:23:27 +02:00
|
|
|
{% if vm.virt_mode != 'pv' %}
|
2017-07-03 23:25:43 +02:00
|
|
|
<cpu mode='host-passthrough'>
|
|
|
|
<!-- disable nested HVM -->
|
|
|
|
<feature name='vmx' policy='disable'/>
|
|
|
|
<feature name='svm' policy='disable'/>
|
|
|
|
<!-- disable SMAP inside VM, because of Linux bug -->
|
|
|
|
<feature name='smap' policy='disable'/>
|
|
|
|
</cpu>
|
2017-07-17 12:26:10 +02:00
|
|
|
{% endif %}
|
2017-07-03 23:25:43 +02:00
|
|
|
{% endblock %}
|
2016-06-13 22:09:48 +02:00
|
|
|
<os>
|
2016-10-04 11:30:29 +02:00
|
|
|
{% block os %}
|
2017-07-17 12:26:10 +02:00
|
|
|
{% if vm.virt_mode == 'hvm' %}
|
2016-10-04 11:30:29 +02:00
|
|
|
<type arch="x86_64" machine="xenfv">hvm</type>
|
2017-09-15 16:01:15 +02:00
|
|
|
<!--
|
|
|
|
For the libxl backend libvirt switches between OVMF (UEFI)
|
|
|
|
and SeaBIOS based on the loader type. This has nothing to
|
|
|
|
do with the hvmloader binary.
|
|
|
|
-->
|
|
|
|
<loader type="{{ "pflash" if vm.features.check_with_template('uefi', False) else "rom" }}">hvmloader</loader>
|
2016-10-04 11:30:29 +02:00
|
|
|
<boot dev="cdrom" />
|
|
|
|
<boot dev="hd" />
|
|
|
|
{% else %}
|
2017-10-02 22:23:27 +02:00
|
|
|
{% if vm.virt_mode == 'pvh' %}
|
|
|
|
<type arch="x86_64" machine="xenfv">hvm</type>
|
|
|
|
{% else %}
|
|
|
|
<type arch="x86_64" machine="xenpv">linux</type>
|
|
|
|
{% endif %}
|
2016-10-04 11:30:29 +02:00
|
|
|
<kernel>{{ vm.storage.kernels_dir }}/vmlinuz</kernel>
|
|
|
|
<initrd>{{ vm.storage.kernels_dir }}/initramfs</initrd>
|
|
|
|
{% endif %}
|
2017-12-14 02:17:42 +01:00
|
|
|
{% if vm.kernel %}
|
|
|
|
<cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0 {{ vm.kernelopts }}</cmdline>
|
|
|
|
{% endif %}
|
2016-10-04 11:30:29 +02:00
|
|
|
{% endblock %}
|
2016-06-13 22:09:48 +02:00
|
|
|
</os>
|
2016-03-02 12:17:29 +01:00
|
|
|
|
2016-06-13 23:20:39 +02:00
|
|
|
<features>
|
2016-10-04 11:30:29 +02:00
|
|
|
{% block features %}
|
2017-10-02 22:23:27 +02:00
|
|
|
{% if vm.virt_mode != 'pv' %}
|
2016-10-04 11:30:29 +02:00
|
|
|
<pae/>
|
|
|
|
<acpi/>
|
|
|
|
<apic/>
|
|
|
|
<viridian/>
|
|
|
|
{% endif %}
|
2016-03-02 12:17:29 +01:00
|
|
|
|
2017-04-08 04:09:46 +02:00
|
|
|
{% if vm.devices['pci'].persistent() | list
|
2016-10-04 11:30:29 +02:00
|
|
|
and vm.features.get('pci-e820-host', True) %}
|
|
|
|
<xen>
|
|
|
|
<e820_host state="on"/>
|
|
|
|
</xen>
|
|
|
|
{% endif %}
|
|
|
|
{% endblock %}
|
2016-06-13 23:20:39 +02:00
|
|
|
</features>
|
|
|
|
|
2016-10-04 11:30:29 +02:00
|
|
|
{% block clock %}
|
2017-07-17 12:26:10 +02:00
|
|
|
{% if vm.virt_mode == 'hvm' %}
|
2016-10-04 11:30:29 +02:00
|
|
|
{% set timezone = vm.features.check_with_template('timezone', 'localtime').lower() %}
|
|
|
|
{% if timezone == 'localtime' %}
|
|
|
|
<clock offset="variable" adjustment="0" basis="localtime" />
|
|
|
|
{% elif timezone.isdigit() %}
|
|
|
|
<clock offset="variable" adjustment="{{ timezone }}" basis="UTC" />
|
|
|
|
{% else %}
|
|
|
|
<clock offset="variable" adjustment="0" basis="UTC" />
|
|
|
|
{% endif %}
|
2016-03-16 18:07:49 +01:00
|
|
|
{% else %}
|
2016-10-04 11:30:29 +02:00
|
|
|
<clock offset='utc' adjustment='reset'>
|
|
|
|
<timer name="tsc" mode="native"/>
|
|
|
|
</clock>
|
2016-03-16 18:07:49 +01:00
|
|
|
{% endif %}
|
2016-10-04 11:30:29 +02:00
|
|
|
{% endblock %}
|
2016-03-02 12:17:29 +01:00
|
|
|
|
2016-10-04 11:30:29 +02:00
|
|
|
{% block on %}
|
|
|
|
<on_poweroff>destroy</on_poweroff>
|
|
|
|
<on_reboot>destroy</on_reboot>
|
|
|
|
<on_crash>destroy</on_crash>
|
|
|
|
{% endblock %}
|
2016-03-02 12:17:29 +01:00
|
|
|
|
2016-10-04 11:30:29 +02:00
|
|
|
<devices>
|
|
|
|
{% block devices %}
|
|
|
|
{% set i = 0 %}
|
|
|
|
{# TODO Allow more volumes out of the box #}
|
|
|
|
{% set dd = ['e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
|
|
|
|
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y']
|
|
|
|
%}
|
|
|
|
{% for device in vm.block_devices %}
|
|
|
|
<disk type="block" device="{{ device.devtype }}">
|
|
|
|
<driver name="phy" />
|
|
|
|
<source dev="{{ device.path }}" />
|
|
|
|
{% if device.name == 'root' %}
|
|
|
|
<target dev="xvda" />
|
|
|
|
{% elif device.name == 'private' %}
|
|
|
|
<target dev="xvdb" />
|
|
|
|
{% elif device.name == 'volatile' %}
|
|
|
|
<target dev="xvdc" />
|
|
|
|
{% elif device.name == 'kernel' %}
|
|
|
|
<target dev="xvdd" />
|
|
|
|
{% else %}
|
|
|
|
<target dev="xvd{{dd[i]}}" />
|
|
|
|
{% set i = i + 1 %}
|
|
|
|
{% endif %}
|
2016-03-02 12:17:29 +01:00
|
|
|
|
2016-10-04 11:30:29 +02:00
|
|
|
{% if not device.rw %}
|
|
|
|
<readonly />
|
|
|
|
{% endif %}
|
2016-03-02 12:17:29 +01:00
|
|
|
|
2016-10-04 11:30:29 +02:00
|
|
|
{% if device.domain %}
|
2017-07-17 12:28:56 +02:00
|
|
|
<backenddomain name="{{ device.domain }}" />
|
2016-10-04 11:30:29 +02:00
|
|
|
{% endif %}
|
2016-03-02 12:17:29 +01:00
|
|
|
|
2016-10-04 11:30:29 +02:00
|
|
|
{% if device.script %}
|
|
|
|
<script path="{{ device.script }}" />
|
|
|
|
{% endif %}
|
|
|
|
</disk>
|
|
|
|
{% endfor %}
|
2016-03-02 12:17:29 +01:00
|
|
|
|
2017-05-29 21:20:06 +02:00
|
|
|
{# start external devices from xvdi #}
|
|
|
|
{% set i = 4 %}
|
|
|
|
{% for assignment in vm.devices.block.assignments(True) %}
|
|
|
|
{% set device = assignment.device %}
|
|
|
|
{% set options = assignment.options %}
|
|
|
|
{% include 'libvirt/devices/block.xml' %}
|
|
|
|
{% endfor %}
|
|
|
|
|
2016-10-04 11:30:29 +02:00
|
|
|
{% if vm.netvm %}
|
|
|
|
{% include 'libvirt/devices/net.xml' with context %}
|
|
|
|
{% endif %}
|
2016-03-02 12:17:29 +01:00
|
|
|
|
2017-05-22 01:01:45 +02:00
|
|
|
{% for assignment in vm.devices.pci.assignments(True) %}
|
|
|
|
{% set device = assignment.device %}
|
|
|
|
{% set options = assignment.options %}
|
2016-10-04 11:30:29 +02:00
|
|
|
{% include 'libvirt/devices/pci.xml' %}
|
|
|
|
{% endfor %}
|
2016-03-02 12:17:29 +01:00
|
|
|
|
2017-07-17 12:26:10 +02:00
|
|
|
{% if vm.virt_mode == 'hvm' %}
|
2017-12-14 02:17:42 +01:00
|
|
|
<!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
|
2016-10-04 11:30:29 +02:00
|
|
|
<emulator
|
2017-05-16 09:01:40 +02:00
|
|
|
{% if vm.features.check_with_template('linux-stubdom', True) %}
|
2017-05-04 20:48:27 +02:00
|
|
|
type="stubdom-linux"
|
|
|
|
{% else %}
|
|
|
|
type="stubdom"
|
|
|
|
{% endif %}
|
2017-05-16 09:01:40 +02:00
|
|
|
{% if vm.netvm and not
|
|
|
|
vm.features.check_with_template('linux-stubdom', True) %}
|
2016-10-04 11:30:29 +02:00
|
|
|
cmdline="-net lwip,client_ip={{ vm.ip -}}
|
2017-01-14 05:05:11 +01:00
|
|
|
,server_ip={{ vm.dns[1] -}}
|
2016-10-04 11:30:29 +02:00
|
|
|
,dns={{ vm.netvm.gateway -}}
|
2017-01-14 05:05:11 +01:00
|
|
|
,gw={{ vm.netvm.gateway -}}
|
2016-10-04 11:30:29 +02:00
|
|
|
,netmask={{ vm.netmask }}"
|
|
|
|
{% endif %}
|
2017-05-04 20:48:27 +02:00
|
|
|
{% if vm.stubdom_mem %}
|
|
|
|
memory="{{ vm.stubdom_mem * 1024 -}}"
|
|
|
|
{% endif %}
|
2016-10-04 11:30:29 +02:00
|
|
|
/>
|
|
|
|
<input type="tablet" bus="usb"/>
|
2017-09-14 02:20:52 +02:00
|
|
|
<video>
|
2017-12-28 02:49:40 +01:00
|
|
|
<model type="{{ vm.features.check_with_template('video-model', 'vga') }}"/>
|
2017-09-14 02:20:52 +02:00
|
|
|
</video>
|
2017-05-16 09:01:40 +02:00
|
|
|
{% if vm.features.check_with_template('linux-stubdom', True) %}
|
2017-05-04 20:48:27 +02:00
|
|
|
{# TODO only add qubes gui if gui-agent is not installed in HVM #}
|
|
|
|
<graphics type="qubes"/>
|
|
|
|
{% endif %}
|
2016-10-04 11:30:29 +02:00
|
|
|
{% else %}
|
2017-10-02 22:23:27 +02:00
|
|
|
{% if vm.virt_mode == 'pvh' %}
|
|
|
|
<emulator type="none"/>
|
|
|
|
{% endif %}
|
2016-10-04 11:30:29 +02:00
|
|
|
<console type="pty">
|
|
|
|
<target type="xen" port="0"/>
|
|
|
|
</console>
|
|
|
|
{% endif %}
|
|
|
|
{% endblock %}
|
2016-06-13 22:09:48 +02:00
|
|
|
</devices>
|
2016-03-02 12:17:29 +01:00
|
|
|
</domain>
|
|
|
|
|
|
|
|
<!-- vim: set ft=jinja ts=4 sts=4 sw=4 et tw=80 : -->
|