From 64782105d17cad9e0d1cdac1c7dab1048e0373aa Mon Sep 17 00:00:00 2001 From: erfrimod Date: Fri, 6 Mar 2026 17:37:18 -0800 Subject: [PATCH 1/2] vf reconfiguration abandoned on device arrival and removal --- openhcl/underhill_core/src/emuplat/netvsp.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/openhcl/underhill_core/src/emuplat/netvsp.rs b/openhcl/underhill_core/src/emuplat/netvsp.rs index 7a36fef53f..00b34ff396 100644 --- a/openhcl/underhill_core/src/emuplat/netvsp.rs +++ b/openhcl/underhill_core/src/emuplat/netvsp.rs @@ -752,7 +752,8 @@ impl HclNetworkVFManagerWorker { let device_arrival = (&mut self.uevent_handler).map(|device_path| { let exists = Path::new(&device_path).exists(); match (vtl2_device_state, exists) { - (Vtl2DeviceState::Missing, true) => NextWorkItem::ManaDeviceArrived, + (Vtl2DeviceState::Missing, true) + | (Vtl2DeviceState::Reconfiguring, true) => NextWorkItem::ManaDeviceArrived, _ => NextWorkItem::Continue, } }); @@ -1045,7 +1046,8 @@ impl HclNetworkVFManagerWorker { } tracing::info!(vtl2_vfid, "VTL2 VF reconfiguration requested"); - // Remove VTL0 VF if present + // Revoke the VTL0 VF from the guest if it has been offered. + // Required for Guest Mana driver to remove stale SoC state. *self.guest_state.vtl0_vfid.lock().await = None; if self.guest_state.is_offered_to_guest().await { tracing::warn!( @@ -1128,10 +1130,9 @@ impl HclNetworkVFManagerWorker { } NextWorkItem::ManaDeviceArrived => { assert!(!self.is_shutdown_active); - assert!( - vf_reconfig_backoff.is_none(), - "device arrival should only occur after device removal and not vf reconfiguration" - ); + if vf_reconfig_backoff.take().is_some() { + tracing::warn!("device arrived, abandoning vf reconfiguration"); + } tracing::info!(vtl2_vfid, "VTL2 VF arrived"); let mut ctx = mesh::CancelContext::new().with_timeout(std::time::Duration::from_secs(1)); @@ -1155,7 +1156,7 @@ impl HclNetworkVFManagerWorker { .await { vtl2_device_state = Vtl2DeviceState::Present; - } + } // else: Device arrived, but startup failed. No attempt to retry. } NextWorkItem::ManaDeviceRemoved => { assert!(!self.is_shutdown_active); @@ -1173,8 +1174,9 @@ impl HclNetworkVFManagerWorker { self.shutdown_vtl2_device(false).await; vtl2_device_state = Vtl2DeviceState::Missing; - // If the device is being removed, remove outstanding vf reconfiguration. - vf_reconfig_backoff = None; + if vf_reconfig_backoff.take().is_some() { + tracing::warn!("device removed, abandoning vf reconfiguration"); + } if let Err(err) = self.update_vtl2_device_bind_state(false).await { tracing::error!( From 4f5102f6f965f8937434307f22db1e8ffe87042f Mon Sep 17 00:00:00 2001 From: erfrimod Date: Fri, 6 Mar 2026 18:18:54 -0800 Subject: [PATCH 2/2] copilot suggestions --- openhcl/underhill_core/src/emuplat/netvsp.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/openhcl/underhill_core/src/emuplat/netvsp.rs b/openhcl/underhill_core/src/emuplat/netvsp.rs index 00b34ff396..b359eefe81 100644 --- a/openhcl/underhill_core/src/emuplat/netvsp.rs +++ b/openhcl/underhill_core/src/emuplat/netvsp.rs @@ -752,8 +752,15 @@ impl HclNetworkVFManagerWorker { let device_arrival = (&mut self.uevent_handler).map(|device_path| { let exists = Path::new(&device_path).exists(); match (vtl2_device_state, exists) { - (Vtl2DeviceState::Missing, true) - | (Vtl2DeviceState::Reconfiguring, true) => NextWorkItem::ManaDeviceArrived, + (Vtl2DeviceState::Missing, true) => NextWorkItem::ManaDeviceArrived, + (Vtl2DeviceState::Reconfiguring, true) => { + if self.is_shutdown_active { + // Reconfig -> Shutdown -> DeviceArrived (ignore arrival) + NextWorkItem::Continue + } else { + NextWorkItem::ManaDeviceArrived + } + } _ => NextWorkItem::Continue, } }); @@ -1132,6 +1139,8 @@ impl HclNetworkVFManagerWorker { assert!(!self.is_shutdown_active); if vf_reconfig_backoff.take().is_some() { tracing::warn!("device arrived, abandoning vf reconfiguration"); + // In case startup fails, state should not be Reconfiguring. + vtl2_device_state = Vtl2DeviceState::Missing; } tracing::info!(vtl2_vfid, "VTL2 VF arrived"); let mut ctx =