Skip to content

Conversation

mattkur
Copy link
Contributor

@mattkur mattkur commented Oct 9, 2025

One of the gaps between the HyperV and OpenVMM Petri backends is the ability to show NVMe storage to VTL2 (or, really, any storage to VTL2) and translate that storage to the VTL0 guest. This work in progress change aims to remove that. Unfortunately, Hyper-V does not support any NVMe emulators, but Microsoft has some ability to do this using Microsoft-proprietary methods. Coverage for this scenario in CI is so important that I think it worth it to leverage those methods, even though doing so is only viable for CI (where Microsoft controls the test environment) and for engineers with access to those Microsoft-internal mechanisms.

TODO:

  • First pass on Microsoft-internal helper scripts
  • Invoke those helper scripts from a VMM test
  • Host capabilities detection written
  • Host capabilities detection tested (relies on CI run)
  • Set VTL2 settings of Hyper-V VM (currently fails in passing the JSON string to PowerShell ... needs another layer of escaping)?
  • Test that adds one of these disks as a second controller
  • Hook this up "nicely" to the Petri Hyper-V backend (hopefully a future PR)

@mattkur mattkur requested a review from a team October 9, 2025 23:13
@mattkur mattkur force-pushed the hyperv-nvme-storage branch from bcd45c7 to 71b9c88 Compare October 10, 2025 22:49
@mattkur mattkur changed the title wip: petri: hyperv backed with emulated nvme rfc: petri: hyperv backed with emulated nvme Oct 10, 2025
@mattkur mattkur marked this pull request as ready for review October 10, 2025 22:50
@mattkur mattkur requested review from a team as code owners October 10, 2025 22:50
@Copilot Copilot AI review requested due to automatic review settings October 10, 2025 22:50
Copy link
Contributor

@Copilot 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 RFC introduces support for NVMe storage in Hyper-V VMs using Microsoft-internal utilities, enabling VTL2 storage emulation that can be accessed by VTL0 guests. This bridges a testing gap between OpenVMM and Hyper-V backends in the Petri testing framework.

  • Adds host capability detection for Microsoft-internal NVMe storage support
  • Implements runtime NVMe device addition and VTL2 settings configuration
  • Refactors command line parameter handling to be shared between OpenVMM and Hyper-V backends

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
vmm_tests/vmm_tests/tests/tests/x86_64/storage.rs Adds new test case for OpenHCL NVMe storage on Hyper-V
vmm_tests/vmm_tests/Cargo.toml Adds dependencies for VHD handling and VTL2 settings
vmm_tests/vmm_test_macros/src/lib.rs Adds hyperv_test macro and NVMe storage requirements detection
petri/src/vm/openvmm/construct.rs Refactors command line parameter handling to use shared function
petri/src/vm/mod.rs Adds shared function for appending log parameters and increases timeout
petri/src/vm/hyperv/vm.rs Adds methods for NVMe storage and VTL2 settings management
petri/src/vm/hyperv/powershell.rs Implements PowerShell commands for NVMe storage and VTL2 settings
petri/src/vm/hyperv/mod.rs Updates backend to support NVMe configuration and shared command line handling
petri/src/vm/hyperv/hyperv.psm1 Adds PowerShell function for setting VTL2 settings
petri/src/requirements.rs Adds host capability detection for NVMe storage support


{
const TIMEOUT_DURATION_MINUTES: u64 = 7;
const TIMEOUT_DURATION_MINUTES: u64 = 10;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

todo Don't merge a difference here...

Copy link

Copy link

let is_nvme = matches!(
config.firmware,
Firmware::OpenhclUefi(OpenhclUefiOptions { nvme: true, .. }, _)
) || name.contains("add_nvme_device");
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we wouldn't be depending on the name, we want to avoid that as much as possible. Is there any other bit we can look for?

If not, this is something that can probably be addressed with future planned refactorings.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could add macro syntax for additional requirements, the same as we have one for additional artifacts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. For now: I think we can just look for nvme as part of the name to simplify this. The current match is set up to catch any of the existing magic (where you add [nvme] into the dependency requirements), or based on certain test names.

I'm certainly not allergic to adding more test macros here, but I'd like to keep the first PR tactical, and to leverage stuff that comes from Microsoft internal tooling. Other future improvements will be for petri to set up NVMe redirection for Hyper-V just like it does for openvmm, for example.

We'd also expand this to the MANA emulator, for example.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not saying add a whole new macro, just add additional syntax to the current one, similar to the [] stuff we do for additional artifact dependencies, but instead for additional host requirements. We could use that for servicing too potentially. I don't think it'd be a huge lift, but up to you if we want to punt.

{
// Not checked for non-Windows platforms, so just assume that the feature
// is supported.
true
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we default to false?

.cmdlet("Test-Path")
.arg(
"Path",
"c:\\OpenVMMCI\\MicrosoftInternalTestHelpers\\MicrosoftInternalTestHelpers.psm1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Where do these come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the crux of the approach: those need to be latent on the CI machines. These come from our internal repositories (although I am still churning on our CI infra).

Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm, not a huge fan of anything that makes our CI setup less easily reproducible...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood. I have heartache about this as well. This conversation I should take offline with you.

Copy link

Copy link

@mattkur
Copy link
Contributor Author

mattkur commented Oct 14, 2025

Split out much of the non-nvme specific stuff to #2171

mattkur added a commit that referenced this pull request Oct 16, 2025
In doing #2137, I realized that I had done almost all the work required
to do scsi-to-scsi relay for the Hyper-V backend.

petri:
- Add infra to set VTL2 settings for a Hyper-V test backend.
- Return the SCSI controller VSID when one is added (required to
reference that controller in VTL2 settings...).
- Add a `hyperv_test` macro, so that the test can get access to the
Hyper-V Petri backend (like `openvmm_test`).

vmm_tests:
- Write a test that uses this infra.
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.

2 participants