Using Open vSwitch with libvirt and QEMU/KVM
2013-09-26 09:07
453 查看
Using Open vSwitch with libvirt and QEMU/KVMThis is a quick and dirty write-up of using Open vSwitch(OVS) with libvirt and QEMU/KVM. I assume you already have libvirt(http://libvirt.org) up and running with QEMU/KVM. Other hypervisors may work but I haven't tried them at this time.
Grab the master of Open vSwitch(http://openvswitch.org/) with git because in previous versions there is an issue with removing ports from a fake bridge when the TAP is just deleted without first removing it from the bridge. This is what happens with libvirt and KVM when a VM is shutdown. This is fixed in the OVS master. The fix will also be in versions 1.2.2, 1.3.0, and later when released.
1) Compile and install OVS by following INSTALL.Linux
2) Compile and install OVS bridge compatibility mode by following INSTALL.bridge
Now you should have a working OVS install with bridge compatibility mode.
3) Create a fake bridge for each VLAN you want available. So say you have br0 as your real bridge and you want a VLAN 101.
ovs-vsctl add-br br101 br0 101
This will create a fake bridge tagged with VLAN 101. Do this for every VLAN you want.
4) In libvirt use a bridge interface setting the source to the appropriate fake bridge.
For example if you want a virtual machine on VLAN 101 assign it to br101
You can add the network interface by editing domain's XML directly with virsh.
<interface type='bridge'>
<source bridge='br101'/>
</interface>
Add this in the <devices> section. Libvirt will fill in the <mac/> and <address/>.
You can also add the network interface with virt-manager.
Now when you boot the VM libvirt will create the TAP interface and add it to br101. Since bridge compatibility mode is running OVS will add the port tagged with the appropriate VLAN when libvirt adds the interface to the bridge.
After starting the VM you should see the associated TAP interface when you list the ports in OVS.
ovs-vsctl list port
It should have the appropriate tag. In this case the tag should be 101.
Notice the port will not show up under br0 if you list-ports. You will have to list-ports on the fake bridge
ovs-vsctl list-ports br101
When you shutdown the VM the TAP interface will be destroyed and the port will be removed from OVS. If the TAP interface is destroyed, but the port still exists in OVS then you are not using a new enough version of OVS.
This will not help with mirrors or other advanced features but will give you the basic ability to automatically add and remove ports on the virtual switch with the appropriate VLAN tags for your virtual machines' interfaces.
I am working on a helper service that will enable the ability to automatically handle mirrors and other advanced functionality. It will also allow you to avoid using bridge compatibility mode if you desire. Eventually I hope to see OVS support built into libvirt but this will help until then.
阅读(320) | 评论(0) | 转发(0) |
0
上一篇:windbg调试kvm windows虚机
下一篇:Using SCSI Persistent Reservations with RHEL6 Advanced Platform Cluster
相关热门文章
linux 常见服务端口
【ROOTFS搭建】busybox的httpd...
什么是shell
linux socket的bug??
linux的线程是否受到了保护?...
关于enqueue 的dump 文件帮看...
tar --newer 05/12/2013 这个...
请教nginx代理tomcat作为子目...
LDAP安装 bus error是什么问...
select语句不修改sql,如何优...
给主人留下些什么吧!~~
评论热议
Grab the master of Open vSwitch(http://openvswitch.org/) with git because in previous versions there is an issue with removing ports from a fake bridge when the TAP is just deleted without first removing it from the bridge. This is what happens with libvirt and KVM when a VM is shutdown. This is fixed in the OVS master. The fix will also be in versions 1.2.2, 1.3.0, and later when released.
1) Compile and install OVS by following INSTALL.Linux
2) Compile and install OVS bridge compatibility mode by following INSTALL.bridge
Now you should have a working OVS install with bridge compatibility mode.
3) Create a fake bridge for each VLAN you want available. So say you have br0 as your real bridge and you want a VLAN 101.
ovs-vsctl add-br br101 br0 101
This will create a fake bridge tagged with VLAN 101. Do this for every VLAN you want.
4) In libvirt use a bridge interface setting the source to the appropriate fake bridge.
For example if you want a virtual machine on VLAN 101 assign it to br101
You can add the network interface by editing domain's XML directly with virsh.
<interface type='bridge'>
<source bridge='br101'/>
</interface>
Add this in the <devices> section. Libvirt will fill in the <mac/> and <address/>.
You can also add the network interface with virt-manager.
Now when you boot the VM libvirt will create the TAP interface and add it to br101. Since bridge compatibility mode is running OVS will add the port tagged with the appropriate VLAN when libvirt adds the interface to the bridge.
After starting the VM you should see the associated TAP interface when you list the ports in OVS.
ovs-vsctl list port
It should have the appropriate tag. In this case the tag should be 101.
Notice the port will not show up under br0 if you list-ports. You will have to list-ports on the fake bridge
ovs-vsctl list-ports br101
When you shutdown the VM the TAP interface will be destroyed and the port will be removed from OVS. If the TAP interface is destroyed, but the port still exists in OVS then you are not using a new enough version of OVS.
This will not help with mirrors or other advanced features but will give you the basic ability to automatically add and remove ports on the virtual switch with the appropriate VLAN tags for your virtual machines' interfaces.
I am working on a helper service that will enable the ability to automatically handle mirrors and other advanced functionality. It will also allow you to avoid using bridge compatibility mode if you desire. Eventually I hope to see OVS support built into libvirt but this will help until then.
阅读(320) | 评论(0) | 转发(0) |
0
上一篇:windbg调试kvm windows虚机
下一篇:Using SCSI Persistent Reservations with RHEL6 Advanced Platform Cluster
相关热门文章
linux 常见服务端口
【ROOTFS搭建】busybox的httpd...
什么是shell
linux socket的bug??
linux的线程是否受到了保护?...
关于enqueue 的dump 文件帮看...
tar --newer 05/12/2013 这个...
请教nginx代理tomcat作为子目...
LDAP安装 bus error是什么问...
select语句不修改sql,如何优...
给主人留下些什么吧!~~
评论热议
相关文章推荐
- Multiple Private Networks with Open vSwitch GRE Tunnels and Libvirt
- QEMU KVM Libvirt手册(10):Managing Virtual Machines with libvirt
- Using VLANs with OVS and libvirt
- How to debug qemu and libvirt using gdb
- QEMU KVM Libvirt手册(10):Managing Virtual Machines with libvirt
- Using VLANs with OVS and libvirt
- Using VLANs with OVS and libvirt
- Guest CPU model configuration in libvirt with QEMU/KVM
- [转] External(and Live) snapshots with libvirt
- 'ft2232' interface using libftdi with 'jtagkey' layout (1457:5118)unable to open ftdi device
- Link Aggregation and LACP with Open vSwitch
- QEMU KVM libvirt手册(4) – images
- Use libvirt to conmunicate with qemu
- sheepdog and libvirt and qemu and corosync
- Adding Linux VLAN and bridge interfaces using libvirt
- Genre-based Music Recommendations Using Open Data (and the problem with recommender systems)
- (OK)(OK) using adb with KVM (qemu)
- QEMU KVM Libvirt手册(7): 硬件虚拟化
- libvirt kvm and lxc 配置文件
- QEMU KVM Libvirt手册(6) – Network Block Device