
方法在虚拟机xml中加入smbios配置信息xml代码解读复制代码os smbios modesysinfo/ ... /os sysinfo typesmbios baseBoard entry nameasset10.145.xx.xx/entry /baseBoard /sysinfo然后使用xml创建并运行虚拟机进入虚拟机内部通过命令dmidecode -t 2进行获取text代码解读复制代码# 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获取