KVM troubleshoot bridged networking

Troubleshoot KVM bridge networking in Debian

A few notes on something that I was called to help with a few times too-many.

Bridged interfaces stop working for the guest machines out of the 'blue'

Not exactly out of the blue every reaction is caused by an action to paraphrase an old smart dude.

I think that it just happens when an admin who sees too many vnet interfaces not used in anything starts taking them down eg:
# ip link set vnet7 down
thinking that since the guests are using only their bridged interfaces it should not matter
and because 20 vnet(s) 4-5 eth(s) and 4-5 br(s) are far too many to follow

But if the vnet that it is not used is defined on a guests definition ( xml ) then the guest bridged interface does not work either.

Is it a bug or a feature of libvirt?
Anyways, here is how I go about it

# virsh
virsh # list 
 Id Name                 State


 7 vm7.meton            running


Shutdown meton
# destroy vm7.meton
Domain vm7.meton destroyed

Edit the definition for the guest vm7.meton
# edit vm7.meton

Remove the target dev from the interface
<target dev='vnet7'/>
Something like the following is enough
   < interface type='bridge'>
      <mac address='58:54:00:18:c1:67'/>
      <source bridge='br0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
Make sure that the MAC address starts with an even number

Redefine the guest vm7.meton
 # define vm7.meton.xml
Domain vm7.meton defined from vm7.meton.xml

Start the guest
virsh # start vm7.meton
Domain vm7.meton started

virsh # quit

which seems to work but it does not
It appears that libvirt ignores target names starting in vnet or vif and
if libvirt does not find any target then creates one starting in vnet.
0ne thing you can do is create interfaces with names that make more sense and let them be
<target dev='meton'/>

KVM bridged networking troubleshooting