Skip to content

New extension: nvme-conversion — Convert VM disk controllers between SCSI and NVMe - #9858

Open
jonathanbrenes wants to merge 12 commits into
Azure:mainfrom
jonathanbrenes:feature/nvme-conversion
Open

jonathanbrenes wants to merge 12 commits into
Azure:mainfrom
jonathanbrenes:feature/nvme-conversion

Conversation

@jonathanbrenes

@jonathanbrenes jonathanbrenes commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

New extension: nvme-conversion — Convert VM disk controllers between SCSI and NVMe


This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

az nvme-conversion check, az nvme-conversion convert

Description

Adds the 1.0.0b1 preview extension for converting Azure VM disk controllers between SCSI and NVMe. The extension orchestrates VM/SKU/OS validation, guest preparation, verified deallocation, disk capabilities, controller/size changes, and optional startup. Linux dry-run remains supported.

Linux guest-kernel inventory correction

Module packages can populate directories for kernel releases that are not installed. Treating every /lib/modules directory as an installed kernel can incorrectly require nonexistent boot images and block preparation.

Kernel discovery now uses installed package file lists and guest boot-image/GRUB/BLS references. Module-only directories, debug/header artifacts, and rescue aliases are excluded. Genuine installed or boot-referenced kernels still require valid images and drivers; missing inventories and package-query failures remain blocking.

Check remains read-only, fixes remain opt-in, and dry-run stages changes without applying them. No package-owned modules are removed as a workaround.

Windows readiness and persistence correction

Aligns guest preparation with Azure-NVMe-Conversion.ps1 in:
https://github.com/Azure/SAP-on-Azure-Scripts-and-Utilities

The upstream comparison used public script version 2026082514.

Windows preparation now requires:

  • The stornvme.sys driver binary.
  • Boot-start DWORD settings for stornvme, vpci, and pci across every ControlSet.
  • Removal of blocking stornvme/vpci startup overrides. PCI StartOverride is allowed and preserved.
  • NVMe DWORD parameters: IoTimeoutValue=240, BusType=17, StorageSupportedFeatures=3, and PnpInterface\5=1.
  • Completed sc.exe operations, successful registry flushing, verified readback, and complete readiness confirmations.

For synchronous Windows NVMe startup, the extension waits for the VM and guest agent, then verifies actual NVMe boot-disk enumeration. With --fix-os, it reapplies settings after first boot, performs a controlled restart, and verifies persistence. Without --fix-os, verification is read-only.

Deferred and --no-wait starts report pending post-boot verification. Explicit checks of already-converted Windows NVMe VMs validate guest settings and boot-disk enumeration without another conversion. Start or post-boot failures report that conversion may already have occurred; no automatic rollback is performed.

Safety corrections retained

  • Reject incomplete or failed guest preparation, failed inspections/rebuilds, and remaining errors—including with --fix-os.
  • Verify actual Linux NVMe PCI and Hyper-V PCI drivers for each genuine guest kernel.
  • Correct fallback udev dollar escaping and namespace-based LUN calculation.
  • Support multi-letter SCSI names and UUID-only blkid output; preserve fstab when an entry cannot be resolved.
  • Reject Windows dry-run before guest mutation.
  • Require confirmed deallocation before disk/controller writes; stopped, transitional, and unknown states are not treated as deallocated.
  • Refuse NVMe for OS/data-disk ADE or unverifiable encryption inventory. Unlocking ADE or removing its extension does not prove decryption. SSE and encryption at host are separate; returning to SCSI remains permitted.
  • Preserve RHEL 7 standalone EFI timeout validation and regeneration safeguards.

CI correction

Existing Windows startup/readiness branches were extracted into focused helpers to satisfy Pylint complexity limits without changing behavior. The error-message line length and Windows test license header were corrected. No lint thresholds were relaxed.

Validation

Command/check Result
python -B -m pytest azext_nvme_conversion/tests/latest -k 'not NvmeConversionCheckTest and not NvmeConversionConvertTest' -q -p no:cacheprovider — extension root, Linux root, existing native PowerShell selected PASSED: 129 tests, 80 subtests; 2 live scenarios deselected
Repository-configured python -B -m pylint --rcfile <repository>/pylintrc <extension>/azext_nvme_conversion PASSED: 10/10
Changed-file flake8 using the documented configuration PASSED
git diff --check PASSED
azdev style nvme-conversion — hosted GitHub and Azure Pipelines checks PASSED; the latest local azdev discovery attempt stalled and is not counted as passed
azdev verify license — hosted check; local verifier scoped to extension Python sources PASSED
Hosted Python 3.10–3.14 integration/build checks PASSED
Hosted extension index, external-source URLs, linter, credential/security scans, and breaking-change checks PASSED
Overall Azure pipeline PASSED

