Skip to content

openvmm_entry: add explicit controller and relay CLI for storage#3607

Open
jstarks wants to merge 5 commits into
microsoft:mainfrom
jstarks:nvme_cli
Open

openvmm_entry: add explicit controller and relay CLI for storage#3607
jstarks wants to merge 5 commits into
microsoft:mainfrom
jstarks:nvme_cli

Conversation

@jstarks
Copy link
Copy Markdown
Member

@jstarks jstarks commented May 30, 2026

The existing --disk and --nvme flags use implicit, unnamed controllers whose identity and VTL are determined by convention. This makes it impossible to precisely control controller placement, and the OpenHCL relay path (uh/uh-nvme) is tightly coupled to hardcoded instance IDs.

This PR introduces explicit, named controller management:

  • --nvme-pci id=<name>,pcie_port=<port>|vpci[=<guid>][,vtl2] creates a named NVMe controller with an explicit transport and VTL. Accepts an optional pre-created mesh channel for runtime hot-plug.

  • --vmbus-scsi id=<name>[,sub_channels=<N>][,vtl2] creates a named VMBus SCSI controller.

  • --openhcl-controller id=<name>,type=scsi|nvme[,guid=<guid>] registers an OpenHCL-managed controller as a relay target.

  • --disk gains on=<name>, nsid=<N>, lun=<N>, and relay=<ctrl>[:<loc>] options. on= attaches the disk to a named controller (NVMe or SCSI, resolved by type at add time). relay= routes the disk through OpenHCL to the named target controller, replacing the uh/uh-nvme mechanism for new usage.

The storage builder is refactored to support these named controllers alongside the existing implicit paths.

--disk without on=, --nvme, and uh/uh-nvme are deprecated with warnings pointing to the new flags. build_underhill is renamed to build_openhcl_settings.

Guide documentation is updated throughout to use the new CLI syntax in examples.

Copilot AI review requested due to automatic review settings May 30, 2026 21:24
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 explicit named storage controller management to openvmm_entry, replacing the previously implicit --disk/--nvme/uh/uh-nvme flows. New CLI flags --nvme-controller, --vmbus-scsi-controller, and --openhcl-controller register named controllers, and --disk gains controller=, nsid=, lun=, and relay= options to attach disks or relay them through OpenHCL. The OpenHCL relay path now looks up source/target controllers by name instead of using hardcoded instance IDs, and deterministic_guid is rewritten to use UUIDv8 with SHA-256.

Changes:

  • New StorageBuilder controller maps (nvme_controllers, scsi_controllers, openhcl_controllers) plus a Named DiskLocation and add_relay flow.
  • CLI parsing for the three new controller types and the new --disk options, with extensive parser unit tests.
  • Legacy --disk/--nvme/uh paths are kept but deprecated; build_underhill is renamed to build_openhcl_settings and now consumes its LUN state via mem::take.

Reviewed changes

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

Show a summary per file
File Description
openvmm/openvmm_entry/src/storage_builder.rs Adds named controllers, relay path, UUIDv8 GUIDs; build_openhcl_settings now takes &mut self and consumes underhill LUN state.
openvmm/openvmm_entry/src/lib.rs Registers named controllers before disk processing; routes --disk to Named/relay; emits deprecation warnings; pre-registers implicit PCIe controllers for legacy --nvme.
openvmm/openvmm_entry/src/cli_args.rs New NvmeControllerCli/ScsiControllerCli/OpenhclControllerCli types, extended DiskCli fields, parser constraints, and tests.
openvmm/openvmm_entry/Cargo.toml Adds sha2 workspace dependency for the new deterministic GUID derivation.
Cargo.lock Records the new sha2 dependency edge.

Comment thread openvmm/openvmm_entry/src/storage_builder.rs
Comment thread openvmm/openvmm_entry/src/storage_builder.rs Outdated
Comment thread openvmm/openvmm_entry/src/storage_builder.rs Outdated
Comment thread openvmm/openvmm_entry/src/lib.rs
Comment thread openvmm/openvmm_entry/src/storage_builder.rs
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

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

