Skip to content

Conversation

@gurasinghMS
Copy link
Contributor

Nvme keepalive will now use more verbose language for cli updates sent to the user mode. This will give us visibility in to why nvme keepalive is being enabled or disabled.

@github-actions github-actions bot added the unsafe Related to unsafe code label Nov 21, 2025
@github-actions
Copy link

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

Ok(v) => v,
Err(e) => {
tracing::warn!(
"failed to parse OPENHCL_NVME_KEEP_ALIVE ('{s}'): {e}. Nvme keepalive will be disabled."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NOTE: Decided to keep this here as opposed to defaulting to disabled in parse. That way we can more accurately log which variable parsing is failing (nvme vs mana)

@gurasinghMS gurasinghMS changed the title wip: keepalive cli arguments now follow what the mana keepalive pattern underhill_core: keepalive cli arguments for nvme follow the "disabled,host,privatepool" pattern Nov 22, 2025
@gurasinghMS gurasinghMS marked this pull request as ready for review November 22, 2025 01:20
@gurasinghMS gurasinghMS requested a review from a team as a code owner November 22, 2025 01:20
Copilot AI review requested due to automatic review settings November 22, 2025 01:20
Copilot finished reviewing on behalf of gurasinghMS November 22, 2025 01:23
Copy link
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

This PR updates NVMe keepalive configuration to use a verbose pattern-based approach (matching the existing MANA keepalive implementation) instead of a simple boolean, providing better visibility into why keepalive is enabled or disabled.

Key Changes:

  • Changed nvme_keep_alive from bool to KeepAliveConfig enum across the codebase
  • Updated command line generation in openhcl_boot to produce verbose patterns like "disabled,host,privatepool"
  • Added parsing support for the "disabled,*" pattern to handle manual override cases

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
openhcl/underhill_core/src/worker.rs Changed nvme_keep_alive field type from bool to KeepAliveConfig and updated usage to call .is_enabled()
openhcl/underhill_core/src/options.rs Added documentation for NVMe keepalive patterns, updated parsing to handle "disabled,*" patterns, improved error messages
openhcl/underhill_core/src/emuplat/netvsp.rs Reorganized import of KeepAliveConfig to follow better ordering
openhcl/underhill_core/src/dispatch/mod.rs Updated all references to use KeepAliveConfig type, replaced boolean flag with config object, added .is_enabled() calls, improved logging
openhcl/openhcl_boot/src/main.rs Rewrote NVMe keepalive command line generation to produce verbose "disabled,host,privatepool" style patterns instead of simple "1" flag

Comment on lines +308 to 311
write!(cmdline, "privatepool ")?;
} else {
write!(cmdline, "noprivatepool ")?;
}
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

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

The space after "privatepool" and "noprivatepool" will become part of the environment variable value, causing parsing to fail. The FromStr implementation for KeepAliveConfig (line 93 in options.rs) does not trim whitespace before parsing.

Move the space outside the environment variable value:

if vtl2_pool_supported {
    write!(cmdline, "privatepool")?;
} else {
    write!(cmdline, "noprivatepool")?;
}
write!(cmdline, " ")?;
Suggested change
write!(cmdline, "privatepool ")?;
} else {
write!(cmdline, "noprivatepool ")?;
}
write!(cmdline, "privatepool")?;
} else {
write!(cmdline, "noprivatepool")?;
}
write!(cmdline, " ")?;

Copilot uses AI. Check for mistakes.
Comment on lines +298 to +310
write!(cmdline, "disabled,")?;
}

if partition_info.nvme_keepalive {
write!(cmdline, "host,")?;
} else {
write!(cmdline, "nohost,")?;
}

if vtl2_pool_supported {
write!(cmdline, "privatepool ")?;
} else {
write!(cmdline, "noprivatepool ")?;
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

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

When disable_nvme_keep_alive is false, the command line will not include the "disabled," prefix. However, when it's true, the pattern becomes "disabled,host,privatepool" or "disabled,nohost,noprivatepool", etc.

The FromStr implementation at line 97 handles strings starting with "disabled," but doesn't have explicit matches for patterns like "disabled,host,privatepool". While the catch-all at line 97 will map these to Disabled, this means the host and privatepool information is ignored even though it's being generated.

Consider either:

  1. Not generating the host/privatepool parts when disabled is true (since they're ignored)
  2. Or adding explicit parsing for these patterns if the information is meant to be preserved for logging/debugging
Suggested change
write!(cmdline, "disabled,")?;
}
if partition_info.nvme_keepalive {
write!(cmdline, "host,")?;
} else {
write!(cmdline, "nohost,")?;
}
if vtl2_pool_supported {
write!(cmdline, "privatepool ")?;
} else {
write!(cmdline, "noprivatepool ")?;
write!(cmdline, "disabled ")?;
} else {
if partition_info.nvme_keepalive {
write!(cmdline, "host,")?;
} else {
write!(cmdline, "nohost,")?;
}
if vtl2_pool_supported {
write!(cmdline, "privatepool ")?;
} else {
write!(cmdline, "noprivatepool ")?;
}

Copilot uses AI. Check for mistakes.
/// - "host,privatepool" - Enable keep alive if both host and private pool support it.
/// - "nohost,privatepool" - Used when the host does not support keepalive, but a private pool is present. Keepalive is disabled.
/// - "nohost,noprivatepool" - Keepalive is disabled.
/// - "disabled, <x>,<x>" - TODO: This needs to be implemented for mana.
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

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

Inconsistent spacing in the documentation. Line 217 has "disabled,," while line 227 has "disabled, ," (note the space after the comma in line 227). These should match for consistency.

Suggested change
/// - "disabled, <x>,<x>" - TODO: This needs to be implemented for mana.
/// - "disabled,<x>,<x>" - TODO: This needs to be implemented for mana.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

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

Labels

backport_1.7.2511 unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants