Skip to content

pillar: apply the network interface order to SR-IOV VFs - #7198

Draft
christoph-zededa wants to merge 4 commits into
lf-edge:masterfrom
christoph-zededa:sriov_iface_order
Draft

christoph-zededa wants to merge 4 commits into
lf-edge:masterfrom
christoph-zededa:sriov_iface_order

Conversation

@christoph-zededa

Copy link
Copy Markdown
Contributor

Description

With EnforceNetworkInterfaceOrder set, SR-IOV virtual functions (VFs) assigned to a VM show up in the guest after all its other network interfaces, whatever interface order is configured for them. Virtual NICs and other directly assigned NICs are ordered as configured, and docs/APP-CONNECTIVITY.md describes the interface order as covering VFs too.

This was introduced by #5604. Commit 68e5122 ("sriov: remove isNet() for Virtual Function") took VFs out of IoType.IsNet() to fix a race in domainmgr: a network adapter is not handed to pciback while NIM tests a network config, so when the testing started while the VFs were being set up, only a part of them was passed through. But IsNet() also decides which adapters take part in the interface order. Since then zedagent drops the interface order of a VF, and the KVM PCI address allocator places VFs after all network interfaces.

The commits:

  1. domainmgr: test handing VFs to pciback while NIM is testing adds a test for that race; there was none. It passes before and after the fix.
  2. pillar: apply the network interface order to SR-IOV VFs reverts 68e5122, so that a VF is a network adapter again and is ordered like any other directly assigned NIC, and fixes the race where it occurs instead: a VF only exists to be passed through and is never an EVE network port, so domainmgr no longer holds it back during network testing.
  3. evetest: add an SR-IOV capable NIC to QEMU and Proxmox lets a test ask for an emulated Intel 82576 (igb), on which EVE can create VFs. The two providers advertise it as CAPABILITY_SRIOV_NIC.
  4. evetest: test the interface order of SR-IOV VFs adds TestSRIOVInterfaceOrder to the app NICs suite.

What else changes for VFs

IsNet() has more callers than the interface order, so a VF is treated like other directly assigned NICs in these places again:

  • With EnforceNetworkInterfaceOrder, the interface order of a VF is no longer ignored, so the documented rules apply to it. It has to be unique within the app, otherwise zedagent reports a config error for the app; an existing app whose VFs have no unique interface order configured (it did not matter so far) gets this error after the upgrade. And VFs that are functions of the same host PCI device (same bus and device number, which the VFs of a NIC usually share) cannot have another interface ordered between them; the app is not started with such an order.
  • For an app that uses EnforceNetworkInterfaceOrder with VFs today, the PCI addresses of its NICs in the guest change with the upgrade. That is the fix, but it can rename interfaces in the guest.
  • VFs are listed among the app's networks in the app info and metrics.
  • domainmgr logs Can't find ifname <pf>vf<N> at error level when it looks up the MAC address of a VF, as no host interface has that name.
  • A VF that the device model declares as a physical IO of its own passes zedagent's "is a network adapter" checks for system adapters, bonds and VLANs, and gets its interface name defaulted from its label if the model gives none.

NIM's testing and the last-resort config still do not see VFs: they look adapters up by the interface name of a port, and the adapter of a VF is named <pf>vf<N>.

How to test and validate this PR

On a device with an SR-IOV capable NIC and the KVM hypervisor:

  1. Configure VFs on a physical function and deploy a VM with the network interface order enforced, with at least one virtual NIC and one VF, and interface orders that put the VF before the virtual NIC (e.g. VF: 1, virtual NIC: 2).
  2. In the guest, list the NICs in the order of their PCI addresses (e.g. lspci | grep -i ethernet). The VF comes before the virtual NIC. Without this PR it comes after it.

Automated tests:

  • TestCreateDomConfigVFInterfaceOrder (pkg/pillar/hypervisor): PCI address allocation for three VFs, two of them functions of one host device, and a virtual NIC. It fails without the fix.
  • TestVfsAssignedToPciBackWhileTestingStarts (pkg/pillar/cmd/domainmgr): the race fixed by SR-IOV: Fix API logic and add I350 NIC support  #5604. It fails if 68e5122 is reverted without the change in domainmgr.
  • evetest TestSRIOVInterfaceOrder (make evetest NAME=TestSRIOVInterfaceOrder): EVE creates two VFs on an emulated igb and assigns them to an app between its two virtual NICs. The test checks the position of the NICs on the guest's PCI bus and the order in the app info and metrics. It is skipped with a device provider that has no SR-IOV capable NIC (libvirt) and with a hypervisor other than KVM.

Tested so far:

  • The unit tests of the affected pillar packages (types, hypervisor, cmd/domainmgr, cmd/zedagent, cmd/zedkube, dpcmanager, dpcreconciler, sriov) pass with -tags k -race.
  • TestSRIOVInterfaceOrder passes with the QEMU provider on an amd64 host with an EVE image built from this branch. On an image of master it fails: the guest sees both VFs after the virtual NICs.

Not tested:

  • A device with a real SR-IOV NIC.
  • The Proxmox provider change on a Proxmox host. Checked instead: the QEMU arguments it generates, and that the EVE kernel, booted with the same PCI layout and vIOMMU settings, creates the VFs and puts each of them into an IOMMU group of its own.
  • TestSRIOVInterfaceOrder in CI. As far as I can tell from evetest/deploy/proxmox, the CI brokers run the broker of master, which does not advertise CAPABILITY_SRIOV_NIC yet, so I expect the test to be skipped in the evetest run of this PR and to run on Proxmox for the first time after the merge.

Changelog notes

