kvm虚拟机中如何知道自己运行在哪台物理机上
方法
<os>
<smbios mode='sysinfo'/>
...
</os>
<sysinfo type='smbios'>
<baseBoard>
<entry name='asset'>10.145.xx.xx</entry>
</baseBoard>
</sysinfo>
- 然后使用xml创建并运行虚拟机
- 进入虚拟机内部通过命令
dmidecode -t 2
进行获取
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 3.2.1 present.
# SMBIOS implementations newer than version 3.0 are not
# fully supported by this version of dmidecode.
Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
Manufacturer: *****
Product Name: *****
Version: *****
Serial Number: *****
Asset Tag: 10.145.xx.xx
Features:
Board is a hosting board
Board is replaceable
Location In Chassis: NULL
Chassis Handle: 0x0003
Type: Motherboard
Contained Object Handles: 0
说明
- libvirt虚拟机xml官方文档
- 该方式是通过打标签的方式将宿主机的ip地址注入到smbios中的
Base Board Information
上了,虚拟机内部通过dmidecode -t 2
获取
- 也可以注入到
Chassis Information
上,虚拟机内部通过dmidecode -t 3
获取