[ovs-discuss] Replace Linux Bridge with Openvswitch on Ubuntu

Scott Lowe scott.lowe at scottlowe.org
Mon Nov 13 18:52:28 UTC 2017


> On Nov 13, 2017, at 2:12 AM, densha at exemail.com.au wrote:
> 
> Hi Forum
> 
> I would like to replace the linux bridge installed with libvirt with a
> openvswitch bridge, so I can learn about openvswitch.
> 
> I cannot get the VM to communicate with the bridge I create with openvswitch.
> 
> Here is what I did on a vanilla Ubutnu 17.10 Server X86_64 installation.
> Installing libvirt and openvswitch.
> 
> PACKAGES="qemu-kvm openvswitch-switch libvirt-bin virtinst virt-manager"
> sudo apt-get update
> sudo apt-get dist-upgrade -qy
> 
> sudo apt-get install -qy ${PACKAGES}
> 
> sudo adduser `id -un` libvirtd
> sudo adduser `id -un` kvm
> 
> I deleted the current linux bridge using
> 
> virsh net-destroy default
> virsh net-undefine default
> systemctl restart libvirtd
> 
> Created a openvswitch bridge and assigned a IP address.
> 
> ovs-vsctl add-br virbr0
> ip addr add 192.168.122.1/24 dev virbr0
> 
> I can see the bridge and ip address.
> 
> 5: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group
> default qlen 1000
>    link/ether 26:68:17:50:25:40 brd ff:ff:ff:ff:ff:ff
>    inet 192.168.122.1/24 scope global virbr0
>       valid_lft forever preferred_lft forever
> 
> I create a VM using virsh-install
> 
> sudo qemu-img create -f qcow2 -o preallocation=metadata
> /var/lib/libvirt/images/kvm01.qcow2 10G
> 
> sudo virt-install -n kvm01 \
> --connect qemu:///system \
> --vcpus=2 \
> -r 4096 \
> --os-type linux \
> --os-variant ubuntu16.04 \
> --network=bridge:virbr0,virtualport_type='openvswitch' \
> --vnc --noautoconsole \
> --keymap=en-us \
> --console pty,target_type=serial \
> -f /var/lib/libvirt/images/kvm01.qcow2 \
> --location /var/lib/libvirt/images/ubuntu-16.04.3-server-amd64.iso \
> get_hostname=kvm01 vga=788"
> 
> 
> When the VM boots I assign a static IP address to 192.168.122.2/24.
> Inside the VM the NIC reoprts as
> 
> 2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen
> 1000
>    link/ether 52:54:00:a5:53:36 brd ff:ff:ff:ff:ff:ff
>    inet 192.168.122.2/24 brd 192.168.122.255 scope global ens3
>       valid_lft forever preferred_lft forever
>    inet6 fe80::5254:ff:faa5:5336/64 scope link
>       valid_lft forever preferred_lft forever
> 
> 
> When I virsh dumpxml on the VM domain I see the network setup as
> <interface type='bridge'>
>      <mac address='52:54:00:a5:53:36'/>
>      <source bridge='virbr0'/>
>      <virtualport type='openvswitch'>
>        <parameters interfaceid='93b23213-15cb-40bd-b053-a04f15ae395d'/>
>      </virtualport>
>      <target dev='vnet0'/>
>      <model type='virtio'/>
>      <alias name='net0'/>
>      <address type='pci' domain='0x0000' bus='0x00' slot='0x03'
> function='0x0'/>
>    </interface>
> 
> From the host machine openswitch reports the vnet0 as an internal port
> sudo ovs-vsctl show
> 30fdaeff-9867-4651-85a6-5b0bf53f5130
>    Bridge "virbr0"
>        Port "vnet0"
>            Interface "vnet0"
>        Port "virbr0"
>            Interface "virbr0"
>                type: internal
>    ovs_version: "2.8.0"
> 
> From the VM I am unable to ping the IP of the bridge.
> #ping 192.168.122.1
> 
> From the host I am also unable to ping the VM
> #ping 192.168.122.2
> 
> I am at my limit of understanding of linux networking and I wonder could
> someone point out what I have done wrong here?


There are a couple different ways to integrate Libvirt with virtual networks with Open vSwitch (OVS). Here's one way:

<https://blog.scottlowe.org/2012/11/07/using-vlans-with-ovs-and-libvirt/>

This doesn't get you the NAT the default Libvirt network uses, but it may be useful nevertheless.

Regards,

--
Scott

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP
URL: <http://mail.openvswitch.org/pipermail/ovs-discuss/attachments/20171113/8081226f/attachment.sig>


More information about the discuss mailing list