Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 250283 - KVM / QEMU kvm-ifup script cant handle mutiple bridges
Summary: KVM / QEMU kvm-ifup script cant handle mutiple bridges
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo QEMU Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-08 12:56 UTC by Philipp Wehrheim
Modified: 2012-10-30 21:10 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
kvm-ifup script with support for more than one bridge on the system (kvm-ifup,553 bytes, text/plain)
2008-12-09 07:25 UTC, Philipp Wehrheim
Details
kvm-ifdown script with support for more than one bridge on the system (kvm-ifdown,478 bytes, text/plain)
2008-12-09 07:27 UTC, Philipp Wehrheim
Details
kvm-ifdown for multiple bridges (kvm-ifdown,1.14 KB, text/plain)
2009-07-17 10:07 UTC, Michael Jinks
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Wehrheim 2008-12-08 12:56:36 UTC
Hey,

the KVM / QEMU script that adds a VM to a (host-)bridge cant handle
setups where a system got more than one bridge.

The simple workaround (store result in an array) below will use the first bridge in all situations - which is not perfect. The right fix would be define a bridge
to the cmd when KVM/QEMU is started. 

/etc/kvm/kvm-ifup

 -switch=$(/sbin/ip route list | awk '/^default / { sub(/.* dev /, ""); print $1 }')
 +switch=( $(/sbin/ip route list | awk '/^default / { sub(/.* dev /, ""); print $1 }') ) 

 -switch=$(/bin/netstat -rn | awk '/^0\.0\.0\.0/ { print $NF }')
 +switch=( $(/bin/netstat -rn | awk '/^0\.0\.0\.0/ { print $NF }') )


Reproducible: Always
Comment 1 Daniel Gryniewicz (RETIRED) gentoo-dev 2008-12-08 18:33:10 UTC
I don't use the script myself (I use vde exclusively).  If you can come up with a new script that works better, I'm willing to include it.
Comment 2 Philipp Wehrheim 2008-12-09 07:25:46 UTC
Created attachment 174696 [details]
kvm-ifup script with support for more than one  bridge on the system

made a small change to the kvm-ifup script so it will not fail if there is more than one bridge on the system - which bridge is used depends only on the output of ifconfig / ip :-/

If more than one bridge is found a warning is send to syslog
Comment 3 Philipp Wehrheim 2008-12-09 07:27:45 UTC
Created attachment 174698 [details]
kvm-ifdown script with support for more than one bridge on the system
Comment 4 Daniel Gryniewicz (RETIRED) gentoo-dev 2008-12-09 15:02:10 UTC
Thanks.  I'll include them in the next bump (which probably won't be 80, since it has so many regressions)
Comment 5 Philipp Wehrheim 2008-12-09 15:08:18 UTC
thanks for your work!
Comment 6 Michael Jinks 2009-07-17 08:15:22 UTC
(In reply to comment #2)
> Created an attachment (id=174696)

This bit:

  [[ ${switch#} -ne "1" ]] && logger -t kvm "$0 found more than one bridge connecting $1 to ${switch}"

...will always log the warning.  "${foo#}" doesn't print the number of words in $foo, it's just the same as saying "${foo}".  The construction "${#foo}" will print the number of characters (not words).  I don't know how to get what you want in plain shell, I'd have to do something like,

  [[ $( echo $switch |wc -w ) -ne "1" ]]
Comment 7 Michael Jinks 2009-07-17 10:07:26 UTC
Created attachment 198274 [details]
kvm-ifdown for multiple bridges

New version of the kvm-ifdown script which combs through the output of 'brctl show' looking for the named interface, and detaches it wherever we find it.
Comment 8 Daniel Gryniewicz (RETIRED) gentoo-dev 2009-09-21 15:01:46 UTC
I can't maintain kvm anymore.
Comment 9 Jorge Manuel B. S. Vicetto (RETIRED) Gentoo Infrastructure gentoo-dev 2010-06-10 19:59:53 UTC
I added some changes to the vde ebuild to support multiple bridges. I'll check if that can be applied here.
Comment 10 Doug Goldstein (RETIRED) gentoo-dev 2012-10-30 21:10:31 UTC
This is one of the reasons it was removed.