Skip to content

petri: add NVMe emulator support#3378

Open
babayet2 wants to merge 4 commits intomicrosoft:mainfrom
babayet2:emulated-nvme
Open

petri: add NVMe emulator support#3378
babayet2 wants to merge 4 commits intomicrosoft:mainfrom
babayet2:emulated-nvme

Conversation

@babayet2
Copy link
Copy Markdown
Collaborator

Adds coverage for HyperV NVMe devices leveraging a closed source emulator

This test is currently marked as unstable, the CI runners are not guaranteed to have the NVMe emulator installed

Copilot AI review requested due to automatic review settings April 26, 2026 22:36
@babayet2 babayet2 requested a review from a team as a code owner April 26, 2026 22:36
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 Hyper-V NVMe coverage in the Petri-based vmm_tests suite by provisioning NVMe devices via a closed-source Hyper-V “NVMe emulator” and wiring it through the Hyper-V Petri backend.

Changes:

  • Adds an (unstable) Hyper-V OpenHCL Linux storage test that validates discovery + IO via an NVMe emulator device.
  • Extends the Hyper-V Petri backend to translate VmbusStorageType::Nvme into post-create NVMe emulator device attachment.
  • Adds PowerShell-side plumbing to attach NVMe emulator devices after New-CustomVM completes.

Reviewed changes

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

File Description
vmm_tests/vmm_tests/tests/tests/x86_64/storage.rs Adds an unstable Hyper-V NVMe emulator storage test that exercises discovery and IO.
petri/src/vm/hyperv/mod.rs Maps VmbusStorageType::Nvme controllers to NVMe emulator device configs for Hyper-V backend runs.
petri/src/vm/hyperv/powershell.rs Adds nvme_emulator_devices to VM creation args and attaches them post-create via PowerShell.

Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/mod.rs Outdated
@github-actions
Copy link
Copy Markdown

Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/mod.rs Outdated
Comment thread petri/src/vm/hyperv/mod.rs Outdated
Comment thread petri/src/vm/hyperv/mod.rs Outdated
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/hyperv.psm1 Outdated
Comment thread petri/src/vm/hyperv/mod.rs Outdated
Comment thread petri/src/vm/hyperv/hyperv.psm1
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Copilot AI review requested due to automatic review settings April 27, 2026 23:31
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 4 out of 4 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

petri/src/vm/hyperv/mod.rs:389

  • ide_controllers is still computed above, but it is no longer passed into HyperVNewCustomVMArgs (only storage_controllers is set). This will silently drop IDE drive configuration for Hyper-V VMs and also leaves an unused ide_controllers local. Include the ide_controllers field in hyperv_args (or remove the mapping if IDE is intentionally unsupported).
            guest_state_path,
            storage_controllers,
            com_3: supports_com3,
            imc_hiv,
            management_vtl_settings,
            ..HyperVNewCustomVMArgs::from_config(&config, &properties)?
        };

        let vm = HyperVVM::new(hyperv_args, log_source.clone(), driver.clone()).await?;

Comment thread petri/src/vm/hyperv/powershell.rs
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/hyperv.psm1 Outdated
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/mod.rs Outdated
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/mod.rs Outdated
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
@github-actions
Copy link
Copy Markdown

Copilot AI review requested due to automatic review settings April 28, 2026 16:35
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 4 out of 4 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

petri/src/vm/hyperv/mod.rs:365

  • ide_controllers is built from the firmware config above, but it is no longer passed into HyperVNewCustomVMArgs (only storage_controllers is set here, and from_config initializes ide_controllers as empty). This silently drops IDE controller configuration for Hyper-V VMs and also leaves an unused local. Pass the computed ide_controllers into hyperv_args (or remove the mapping if it’s intentionally unsupported).
        let hyperv_args = HyperVNewCustomVMArgs {
            firmware_file: igvm_file.clone(),
            firmware_parameters: openhcl_command_line,
            guest_state_path,
            storage_controllers,
            com_3: supports_com3,
            imc_hiv,
            management_vtl_settings,
            ..HyperVNewCustomVMArgs::from_config(&config, &properties)?
        };

Comment thread petri/src/vm/hyperv/powershell.rs Outdated
Comment thread petri/src/vm/hyperv/powershell.rs
Comment thread petri/src/vm/hyperv/powershell.rs Outdated
assert_eq! panics the test runner instead of returning a structured
error. Use anyhow::ensure! so NSID validation failures surface as
clean error messages.

Co-authored-by: Copilot <[email protected]>
@github-actions
Copy link
Copy Markdown

@jstarks
Copy link
Copy Markdown
Member

jstarks commented Apr 29, 2026

Fundamentally, why do we need a separate Hyper-V test? Why can't we just make the existing NVMe test(s) work on Hyper-V transparently?

# Vsid => {
# Vtl,
# Drives => @(
# @{ Nsid; DiskPath },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can simplify this a bit and make the comments consistent:

The word "DiskPath" does not need to appear in the actual object passed in, Drives can be a hashtable with int keys and string values (rather than having a hashtable with only one thing)

        # NvmeControllers => {
        #     Vsid => {
        #         Vtl,
        #         Drives => {
        #             Nsid => DiskPath,
        #             ...
        #         }
        #     },
        #     ...
        # }

$targetVtl = $controller.Value["Vtl"]
$drives = $controller.Value["Drives"]
# Drives arrive pre-sorted by NSID from the Rust layer.
$vhdPaths = @($drives | ForEach-Object { $_["DiskPath"] })
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line is unnecessary with the above change

@tjones60
Copy link
Copy Markdown
Contributor

Fundamentally, why do we need a separate Hyper-V test? Why can't we just make the existing NVMe test(s) work on Hyper-V transparently?

This is a good point, we should now be able to write a backend-agnostic test for using the nvme emulator. I think the closest openvmm test would be openhcl_linux_stripe_storvsp but we should probably go through and see what it would take to get rid of all the remaining calls to modify_backend and make all of the tests in vmm_tests/vmm_tests/tests/tests/x86_64/storage.rs backend-agnostic.

We should also install the closed source components on at least one runner before we merge this to make sure the test actually works (even though it is still marked as unstable.

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.

4 participants