Skip to content

netvsp: vtl0 vf operations safe when vtl2 absent#3891

Open
erfrimod wants to merge 15 commits into
microsoft:mainfrom
erfrimod:erfrimod/fix-revoke-update
Open

netvsp: vtl0 vf operations safe when vtl2 absent#3891
erfrimod wants to merge 15 commits into
microsoft:mainfrom
erfrimod:erfrimod/fix-revoke-update

Conversation

@erfrimod

@erfrimod erfrimod commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

When EQE 135 resets the VTL 2 VF and the NIC has set revoke_vtl0_vf to false then the VTL0 VF will still be offered to the Guest. This causes problems in functions like update_vtl0_vf and hide_vtl0_vf which have assumptions about the VTL2 device being Present when VTL0 VF is offered. But now it is valid for the VTL2 device to be in Reconfiguring and Missing.

  • try_notify_guest_and_revoke_vtl0_vf - can be called from ManaDeviceRemoved. Modified so that when VTL2 device is not Present the HWC call to change MAC filter to synthetic path is skipped. Also modified bus-selection to skip calling revoke_vtl0_vf when VTL0 bus no present, in response to a hide_vtl0_vf.
  • update_vtl0_vf - Removed panicking asserts that VTL0 VF could not be offered to guest when VTL2 was not Present. Nested match logic replaced with a match(vtl2_device_state, vtl0_bus_control).
  • add_vtl0_vf - Early skip if VTL2 device is not Present. When VTL2 device returns, starup_vtl2_device will re-announce the VF arrival to Guest.
  • remove_vtl0_vf - Unchanged.
  • hide_vtl0_vf - When hiding, calls try_notify_guest_and_revoke_vtl0_vf regardless of VTL2 state.

@erfrimod
erfrimod requested a review from a team as a code owner July 8, 2026 18:14
Copilot AI review requested due to automatic review settings July 8, 2026 18:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens the netvsp VF manager’s state transitions so that a VTL0 VF is not left offered to the guest when VTL2 MANA device reconfiguration fails, preserving invariants relied on by subsequent state transitions (e.g., Hidden / Missing).

Changes:

  • Extend hide_vtl0_vf to revoke the VTL0 VF if it is still offered, even when VTL2 isn’t Present.
  • Refactor update_vtl0_vf into a match and add explicit handling for Vtl2DeviceState::Reconfiguring to revoke any still-offered VF.
  • Update reconfigure_vf_restart to revoke any still-offered VTL0 VF before marking the VTL2 device Missing when retries are exhausted.

Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs
Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs Outdated
Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs Outdated
Copilot AI review requested due to automatic review settings July 8, 2026 18:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Copilot AI review requested due to automatic review settings July 15, 2026 19:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs
Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs Outdated
Copilot AI review requested due to automatic review settings July 15, 2026 21:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@github-actions

Copy link
Copy Markdown

