fix(devices): expose VFIO IOMMU group nodes for PCI passthrough - #817
Open
silentone12725 wants to merge 4 commits into
Open
fix(devices): expose VFIO IOMMU group nodes for PCI passthrough#817silentone12725 wants to merge 4 commits into
silentone12725 wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix PCI passthrough for the containerized QEMU backend by exposing the VFIO
IOMMU-group device nodes required by assigned PCI devices.
Previously, WinPodX added only the global VFIO control device:
to the generated container configuration. A PCI device bound to
vfio-pcialso requires its corresponding IOMMU-group device node:
Without that node inside the container, QEMU cannot open the assigned VFIO
device even when the host-side device has been correctly bound to
vfio-pci.This PR resolves the IOMMU group for each configured PCI device and exposes
the corresponding
/dev/vfio/<group>node alongside/dev/vfio/vfio.Changes
VFIO device-node discovery
Updated
host_device_nodes()insrc/winpodx/core/devices.pyso PCIpassthrough now:
/dev/vfio/vfiowhen at least one PCI device is assigned;/dev/vfio/<group>for each resolved group;IOMMU group;
This is necessary because
/dev/vfio/vfiois only the VFIO control device.The actual assigned PCI device is accessed by QEMU through the VFIO group
character device.
For example, a PCI device in IOMMU group
14now results in:instead of only:
Compose generation
Updated
src/winpodx/core/pod/compose.pyso the VFIO nodes returned byhost_device_nodes()are included in the generated container device list.The existing USB live-passthrough handling remains separate:
/dev/bus/usbcontinues to be managed by the USB-specific path rather thanbeing duplicated in this block.
The SELinux handling for PCI passthrough is also preserved: exposing VFIO
character devices requires the existing
label=disablebehavior on SELinuxhosts because the normal container label cannot access those host device
nodes.
Tests
Expanded
tests/test_devices.pyto cover the VFIO group-node behavior,including:
/dev/vfio/vfioand the corresponding/dev/vfio/<group>;node;
The targeted device test suites pass:
with:
Formatting and linting
The changed Python files were formatted with Ruff.
Validation:
Result:
git diff --checkalso reports no whitespace errors.Documentation
Updated both changelogs under
[Unreleased]:CHANGELOG.mddocs/CHANGELOG.ko.mdThey now document why exposing only
/dev/vfio/vfiowas insufficient andthat WinPodX also exposes and de-duplicates the required VFIO IOMMU-group
nodes.
Validation
The directly affected device and compose functionality has been validated
with the targeted test suites:
Ruff and formatting checks also pass with no whitespace errors.
Commits
Checklist
43 passed)ruff check src/ tests/: zero errorsruff format --check src/ tests/: formatted