core-admin/templates/libvirt/devices/block.xml
Pawel Marczewski fe72fe1681
Fix overlapping block device names
This was caused by a change in Jinja template engine that breaks
assignments like {% set i = i + 1 %} in a loop.

Jinja 2.10 introduces a "namespace" object for this use case, but
unfortunately dom0-fc25 uses 2.8.1.

See:

https://github.com/pallets/jinja/issues/641
https://github.com/pallets/jinja/pull/684

Fixes QubesOS/qubes-issues#5551.
2020-01-23 11:27:05 +01:00

22 lines
758 B
XML

<disk type="block" device="{{ options.get('devtype', 'disk') }}">
<driver name="phy" />
<source dev="{{ device.device_node }}" />
{%- if 'frontend-dev' in options %}
<target dev="{{ options.get('frontend-dev') }}" />
{%- elif options.get('devtype', 'disk') == 'cdrom' and not vm.kernel %}
<!-- prefer xvdd for CDROM -->
<target dev="xvdd" />
{%- else %}
<target dev="xvd{{dd[counter.i]}}" />
{% if counter.update({'i': counter.i + 1}) %}{% endif %}
{%- endif %}
{%- if options.get('read-only', 'no') == 'yes' %}
<readonly />
{%- endif %}
{%- if device.backend_domain.name != 'dom0' %}
<backenddomain name="{{ device.backend_domain.name }}" />
{%- endif %}
</disk>