Skip to content

[AI Generated] Hyper-V: add safe NVMe discovery and recovery tooling - #4759

Open
Ajay R (AjayMsft9) wants to merge 2 commits into
microsoft:mainfrom
AjayMsft9:v-aratakonda/hyperv-nvme-auto-discovery-recovery
Open

Ajay R (AjayMsft9) wants to merge 2 commits into
microsoft:mainfrom
AjayMsft9:v-aratakonda/hyperv-nvme-auto-discovery-recovery

Conversation

@AjayMsft9

@AjayMsft9 Ajay R (AjayMsft9) commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds a reusable Hyper-V NVMe discovery and recovery utility for storage passthrough workflows.

The utility:

  • Auto-discovers exactly one eligible PCI NVMe controller using compatible ID CC_010802.
  • Supports raw or unpartitioned NVMe disks with zero partition rows.
  • Rejects boot, system, mounted, non-NVMe, ambiguous, VM-owned, and non-primordial storage-pool disks.
  • Maps the selected controller to an exact Windows disk identity.
  • Atomically persists the controller identity, stable disk identity, and original online/offline state.
  • Preserves the original state across repeated preflight executions.
  • Validates expected VM ownership before removing a DDA assignment.
  • Stops the owning VM, removes the assignment, returns the controller to the host, and enables the device.
  • Waits for the exact disk identity to reappear and restores its original online/offline state.
  • Fails closed when inventory, identity, ownership, or recovery state is missing or ambiguous.

Partition inventory uses the Windows Storage CIM provider directly. Zero MSFT_Partition rows are treated as a valid raw-disk state, while actual inventory query failures remain fatal.

This allows Hyper-V storage passthrough workflows to recover safely after successful, failed, or interrupted test execution without relying on a hardcoded PCI location path.

Related Issue

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Documentation update

Checklist

  • Description is filled in above
  • No credentials, secrets, or internal details are included
  • Peer review requested (if not, add required peer reviewers after raising PR)
  • Tests executed and results posted below

Test Validation

Key Test Cases:
verify_storage_passthrough_nvme_visible|perf_storage_passthrough_fio_randread|perf_storage_passthrough_fio_randwrite

Impacted LISA Features:
Nvme

Tested Azure Marketplace Images:

  • N/A - physical Windows Hyper-V host workflow

Test Results

Image VM Size Result
N/A - focused Pester validation Physical Hyper-V host workflow PASSED - 11/11
N/A - GitHub CI N/A PASSED - 29/29
N/A - physical Hyper-V E2E Physical Hyper-V host PASSED - 3/3 tests and host recovery

Copilot AI balanced review requested due to automatic review settings October 9, 2026 11:14

Copilot AI left a comment

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.

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

Copilot AI balanced review requested due to automatic review settings October 9, 2026 19:21

Copilot AI left a comment

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.

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

@@ -0,0 +1,583 @@
# Copyright (c) Microsoft Corporation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please remove this file

@@ -0,0 +1,592 @@
# Copyright (c) Microsoft Corporation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why need this file? where it is used? We don't want to use ps file directly, instead, we'd like to use python + wrap ps commands

@LiliDeng LiliDeng changed the title Hyper-V: add safe NVMe discovery and recovery tooling [AI Generated] Hyper-V: add safe NVMe discovery and recovery tooling Oct 10, 2026

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants