先谢谢楼主提供的驱动和这位发现桥接影响速度的老哥,虽然查了一下原因不明,但是关掉之后确实好了。
另外跟各位补充一下,关掉桥接之后虚拟机还是有办法直接桥接到物理网络的,可以通过 macvtap 的方法配置,具体方法如下:
1. 先在 SETTINGS - VM Manager 里把 Default network source: 改为 virbr0,这个是用于虚拟机和宿主机(Unraid)之间通信的网络,因为 macvtap 桥接方式下虚拟机和宿主机不能直接通信
2.在虚拟机编辑界面右上角打开XML VIEW,找到网卡的位置,改成使用两个卡:
<interface type='direct'>
<mac address='xx:xx:xx:xx:xx:x1'/>
<source dev='bond0' mode='vepa'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>
<interface type='bridge'>
<mac address='xx:xx:xx:xx:xx:x2'/>
<source bridge='virbr0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
</interface>
其中,
第一个 interface 是用 macvtap 的方式通过 bond0 网卡来跟物理网络连接(如果没有打开 bonding 的话这里 bond0 应该可以对应修改为 eth0 等物理网卡),
第二个 interface 是用默认的 NAT 网络 virbr0 来跟宿主机(Unraid)连接(会有单独的子网),如果只是需要虚拟机和宿主机互联用默认的 virbr0 应该就够了,但也可以参考官方文档[1]和示例配置步骤[3]来定制,配置文件目录在 /etc/libvirt/qemu/networks 里,但是不能直接编辑,要用 virsh 命令来编辑。
不过 Unraid 的表格编辑不支持 direct 这种配置,所以如果在 FORM VIEW 下修改了配置,网卡会被强制改回 bridge,所以每次在表格模式改完别的配置之后要再进 XML VIEW 手动修改网卡的部分。
这样配置物理网络、虚拟机、Unraid两两之间都能跑满速,暂时没发现有什么问题。
English Version:
If you need VMs to still connected to physical network after disabling bridging for full speed, you could follow the following steps to connect VMs to the physical network via macvtap [1]:
1. In SETTINGS - VM Manager, change "Default network source:" to virbr0 for connections between VMs and the Unraid host because macvtap doesn't allow communication betweeen VM guests and the host,
2. In the VM's edit page, change to XML VIEW by toggling the switch in the top-right corner of the page. Then edit the network cards section as below:
<interface type='direct'>
<mac address='xx:xx:xx:xx:xx:x1'/>
<source dev='bond0' mode='vepa'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>
<interface type='bridge'>
<mac address='xx:xx:xx:xx:xx:x2'/>
<source bridge='virbr0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
</interface>
What the above config does is,
a. the first interface is connected using macvtap via bond0 to the physical network, so if bonding is disabled, you may need to change "bond0" to physical interfaces like "eth0";
b. the second interface uses the default NAT based virbr0 to connect the Unraid host with an independent subnet. For advanced customizations, you can refer to the libvirt docs[1] and this example guide[3]. Note that the configs are located in /etc/libvirt/qemu/networks but you must use the virsh command to edit them in the command line.
Also note that the FORM VIEW of the VM edit page in the Unraid GUI doesn't support "direct" type interface, so you will need to manually edit the network interfaces section every time you change other settings in FORM VIEW.
With the above configuration, machines on the physical networks, VMs, and Unraid should be able to all connected to each other at full speed now.
参考资料(References):
[1] https://libvirt.org/formatnetwork.html#using-a-macvtap-direct-connection
[2] https://notes.wadeism.net/post/kvm-network-setup/
[3] https://fabianlee.org/2019/06/05/kvm-creating-a-guest-vm-on-a-network-in-routed-mode/