<domain type='{{ definition[1]['driver'] | default('kvm') }}'>
  <name>{{ definition[0] }}_{{ definition[1]['name'] | default(definition[1]['res_name']) }}_{{ definition[2] }}</name>
  <memory unit='KiB'>{{ definition[1]['memory'] * 1024 | int }}</memory>
  <vcpu placement='static'>{{ definition[1]['vcpus'] }}</vcpu>
  <os>
    <type arch='{{ definition[1]['arch'] | default('x86_64') }}'>hvm</type>
    <boot dev='{{ definition[1]['boot_dev'] | default('hd') }}'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <cpu mode='host-model'>
    <model fallback='allow' />
  </cpu>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
{% if definition[1]['driver'] is defined and definition[1]['driver'] == 'qemu' %}
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
{% else %}
    <emulator>{{ qemu_path }}qemu-kvm</emulator>
{% endif %}
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='{{ definition[3] }}{{ definition[0] }}_{{ definition[1]['name'] | default(definition[1]['res_name']) }}_{{ definition[2] }}.{{ definition[4] }}'/>
      <target dev='vda' bus='virtio'/>
    </disk>
{% for network in definition[1]['networks'] %}
    <interface type='network'>
      <model type='virtio'/>
      <source network='{{ network['name'] }}'/>
      <guest dev='eth{{ loop.index0 }}'/>
  {% if network['mac'] is defined %}
    <mac address='{{ network['mac'] }}'/>
  {% endif %}
    </interface>
{% endfor %}
    <controller type='usb' index='0'/>
    <controller type='pci' index='0' model='pci-root'/>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <video>
      <model type='cirrus' vram='16384' heads='1'/>
    </video>
  </devices>
</domain>
