我想要使用 Hyper-V WMI 类获取虚拟机的内存。 有4个内存类别;但我找不到它们的任何属性来获取内存值。
Msvm_Memory 类具有 BlockSize 和 NumberOfBlocks 属性。 当我将它们相乘时,我无法获得正确的内存。
尊重 https://msdn.microsoft.com/en-us/library/hh850175(v=vs.85).aspx这已经是错误的做法了。
BlockSize Data type: uint64 Access type: Read-only The size, in bytes, of the blocks that form the storage extent. If variable block size, then the maximum block size, in bytes, should be specified. If the block size is unknown, or if a block concept is not valid (for example, for aggregate extents, memory, or logical disks), enter a 1 (one). This property is inherited from CIM_StorageExtent, and it is always set to 1048576.
我应该使用哪个类和属性?
最佳答案
您可以使用 Msvm_MemorySettingData
类来访问实例的已定义内存属性。您可以通过InstanceID
过滤结果,并将AllocationUnits
与Limit
一起解析以获得配置的最大内存量。
在以下情况下,可以为特定实例“4764334E-E001-4176-82EE-5594EC9B530E
”分配 1 TB 内存。
Example InstanceID: "Microsoft:Definition\\4764334E-E001-4176-82EE-5594EC9B530E\\Default"
AllocationUnits: "bytes * 2^20"
Limit: 1048576
Msvm_MemorySettingData:https://msdn.microsoft.com/en-us/library/hh850176(v=vs.85).aspx
关于windows - Hyper-V WMI 类的哪些属性可访问内存信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28746019/