Skip to content

Commit 874531e

Browse files
committed
Add support for specfying vfio id's
1 parent 960abbe commit 874531e

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

roles/iommu/handlers/main.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: Regenerate initramfs
3+
ansible.builtin.shell: |-
4+
#!/bin/bash
5+
set -eux
6+
dracut -v -f /boot/initramfs-$(uname -r).img $(uname -r)
7+
become: true
8+
changed_when: true
9+
- name: Reboot
10+
ansible.builtin.reboot:
11+
msg: "Rebooting the hypervisor"
12+
become: true

roles/iommu/tasks/main.yml

+33-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,43 @@
11
---
2+
- name: Template dracut config for vfio
3+
ansible.builtin.blockinfile:
4+
path: /etc/dracut.conf.d/gpu-vfio.conf
5+
block: |
6+
add_drivers+="vfio vfio_iommu_type1 vfio_pci vfio_virqfd"
7+
owner: root
8+
group: root
9+
mode: "0660"
10+
create: true
11+
become: true
12+
when: iommu_vfio_pci_ids is defined
13+
notify:
14+
- Regenerate initramfs
15+
- reboot
16+
17+
- name: Add vfio to modules-load.d
18+
ansible.builtin.blockinfile:
19+
path: /etc/modules-load.d/vfio.conf
20+
block: |
21+
vfio
22+
vfio_iommu_type1
23+
vfio_pci
24+
vfio_virqfd
25+
owner: root
26+
group: root
27+
mode: "0664"
28+
create: true
29+
become: true
30+
when: iommu_vfio_pci_ids is defined
31+
notify: reboot
32+
233
- name: Add iommu to kernel command line (Intel)
334
ansible.builtin.include_role:
435
name: stackhpc.linux.grubcmdline
536
vars:
6-
kernel_cmdline: # noqa: var-naming[no-role-prefix]
7-
- intel_iommu=on
37+
kernel_cmdline: "{{ ['intel_iommu=on'] + (['vfio-pci.ids=' + iommu_vfio_pci_ids] if iommu_vfio_pci_ids is defined else []) }}" # noqa: var-naming[no-role-prefix]
838
kernel_cmdline_remove: # noqa: var-naming[no-role-prefix]
939
- ^intel_iommu=
40+
- ^vfio-pci\.ids=
1041
when: ansible_facts.processor | select('search', 'Intel') | list | length > 0
1142

1243
- name: Set iommu=pt

0 commit comments

Comments
 (0)