You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/devices/README.md
+20-13Lines changed: 20 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ lib/devices/
37
37
├── vfio.go # VFIO bind/unbind operations
38
38
├── manager.go # Manager interface and implementation
39
39
├── manager_test.go # Unit tests
40
-
├── gpu_e2e_test.go # End-to-end GPU passthrough test
40
+
├── gpu_e2e_test.go # End-to-end GPU passthrough test (auto-skips if no GPU)
41
41
└── scripts/
42
42
└── gpu-reset.sh # GPU recovery script (see Troubleshooting)
43
43
```
@@ -285,29 +285,36 @@ Then reboot.
285
285
286
286
### Running the E2E Test
287
287
288
-
The GPU passthrough E2E test requires:
289
-
- Root permissions (for driver bind/unbind)
288
+
The GPU passthrough E2E test **automatically detects** GPU availability and skips if prerequisites aren't met.
289
+
290
+
**Why GPU tests require root**: Unlike network tests which can use Linux capabilities (`CAP_NET_ADMIN`), GPU passthrough requires writing to sysfs files (`/sys/bus/pci/drivers/*/unbind`, etc.) which are protected by standard Unix file permissions (owned by root, mode 0200). Capabilities don't bypass DAC (discretionary access control) for file writes.
291
+
292
+
Prerequisites for the test to run (not skip):
293
+
-**Root permissions** (sudo) - required for sysfs driver operations
290
294
- NVIDIA GPU on host
291
-
- IOMMU enabled
295
+
- IOMMU enabled (`intel_iommu=on` or `amd_iommu=on`)
292
296
-`vfio_pci` and `vfio_iommu_type1` modules loaded
293
297
-`/sbin` in PATH (for `mkfs.ext4`)
294
298
295
299
```bash
296
-
#Load VFIO modules
300
+
#Prepare the environment
297
301
sudo modprobe vfio_pci vfio_iommu_type1
298
302
299
-
# Run the test
303
+
# Run via make - test auto-skips if not root or no GPU
304
+
make test
305
+
306
+
# Or run directly with sudo
300
307
sudo env PATH=$PATH:/sbin:/usr/sbin \
301
-
go test -v -tags=integration,gpu -run TestGPUPassthrough \
302
-
-timeout 5m ./lib/devices/...
308
+
go test -v -run TestGPUPassthrough -timeout 5m ./lib/devices/...
303
309
```
304
310
305
311
The test will:
306
-
1. Discover available NVIDIA GPUs
307
-
2. Register the first GPU found
308
-
3. Create a VM with GPU passthrough
309
-
4. Verify the GPU is visible inside the VM
310
-
5. Clean up (delete VM, unbind from VFIO, restore nvidia driver)
312
+
1. Check prerequisites and skip if not met (not root, no GPU, no IOMMU, etc.)
313
+
2. Discover available NVIDIA GPUs
314
+
3. Register the first GPU found
315
+
4. Create a VM with GPU passthrough
316
+
5. Verify the GPU is visible inside the VM
317
+
6. Clean up (delete VM, unbind from VFIO, restore nvidia driver)
0 commit comments