@sunilmut sunilmut changed the title netvsp: revoke VTL0 VF when VTL2 device reconfigure fails netvsp: revoke VTL0 VF when VTL2 device reset fails Jul 16, 2026
if matches!(vtl2_device_state, Vtl2DeviceState::Present) {
let vtl0_vf_offered = self.guest_state.is_offered_to_guest().await;
if vtl0_vf_offered {
// Reconfigure may have left the VTL0 VF offered to the guest.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lets remove this line from the comment Reconfigure may have left the VTL0 VF offered to the guest.

Copilot AI review requested due to automatic review settings July 18, 2026 00:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs Outdated
Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs Outdated
Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs Outdated
Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs
@github-actions

Copy link
Copy Markdown

@erfrimod erfrimod changed the title netvsp: revoke VTL0 VF when VTL2 device reset fails netvsp: vtl0 vf operations safe when vtl2 absent Jul 20, 2026
Copilot AI review requested due to automatic review settings July 20, 2026 20:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs Outdated
Copilot AI review requested due to automatic review settings July 20, 2026 20:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

openhcl/underhill_core/src/emuplat/netvsp.rs:823

  • update_vtl0_vf currently panics if it receives a redundant/duplicate update (e.g. Present→Present or NotPresent→NotPresent) due to assert!(is_present != bus_control.is_some()). This RPC is ultimately driven by modify_network_settings/update_vtl0_instance_id, which can plausibly be invoked multiple times with the same subordinate instance id (or None) and should be handled idempotently rather than crashing the worker.
            let is_present = matches!(
                self.vtl0_bus_control,
                Vtl0Bus::Present(_) | Vtl0Bus::HiddenPresent(_)
            );
            assert!(is_present != bus_control.is_some());
            let is_offered_to_guest = self.guest_state.is_offered_to_guest().await;

@github-actions

Copy link
Copy Markdown

// VTL0 VF revoke will no-op when VTL2 is absent. Once the VTL2 device
// returns `startup_vtl2_device` will notify the netvsp cooridnator of
// the arrival, which will send a fresh `RemoveVtl0VF`.
self.try_notify_guest_and_revoke_vtl0_vf(&Vtl0Bus::NotPresent, vtl2_device_state)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these functions do different things

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverting

Copilot AI review requested due to automatic review settings July 21, 2026 00:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs Outdated
Copilot AI review requested due to automatic review settings July 21, 2026 00:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

openhcl/underhill_core/src/emuplat/netvsp.rs:897

  • In update_vtl0_vf, when vtl2_device_state is not Present the code updates self.vtl0_bus_control but leaves guest_state.vtl0_vfid untouched. That can leave VirtualFunction::id() returning a stale VF id after a removal (or other bus transition) while VTL2 is missing/reconfiguring. If the intention is for guest_state to remain a projection of the current bus visibility, it should be updated here too.
                (
                    Vtl2DeviceState::Reconfiguring
                    | Vtl2DeviceState::Missing
                    | Vtl2DeviceState::DeviceEnumerated,
                    _,
                ) => {
                    self.vtl0_bus_control = bus_control
                        .map(Vtl0Bus::Present)
                        .unwrap_or(Vtl0Bus::NotPresent);
                }

Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs
Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs Outdated
@github-actions

Copy link
Copy Markdown

Copilot AI review requested due to automatic review settings July 21, 2026 18:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

openhcl/underhill_core/src/emuplat/netvsp.rs:609

  • On revoke failure, vtl0_bus is logged as the worker's current self.vtl0_bus_control, but the revoke is issued against vpci_bus_control (which may come from the caller-provided bus_control, e.g. during hide). Logging the actual revoke target avoids confusing traces.
                tracing::error!(
                    vtl2_vfid,
                    vtl0_bus = %self.vtl0_bus_control,
                    revoke_vtl0_vfid = vfid_from_guid(&vpci_bus_control.instance_id()),
                    err = err.as_ref() as &dyn std::error::Error,

Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs Outdated
Comment thread openhcl/underhill_core/src/emuplat/netvsp.rs
@github-actions

Copy link
Copy Markdown

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 22, 2026 17:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

openhcl/underhill_core/src/emuplat/netvsp.rs:609

  • The revoke failure log uses vtl0_bus = %self.vtl0_bus_control, but the revoke may be issued against the caller-supplied vpci_bus_control (e.g. after self.vtl0_bus_control has been replaced during hide/reconfig flows). Logging the bus control actually being revoked (and optionally the worker’s current bus state) will make these errors much easier to diagnose.
                tracing::error!(
                    vtl2_vfid,
                    vtl0_bus = %self.vtl0_bus_control,
                    revoke_vtl0_vfid = vfid_from_guid(&vpci_bus_control.instance_id()),
                    err = err.as_ref() as &dyn std::error::Error,

Comment on lines 844 to 846
Vtl0Bus::Present(_) | Vtl0Bus::HiddenPresent(_)
);
assert!(is_present != bus_control.is_some());
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.

4 participants