<domain type='{{ hypervisor }}'>
        <name>{{ name }}</name>
        <vcpu>{{ cpu }}</vcpu>
        <memory unit='KiB'>{{ mem }}</memory>
        <currentMemory unit='KiB'>{{ mem }}</currentMemory>
        <os {{boot.os_attrib}}>
                <type arch='{{ arch }}'>{{ os_type }}</type>
                {% if boot %}
                  {% if 'kernel' in boot %}
                    <kernel>{{ boot.kernel }}</kernel>
                  {% endif %}
                  {% if 'initrd' in boot %}
                    <initrd>{{ boot.initrd }}</initrd>
                  {% endif %}
                  {% if 'cmdline' in boot %}
                    <cmdline>{{ boot.cmdline }}</cmdline>
                  {% endif %}
                  {% if 'loader' in boot %}
                    <loader readonly='yes' type='pflash'>{{ boot.loader }}</loader>
                  {% endif %}
                  {% if 'nvram' in boot %}
                    <nvram template='{{boot.nvram}}'></nvram>
                  {% endif %}
                {% endif %}
                {% for dev in boot_dev %}
                <boot dev='{{ dev }}' />
                {% endfor %}
        </os>
        <devices>
                {% for disk in disks %}
                <disk type='{{ disk.type }}' device='{{ disk.device }}'>
                        {% if disk.type == 'file' and 'source_file' in disk -%}
                        <source file='{{ disk.source_file }}' />
                        {% endif %}
                        {% if disk.type == 'volume' and 'pool' in disk -%}
                        <source pool='{{ disk.pool }}' volume='{{ disk.volume }}' />
                        {% endif %}
                        {%- if disk.type == 'network' %}
                        <source protocol='{{ disk.protocol }}' name='{{ disk.volume }}'{% if disk.get('query') %} query='{{ disk.query }}'{% endif %}>
                          {%- for host in disk.get('hosts') %}
                          <host name='{{ host.name }}'{% if host.get("port") %} port='{{ host.port }}'{% endif %}/>
                          {%- endfor %}
                          {%- if disk.get("auth") %}
                          <auth username='{{ disk.auth.username }}'>
                            <secret type='{{ disk.auth.type }}' usage='{{ disk.auth.usage}}'/>
                          </auth>
                          {%- endif %}
                        </source>
                        {%- endif %}
                        <target dev='{{ disk.target_dev }}' bus='{{ disk.disk_bus }}' />
                        {% if disk.address -%}
                        <address type='drive' controller='0' bus='0' target='0' unit='{{ disk.index }}' />
                        {% endif %}
                        {% if disk.driver -%}
                        <driver name='qemu' type='{{ disk.format}}' cache='none' io='native'/>
                        {% endif %}
                </disk>
                {% endfor %}

                {% if controller_model %}
                <controller type='scsi' index='0' model='{{ controller_model }}' />
                {% endif %}

                {% for nic in nics %}
                <interface type='{{ nic.type }}'>
                    <source {{ nic.type }}='{{ nic.source }}'/>
                    {% if nic.get('mac') -%}
                    <mac address='{{ nic.mac }}'/>
                    {%- endif %}
                    {% if nic.model %}<model type='{{ nic.model }}'/>{% endif %}
                </interface>
                {% endfor %}
                {% if graphics %}
                <graphics type='{{ graphics.type }}'
                          {% if graphics.listen.address %}
                          listen='{{ graphics.listen.address }}'
                          {% endif %}
                          {% if graphics.port %}
                          port='{{ graphics.port }}'
                          {% endif %}
                          {% if graphics.type == 'spice' and graphics.tls_port %}
                          tlsPort='{{ graphics.tls_port }}'
                          {% endif %}
                          autoport='{{ 'no' if graphics.port or graphics.tls_port else 'yes' }}'>
                    <listen type='{{ graphics.listen.type }}'
                            {% if graphics.listen.address %}
                            address='{{ graphics.listen.address }}'
                            {% endif %}/>
                </graphics>
                {% endif %}
                {% if serial_type == 'pty' %}
                <serial type='pty'>
                        <target port='0'/>
                </serial>
                {% if console %}
                <console type='pty'>
                        <target type='serial' port='0'/>
                </console>
                {% endif %}
                {% endif %}

                {% if serial_type == 'tcp' %}
                <serial type='tcp'>
                        <source mode='bind' host='' service='{{ telnet_port }}'/>
                        <protocol type='telnet'/>
                        <target port='0'/>
                </serial>
                {% if console %}
                <console type='tcp'>
                        <source mode='bind' host='' service='{{ telnet_port }}'/>
                        <protocol type='telnet'/>
                        <target type='serial' port='0'/>
                </console>
                {% endif %}
                {% endif %}

        </devices>
        <features>
                <acpi />
        </features>
</domain>
