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
|
|
|
|
2016-06-13 23:20:39 +02:00
|
|
|
<features>
|
|
|
|
{% if vm.hvm %}
|
2016-06-13 22:09:48 +02:00
|
|
|
<pae/>
|
|
|
|
<acpi/>
|
|
|
|
<apic/>
|
|
|
|
<viridian/>
|
2016-06-13 23:20:39 +02:00
|
|
|
{% endif %}
|
2016-03-02 12:17:29 +01:00
|
|
|
|
2016-06-13 23:20:39 +02: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>
|
2016-03-27 22:55:09 +02:00
|
|
|
{% 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 %}
|
2016-03-27 22:55:09 +02:00
|
|
|
<disk type="block" device="{{ device.devtype }}">
|
2016-03-02 12:17:29 +01:00
|
|
|
<driver name="phy" />
|
|
|
|
<source dev="{{ device.path }}" />
|
2016-03-27 22:55:09 +02:00
|
|
|
{% 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 %}
|
2016-08-09 03:13:36 +02:00
|
|
|
<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 %}
|
2016-06-15 19:41:11 +02:00
|
|
|
{% 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 : -->
|