qemu定制smbios信息

本文拟分享定制qemu虚拟机smbios信息的方法

背景

为虚拟机定制smbios信息,使得可以定制化像dmidecode这种命令查看出来的信息内容。

SMBIOS(System Management BIOS)是由工业化组织DMTF提出的通过系统固件传递管理信息的标准。
在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)

更多的type可以参考SMBIOS Reference Specification

实现

qemu命令

参考qemu使用手册,可以看出,直接通过-smbios 参数即可定制smbios。

启动一个简单的虚机,修改它的type 1 smbios info:

# -smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str][,uuid=uuid][,sku=str][,family=str]
qemu-system-x86_64 -m 2G  --enable-kvm -smp 4 -drive if=virtio,file=linux-bios.qcow2 -smbios "type=1,manufacturer=dev,product=vm,version=0.0.1,serial=123456,uuid=11111111-1111-1111-1111-111111111111,sku=test,family=vm"

启动后查看dmidecode信息:
在这里插入图片描述
与设置的一致。

libvirt xml配置

参看libvirt官方提供的手册:https://libvirt.org/formatdomain.html#smbios-system-information

<os>
  <smbios mode='sysinfo'/>
  ...
</os>
<sysinfo type='smbios'>
  <bios>
    <entry name='vendor'>LENOVO</entry>
  </bios>
  <system>
    <entry name='manufacturer'>Fedora</entry>
    <entry name='product'>Virt-Manager</entry>
    <entry name='version'>0.9.4</entry>
  </system>
  <baseBoard>
    <entry name='manufacturer'>LENOVO</entry>
    <entry name='product'>20BE0061MC</entry>
    <entry name='version'>0B98401 Pro</entry>
    <entry name='serial'>W1KS427111E</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>
<sysinfo type='fwcfg'>
  <entry name='opt/com.example/name'>example value</entry>
  <entry name='opt/com.coreos/config' file='/tmp/provision.ign'/>
</sysinfo>
...

里面的子元素分别对应着smbios的type。
运行后查看dmidecode信息:
在这里插入图片描述

参考

QEMU User Documentation

如何定制虚拟机smbios信息

Mappings for DMI/SMBIOS to Linux and dmidecode

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值