core-admin/templates/libvirt/xen.xml

152 lines
5.7 KiB
XML
Raw Normal View History

2016-03-02 12:17:29 +01:00
<domain type="xen">
{% block basic %}
<name>{% if prepare_dvm %}%NAME%{% else %}{{ vm.name }}{% endif %}</name>
<uuid>{{ vm.uuid }}</uuid>
<memory unit="MiB">{{ vm.maxmem }}</memory>
<currentMemory unit="MiB">{{ vm.memory }}</currentMemory>
<vcpu placement="static">{{ vm.vcpus }}</vcpu>
{% endblock %}
2016-06-13 22:09:48 +02:00
<os>
{% block os %}
{% if vm.hvm %}
<type arch="x86_64" machine="xenfv">hvm</type>
<loader>hvmloader</loader>
<boot dev="cdrom" />
<boot dev="hd" />
<!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
{% else %}
<type arch="x86_64" machine="xenpv">linux</type>
<kernel>{{ vm.storage.kernels_dir }}/vmlinuz</kernel>
<initrd>{{ vm.storage.kernels_dir }}/initramfs</initrd>
<cmdline>root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0 {{ vm.kernelopts }}</cmdline>
{% endif %}
{% endblock %}
2016-06-13 22:09:48 +02:00
</os>
2016-03-02 12:17:29 +01:00
<features>
{% block features %}
{% if vm.hvm %}
<pae/>
<acpi/>
<apic/>
<viridian/>
{% endif %}
2016-03-02 12:17:29 +01:00
{% if vm.devices['pci'].persistent() | list
and vm.features.get('pci-e820-host', True) %}
<xen>
<e820_host state="on"/>
</xen>
{% endif %}
{% endblock %}
</features>
{% block clock %}
{% if vm.hvm %}
{% 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 %}
<clock offset='utc' adjustment='reset'>
<timer name="tsc" mode="native"/>
</clock>
2016-03-16 18:07:49 +01:00
{% endif %}
{% endblock %}
2016-03-02 12:17:29 +01: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
<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
{% if not device.rw %}
<readonly />
{% endif %}
2016-03-02 12:17:29 +01:00
{% if device.domain %}
<backenddomain name="{{ domain }}" />
{% endif %}
2016-03-02 12:17:29 +01:00
{% if device.script %}
<script path="{{ device.script }}" />
{% endif %}
</disk>
{% endfor %}
2016-03-02 12:17:29 +01:00
{% if vm.netvm %}
{% include 'libvirt/devices/net.xml' with context %}
{% endif %}
2016-03-02 12:17:29 +01:00
{% for device in vm.devices.pci.persistent() %}
{% include 'libvirt/devices/pci.xml' %}
{% endfor %}
2016-03-02 12:17:29 +01:00
{% if vm.hvm %}
<emulator
{% if vm.features.check_with_template('linux-stubdom', True) %}
type="stubdom-linux"
{% else %}
type="stubdom"
{% endif %}
{% if vm.netvm and not
vm.features.check_with_template('linux-stubdom', True) %}
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"/>
{% if vm.features.check_with_template('linux-stubdom', True) %}
<video type="cirrus"/>
{% else %}
<video type="vga"/>
{% endif %}
{% if vm.features.check_with_template('linux-stubdom', True) %}
{# 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"/>
</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 : -->