Linux regressions use disposable synthetic chroots and image files. Native Windows tests execute the guest scripts against virtual registry/disk handles, including flush failures and persistence drift; they do not modify the host registry or services.

These results are not new live Windows boot certification. No live Windows conversion, registry-flush race, or first-device-installation cycle was executed for these changes. Earlier live results remain historical and are not acceptance evidence for the revised CLI payload or ADE conversion support.

Release scope

These changes correct existing readiness and boot-persistence behavior; they do not add commands, supported platforms, dependencies, or a new SDK/API path. The preview version and proposed January 2027 milestone remain unchanged. No automatic peer-VM shutdown or policy/network changes are introduced.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

The latest local azdev discovery attempt did not complete. Standalone repository-configured Pylint and changed-file flake8 passed, and both hosted azdev style checks passed. The local index command passed earlier validation; the current hosted index check also passed.

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

…SCSI and NVMe

Adds the nvme-conversion extension that orchestrates the full SCSI<->NVMe
conversion lifecycle for Azure VMs:
- Pre-flight validation (Gen2, ADE, SKU capabilities, OS readiness)
- OS preparation via RunCommand (Windows stornvme, Linux initramfs/grub/fstab)
- VM deallocate, OS disk capability update, VM resize + controller change
- Optional VM start with rollback instructions

Commands:
  az nvme-conversion check   - Validate VM readiness without changes
  az nvme-conversion convert - Full conversion with --fix-os, --dry-run, --no-wait

Tested on: Ubuntu 24.04, RHEL 8/9/10, SLES 15 SP6, Azure Linux 4,
Windows Server 2019/2022 — 20 VMs, 56 unit tests, azdev style/test/linter passed.
- custom.py: reject unmanaged (page-blob) OS disks in _validate_vm with a clear ValidationError.

- custom.py: add _get_vm_skus() helper; share resource_skus.list() result between _resolve_vm_size and _validate_sku to avoid duplicate API calls.

- custom.py: switch user-progress logger.warning calls to logger.info (Gen2 banner, controller arrows, SKU validating, VM updated, VM started, etc.); reserve warnings for actual problems.

- custom.py: collapse _check_os_readiness into a thin wrapper around _prepare_os(fix_os=False, dry_run=False) to remove duplicated logic.

- custom.py: validate SKU capabilities across all vm.zones, not just vm.zones[0].

- _linux_checks.py / _windows_checks.py: add timeout=600 to begin_run_command(...).result() calls so RunCommand cannot hang indefinitely.

- commands.py: replace confirmation=True with a custom yes/no prompt that names the VM and target controller for the convert command.

- setup.py: pin azure-mgmt-compute>=30.0.0.

Validated end-to-end against live Azure VMs in westus3:

- 6/6 RHEL 9 LVM Gen2 VMs converted Standard_D2s_v5 (SCSI) -> Standard_D2s_v6 (NVMe) and verified post-conversion.

- Unmanaged-disk guard verified live: az nvme-conversion check on an unmanaged-disk VM fails with the new clear error message.

- pytest: 56 passed, 2 skipped. azdev style (pylint + flake8): PASSED.
Copilot AI review requested due to automatic review settings May 11, 2026 21:36
@azure-client-tools-bot-prd

Copy link
Copy Markdown
Validation for Breaking Change Starting...

Thanks for your contribution!

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new Azure CLI extension (nvme-conversion) to pre-flight check and convert Azure VM disk controllers between SCSI and NVMe, including OS readiness checks/fixes and user-facing help/output.

Changes:

  • Introduces az nvme-conversion check and az nvme-conversion convert commands with SKU/ADE/Gen2/power-state validation and conversion orchestration.
  • Adds OS preparation implementations for Linux (embedded RunCommand bash script) and Windows (stornvme checks/fix via RunCommand).
  • Adds unit + mocked end-to-end tests plus extension packaging metadata and docs.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/nvme-conversion/setup.py Extension packaging metadata and dependencies
