错误:无法从错误附加设备:内部错误:没有更多可用的PCI插槽

发布于 2025-02-04 10:16:01 字数 1610 浏览 4 评论 0原文

假设

  • 访客VM已安装。
  • 访客VM正在运行:virsh start< vm_domain_name>
  • 使用virsh列表进行验证-All
  • 目标PCI设备已用virsh nodedev-detach< pci_< domain> _ _ _ bus> >。可以通过验证virsh nodedev-list的输出来查看PCI目标列表。可以看到标签格式(< pci_ _>)可能与此处的示例有所不同。

问题描述

error: Failed to attach device from add_pci_vf.xml
error: internal error: No more available PCI slots

尝试将多个PCI设备添加到访客虚拟机中时出现此错误。

如果只需要添加一个PCI设备,那么以下命令就足以启用其PCI通行证:

virsh attach decter-device ubuntu-guest add_pci_vf.xml-live

option live live live在命令末尾允许PCI通行直接立即生效。访问访客并运行lspci -nn断言该设备现在可以由来宾看到。

解决方案

如果一个人希望添加其他设备,则必须替换- live by - config。更改不会立即生效。按照下面的食谱添加多个PCI设备,并避免上述错误。

virsh attach-device <vm_domain_name> <pci_device_0.xml> --config
virsh attach-device <vm_domain_name> <pci_device_1.xml> --config
virsh attach-device <vm_domain_name> <pci_device_2.xml> --config
virsh destroy <vm_domain_name>
virsh start <vm_domain_name>

PCI_DEVICE的语法_?。

<hostdev mode='subsystem' type='pci' managed='yes'>
<driver name='vfio' />
<source>
<address domain='0x0000' bus='0x6b' slot='0x00' function='0x01' />
</source>
</hostdev>

注意:根据我的经验,属性管理='是'是必不可少的。

Assumptions

  • Guest VM has been installed.
  • Guest VM is running: virsh start <vm_domain_name>.
  • Verify it with virsh list --all
  • Target PCI devices have been detached from the host with virsh nodedev-detach <pci_<domain>_<bus>_<slot>_<function>>. One can see a list of PCI targets by verifying the output of virsh nodedev-list. One can see that the tag format (<pci__>) may differ from the example here.

Problem Description

error: Failed to attach device from add_pci_vf.xml
error: internal error: No more available PCI slots

This error appears when trying to add multiple PCI devices to a guest virtual machine.

If one just needs to add a single PCI device, then the following command suffice to enable its PCI passthrough:

virsh attach-device ubuntu-guest add_pci_vf.xml --live

The option --live at the end of the command allows the PCI passthrough to be effective immediately. Access the guest and run lspci -nn to assert that the device can now be seen by the guest.

Solution

If one wish to add additional devices, one must replace --live by --config. The changes will not be effective immediately. Follow the recipe below to add multiple PCI devices and avoid the aforementioned error.

virsh attach-device <vm_domain_name> <pci_device_0.xml> --config
virsh attach-device <vm_domain_name> <pci_device_1.xml> --config
virsh attach-device <vm_domain_name> <pci_device_2.xml> --config
virsh destroy <vm_domain_name>
virsh start <vm_domain_name>

The syntax of pci_device_?.xml files should look like the following (may vary depending on the target co-processor):

<hostdev mode='subsystem' type='pci' managed='yes'>
<driver name='vfio' />
<source>
<address domain='0x0000' bus='0x6b' slot='0x00' function='0x01' />
</source>
</hostdev>

Note: The attribute managed='yes' is essential as per my experience.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘿嘿嘿 2025-02-11 10:16:01

原始帖子中描述的解决方案对我有用。由于我很难在网上找到它,因此我将其发布在此处,为其他面临类似问题的其他人发布。

摘要

一一添加设备(VFS)。

virsh attach-device <vm_domain_name> <pci_device_0.xml> --config
virsh attach-device <vm_domain_name> <pci_device_1.xml> --config
virsh attach-device <vm_domain_name> <pci_device_2.xml> --config

然后,

virsh destroy <vm_domain_name>
virsh start <vm_domain_name>

pci_device的语法_?。XML文件类似于:

<hostdev mode='subsystem' type='pci' managed='yes'>
<driver name='vfio' />
<source>
<address domain='0x0000' bus='0x6b' slot='0x00' function='0x01' />
</source>
</hostdev>

The solution described in the original post worked for me. Since I had trouble finding it online, I am posting it here for others facing similar issues.

Summary

Add the devices (VFs) one by one.

virsh attach-device <vm_domain_name> <pci_device_0.xml> --config
virsh attach-device <vm_domain_name> <pci_device_1.xml> --config
virsh attach-device <vm_domain_name> <pci_device_2.xml> --config

Then,

virsh destroy <vm_domain_name>
virsh start <vm_domain_name>

The syntax of pci_device_?.xml files is similar to:

<hostdev mode='subsystem' type='pci' managed='yes'>
<driver name='vfio' />
<source>
<address domain='0x0000' bus='0x6b' slot='0x00' function='0x01' />
</source>
</hostdev>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文