- name: install required packages pacman: name: - qemu - libvirt - 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 - name: create hooks directory file: path: /etc/libvirt/hooks state: directory - name: install qemu hook copy: 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 vfio-pci device ids template: src: vfio.conf.j2 dest: /etc/modprobe.d/vfio.conf notify: regenerate linux initramfs - name: install boot entry copy: 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 %} "/dev/input/by-id/uinput-persist-keyboard{{ loop.index0 }}", {% endfor %} {% for item in mice %} "/dev/input/by-id/uinput-persist-mouse{{ loop.index0 }}", {% 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