This week I run one VM in my OpenNebula/KVM host, but as I like to shutdown my physical host every day (I don’t like to waste electricity when I’m not playing with my HP N40L), I encountered a problem when the host was up again.
The VM was in FAILED state and I found the following log when OpenNebula/KVM tried to run the VM:
error: Unable to add bridge br0 port vnet0: Invalid argument
Openvswitch wrote this log in /var/log/messages:
ovs-vsctl: 00002|vsctl|ERR|cannot create a port named vnet0 because a port named vnet0 already exists on bridge br0
It was clear that there was a problem with my openvswitch. I maybe wrong, (please understand that I’m learning how to use all this stuff ) but when OpenNebula oned daemon is stopped when my physical host is going to be halted, the virtual ports are not removed from the bridge so it’s not possible to add them when resuming operations (the virtual port is indeed removed if you first stop the VM).
This discussion helped me to understand the problem. According to that thread, Libvirt >= 0.9.11 seems to deal with abrupt restarts more nicely and it suggests not to use brcompatd mode.
If I remove –brcompat from my initd script, OpenNebula/KVM will show a different message
error: Unable to add bridge br0 port vnet1: Operation not supported
Although I compiled Libvirt 0.10.1, so no bridge compatibility mode should be needed, OpenNebula’s documentation states that “It is also necessary to install the Open vSwitch compatibility layer for Linux bridging“, so no choice for me!, I need to add –brcompat.
I’ve solved this problem using –delete-bridges (read the discussion) in my init.d script, so every bridge is removed from openvswitch’s database and, therefore, any port created by OpenNebula/KVM is also removed. Important: I’ve included the ovs-vsctl commands to add the bridge again so the network interface is ready to be used.
start() { $exec start --system-id=random --brcompat --delete-bridges retval=$? [ $retval -eq 0 ] && touch $lockfile /usr/local/bin/ovs-vsctl add-br br0 /usr/local/bin/ovs-vsctl add-port br0 eth0 return $retval }
I’m sure it’s only a problem with my server, but if you happen to have the same problem please leave a comment if you find a better or cleaner solution.
Enjoy!