Bug 479622

Summary: libvirt should avoid creating virtual networks with the same bridge name
Product: [Fedora] Fedora Reporter: Edouard Bourguignon <madko>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 11CC: berrange, clalance, crobinso, hbrock, markmc, veillard, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-11-18 13:52:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Edouard Bourguignon 2009-01-12 08:13:43 UTC
Description of problem:
When setting many virtual networks with virt-manager on a kvm host, and activating them at boot, only one really starts at boot (the last you defined). You have to manually shut this one off (in virt-manager), and then start all the virtual networks. Seems that each of the virtual networks want to be named as virbr0, libvirt doesn't check if the network if name is already in use?

Version-Release number of selected component (if applicable):
libvirt-0.5.1-2.fc10.x86_64
kvm-74-10.fc10.x86_64
virt-manager-0.6.0-5.fc10.x86_64

How reproducible:
static

Steps to Reproduce:
1. Open virt-manager and connect to the host, details -> virtual network
2. Add one virtual network with a new network address range and check "at boot"
3. reboot
4. ifconfig only shows one virbr0
  
Actual results:
Only the last defined virtual network seems to be up at boot

Expected results:
All the "activated at boot" virtual networks should be up


Additional info:
In virt-manager there is an input text widget for the network name but you can't enter any thing...
When you try to activate the other virtual network it says virbr0 already exists... have to shut the active virtual network and then start all the virtual-networks manually.

Comment 1 Edouard Bourguignon 2009-01-17 10:36:52 UTC
virsh # net-list --all
Nom                  État      Démarrage automatique
-----------------------------------------
reseau_interne       actif      yes       
default              inactif yes

virsh # net-dumpxml default
<network>
  <name>default</name>
  <uuid>f3436898-c765-4ac1-8c0c-19c90a4a55af</uuid>
  <forward mode='nat'/>
  <bridge name='virbr0' stp='on' forwardDelay='0' />
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254' />
    </dhcp>
  </ip>
</network>

virsh # net-dumpxml reseau_interne
<network>
  <name>reseau_interne</name>
  <uuid>10b9aa94-a0cf-ec18-78c2-77c3cd00e253</uuid>
  <bridge name='virbr0' stp='on' forwardDelay='0' />
  <ip address='192.168.100.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.100.128' end='192.168.100.254' />
    </dhcp>
  </ip>
</network>

Why the bridge name is the same?

Comment 2 Cole Robinson 2009-01-23 19:02:57 UTC
Okay, there is definitely a legit bug here, not really sure what the proper fix is though.

Whenever a virtual network is brought up, it grabs the first available 'virbrX' interface. From that point on, it will _always_ try to grab that same interface, and if it can't, it errors out.

The 'default' network is always going to grab 'virbr0'. So what happens if you define a new virtual network and set it to autostart? If its name comes before 'default' alphabetically, when libvirtd starts up, the new network will grab 'virbr0', and then 'default' will fail to come up.

I think the reasonable solutions are:

1) Have network_driver.c:networkStartNetworkDaemon or bridge.c:brAddBridge be intelligent enough to fall back to a sequentially allocated bridge name if the hardcoded xml bridge name doesn't fly

2) Add some intelligence somewhere in the stack to not allocate a 'virbrX' interface to a new network if it is already present in another net's xml.

I think 2 is probably the way to go. Dan or Mark, any suggestions?

Comment 3 Daniel Berrangé 2009-01-24 17:23:11 UTC
Dynamically assigning bridge name on each startup is not desirable - it won't work with Xen, because when we attach a guest to a virtual network, the bridge device name ends up in the Xen config. So we must guarentee that the same bridge device name is used on every boot. Really virt-manager should never create a network XML without an explicit bridge name.

libvirt however, should never have allowed 2 configs with the same bridge name to come into existance. When defining a new guest, or auto-allocating a bridge name, it must ensure it doesn't clash with any inactive network config, as well as the existing check against active bridges.

Comment 4 Cole Robinson 2009-01-24 18:07:41 UTC
> Dynamically assigning bridge name on each startup is not desirable - it won't
> work with Xen, because when we attach a guest to a virtual network, the bridge
> device name ends up in the Xen config. So we must guarentee that the same
> bridge device name is used on every boot. Really virt-manager should never
> create a network XML without an explicit bridge name.
> 

Seems reasonable that libvirt could also auto assign an unused bridge name to a network at define time, if the user doesn't specify one. That would save api users the hassle of reimplementing the collision detection. The code for generating a name of 'virbrX' is largely present anyways.

> libvirt however, should never have allowed 2 configs with the same bridge name
> to come into existance. When defining a new guest, or auto-allocating a bridge
> name, it must ensure it doesn't clash with any inactive network config, as well
> as the existing check against active bridges.

Sounds good.

Comment 5 Daniel Berrangé 2009-03-10 12:32:32 UTC
This was posted upstream

http://www.redhat.com/archives/libvir-list/2009-February/msg00309.html

and included in 0.6.1 release.

NB, any existing defined virtual networks with clashing bridge names still won't work, but we have prevented any newly defined networks breaking in this way.

Comment 6 Fedora Update System 2009-03-11 17:59:08 UTC
libvirt-0.6.1-1.fc10 has been pushed to the Fedora 10 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update libvirt'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F10/FEDORA-2009-2396

Comment 7 Bug Zapper 2009-11-18 10:43:59 UTC
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 8 Cole Robinson 2009-11-18 13:52:18 UTC
libvirt-0.6.1 isn't pushed to stable, and is sitting in updates testing for F10. This bug won't be fixed in the stable f10 package, but is fixed in F11.

Moving to F11 and closing as CURRENTRELEASE.