查找特定的SCSI控制器与WMI查询Msvm_ResourceAllocationSettingData
本文关键字:查询 WMI Msvm ResourceAllocationSettingData 控制器 SCSI 查找 | 更新日期: 2023-09-27 18:07:28
使用虚拟化样例(V2)的常用实用程序
我创建了一个类来查询Msvm_VirtualSystemSettingData -
public static ManagementObject GetVirtualMachineSettings(ManagementObject virtualMachine)
{
using (ManagementObjectCollection settingsCollection =
virtualMachine.GetRelated("Msvm_VirtualSystemSettingData", "Msvm_SettingsDefineState",
null, null, null, null, false, null))
{
ManagementObject virtualMachineSettings =
GetFirstObjectFromCollection(settingsCollection);
return virtualMachineSettings;
}
}
在Main中,我使用的类如下-
ManagementObject vmSettings = GetVirtualMachineSettings(vm);
ManagementObjectCollection scsiController = vmSettings.GetRelated("Msvm_ResourceAllocationSettingData");
foreach (ManagementObject controller in scsiController)
{
if (controller["ResourceType"].ToString() == "6")
{
Console.WriteLine("'nCaption: {0}'nDescription: {1}'nInstance ID: {2}'nElementName: {3}'nResource Type: {4}'nResource SubType: {5}'n",
controller["Caption"].ToString(),
controller["Description"].ToString(),
controller["InstanceID"].ToString(),
controller["ElementName"].ToString(),
controller["ResourceType"].ToString(),
controller["ResourceSubType"].ToString());
}
}
我如何确切地看到哪一个是SCSI 0, SCSI 1, SCSI 2, SCSI 3?我知道"HyperV:合成Scsi设备"都有实例ID,但我的意思是Hyper-V如何将每个Scsi控制器转换为0、1、2和3?
如果你看InstanceID字段-你会看到
微软:219513 e4 - 7641 - 49 - b0 - 810 e - dc7621e1b01b ' 3 bae5515 - 9 - d6c - 4216 - 85 - f4 - 9335 cee41629 ' 0
,其中第二个GUID (3BAE5515-9D6C-4216-85F4-9335CEE41629)是SCSI控制器id。您可以通过在Hyper-V主机的Powershell中运行:Get-VirtualSCSIAdapter -ID 3BAE5515-9D6C-4216-85F4-9335CEE41629
来获取总线号。
该命令返回:
总线:0
ID: 3BAE5515-9D6C-4216-85F4-9335CEE41629