向虚拟机添加更多 PCI 插槽

向虚拟机添加更多 PCI 插槽

我正在使用 kvm 运行虚拟机来模拟网络交换机。我需要模拟很多链路,所以全部都使用PCI连接。如果我附加 27 个或更多接口,则会出现错误。

这是我用来启动机器的命令:

/usr/libexec/qemu-kvm -m 2048 -name vm1 -device e1000,netdev=net0,mac=DE:AD:BE:EF:8D:11 -netdev tap,id=net0,script=sonic-if-mgmt-script -device e1000,netdev=net1,mac=DE:AD:BE:EF:8D:12 -netdev tap,id=net1,script=sonic-if-data-script -device e1000,netdev=net2,mac=DE:AD:BE:EF:8D:13 -netdev tap,id=net2,script=sonic-if-data-script -device e1000,netdev=net3,mac=DE:AD:BE:EF:8D:14 -netdev tap,id=net3,script=sonic-if-data-script -device e1000,netdev=net4,mac=DE:AD:BE:EF:8D:15 -netdev tap,id=net4,script=sonic-if-data-script -device e1000,netdev=net5,mac=DE:AD:BE:EF:8D:16 -netdev tap,id=net5,script=sonic-if-data-script -device e1000,netdev=net6,mac=DE:AD:BE:EF:8D:17 -netdev tap,id=net6,script=sonic-if-data-script -device e1000,netdev=net7,mac=DE:AD:BE:EF:8D:18 -netdev tap,id=net7,script=sonic-if-data-script -device e1000,netdev=net8,mac=DE:AD:BE:EF:8D:19 -netdev tap,id=net8,script=sonic-if-data-script -device e1000,netdev=net9,mac=DE:AD:BE:EF:8D:1A -netdev tap,id=net9,script=sonic-if-data-script -device e1000,netdev=net10,mac=DE:AD:BE:EF:8D:1B -netdev tap,id=net10,script=sonic-if-data-script -device e1000,netdev=net11,mac=DE:AD:BE:EF:8D:1C -netdev tap,id=net11,script=sonic-if-data-script -device e1000,netdev=net12,mac=DE:AD:BE:EF:8D:1D -netdev tap,id=net12,script=sonic-if-data-script -device e1000,netdev=net13,mac=DE:AD:BE:EF:8D:1E -netdev tap,id=net13,script=sonic-if-data-script -device e1000,netdev=net14,mac=DE:AD:BE:EF:8D:1F -netdev tap,id=net14,script=sonic-if-data-script -device e1000,netdev=net15,mac=DE:AD:BE:EF:8D:20 -netdev tap,id=net15,script=sonic-if-data-script -device e1000,netdev=net16,mac=DE:AD:BE:EF:8D:21 -netdev tap,id=net16,script=sonic-if-data-script -device e1000,netdev=net17,mac=DE:AD:BE:EF:8D:22 -netdev tap,id=net17,script=sonic-if-data-script -device e1000,netdev=net18,mac=DE:AD:BE:EF:8D:23 -netdev tap,id=net18,script=sonic-if-data-script -device e1000,netdev=net19,mac=DE:AD:BE:EF:8D:24 -netdev tap,id=net19,script=sonic-if-data-script -device e1000,netdev=net20,mac=DE:AD:BE:EF:8D:25 -netdev tap,id=net20,script=sonic-if-data-script -device e1000,netdev=net21,mac=DE:AD:BE:EF:8D:26 -netdev tap,id=net21,script=sonic-if-data-script -device e1000,netdev=net22,mac=DE:AD:BE:EF:8D:27 -netdev tap,id=net22,script=sonic-if-data-script -device e1000,netdev=net23,mac=DE:AD:BE:EF:8D:28 -netdev tap,id=net23,script=sonic-if-data-script -device e1000,netdev=net24,mac=DE:AD:BE:EF:8D:29 -netdev tap,id=net24,script=sonic-if-data-script -device e1000,netdev=net25,mac=DE:AD:BE:EF:8D:2A -netdev tap,id=net25,script=sonic-if-data-script -device e1000,netdev=net26,mac=DE:AD:BE:EF:8D:2B -netdev tap,id=net26,script=sonic-if-data-script -device e1000,netdev=net27,mac=DE:AD:BE:EF:8D:2C -netdev tap,id=net27,script=sonic-if-data-script -device e1000,netdev=net28,mac=DE:AD:BE:EF:8D:2D -netdev tap,id=net28,script=sonic-if-data-script -vnc 0.0.0.0:9095 -vga std -drive file=vm1.img,media=disk,if=virtio,index=0 -serial telnet:127.0.0.1:9095,server

我得到的错误是这样的:

kvm: -drive file=vm1.img,media=disk,if=virtio,index=0: PCI: no slot/function available for virtio-blk-pci, all in use

kvm: -drive file=vm1.img,media=disk,if=virtio,index=0: Device initialization failed.

kvm: -drive file=vm1.img,media=disk,if=virtio,index=0: Device 'virtio-blk-pci' could not be initialized

这个问题与这个问题类似:

libvirtd:没有更多可用的 PCI 插槽

或者这个:

https://www.suse.com/support/kb/doc/?id=000019383

但就我而言,我没有使用 virsh,所以我不确定如何复制此功能。

谢谢

相关内容