<domain type='{{ hypervisor }}'>
        <name>{{ name }}</name>
        <vcpu>{{ cpu }}</vcpu>
        <memory unit='KiB'>{{ mem }}</memory>
        <currentMemory unit='KiB'>{{ mem }}</currentMemory>
        <os>
                <type arch='{{ arch }}'>{{ os_type }}</type>
                {% if kernel %}<kernel>{{ kernel }}</kernel>{% endif %}
                {% for dev in boot_dev %}
                <boot dev='{{ dev }}' />
                {% endfor %}
        </os>
        <devices>
                {% for disk in disks %}
                <disk type='file' device='{{ disk.device }}'>
                        {% if 'source_file' in disk %}
                        <source file='{{ disk.source_file }}' />
                        {% 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.type }}' 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 }}'/>
                    <mac address='{{ nic.mac }}'/>
                    {% 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>
