Desktop setup

This commit is contained in:
Jonathan Cremin 2020-04-29 21:51:12 +01:00
commit a7eaa7dbfb
14 changed files with 325 additions and 0 deletions

View file

@ -0,0 +1,7 @@
---
- name: restart libvirtd
service:
name: libvirtd
state: restarted
become: yes

68
roles/vm/tasks/main.yml Normal file
View file

@ -0,0 +1,68 @@
---
- name: Install vm deps
apt:
name:
- libvirt-daemon-system
- libvirt-clients
- qemu-kvm
- qemu-utils
- virt-manager
- ovmf
become: yes
- name: Update grub for amd_iommu
lineinfile:
path: /etc/default/grub
state: present
regexp: '^GRUB_CMDLINE_LINUX_DEFAULT='
line: 'GRUB_CMDLINE_LINUX_DEFAULT="quiet splash amd_iommu=on"'
become: yes
- name: Create subdirectories
file:
dest: '{{item}}'
mode: '0755'
owner: root
group: root
state: directory
with_items:
- /etc/libvirt/hooks/
- /etc/libvirt/hooks/qemu.d/win10/prepare/begin/
- /etc/libvirt/hooks/qemu.d/win10/release/end/
become: yes
- name: Fetch libvirt qemu hook
get_url:
url: https://raw.githubusercontent.com/PassthroughPOST/VFIO-Tools/master/libvirt_hooks/qemu
dest: /etc/libvirt/hooks/qemu
mode: 0744
become: yes
notify: restart libvirtd
- name: Create kvm.conf
template:
src: kvm.conf.j2
dest: /etc/libvirt/hooks/kvm.conf
owner: root
group: root
mode: '0644'
become: yes
- name: bind_vfio.sh
template:
src: bind_vfio.sh.j2
dest: /etc/libvirt/hooks/qemu.d/win10/prepare/begin/bind_vfio.sh
owner: root
group: root
mode: '0744'
become: yes
- name: unbind_vfio.sh
template:
src: unbind_vfio.sh.j2
dest: /etc/libvirt/hooks/qemu.d/win10/release/end/unbind_vfio.sh
owner: root
group: root
mode: '0744'
become: yes

View file

@ -0,0 +1,13 @@
#!/bin/bash
## Load the config file
source "/etc/libvirt/hooks/kvm.conf"
## Load vfio
modprobe vfio
modprobe vfio_iommu_type1
modprobe vfio_pci
## Unbind gpu from nvidia and bind to vfio
virsh nodedev-detach $VIRSH_GPU_VIDEO
virsh nodedev-detach $VIRSH_GPU_AUDIO

View file

@ -0,0 +1,3 @@
## Virsh devices
VIRSH_GPU_VIDEO=pci_0000_0c_00_0
VIRSH_GPU_AUDIO=pci_0000_0c_00_1

View file

@ -0,0 +1,13 @@
#!/bin/bash
## Load the config file
source "/etc/libvirt/hooks/kvm.conf"
## Unbind gpu from vfio and bind to nvidia
virsh nodedev-reattach $VIRSH_GPU_VIDEO
virsh nodedev-reattach $VIRSH_GPU_AUDIO
## Unload vfio
modprobe -r vfio_pci
modprobe -r vfio_iommu_type1
modprobe -r vfio