Unable to add bridge brX port vnetX: Invalid argument or Operation not supported

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!

Advertisements

5 thoughts on “Unable to add bridge brX port vnetX: Invalid argument or Operation not supported

  1. Wayne says:

    Dear expert:

    I have the same problems that you faced, and my solution is almost the same like yours.
    But I delete the OVS bridge using ”ovs-vsctl del-br br0” which is different from the start command.
    Thanks for your sharing~

    Like

    • n40lab says:

      Thank you for your comment and your proposed solution, I’m sure it’ll help other users with the same problem. It’s great to have your feedback.

      Like

  2. Saurabh Hirani says:

    Hey thanks for sharing this. I had a similar problem and doing the ovs-vsctl deletion and creation helped. Had it not been for your post, I would still be searching for the solution. Appreciate your sharing this. Keep up the good work.

    Like

  3. buffygb says:

    This isn’t quite the right solution, which may be a problem with the OpenNebula Documentation. The reason you’re worrying about legacy bridge compatibility is that libvirt doesn’t recognise this as an openvswitch bridge. There’s nothing in the virt-manager GUI that exposes this, so you need to add this to the NIC section of the domain’s definition by using the edit command in virsh:

    You may also need add things like vlan tags while you’re at it. The underlying bug is reported here:

    https://www.redhat.com/archives/libvirt-users/2013-May/msg00043.html

    Like

    • n40lab says:

      Thanks a lot for the feedback. It was an old post that I keep if someone had the same problems, I’m sure your comment will help others if the visit this post.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s