1
0
Fork 0
vfio-win10/roles/win10/tasks/main.yml

138 lines
3.2 KiB
YAML

- name: install required packages
pacman:
name:
- qemu
# - qemu-audio-jack
- libvirt
- dmidecode
- bridge-utils
- ovmf
- virt-manager
- python-evdev
- python-pyudev
notify:
- restart libvirtd.service
- restart virtlogd.socket
- name: install required aur packages
aur:
name:
- vfio-isolate
- persistent-evdev-git
- vendor-reset-dkms-git
- name: create hooks directory
file:
path: /etc/libvirt/hooks
state: directory
- name: install qemu hook
template:
src: hooks/qemu
dest: /etc/libvirt/hooks/qemu
mode: '755'
- name: install vfio-usb
copy:
src: vfio-usb
dest: /usr/bin/vfio-usb
mode: '755'
- name: install win10-usb service
template:
src: win10-usb.service.j2
dest: /etc/systemd/system/win10-usb.service
notify: reload systemd services
- name: configure kernel modules
lineinfile:
path: /etc/mkinitcpio.conf
regexp: '^MODULES='
line: 'MODULES=(vfio_pci vfio vfio_iommu_type1 vfio_virqfd i915)'
notify: regenerate linux initramfs
- name: configure kvm kernel module
copy:
src: modprobe/kvm.conf
dest: /etc/modprobe.d/kvm.conf
notify: regenerate linux initramfs
- name: install boot entry
template:
src: archlinux_iommu.conf
dest: /boot/loader/entries/archlinux_iommu.conf
- name: configure qemu user
lineinfile:
path: /etc/libvirt/qemu.conf
regexp: '^#?user'
line: 'user = "1000"'
- name: configure qemu group
lineinfile:
path: /etc/libvirt/qemu.conf
regexp: '^#?group'
line: 'group = "kvm"'
- name: setup headless audio
lineinfile:
path: /etc/libvirt/qemu.conf
regexp: '^#?nographics_allow_host_audio ='
line: 'nographics_allow_host_audio = 1'
- name: setup ovmf firmware image
blockinfile:
path: /etc/libvirt/qemu.conf
insertbefore: '^#nvram'
marker: '# {mark} NVRAM CONFIGURATION'
block: |
nvram = [
"/usr/share/ovmf/x64/OVMF_CODE.fd:/usr/share/ovmf/x64/OVMF_VARS.fd"
]
notify: restart libvirtd.service
- name: setup cgroup device acl
blockinfile:
path: /etc/libvirt/qemu.conf
insertbefore: '^#cgroup_device_acl'
marker: '# {mark} DEVICE ACL CONFIGURATION'
block: |
cgroup_device_acl = [
{% for item in keyboards %}
"{{ item }}",
{% endfor %}
{% for item in mice %}
"{ item }}",
{% endfor %}
"/dev/kvm",
"/dev/null", "/dev/full", "/dev/zero",
"/dev/random", "/dev/urandom",
"/dev/ptmx", "/dev/kvm", "/dev/kqemu",
"/dev/rtc","/dev/hpet", "/dev/sev"
]
- name: install domain configuration
template:
src: win10.xml
dest: /etc/libvirt/qemu/win10.xml
validate: /usr/bin/virt-xml-validate %s
notify: restart libvirtd.service
# - name: configure systemd CPUAffinity
# lineinfile:
# path: /etc/systemd/system.conf
# regexp: '^#?CPUAffinity'
# line: 'CPUAffinity=0 4'
- name: configure persistent-evedev
template:
src: persistent-evdev/config.json.j2
dest: /opt/persistent-evdev/etc/config.json
notify: restart persistent-evdev
- name: enable libvirtd.socket
systemd:
name: libvirtd.socket
enabled: yes
state: started