src/nvme-conversion/setup.cfg Placeholder config file
src/nvme-conversion/azext_nvme_conversion/custom.py Primary check/convert orchestration and internal helpers
src/nvme-conversion/azext_nvme_conversion/commands.py CLI command registration + confirmation/table formatting wiring
src/nvme-conversion/azext_nvme_conversion/_params.py CLI parameters and validators wiring
src/nvme-conversion/azext_nvme_conversion/_validators.py Input validation for --vm-size and --sleep-seconds
src/nvme-conversion/azext_nvme_conversion/_windows_checks.py Windows RunCommand checks/fix + version validation
src/nvme-conversion/azext_nvme_conversion/_linux_checks.py Linux RunCommand wrapper and error parsing
src/nvme-conversion/azext_nvme_conversion/_linux_script.py Embedded bash script for Linux NVMe readiness + fixes
src/nvme-conversion/azext_nvme_conversion/_format.py Table output transformers for -o table
src/nvme-conversion/azext_nvme_conversion/_help.py Help text and examples
src/nvme-conversion/azext_nvme_conversion/_client_factory.py Compute client factory
src/nvme-conversion/azext_nvme_conversion/azext_metadata.json Extension metadata (preview + min CLI core)
src/nvme-conversion/azext_nvme_conversion/tests/latest/test_nvme_conversion.py Unit + mocked end-to-end tests
src/nvme-conversion/README.md User-facing overview and usage
src/nvme-conversion/HISTORY.rst Initial release notes
src/nvme-conversion/DEVELOPMENT.md Development guide and architecture notes
src/nvme-conversion/ROADMAP.md Implementation roadmap and design notes
src/nvme-conversion/TESTING.md Live test tracker

Comment thread src/nvme-conversion/setup.py Resolved
Comment thread src/nvme-conversion/setup.py Resolved
Comment thread src/nvme-conversion/TESTING.md Resolved
@yonzhan

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions

Copy link
Copy Markdown
Contributor

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@github-actions

Copy link
Copy Markdown
Contributor

jonathanbrenes and others added 3 commits May 11, 2026 17:00
Validate and regenerate the resolved RHEL 7 standalone EFI boot entries instead of accepting timeout defaults from an unrelated configuration. Add isolated shell regressions and document runtime validation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add the top-level nvme-conversion command to the service mapping required by Azure Pipelines style and linter validation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jonathanbrenes and others added 2 commits November 24, 2026 21:56
Verify ADE handlers and OS/all data-disk encryption metadata before NVMe
preparation or writes. Refuse incomplete inventory and API failures without
blocking SSE, encryption at host or a return to SCSI.

Emit versioned source-VM eligibility for trusted offline ALAR handoff, with
mocked regressions and actual SDK response-wrapper compatibility coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep VM-wide ADE preflight unchanged while clarifying that its diagnostic
JSON is no longer required by ALAR's independent local BEK/encryption guard.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

Critical gaps in readiness checks, OS repairs, and deallocation safeguards can allow unsafe NVMe conversion and leave VMs unable to boot.

13 open issues
12 resolved since last review

Review effort: Balanced

@x-engineering-agent

Copy link
Copy Markdown

Automated sensitive-information remediation ran on this pull request.

Possible secrets (heuristic matches that may be test data or placeholders):

X Engineering Agent does not modify source files. The PR creator should remove or replace each listed source value.

If this is not sensitive, react with -1 on this comment. A -1 from anyone clears possible secrets; known credential formats need a maintainer's -1. Detected values are never copied into this comment.

React with +1 to confirm the finding or -1 to dispute it. The bot-created reactions are only poll choices.

jonathanbrenes and others added 2 commits November 25, 2026 08:57
Address the 13 reviewed readiness, Linux driver/UUID/udev, Windows
driver/completion/dry-run, and power-state findings with fault regressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename the flagged fixture identifier to timeout_argument and use
argument/authorization-header wording in the related documentation.
Keep the fixture values, assertions and production behavior unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanbrenes

Copy link
Copy Markdown
Contributor Author

Addressed the automated sensitive-information finding in eda441973.

The flagged identifier named an EFI test fixture for a public kernel timeout setting; it was not a secret. It is now timeout_argument, and related documentation uses argument/authorization-header wording. The previously flagged wording no longer appears in the NVMe extension source or documentation.

