overlay - 使用 vhost-user-client 和 ovs-dpdk 连接 QEMU-KVM 虚拟机
问题描述
我的目标是在覆盖网络上连接两个 QEMU-KVM 虚拟机。每个 VM 都在单独的物理主机上运行,并且必须在网络 10.0.0.0/24 上具有静态 IP。为了实现这个目标,我想使用带有 DPDK 的 OVS 桥接器。我想使用 vhost-user-client 协议将 OVS 网桥与 VM 连接起来。
我的物理设置如下:两台配备 Mellanox ConnectX6-DX 的物理机,并背靠背连接(无物理交换机)。我想要实现的是:
+------------------+ +------------------+
| HOST_1 | | HOST_2 |
| | | |
| +------------+ | | +------------+ |
| | VM_1 | | | | VM_2 | |
| | | | | | | |
| | +--------+ | | | | +--------+ | |
| | | ens_2 | | | | | | ens_2 | | |
| | |10.0.0.1| | | | | |10.0.0.2| | |
| +-+---+----+-+ | | +-+---+----+-+ |
| | | | | |
| vhost-client-1 | | vhost-client-1 |
| | | | | |
| +-----+------+ | | +-----+------+ |
| | bridge | | | | bridge | |
| | br0 | | | | br0 | |
| |192.168.57.1| | | |192.168.57.2| |
| +-----+------+ | | +-----+------+ |
| | | | | |
| +---+--- | | +---+---+ |
| | dpdk0 | | | | dpdk0 | |
+----+---+--+------+ +----+---+---+-----+
| |
+-------------------------------+
我成功创建了 OVS 网桥(此处为 br0)和 DPDK 端口(此处为 dpdk0)。在每台物理机器上,我都可以 ping 另一台机器上的网桥。然后,我创建了一个 vhost-user-client 端口并将其连接到网桥。在每个guest上,我按照上图分配了一个静态IP,ens2接口就起来了。
但是,此时我无法从 VM1 ping VM2,反之亦然。似乎根本没有通过 vhost-client 端口交换流量。Ping 失败并显示Destination Host Unreachable消息。
一些有用的信息:
ovs-vsctl 显示
Bridge br0
datapath_type: netdev
Port br0
Interface br0
type: internal
Port dpdk0
Interface dpdk0
type: dpdk
options: {dpdk-devargs="0000:01:00.0"}
Port vhost-client-1
Interface vhost-client-1
type: dpdkvhostuserclient
options: {vhost-server-path="/tmp/vhost-client-1"}
ovs_version: "2.16.1"
ovs-vsctl -- --columns=name,ofport list 接口
name : br0
ofport : 65534
name : dpdk0
ofport : 6
name : vhost-client-1
ofport : 2
ovs-ofctl 转储流 br0
cookie=0x0, duration=104.689s, table=0, n_packets=0, n_bytes=0, in_port="vhost-client-1" actions=output:dpdk0
cookie=0x0, duration=99.573s, table=0, n_packets=4, n_bytes=924, in_port=dpdk0 actions=output:"vhost-client-1"
ovs-ofctl 显示 br0
OFPT_FEATURES_REPLY (xid=0x2): dpid:0000b8cef64def2e
n_tables:254, n_buffers:0
capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
2(vhost-client-1): addr:00:00:00:00:00:00
config: 0
state: LINK_DOWN
speed: 0 Mbps now, 0 Mbps max
6(dpdk0): addr:b8:ce:f6:4d:ef:2e
config: 0
state: 0
current: AUTO_NEG
speed: 0 Mbps now, 0 Mbps max
LOCAL(br0): addr:b8:ce:f6:4d:ef:2e
config: 0
state: 0
current: 10MB-FD COPPER
speed: 10 Mbps now, 0 Mbps max
OFPT_GET_CONFIG_REPLY (xid=0x4): frags=normal miss_send_len=0
Libvirt XML 配置(相关部分)
<domain type='kvm'>
<name>ubuntu-server</name>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<interface type='vhostuser'>
<mac address='52:54:00:16:a5:76'/>
<source type='unix' path='/tmp/vhost-client-1' mode='server'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</interface>
</devices>
</domain>
我缺少哪个配置选项?我遵循了几个指南,但仍然无法在我的虚拟机之间路由任何流量。
我怀疑问题与ovs-ofctl show命令报告的 vhost-client-1 端口的LINK_DOWN状态有关。我尝试使用命令ovs-ofctl mod-port br0 vhost-client-1 up将该状态设置为 UP 。即使命令没有失败,也没有任何改变。
有什么想法吗?
解决方案
最终,我设法解决了我的问题。Vipin 的回答很有用,但没有解决问题。我缺少的配置选项是元素中的numa
选项。cpu
我发布工作配置文件以防万一它对其他人有用。第一部分是关于内存支持(在domain
元素下):
<memory unit='KiB'>[VM memory size]</memory>
<currentMemory unit='KiB'>[VM memory size]</currentMemory>
<memoryBacking>
<hugepages>
<page size='2048' unit='KiB'/>
</hugepages>
<locked/>
<source type='file'/>
<access mode='shared'/>
<allocation mode='immediate'/>
<discard/>
</memoryBacking>
但我们也需要numa
配置,即使我们的机器只有一个处理器:
<cpu mode='custom' match='exact' check='full'>
<model fallback='forbid'>qemu64</model>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='hypervisor'/>
<feature policy='require' name='lahf_lm'/>
<feature policy='disable' name='svm'/>
<numa>
<cell id='0' cpus='0-1' memory='[VM memory size]' unit='KiB' memAccess='shared'/>
</numa>
</cpu>
推荐阅读
- c# - Web Api - 在 C# 中接收请求并等待来自客户端的响应
- powershell - 如何自动化 UI 键盘输入?pywin32 PostMessage vs Powershell SendKeys
- html - 使图像宽度适合跨度元素的长度?
- java - 如何找到基本操作数的范围?
- python - boto3 generate_presigned_post 未能设置自定义元标记
- python - 在 Python 中计算图形的交集
- python - Pandas:转换为具有频率计数+维护索引的时间序列
- xml - 如何对 XML 文件进行以下编辑?
- amazon-web-services - 定义 Lambda 策略并承担角色策略
- vba - 根据组合框中的是/否值逐行更新表格列