diff --git a/windows/utils/win_get_nvme_spec_version.yml b/windows/utils/win_get_nvme_spec_version.yml new file mode 100644 index 000000000..f7ec53138 --- /dev/null +++ b/windows/utils/win_get_nvme_spec_version.yml @@ -0,0 +1,27 @@ +# Copyright 2025 VMware, Inc. +# SPDX-License-Identifier: BSD-2-Clause +--- +# Get implemented NVMe spec version in Windows guest OS. +# Return: +# win_nvme_spec_version: the NVMe spec version got in guest OS. +# +- name: "Initialize the NVMe spec version in Windows guest OS" + ansible.builtin.set_fact: + win_nvme_spec_version: '' + +- name: "Get NVMe spec version in Windows guest OS" + include_tasks: win_execute_cmd.yml + vars: + win_powershell_cmd: >- + (Get-Physicaldisk | where-object {$_.Friendlyname -like '*NVMe*'} | + Get-StorageFirmwareInformation).FirmwareVersionInSlot + +- name: "Set fact of NVMe spec version" + ansible.builtin.set_fact: + win_nvme_spec_version: "{{ win_powershell_cmd_output.stdout_lines[0] }}" + when: + - win_powershell_cmd_output.stdout_lines is defined + - win_powershell_cmd_output.stdout_lines | length != 0 + +- name: "Print NVMe spec version in Windows guest OS" + ansible.builtin.debug: var=win_nvme_spec_version diff --git a/windows/vhba_hot_add_remove/check_disk_after_adding.yml b/windows/vhba_hot_add_remove/check_disk_after_adding.yml index e7dcd728e..17fa388a7 100644 --- a/windows/vhba_hot_add_remove/check_disk_after_adding.yml +++ b/windows/vhba_hot_add_remove/check_disk_after_adding.yml @@ -41,6 +41,10 @@ the same as the expected value {{ ctrl_num_guest_before | int + 1 }}. when: on_new_controller +- name: "Get NVMe spec version in guest OS" + include_tasks: ../utils/win_get_nvme_spec_version.yml + when: test_disk_ctrl_type == "nvme" + - name: "Initialize new disk and create disk partition in guest OS" include_tasks: create_partition_raw_disk.yml vars: diff --git a/windows/vhba_hot_add_remove/hot_extend_disk_test.yml b/windows/vhba_hot_add_remove/hot_extend_disk_test.yml index 1e083d212..98aa0250a 100755 --- a/windows/vhba_hot_add_remove/hot_extend_disk_test.yml +++ b/windows/vhba_hot_add_remove/hot_extend_disk_test.yml @@ -91,3 +91,6 @@ that: - win_disk_volume_size_after | int == 2 fail_msg: "Got disk volume '{{ drive_letter_new }}' size '{{ win_disk_volume_size_after }}' GB after extend, not 2GB." + +- name: "Get NVMe spec version in guest OS" + include_tasks: ../utils/win_get_nvme_spec_version.yml diff --git a/windows/vhba_hot_add_remove/nvme_vhba_device_ops_spec13.yml b/windows/vhba_hot_add_remove/nvme_vhba_device_ops_spec13.yml index 386127d68..89b0aa3d6 100644 --- a/windows/vhba_hot_add_remove/nvme_vhba_device_ops_spec13.yml +++ b/windows/vhba_hot_add_remove/nvme_vhba_device_ops_spec13.yml @@ -3,7 +3,16 @@ --- # Description: # This test case is used for check hotadd, hot remove disk -# on a new and existing NVMe controller with NVMe Spec 1.3 enabled. +# on a new and existing NVMe controller with NVMe Spec 1.3 enabled +# manually. +# Notes: +# Please refer to the release notes of ESXi 8.0.2: +# https://techdocs.broadcom.com/us/en/vmware-cis/vsphere/vsphere/8-0/ +# release-notes/esxi-update-and-patch-release-notes/vsphere-esxi-802-release-notes.html +# Default NVMe version 1.3 for Windows virtual machines: +# Starting with vSphere 8.0 Update 2, the NVMe version is set to 1.3 by default for +# Windows Server 2022 or Windows 11 and later VMs with hardware version 21 and later. +# Set this test case result to "Not Applicable" in above situation. # - name: nvme_vhba_device_ops_spec13 hosts: localhost diff --git a/windows/vhba_hot_add_remove/vhba_test.yml b/windows/vhba_hot_add_remove/vhba_test.yml index d00ef06c9..808028905 100755 --- a/windows/vhba_hot_add_remove/vhba_test.yml +++ b/windows/vhba_hot_add_remove/vhba_test.yml @@ -6,6 +6,36 @@ # - lsilogic: no inbox driver in Windows guest OS now, so no testing. # - buslogic: not supported in 64bit Windows guest OS, so no testing. # +- name: "Set fact of whether VM NVMe version 1.3 is enabled by default" + when: + - vm_hardware_version_num | int >= 21 + - test_disk_ctrl_type == 'nvme' + - vm_nvme_spec13_enabled is undefined + block: + - name: "For Windows {{ guest_os_product_type }} with guest ID {{ vm_guest_id }}" + ansible.builtin.set_fact: + vm_nvme_spec13_enabled: "{{ vm_guest_id | regex_search('windows(\\d+)srvNext', '\\1') | first | int >= 2019 }}" + when: vm_guest_id | regex_search('windows(\\d+)srvNext') + + - name: "For Windows {{ guest_os_product_type }} with guest ID {{ vm_guest_id }}" + ansible.builtin.set_fact: + vm_nvme_spec13_enabled: "{{ vm_guest_id | regex_search('windows(\\d+)_', '\\1') | first | int >= 11 }}" + when: vm_guest_id | regex_search('windows(\\d+)_') + +- name: "Skip test case" + include_tasks: ../../common/skip_test_case.yml + vars: + skip_msg: >- + Skip testing on this guest OS '{{ guest_os_ansible_distribution }}' with VM hardware version + '{{ vm_hardware_version_num }}', since NVMe version is 1.3 by default for Windows Server 2022, + Windows 11 and later VMs with hardware version 21 on ESXi 8.0.2 and later. + So skip this test case and only run test case 'nvme_vhba_device_ops' with default NVMe v1.3. + skip_reason: "Not Applicable" + when: + - test_disk_ctrl_type == 'nvme' + - test_purpose == "hot-add-spec13" + - vm_nvme_spec13_enabled is defined and vm_nvme_spec13_enabled + - name: "Get VM current disk controller info" include_tasks: get_vm_disk_ctrl_info.yml diff --git a/windows/vhba_hot_add_remove/vhba_test_prepare.yml b/windows/vhba_hot_add_remove/vhba_test_prepare.yml index 48ff0d459..4957fea5a 100644 --- a/windows/vhba_hot_add_remove/vhba_test_prepare.yml +++ b/windows/vhba_hot_add_remove/vhba_test_prepare.yml @@ -16,8 +16,9 @@ disk_controller_facts_data: "{{ disk_ctrls_before_hotadd }}" new_vhba_type: "{{ disk_controller }}" -- name: "Enable NVMe spec 1.3" +- name: "Enable NVMe spec 1.3 for NVMe '{{ test_purpose }}' testing" include_tasks: enable_vm_nvme_spec13.yml when: - test_disk_ctrl_type == 'nvme' - - test_purpose in ["hot-add-spec13", "hot-extend"] + - test_purpose == "hot-add-spec13" or (test_purpose == "hot-extend" and + (vm_nvme_spec13_enabled is undefined or not vm_nvme_spec13_enabled))