Fixture values, assertions and production behavior are unchanged.

Validation:

  • python -B -m pytest azext_nvme_conversion/tests/latest/test_linux_efi_timeout.py -q -p no:cacheprovider (extension root, Linux root): 13 passed.
  • python -B -m flake8 --config .flake8 src/nvme-conversion/azext_nvme_conversion/tests/latest/test_linux_efi_timeout.py (repository root): passed.
  • Source wording scan and git diff --cached --check: passed.

The original heuristic notice was disputed with a -1 reaction based on the verified test-only context.

@x-engineering-agent

Copy link
Copy Markdown

Finding disputed by jonathanbrenes.

Nothing blocks automation any more, so it will continue.

X Engineering Agent never restores redacted text because doing so could publish a value again.

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.

Comment on lines +134 to +135
KERNEL=="nvme*[0-9]n1", ENV{DEVTYPE}=="disk", SYMLINK+="disk/azure/root"
KERNEL=="nvme*[0-9]n1p[0-9]*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/azure/root-part%n"
Comment on lines +468 to +469
if { [ -n "$_rhel7_efi_config" ] && nvme_timeout_entries_ready "$_rhel7_efi_config"; } ||
{ [ -z "$_rhel7_efi_config" ] && grep -q "nvme_core.io_timeout=240" $_grub_check_files 2>/dev/null; }; then
Comment on lines +109 to +110
elif not vm_is_running:
_status('[5/8] OS readiness check skipped (VM is not running).')
Comment on lines +262 to +263
'status': 'passed' if vm_is_running else 'info',
'message': '' if vm_is_running else 'VM is not running. OS checks skipped.'
Comment on lines +558 to +562
# Zone availability — must be available in every zone the VM is pinned to
if vm.zones:
sku_zones = set()
for loc_info in (target_sku.location_info or []):
sku_zones.update(loc_info.zones or [])
@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

jonathanbrenes and others added 2 commits November 26, 2026 15:11
RHEL 9.8 can contain a kmod-kvdo directory for a kernel that is not installed. Discover kernels from installed package files and boot references while retaining genuine missing-image and driver failures. Preserve check, fix and dry-run behavior and add focused regressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Align guest readiness with Azure-NVMe-Conversion.ps1 in https://github.com/Azure/SAP-on-Azure-Scripts-and-Utilities. Verify the driver binary, PCI boot state and required NVMe DWORD parameters across ControlSets; preserve valid PCI overrides and flush registry changes before readiness is confirmed.

After Windows startup, wait for guest readiness, verify NVMe OS-disk enumeration, reapply opt-in settings and check persistence after restart. Keep check mode read-only and deferred/no-wait starts explicit. Report partial-conversion failures without automatic rollback and add functional regressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanbrenes
jonathanbrenes force-pushed the feature/nvme-conversion branch from cc1ff55 to af53bfb Compare November 26, 2026 21:58
@x-engineering-agent

Copy link
Copy Markdown

Extract existing VM start and Windows readiness branches into focused helpers without changing behavior. Add the standard license header to the Windows regression tests and keep error messages within the repository line limit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanbrenes

Copy link
Copy Markdown
Contributor Author

@x-engineering-agent The failures reported in your CI notice are resolved by c98a5ba.

The correction:

  • Extracts the existing VM-start/Windows post-boot flow and already-converted Windows readiness check into focused helpers, bringing the CLI functions within the repository's Pylint local-variable and branch limits.
  • Shortens the error-message source line to meet the 120-character limit.
  • Adds the required Microsoft copyright/MIT license header to test_windows_readiness.py.

This is a behavior-preserving CI correction, not a relaxation of lint rules or a change to conversion safety. The RHEL and Windows fixes remain separate preceding commits.

Validation:

  • Repository-configured Pylint: passed, 10/10.
  • Actual azdev license-header verifier on extension Python sources: passed.
  • Regression suite: 129 passed, 80 subtests passed; 2 live scenarios deselected. Native Windows cases used mocked registry/disk handles, not live VM boots.
  • Changed-file flake8 and git diff --check: passed.

The hosted rerun now reports SUCCESS for all four checks you identified: GitHub azdev-style, Azure Pipelines style, Check License, and the overall Azure pipeline (build 380239).

The PR description, review state, and January 2027 milestone are unchanged.

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