记录日常工作关于系统运维,虚拟化云计算,数据库,网络安全等各方面问题。
在某些需要给机器做认证和加密的场景下,会需要读取机器的厂家和主板等信息,这些信息都存放在SMBIOS信息中。在虚拟化场景下可以定制虚拟机的SMBIOS信息。

SMBIOS是什么
SMBIOS(System Management BIOS)是由工业化组织DMTF提出的通过系统固件传递管理信息的标准。详见https://www.dmtf.org/cn/standards/smbios
在SMBIOS标准中规定了若干的Type,每种Type都包含特定信息。例如:
BIOS Information (Type 0)
System Information (Type 1)
Baseboard (or Module) Information (Type 2)
System Enclosure or Chassis (Type 3)
Processor Information (Type 4)
Memory Controller Information (Type 5, Obsolete)
Memory Module Information (Type 6, Obsolete)
OEM Strings (Type 11)

在libvirt中可以定制Guest的smbios信息,首先填写smbios的mode,然后定制sysinfo。

指定smbios mode
在<os>中指定<smbios mode='sysinfo'/>:
  <os>
    ......
    <smbios mode='sysinfo'/>
  </os>
这里的mode有三种取值:
"emulate": 让qemu自动产生
"host"      :从宿主机上拷贝SMBIOS的 Block 0和Block 1(UUID除外)
"sysinfo"  :(使用sysinfo单元中指定的值)

填写sysinfo单元
<sysinfo type='smbios'>
  <bios>
      <entry name='vendor'>myvendor</entry>
    </bios>
    <system>
      <entry name='manufacturer'>manufacturer01</entry>
      <entry name='product'>test</entry>
      <entry name='version'>0.1</entry>
    </system>
    <baseBoard>
      <entry name='manufacturer'>manufacturer02</entry>
      <entry name='product'>0101010101</entry>
      <entry name='version'>0202020202</entry>
      <entry name='serial'>abcdefgh</entry>
    </baseBoard>
  <chassis>
    <entry name='manufacturer'>Dell Inc.</entry>
    <entry name='version'>2.12</entry>
    <entry name='serial'>65X0XF2</entry>
    <entry name='asset'>40000101</entry>
    <entry name='sku'>Type3Sku1</entry>
  </chassis>
  <oemStrings>
    <entry>myappname:some arbitrary data</entry>
    <entry>otherappname:more arbitrary data</entry>
  </oemStrings>
</sysinfo>
其中:
bios:对应SMBIOS标准中的 BIOS Information (Type 0)
system:对应SMBIOS标准中的 System Information (Type 1)
baseBoard:对应SMBIOS标准中的 Baseboard (or Module) Information (Type 2)
chassis:对应SMBIOS标准中的 System Enclosure or Chassis (Type 3)
oemStrings:对应SMBIOS标准中的 OEM Strings (Type 11)
(chassis和oemStrings从libvirt4.1.0开始支持)

在虚拟机内部查看
# dmidecode

可以看到在虚拟机中查询到的每一个type和我们在libvirt的domain中定制的完全相同。


转载请标明出处【如何定制虚拟机smbios信息】。

《www.micoder.cc》 虚拟化云计算,系统运维,安全技术服务.

网站已经关闭评论