美文网首页
KVM的VMs连接Open vSwitch

KVM的VMs连接Open vSwitch

作者: Traphix | 来源:发表于2016-06-27 10:23 被阅读2842次

都说KVM配OVS很好用,可是网上找了很多资料,配置方法仿佛还停留在上世纪,太老了。。于是我就根据这位的文章,写一个小心得。
1、创建虚拟机时,可以索性选择不带网卡。
2、创建一个ovsbr0

ovs-vsctl add-br ovsbr0

3、创建好以后,用virt-manager加一个网卡,搭到ovsbr0上,截图为证



4、然后我们就需要编辑xml文件了,输入下面指令

sudo virsh edit ubuntu // 这里的ubuntu就是VM的name

你就回看到一大堆xml语句,找到如下部分

<interface type='bridge'>
      <mac address='52:54:00:fc:4e:b6'/>
      <source bridge='ovsbr1'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
</interface>

添加一行,变成了下面这个样子

<interface type='bridge'>
      <mac address='52:54:00:fc:4e:b6'/>
      <source bridge='ovsbr1'/>
      <virtualport type='openvswitch'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
</interface>

然后当你启动虚拟机,再看这一段xml的时候,你会发现他们变了,并且VM也连上ovsbr0了!

<interface type='bridge'>
      <mac address='52:54:00:ea:ea:23'/>
      <source bridge='ovsbr0'/>
      <virtualport type='openvswitch'>
        <parameters interfaceid='739db74f-f588-415d-ae4d-83387e4c0f5f'/>
      </virtualport>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

这是因为修改以后,系统会自动(qemu或者KVM或者virsh不知道是谁加的)添加其它的信息的。

相关文章

网友评论

      本文标题:KVM的VMs连接Open vSwitch

      本文链接:https://www.haomeiwen.com/subject/adezdttx.html