feat: Add VFIO binding script and update playbook for enhanced virtualization support

This commit is contained in:
2026-01-02 23:15:08 +01:00
parent 03d5b39a4b
commit 3c6647c215
13 changed files with 540 additions and 135 deletions
+41 -12
View File
@@ -2,8 +2,8 @@
<name>{{ vm.name }}</name>
<uuid>{{ vm.uuid }}</uuid>
<title>{{ vm.title }}</title>
<memory unit='KiB'>{{ vm.memory }}</memory>
<currentMemory unit='KiB'>{{ vm.memory }}</currentMemory>
<memory unit='GiB'>{{ vm.memory }}</memory>
<currentMemory unit='GiB'>{{ vm.memory }}</currentMemory>
<memoryBacking>
<hugepages/>
<source type='memfd'/>
@@ -23,9 +23,9 @@
<emulatorpin cpuset='{{ vm.reserved_cpus }}'/>
</cputune>
<os>
<type arch='x86_64' machine='pc-q35-7.0'>hvm</type>
<loader readonly='yes' secure='{% if vm.secure_boot %}yes{% else %}no{% endif %}' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE{% if vm.secure_boot %}.secboot{% endif %}.fd</loader>
<nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/{{ vm.name }}_VARS.fd</nvram>
<type arch='x86_64' machine='pc-q35-8.2'>hvm</type>
<loader readonly='yes' secure='{% if vm.secure_boot %}yes{% else %}no{% endif %}' type='pflash' format='qcow2'>/usr/share/edk2/ovmf/OVMF_CODE_4M{% if vm.secure_boot %}.secboot{% endif %}.qcow2</loader>
<nvram template='/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2' templateFormat='qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/{{ vm.name }}_VARS.fd.qcow2</nvram>
<boot dev='hd'/>
<bootmenu enable='no'/>
</os>
@@ -44,7 +44,12 @@
{% endif %}
<smm state='on'/>
</features>
{% if vm.cpu is defined %}
<cpu mode='custom' match='exact' check='none'>
<model fallback='allow'>{{ vm.cpu }}</model>
{% else %}
<cpu mode='host-passthrough' check='none' migratable='on'>
{% endif %}
<topology sockets='1' dies='1' cores='{{ vm.cores }}' threads='{{ vm.threads }}'/>
</cpu>
<clock offset='localtime'>
@@ -81,6 +86,16 @@
<target dev='{{ block_dev.target_dev }}' bus='virtio'/>
</disk>
{% endfor %}
{% if vm.cloud_init is defined %}
{% if vm.cloud_init | default(false) %}
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/{{ vm.name }}-cloudinit.img'/>
<target dev='hdb' bus='virtio'/>
<readonly/>
</disk>
{% endif %}
{% endif %}
{% if vm.cdrom %}
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
@@ -187,15 +202,15 @@
<address type='usb' bus='0' port='1'/>
</controller>
{% endif %}
{% endif %}
{% endif %}
{% if vm.virtio_fs is defined %}
{% if vm.virtio_fs | default(false) %}
{% for fs in vm.virtio_fs %}
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs'/>
<source dir='{{ vm.virtio_fs.source }}'/>
<target dir='{{ vm.virtio_fs.target }}'/>
<driver type='virtiofs' queue='1024'/>
<source dir='{{ fs.source }}'/>
<target dir='{{ fs.target }}'/>
</filesystem>
{% endif %}
{% endfor %}
{% endif %}
<interface type='bridge'>
<mac address='{{ vm.mac_address }}'/>
@@ -221,7 +236,7 @@
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
{% if vm.tpm %}
<tpm model='tpm-tis'>
<tpm model='tpm-crb'>
<backend type='emulator' version='2.0'/>
</tpm>
{% endif %}
@@ -248,8 +263,22 @@
{% endif %}
</hostdev>
{% endfor %}
{% if vm.guest_agent is defined %}
{% if vm.guest_agent | default(false) %}
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/{{ vm.name }}.agent'/>
<target type='virtio' name='org.qemu.guest_agent.0' state='connected'/>
</channel>
{% endif %}
{% endif %}
{% if vm.mem_balloon is defined %}
{% if vm.mem_balloon | default(false) %}
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
</memballoon>
{% endif %}
{% else %}
<memballoon model='none'/>
{% endif %}
</devices>
</domain>