feat(opennebula): support PCIx_* passthrough network interfaces#6816
feat(opennebula): support PCIx_* passthrough network interfaces#6816mcanevet wants to merge 1 commit intocanonical:mainfrom
Conversation
055f1e6 to
99f7bec
Compare
|
Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close. If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging blackboxsw, and he will ensure that someone takes a look soon. (If the pull request is closed and you would like to continue working on it, please do tag blackboxsw to reopen it.) |
99f7bec to
67b1393
Compare
|
@blackboxsw rebased |
OpenNebula's context-linux package configures PCI passthrough NICs using PCIx_ADDRESS / PCIx_IP / PCIx_MASK / PCIx_GATEWAY / PCIx_MTU / PCIx_VLAN_ID variables. cloud-init ignored these entirely. Add _get_pci_context_ifaces() to scan context keys for PCIx_ADDRESS entries, and _pci_addr_to_dev() to resolve a PCI address to a system device name via /sys/bus/pci/devices/<addr>/net/. Extend gen_conf() to emit ethernets: entries for each PCI device, with optional VLAN support matching the existing ETHx_VLAN_ID behaviour. Devices whose sysfs path cannot be found are skipped with a warning.
67b1393 to
2d6cb65
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the OpenNebula datasource’s network configuration generation to support PCI passthrough NICs configured via OpenNebula context variables (PCI<x>_*), resolving PCI addresses to interface names through sysfs and emitting corresponding netplan configuration.
Changes:
- Add helpers to discover
PCI<x>_ADDRESScontext entries and map PCI addresses to netdev names via/sys/bus/pci/devices/<addr>/net/. - Extend
OpenNebulaNetwork.gen_conf()to emit netplan entries for PCI passthrough NICs, including optional VLAN configuration. - Add unit tests and update OpenNebula datasource documentation to describe the new PCI context variables.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
cloudinit/sources/DataSourceOpenNebula.py |
Adds PCI context scanning + sysfs resolution and emits netplan config for PCI passthrough NICs (with VLAN support). |
tests/unittests/sources/test_opennebula.py |
Adds unit tests covering PCI context parsing, sysfs resolution, and basic PCI static config emission. |
doc/rtd/reference/datasources/opennebula.rst |
Documents supported PCI<x>_* context variables and behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| m = re.match(r"^(PCI\d+)_ADDRESS$", key) | ||
| if m: | ||
| seen.add(m.group(1)) | ||
| return sorted(seen) |
| """ | ||
| sysfs = os.path.join(self._pci_sysfs_root, pci_address, "net") | ||
| try: | ||
| devs = os.listdir(sysfs) |
| pci_devconf["gateway4"] = gateway | ||
| mtu = self.get_field(pci_prefix, "mtu") | ||
| if mtu: | ||
| pci_devconf["mtu"] = mtu |
| vlan_id: Optional[str] = self.get_field(pci_prefix, "vlan_id") | ||
| if vlan_id: | ||
| netconf["ethernets"][pci_dev] = {} | ||
| target_name = "%s.%s" % (pci_dev, vlan_id) | ||
| pci_devconf["id"] = int(vlan_id) | ||
| pci_devconf["link"] = pci_dev | ||
| netconf.setdefault("vlans", {})[target_name] = pci_devconf | ||
| else: | ||
| netconf["ethernets"][pci_dev] = pci_devconf |
Proposed Commit Message
Additional Context
Part of a series bringing cloud-init's OpenNebula datasource to feature
parity with the context-linux package from one-apps.
PCI passthrough NICs cannot be matched by MAC address (they have no
ETHx_MACequivalent), so_pci_addr_to_dev()resolves via sysfsinstead. The
_pci_sysfs_rootclass attribute is overridable in teststo avoid touching the real filesystem.
Test Steps
In an OpenNebula VM with a PCI passthrough NIC at address
0000:00:06.0,set:
After boot, verify
ip addr show enp0s6(or whatever the device isnamed) shows
10.5.0.1/24.Merge type