SR-IOV virtual functions assigned to a VM now follow the configured network interface order (when enforcing the network interface order is enabled for the VM), like other directly assigned NICs. Until now they always appeared in the guest after all other network interfaces. For VMs that use this option together with virtual functions, the PCI addresses of the NICs in the guest change accordingly, and each virtual function needs an interface order that is unique within the VM.

PR Backports

The interface order of VFs is broken on every branch that has both the network interface order and the change of #5604, which was backported to 16.0-stable (b82f09f) and 14.5-stable (d7d1c95). 13.4-stable has that change as well (8e762db), but not the network interface order.

  • 17.0-stable: To be backported.
  • 16.0-stable: To be backported.
  • 14.5-stable: To be backported.
  • 13.4-stable: No, as the network interface order is not available there.

Checklist

  • I've provided a proper description
  • I've added the proper documentation (docs/APP-CONNECTIVITY.md already describes the interface order as covering VFs; evetest/sdn/README.md describes the new eve_sriov port attribute)
  • I've tested my PR on amd64 device (an emulated one with an emulated SR-IOV NIC, see above; not on hardware with a real SR-IOV NIC)
  • I've tested my PR on arm64 device (not tested; no arch-specific code)
  • I've written the test verification instructions
  • I've set the proper labels to this PR

And the last but not least:

  • I've checked the boxes above, or I've provided a good reason why I didn't
    check them.

🤖 Generated with Claude Code

christoph-zededa and others added 4 commits November 23, 2026 19:29
Commit 68e5122 ("sriov: remove isNet() for Virtual Function")
fixed a race in domainmgr: a network adapter is not handed to pciback
while NIM tests a network config, so when the testing started while the
VFs of a NIC were being set up, only a part of them was passed through.
That commit came without a test.

TestVfsAssignedToPciBackWhileTestingStarts lets the testing start
before each of four VFs in turn, and after the last one, and expects
all of them to be handed to pciback, while a regular NIC is held back.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Christoph Ostarek <christoph@zededa.com>
Commit 68e5122 ("sriov: remove isNet() for Virtual Function") took
SR-IOV VFs out of IoType.IsNet() to fix a race in domainmgr: a network
adapter is not handed to pciback while NIM tests a network config, so
when the testing started while the VFs were being set up, only a part
of them was passed through.

IsNet() also decides which adapters take part in the user-defined
network interface order (EnforceNetworkInterfaceOrder). Since that
commit zedagent dropped the interface order of a VF and the KVM PCI
address allocator placed VFs after all other network interfaces, so a
VM saw its VFs last, whatever order was configured.

Revert that commit, so that a VF is a network adapter again and is
ordered like any other directly assigned NIC. Fix the race where it
occurs instead: a VF only exists to be passed through and is never an
EVE network port, so do not hold it back during network testing.

TestCreateDomConfigVFInterfaceOrder covers the PCI address allocator
with two VFs of one host device, which share a bridge, and a VF of
another device.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Christoph Ostarek <christoph@zededa.com>
A test of SR-IOV needs an edge device with a NIC that supports it. QEMU
emulates one: igb, an Intel 82576, on which the guest can create up to
7 virtual functions.

Let a client ask for such a NIC per interface of an EVE device
(EVEInterface.sriov). The QEMU and the Proxmox provider then attach an
igb in place of the virtio NIC, and advertise that they can with the
new capability CAPABILITY_SRIOV_NIC. The libvirt provider does not
offer such a NIC yet.

The NIC sits behind a PCIe root port: a new one with the QEMU provider,
the one every cross-connected NIC already has with Proxmox. Its virtual
functions show up behind that port, where Linux puts each of them into
an IOMMU group of its own, so that EVE can pass every one of them
through to an application separately.

igb has no boot ROM, so a device cannot boot from the network over such
a NIC.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Christoph Ostarek <christoph@zededa.com>
Add TestSRIOVInterfaceOrder to the app NICs suite. It lets EVE create
two virtual functions on a NIC and assigns both to an application whose
interface order puts them between its two virtual NICs. The guest must
find the VFs between the virtual NICs on its PCI bus (it cannot tell
the two VFs apart), and the app info and metrics must list all four
adapters in the configured order. EVE used to place VFs after all other
network interfaces, whatever their interface order, and the test fails
on such an image.

For this a port of the network model can be marked as SR-IOV capable
(Port.eve_sriov). The harness passes that on to the broker and requires
CAPABILITY_SRIOV_NIC, so the test is skipped with a provider that has
no such NIC. Like the set of ports, the property cannot be changed
while a test runs.

EVE loads the driver of the NIC, igb, as a kernel module, later than
the built-in virtio_net of the other NICs, so it numbers such a NIC
(ethN) after all the others, whatever the order of ports. The harness
therefore rejects a network model that lists an SR-IOV capable port of
a device before another port of that device.

The device config builder learns the number of VFs of a physical
function (PhysicalIOConfig.VFCount) and the type of a directly assigned
network adapter (DirectlyAssignedNetworkAdapter.Type).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Christoph Ostarek <christoph@zededa.com>
@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 31.47%. Comparing base (9267176) to head (cb497ee).

Files with missing lines Patch % Lines
pkg/pillar/cmd/domainmgr/domainmgr.go 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7198      +/-   ##
==========================================
+ Coverage   30.99%   31.47%   +0.48%     
==========================================
  Files         562      573      +11     
  Lines      101231   102827    +1596     
==========================================
+ Hits        31380    32369     +989     
- Misses      67412    68063     +651     
+ Partials     2439     2395      -44     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@milan-zededa

milan-zededa commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

@christoph-zededa When you are ready with this for review/merge -- could you split the evetest broker enhancements together with evetest/grpcapi addition into a separate PR? Once that is merged, broker will upgrade (as soon as there are no running tests), and therefore the newly added test should then succeed here. You will be also able to update sdn/vm/go.mod properly here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants