<domain type='kvm'>
  <name>{{ hostname }}</name>
  <memory>{{ vm_memory | int * 1024 }}</memory>
  {% if vm_ballo is defined %}<currentMemory>{{ vm_ballo | int * 1024 }}</currentMemory>{% endif %}
  <vcpu placement='static'>{{ vm_cpus }}</vcpu>
  <os>
    <type arch='x86_64' machine="pc-q35-8.0">hvm</type>
    <bootmenu enable='no'/>
    <boot dev='hd'/>
    <boot dev='cdrom'/>
    <loader readonly="yes" type="pflash">/usr/share/edk2/x64/OVMF_CODE.secboot.fd</loader>
    <nvram template="/usr/share/edk2/x64/OVMF_VARS.fd"/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <cpu mode="host-passthrough" check="none" migratable="on"/>
  <clock offset="utc"/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='{{ vm_path | default('/var/lib/libvirt/images/') }}{{ hostname }}.qcow2'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="{{ boot_iso }}"/>
      <target dev="sda" bus="sata"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="{{ vm_path | default('/var/lib/libvirt/images/') }}{{ hostname }}-cloudinit.iso"/>
      <target dev="sdb" bus="sata"/>
    </disk>
    {% if rhel_iso is defined %}
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="{{ rhel_iso }}"/>
      <target dev="sdc" bus="sata"/>
    </disk>
    {% endif %}
    <interface type='network'>
      <mac address="{{ mac_address_output.stdout }}"/>
      <source network='default'/>
      <model type='virtio'/>
    </interface>
    <input type="tablet" bus="usb"/>
    <input type="mouse" bus="ps2"/>
    <input type="keyboard" bus="ps2"/>
    <graphics type='spice' autoport="yes">
      <listen type="address"/>
    </graphics>
    <video>
      <model type="virtio" heads="1" primary="yes"/>
    </video>
  </devices>
</domain>