lost and found ( for me ? )

LXC error : failed to attach 'vethBQX66C' to the bridge 'ovsbr10' : No such device

Reference

# dpkg -l lxc
ii  lxc            1.0.6-0ubunt amd64        Linux Containers userspace tools

# ovs-vsctl --version
ovs-vsctl (Open vSwitch) 2.0.2
Compiled Aug 15 2014 14:31:02

# libvirtd --version
libvirtd (libvirt) 1.2.2


When I tried to start a container in combination with openvswitch, I saw the following errors.
-
lxc-start: failed to attach 'vethBQX66C' to the bridge 'ovsbr10' : No such device
-
here is what I did.

create the bridge via ovs-vsct
assign that bridge to the container
start the container.
# ovs-vsctl add-br ovsbr10

# grep -v ^# /var/lib/lxc/ubuntu-cn1/config | grep -v ^$
lxc.include = /usr/share/lxc/config/ubuntu.common.conf
lxc.rootfs = /var/lib/lxc/ubuntu-cn1/rootfs
lxc.mount = /var/lib/lxc/ubuntu-cn1/fstab
lxc.utsname = ubuntu-cn1
lxc.arch = amd64
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = ovsbr10


# lxc-start -n ubuntu-cn1
lxc-start: failed to attach 'vethBQX66C' to the bridge 'ovsbr10' : No such device
lxc-start: failed to create netdev
lxc-start: failed to create the network
lxc-start: failed to spawn 'ubuntu-cn1'
lxc-start: The container failed to start.
lxc-start: Additional information can be obtained by setting the --logfile and --logpriority options.

the workaround on this is

set USE_LXC_BRIDGE to false.
# less /etc/default/lxc-net
# This file is auto-generated by lxc.postinst if it does not
# exist.  Customizations will not be overridden.
# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
# containers.  Set to "false" if you'll use virbr0 or another existing
# bridge, or mavlan to your host's NIC.
USE_LXC_BRIDGE="false"

or

set USE_LXC_BRIDGE to true
# less /etc/default/lxc-net
# This file is auto-generated by lxc.postinst if it does not
# exist.  Customizations will not be overridden.
# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
# containers.  Set to "false" if you'll use virbr0 or another existing
# bridge, or mavlan to your host's NIC.
USE_LXC_BRIDGE="true"

delete the bridge
# ovs-vsctl del-br ovsbr10

add a bridge via virsh.
# cat /etc/libvirt/qemu/networks/ovs-network1.xml
<network>
 <name>ovs-network10</name>
 <bridge name='ovsbr10' stp='off' delay='0'/>
 <ip address='192.168.210.1' netmask='255.255.255.0'>
 </ip>
 <virtualport type='openvswitch'/>
</network>

define the network and start the network.
# virsh net-define ovs-network1.xml
Network ovs-network10 defined from ovs-network1.xml

# virsh net-start ovs-network10
Network ovs-network10 started

# virsh net-info ovs-network10
Name:           ovs-network10
UUID:          
Active:         yes
Persistent:     yes
Autostart:      no
Bridge:         ovsbr10

start the container.
# lxc-start -n ubuntu-cn1

root@ubuntu-cn1:~# ping 192.168.210.1 -c 1
PING 192.168.210.1 (192.168.210.1) 56(84) bytes of data.
64 bytes from 192.168.210.1: icmp_seq=1 ttl=64 time=0.071 ms

--- 192.168.210.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.071/0.071/0.071/0.000 ms

# grep -v ^# /etc/libvirt/qemu/networks/ovs-network10.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
 virsh net-edit ovs-network10
or other application using the libvirt API.
-->

<network>
 <name>ovs-network10</name>
 <uuid>e3f3ccfd-990e-491d-98a9-1f8941ae3b8f</uuid>
 <bridge name='ovsbr10' stp='off' delay='0'/>
 <mac address='52:54:00:18:21:f3'/>
 <ip address='192.168.210.1' netmask='255.255.255.0'>
 </ip>
 <virtualport type='openvswitch'/>
</network>

# grep -v ^# /etc/default/lxc

LXC_AUTO="true"

USE_LXC_BRIDGE="false"  # overridden in lxc-net
[ -f /etc/default/lxc-net ] && . /etc/default/lxc-net

LXC_SHUTDOWN_TIMEOUT=120

# grep -v ^# /etc/default/lxc-net
USE_LXC_BRIDGE="true"

LXC_BRIDGE="lxcbr0"
LXC_ADDR="10.0.3.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.3.0/24"
LXC_DHCP_RANGE="10.0.3.2,10.0.3.254"
LXC_DHCP_MAX="253"

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.