Comment thread openvmm/openvmm_entry/src/storage_builder.rs
Comment thread openvmm/openvmm_entry/src/storage_builder.rs
Comment thread openvmm/openvmm_entry/src/storage_builder.rs Outdated
@jstarks jstarks marked this pull request as ready for review June 1, 2026 04:28
@jstarks jstarks requested a review from a team as a code owner June 1, 2026 04:28
Copilot AI review requested due to automatic review settings June 1, 2026 04:28
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

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

Comment thread openvmm/openvmm_entry/Cargo.toml Outdated
Comment thread openvmm/openvmm_entry/src/storage_builder.rs
Comment thread openvmm/openvmm_entry/src/storage_builder.rs
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

@smalis-msft smalis-msft left a comment

Choose a reason for hiding this comment

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

Overall looks fine by me, but copilot's still got some feedback

jstarks added 5 commits June 1, 2026 13:21
The existing --disk and --nvme flags use implicit, unnamed controllers
whose identity and VTL are determined by convention. This makes it
impossible to precisely control controller placement, and the OpenHCL
relay path (uh/uh-nvme) is tightly coupled to hardcoded instance IDs.

Introduce explicit, named controller management:

- --nvme-controller id=<name>,pcie_port=<port>|vpci[=<guid>][,vtl2]
  creates a named NVMe controller with an explicit transport and VTL.
  Accepts an optional pre-created mesh channel for runtime hot-plug.

- --vmbus-scsi-controller id=<name>[,sub_channels=<N>][,vtl2]
  creates a named VMBus SCSI controller.

- --openhcl-controller id=<name>,type=scsi|nvme[,guid=<guid>]
  registers an OpenHCL-managed controller as a relay target.

- --disk gains controller=<name>, nsid=<N>, lun=<N>, and
  relay=<ctrl>[:<loc>] options. controller= attaches the disk to a
  named controller (NVMe or SCSI, resolved by type at add time).
  relay= routes the disk through OpenHCL to the named target
  controller, replacing the uh/uh-nvme mechanism for new usage.

The storage builder is refactored to support these named controllers
alongside the existing implicit paths. Named NVMe controllers carry
VTL, transport, and an optional hot-plug channel. Named SCSI
controllers carry VTL, instance ID, and sub-channel count. The relay
path (add_relay) looks up the source controller to determine VTL and
instance ID, adds the disk, then creates an OpenHCL LUN entry on the
target controller.

The deterministic_guid function is rewritten to use UUIDv8 (RFC 9562)
with SHA-256 instead of DefaultHasher, which is not stable across Rust
versions.

--disk without controller=, --nvme, and uh/uh-nvme are deprecated with
warnings pointing to the new flags. build_underhill is renamed to
build_openhcl_settings.
Copilot AI review requested due to automatic review settings June 1, 2026 20:23
@jstarks jstarks enabled auto-merge (squash) June 1, 2026 20:23
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

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

Comment on lines 202 to +214
pub fn has_vtl0_nvme(&self) -> bool {
!self.vtl0_nvme_namespaces.is_empty() || !self.underhill_nvme_luns.is_empty()
!self.vtl0_nvme_namespaces.is_empty()
|| !self.underhill_nvme_luns.is_empty()
|| self.controllers.values().any(|entry| {
matches!(
entry,
ControllerEntry::Nvme(nvme)
if nvme.vtl == DeviceVtl::Vtl0
&& matches!(nvme.transport, NvmeControllerTransport::Vpci(_))
&& !nvme.namespaces.is_empty()
)
})
}
Comment on lines +564 to +584
if !opt.nvme.is_empty() {
tracing::warn!("--nvme is deprecated; use --nvme-pci and --disk on=<name> instead");

// Pre-register implicit PCIe controllers for unique port names.
let mut registered_ports = std::collections::BTreeSet::new();
for disk in &opt.nvme {
if let Some(port) = &disk.pcie_port {
if registered_ports.insert(port.clone()) {
storage.add_nvme_controller(
port.clone(),
DeviceVtl::Vtl0,
storage_builder::NvmeControllerTransport::Pcie(port.clone()),
None,
).with_context(|| format!(
"legacy --nvme flag conflicts with an explicit controller named '{port}'; \
use --nvme-pci and --disk on=<name> instead"
))?;
}
}
}
}
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants