2019-10-12 22:55:19 +00:00
|
|
|
- name: install required packages
|
|
|
|
pacman:
|
|
|
|
name:
|
|
|
|
- qemu
|
2022-08-30 04:40:49 +00:00
|
|
|
# - qemu-audio-jack
|
2019-10-12 22:55:19 +00:00
|
|
|
- libvirt
|
2022-01-31 14:16:38 +00:00
|
|
|
- bridge-utils
|
2019-10-12 22:55:19 +00:00
|
|
|
- ovmf
|
|
|
|
- virt-manager
|
2021-07-22 13:40:24 +00:00
|
|
|
- python-evdev
|
|
|
|
- python-pyudev
|
2019-10-12 22:55:19 +00:00
|
|
|
notify:
|
2021-07-22 13:40:24 +00:00
|
|
|
- restart libvirtd.service
|
2019-10-12 22:55:19 +00:00
|
|
|
- restart virtlogd.socket
|
|
|
|
|
2021-07-22 13:40:24 +00:00
|
|
|
- name: install required aur packages
|
|
|
|
aur:
|
|
|
|
name:
|
|
|
|
- vfio-isolate
|
|
|
|
- persistent-evdev-git
|
2022-04-26 01:59:00 +00:00
|
|
|
- vendor-reset-dkms-git
|
2021-03-04 22:03:16 +00:00
|
|
|
|
2019-10-12 22:55:19 +00:00
|
|
|
- name: create hooks directory
|
|
|
|
file:
|
|
|
|
path: /etc/libvirt/hooks
|
|
|
|
state: directory
|
|
|
|
|
2021-03-04 22:03:16 +00:00
|
|
|
- name: install qemu hook
|
2022-01-31 14:16:38 +00:00
|
|
|
template:
|
2021-03-04 22:03:16 +00:00
|
|
|
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
|
|
|
|
|
2019-10-12 22:55:19 +00:00
|
|
|
- name: configure kernel modules
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/mkinitcpio.conf
|
2019-10-12 23:13:45 +00:00
|
|
|
regexp: '^MODULES='
|
2019-10-12 22:55:19 +00:00
|
|
|
line: 'MODULES=(vfio_pci vfio vfio_iommu_type1 vfio_virqfd i915)'
|
|
|
|
notify: regenerate linux initramfs
|
|
|
|
|
2021-11-21 07:14:25 +00:00
|
|
|
- name: configure kvm kernel module
|
|
|
|
copy:
|
|
|
|
src: modprobe/kvm.conf
|
|
|
|
dest: /etc/modprobe.d/kvm.conf
|
|
|
|
notify: regenerate linux initramfs
|
|
|
|
|
2019-10-12 22:55:19 +00:00
|
|
|
- name: install boot entry
|
2022-04-26 01:59:00 +00:00
|
|
|
template:
|
2019-10-12 22:55:19 +00:00
|
|
|
src: archlinux_iommu.conf
|
|
|
|
dest: /boot/loader/entries/archlinux_iommu.conf
|
|
|
|
|
2019-10-12 23:13:45 +00:00
|
|
|
- name: configure qemu user
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/libvirt/qemu.conf
|
|
|
|
regexp: '^#?user'
|
|
|
|
line: 'user = "1000"'
|
|
|
|
|
2019-10-12 22:55:19 +00:00
|
|
|
- name: configure qemu group
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/libvirt/qemu.conf
|
2019-10-12 23:13:45 +00:00
|
|
|
regexp: '^#?group'
|
2019-10-12 22:55:19 +00:00
|
|
|
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
|
2019-10-12 23:13:45 +00:00
|
|
|
insertbefore: '^#nvram'
|
|
|
|
marker: '# {mark} NVRAM CONFIGURATION'
|
2019-10-12 22:55:19 +00:00
|
|
|
block: |
|
|
|
|
nvram = [
|
|
|
|
"/usr/share/ovmf/x64/OVMF_CODE.fd:/usr/share/ovmf/x64/OVMF_VARS.fd"
|
|
|
|
]
|
2020-01-07 22:54:19 +00:00
|
|
|
notify: restart libvirtd.service
|
2019-10-12 22:55:19 +00:00
|
|
|
|
|
|
|
- name: setup cgroup device acl
|
|
|
|
blockinfile:
|
|
|
|
path: /etc/libvirt/qemu.conf
|
2019-10-12 23:13:45 +00:00
|
|
|
insertbefore: '^#cgroup_device_acl'
|
|
|
|
marker: '# {mark} DEVICE ACL CONFIGURATION'
|
2019-10-12 22:55:19 +00:00
|
|
|
block: |
|
|
|
|
cgroup_device_acl = [
|
2021-07-22 13:40:24 +00:00
|
|
|
{% 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 %}
|
2019-10-12 22:55:19 +00:00
|
|
|
"/dev/kvm",
|
|
|
|
"/dev/null", "/dev/full", "/dev/zero",
|
|
|
|
"/dev/random", "/dev/urandom",
|
|
|
|
"/dev/ptmx", "/dev/kvm", "/dev/kqemu",
|
2021-07-22 13:40:24 +00:00
|
|
|
"/dev/rtc","/dev/hpet", "/dev/sev"
|
2019-10-12 22:55:19 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
- name: install domain configuration
|
2021-03-04 22:03:16 +00:00
|
|
|
template:
|
2019-10-12 22:55:19 +00:00
|
|
|
src: win10.xml
|
|
|
|
dest: /etc/libvirt/qemu/win10.xml
|
2020-01-07 22:54:19 +00:00
|
|
|
validate: /usr/bin/virt-xml-validate %s
|
|
|
|
notify: restart libvirtd.service
|
2019-10-12 22:55:19 +00:00
|
|
|
|
2020-08-21 20:19:00 +00:00
|
|
|
# - name: configure systemd CPUAffinity
|
|
|
|
# lineinfile:
|
|
|
|
# path: /etc/systemd/system.conf
|
|
|
|
# regexp: '^#?CPUAffinity'
|
|
|
|
# line: 'CPUAffinity=0 4'
|
|
|
|
|
2021-07-22 13:40:24 +00:00
|
|
|
- name: configure persistent-evedev
|
|
|
|
template:
|
|
|
|
src: persistent-evdev/config.json.j2
|
|
|
|
dest: /opt/persistent-evdev/etc/config.json
|
|
|
|
notify: restart persistent-evdev
|
|
|
|
|
2020-01-07 22:54:19 +00:00
|
|
|
- name: enable libvirtd.socket
|
|
|
|
systemd:
|
|
|
|
name: libvirtd.socket
|
|
|
|
enabled: yes
|
2021-07-22 13:40:24 +00:00
|
|
|
state: started
|