Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions openhcl/underhill_core/src/emuplat/netvsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,14 @@ impl HclNetworkVFManagerWorker {
let exists = Path::new(&device_path).exists();
match (vtl2_device_state, exists) {
(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,
}
});
Expand Down Expand Up @@ -1045,7 +1053,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!(
Expand Down Expand Up @@ -1128,10 +1137,11 @@ 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");
// In case startup fails, state should not be Reconfiguring.
vtl2_device_state = Vtl2DeviceState::Missing;
}
tracing::info!(vtl2_vfid, "VTL2 VF arrived");
let mut ctx =
mesh::CancelContext::new().with_timeout(std::time::Duration::from_secs(1));
Expand All @@ -1155,7 +1165,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);
Expand All @@ -1173,8 +1183,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!(
Expand Down