1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/virt-binding-devices-vfio-driver.adoc
2025-11-18 16:29:25 +01:00

121 lines
3.8 KiB
Plaintext

// Module included in the following assemblies:
//
// * virt/virtual_machines/advanced_vm_management/virt-configuring-pci-passthrough.adoc
:_mod-docs-content-type: PROCEDURE
[id="virt-binding-devices-vfio-driver_{context}"]
= Binding PCI devices to the VFIO driver
[role="_abstract"]
To bind PCI devices to the VFIO (Virtual Function I/O) driver, obtain the values for `vendor-ID` and `device-ID` from each device and create a list with the values. Add this list to the `MachineConfig` object.
The `MachineConfig` Operator generates the `/etc/modprobe.d/vfio.conf` on the nodes with the PCI devices, and binds the PCI devices to the VFIO driver.
.Prerequisites
* You added kernel arguments to enable IOMMU for the CPU.
* You have installed the {oc-first}.
.Procedure
. Run the `lspci` command to obtain the `vendor-ID` and the `device-ID` for the PCI device.
+
[source,terminal]
----
$ lspci -nnv | grep -i nvidia
----
+
Example output:
+
[source,terminal]
----
02:01.0 3D controller [0302]: NVIDIA Corporation GV100GL [Tesla V100 PCIe 32GB] [10de:1eb8] (rev a1)
----
. Create a Butane config file, `100-worker-vfiopci.bu`, binding the PCI device to the VFIO driver.
+
[NOTE]
====
include::snippets/butane-version.adoc[]
====
+
Example:
+
[source,yaml,subs="attributes+"]
----
variant: openshift
version: {product-version}.0
metadata:
name: 100-worker-vfiopci
labels:
machineconfiguration.openshift.io/role: worker <1>
storage:
files:
- path: /etc/modprobe.d/vfio.conf
mode: 0644
overwrite: true
contents:
inline: |
options vfio-pci ids=10de:1eb8 <2>
- path: /etc/modules-load.d/vfio-pci.conf <3>
mode: 0644
overwrite: true
contents:
inline: vfio-pci
----
<1> Applies the new kernel argument only to worker nodes.
<2> Specify the previously determined `vendor-ID` value (`10de`) and the `device-ID` value (`1eb8`) to bind a single device to the VFIO driver. You can add a list of multiple devices with their vendor and device information.
<3> The file that loads the vfio-pci kernel module on the worker nodes.
. Use Butane to generate a `MachineConfig` object file, `100-worker-vfiopci.yaml`, containing the configuration to be delivered to the worker nodes:
+
[source,terminal]
----
$ butane 100-worker-vfiopci.bu -o 100-worker-vfiopci.yaml
----
. Apply the `MachineConfig` object to the worker nodes:
+
[source,terminal]
----
$ oc apply -f 100-worker-vfiopci.yaml
----
. Verify that the `MachineConfig` object was added.
+
[source,terminal]
----
$ oc get MachineConfig
----
+
Example output:
+
[source,terminal]
----
NAME GENERATEDBYCONTROLLER IGNITIONVERSION AGE
00-master d3da910bfa9f4b599af4ed7f5ac270d55950a3a1 3.5.0 25h
00-worker d3da910bfa9f4b599af4ed7f5ac270d55950a3a1 3.5.0 25h
01-master-container-runtime d3da910bfa9f4b599af4ed7f5ac270d55950a3a1 3.5.0 25h
01-master-kubelet d3da910bfa9f4b599af4ed7f5ac270d55950a3a1 3.5.0 25h
01-worker-container-runtime d3da910bfa9f4b599af4ed7f5ac270d55950a3a1 3.5.0 25h
01-worker-kubelet d3da910bfa9f4b599af4ed7f5ac270d55950a3a1 3.5.0 25h
100-worker-iommu 3.5.0 30s
100-worker-vfiopci-configuration 3.5.0 30s
----
.Verification
* Verify that the VFIO driver is loaded.
+
[source,terminal]
----
$ lspci -nnk -d 10de:
----
The output confirms that the VFIO driver is being used.
+
Example output:
+
----
04:00.0 3D controller [0302]: NVIDIA Corporation GP102GL [Tesla P40] [10de:1eb8] (rev a1)
Subsystem: NVIDIA Corporation Device [10de:1eb8]
Kernel driver in use: vfio-pci
Kernel modules: nouveau
----