core-admin/templates/libvirt/xen.xml

123 lines
4.1 KiB
XML
Raw Normal View History

2016-03-02 12:17:29 +01:00
<domain type="xen">
<name>{% if prepare_dvm %}%NAME%{% else %}{{ vm.name }}{% endif %}</name>
2016-06-13 22:09:48 +02:00
<uuid>{{ vm.uuid }}</uuid>
<memory unit="MiB">{{ vm.maxmem }}</memory>
<currentMemory unit="MiB">{{ vm.memory }}</currentMemory>
<vcpu placement="static">{{ vm.vcpus }}</vcpu>
<os>
{% if vm.hvm %}
<type arch="x86_64" machine="xenfv">hvm</type>
<loader>hvmloader</loader>
<boot dev="cdrom" />
<boot dev="hd" />
2016-03-02 12:17:29 +01:00
<!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
2016-06-13 22:09:48 +02:00
{% 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 3 {{ vm.kernelopts }}</cmdline>
{% endif %}
</os>
2016-03-02 12:17:29 +01:00
<features>
{% if vm.hvm %}
2016-06-13 22:09:48 +02:00
<pae/>
<acpi/>
<apic/>
<viridian/>
{% endif %}
2016-03-02 12:17:29 +01:00
{% if vm.devices['pci'] and vm.features.get('pci-e820-host', True) %}
<xen>
<e820_host state="on"/>
</xen>
{% endif %}
</features>
{% if vm.hvm %}
2016-03-16 18:07:49 +01: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-06-13 22:09:48 +02:00
{% else %}
<clock offset='utc' adjustment='reset'>
<timer name="tsc" mode="native"/>
</clock>
{% endif %}
2016-03-02 12:17:29 +01:00
2016-06-13 22:09:48 +02:00
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<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']
%}
2016-06-13 22:09:48 +02:00
{% for device in vm.block_devices %}
<disk type="block" device="{{ device.devtype }}">
2016-03-02 12:17:29 +01:00
<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 %}
{% if device.domain %}
<domain name="{{ domain }}" />
{% endif %}
{% if device.script %}
<script path="{{ device.script }}" />
2016-03-02 12:17:29 +01:00
{% endif %}
</disk>
2016-06-13 22:09:48 +02:00
{% endfor %}
2016-03-02 12:17:29 +01:00
2016-06-13 22:09:48 +02:00
{% if vm.netvm %}
{% include 'libvirt/devices/net.xml' %}
2016-06-13 22:09:48 +02:00
{% endif %}
2016-03-02 12:17:29 +01:00
2016-06-13 22:09:48 +02:00
{% for device in vm.devices.pci %}
2016-07-20 17:52:49 +02:00
{% include 'libvirt/devices/pci.xml' %}
2016-06-13 22:09:48 +02:00
{% endfor %}
2016-03-02 12:17:29 +01:00
2016-06-13 22:09:48 +02:00
{% if vm.hvm %}
2016-03-02 12:17:29 +01:00
<emulator
type="stubdom"
{% if vm.netvm %}
cmdline="-net lwip,client_ip={{ vm.ip -}}
,server_ip={{ vm.secondary_dns -}}
,dns={{ vm.netvm.gateway -}}
,gw={{ self.netvm.gateway -}}
,netmask={{ vm.netmask }}"
{% endif %}
/>
2016-06-13 22:09:48 +02:00
<input type="tablet" bus="usb"/>
<video type="vga"/>
{% else %}
<console type="pty">
<target type="xen" port="0"/>
</console>
{% endif %}
2016-03-02 12:17:29 +01:00
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 : -->