qemu-kvm: CPU feature spec-ctrl not found

今天我在准备虚拟机环境的时候,遇到了一个故障,kmv报错如下

internal error: process exited while connecting to monitor: 2018-11-28T16:04:46.324652Z qemu-kvm: CPU feature spec-ctrl not found

具体的意思,就是CPU架构不支持spec-ctrl,于时我各种查资料,抱着一线希望查了一下百度,那么结果可能大家都知道,百度没什么卵用,最后还是去google上面去查,找到了答案:

原因就是我之前更新了linux,但是新版本的KVM/LIBVIRT/QEMU之间的版本兼容性出现了问题,之前旧版本的XML文件,新版本居然不认识了,重现修改CPU的配置如下:

修改前

  <cpu mode='custom' match='exact' check='partial'>
    <model fallback='allow'>Haswell-noTSX-IBRS</model>
  </cpu>

修改后

  <cpu mode='custom' match='exact' check='partial'>
    <model fallback='allow'>Haswell-noTSX</model>
  </cpu>

改完,收工,重新define,一切正常。

以下是这个小哥的原文,链接是

“Failed to start domain – Host CPU does not provide required features: spec-ctrl”

“Failed to start domain – Host CPU does not provide required features: spec-ctrl”

[[email protected] ~]# virsh start bar
error: Failed to start domain bar
error: the CPU is incompatible with host CPU: Host CPU does not provide required features: spec-ctrl

After a recent CentOS update and reboot, certain VMs refused to start, bailing out with the error message above. The interwebz didn’t really offer much in terms of advice. After talking to people with more clue, a working theory was formed: the version combination of kernel/libvirt/kvm/qemu is messed up. Rolling back to an older version was not an option.

The root cause is Intel’s Spectre vulnerability and its mitigation. The fix proved to be surprisingly simple. Simply edit the VM definition (“virsh edit foo”) and remove “-IBRS” from the CPU definition. Bear in mind that this does disable the Indirect Branch Restricted Speculation mitigation, so consider this a security disclaimer.

To recap:

  <cpu mode='custom' match='exact' check='partial'>
    <model fallback='allow'>Haswell-noTSX-IBRS</model>
  </cpu>

becomes

  <cpu mode='custom' match='exact' check='partial'>
    <model fallback='allow'>Haswell-noTSX</model>
  </cpu>

I’m not sure how this CPU model definition came to be. Did updating libvirt update the definition? Was the definition automatically detected when the VM was created, and did it stop working after an upgrade?

此条目发表在kvm分类目录,贴了标签。将固定链接加入收藏夹。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注