Skip to content

netvsp: Support hot remove/add of network pci device#3580

Open
sunilmut wants to merge 1 commit into
microsoft:mainfrom
sunilmut:sunilmut/hot_add_remove_mana
Open

netvsp: Support hot remove/add of network pci device#3580
sunilmut wants to merge 1 commit into
microsoft:mainfrom
sunilmut:sunilmut/hot_add_remove_mana

Conversation

@sunilmut
Copy link
Copy Markdown
Member

If network PCI devices get hot removed or added, currently the openhcl networking code will not behave properly, in the sense that it will keep an handle open to the PCI device. And, from there on, OpenHCL cannot recover from that point.

This PR adds support for hot add/remove of network PCI devices using the uevent mechanism, and when:

  • Device is hot removed, it will remove the actual network endpoint and connect the disconnectable endpoint. The guest continues to see the synthetic network channel and packets are dropped as usual.
  • Device is hot added, the code will create a network endpoint on it and then attach that instead of the disconnectable endpoint. Network traffic can resume from there on.

This allows other components to disconnect VTL2 network devices, service their components and reattach it. The existing flexiov hot restart (FHR) flows doesnt work for all cases because in emulation mode, FHR servicing is not visible to OpenHCL

Copilot AI review requested due to automatic review settings May 28, 2026 00:00
@sunilmut sunilmut requested a review from a team as a code owner May 28, 2026 00:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for surprise hot remove/add of MANA network PCI devices in OpenHCL's HclNetworkVFManagerWorker. Previously, after a surprise PCI hotplug, OpenHCL would keep a stale handle to the device and could not recover. The worker now distinguishes between vPCI-coordinated and uevent-driven (surprise) device state transitions, and avoids reporting an unsolicited binding-state change to the host on surprise events.

Changes:

  • mana_device_arrived/mana_device_removed and their NextWorkItem variants now carry an is_surprise_* flag and skip update_vtl2_device_bind_state on surprise transitions.
  • Uevent dispatch logic in the run loop matches on (state, action, exists) and uses a new seen_device_enumerated atomic flag to correlate vPCI DeviceEnumerated with a subsequent uevent add/rescan.
  • HclNetworkVfManagerUeventHandler now also matches child paths under the device and PCI bus removal paths, and translates RESCAN=true notifications into a new UeventAction::Rescan.

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