Network Manager disabling Virt-manager’s bridge

This doesn't work, and it's filed as bug 1099949 in Ubuntu. So we'll see how that goes.

As of about six hours ago, I've had this regularly popping up in my syslog:

Jan 13 20:13:54 amazing NetworkManager[1347]:  (virbr0): device state change: unavailable -> disconnected (reason 'none') [20 30 0]

virbr0 is the bridge created by virt-manager for its VMs to communicate on and, franky, NetworkManager has no business doing anything to it, let alone disconnecting it (especially when it doesn't know why it's doing it).

Fortunately, NetworkManager has an unmanaged-devices option that you can put in the irritatingly-capitalised file at /etc/NetworkManager/NetworkManager.conf. It belongs in the keyfile section (so you need to make sure keyfile is listed under plugins:

[main]
plugins=ifupdown,keyfile
dns=dnsmasq

[ifupdown]
managed=false

[keyfile]
unmanaged-devices=mac:2e:e7:1f:7c:ef:76

Annoyingly, there doesn't appear to be a 'managed-devices' configuration, and virbr0's mac address changes from time to time. So far, sticking this at the end of /etc/rc.local to get the mac address of virbr0 and replace the old one in that file seems to be working:

#! /bin/bash

echo -n "Before  : "
egrep '^unmanaged-devices' /etc/NetworkManager/NetworkManager.conf
mac=$(ifconfig virbr0 | grep HWaddr | awk '{print $NF}');
echo "New mac : $mac";
perl -pi -e "s/^unmanaged-devices.+/unmanaged-devices=mac:$mac/" /etc/NetworkManager/NetworkManager.conf
echo -n "After   : "
egrep '^unmanaged-devices' /etc/NetworkManager/NetworkManager.conf

Half an hour in, I've still got network connectivity on my VMs! :)