On Tue, 2011-04-19 at 11:17 +0800, Amos Kong wrote: > Script is used to setup/remove of private bridge > it provides dhcp service to guests by dnsmasq.
Ok, this is a great start! I'd rather have this as python code as part of the framework, so I'll play with it a little and we can get this going. Jason, would you please re-send that patchset that removes the need for the qemu-ifup script? We can make everything work together and deliver a good experience for users and completely getting rid of user mode for ever and ever :) > Signed-off-by: Amos Kong <ak...@redhat.com> > --- > client/tests/kvm/scripts/set_private_br.sh | 53 > ++++++++++++++++++++++++++++ > 1 files changed, 53 insertions(+), 0 deletions(-) > create mode 100755 client/tests/kvm/scripts/set_private_br.sh > > diff --git a/client/tests/kvm/scripts/set_private_br.sh > b/client/tests/kvm/scripts/set_private_br.sh > new file mode 100755 > index 0000000..4c4cff0 > --- /dev/null > +++ b/client/tests/kvm/scripts/set_private_br.sh > @@ -0,0 +1,53 @@ > +#!/bin/bash > +# > +# Author: Amos Kong <kongjian...@gmail.com> > +# Date: Apr 14, 2011 > +# Description: this script is used to create/delete a private bridge, > +# launch a dhcp server on the bridge by dnsmasq. > +# > +# @ ./set_private_br.sh $bridge_name $subnet_prefix > +# @ ./set_private_br.sh vbr0 192.168.33 > + > +brname='vbr0' > +subnet='192.168.33' > + > +add_br() > +{ > + echo "add new private bridge: $brname" > + /usr/sbin/brctl show |egrep "\b$brname\b" && exit > + /usr/sbin/brctl addbr $brname > + echo 1 > /proc/sys/net/ipv4/ip_forward > + /usr/sbin/brctl stp $brname on > + /usr/sbin/brctl setfd $brname 0 > + ifconfig $brname $subnet.1 up > + # Add forward rule, then guest can access public network > + iptables -t nat -A POSTROUTING -s $subnet.254/24 ! -d $subnet.254/24 -j > MASQUERADE > + /etc/init.d/dnsmasq stop > + dnsmasq --strict-order --bind-interfaces --listen-address $subnet.1 > --dhcp-range $subnet.1,$subnet.254 --pid-file=/tmp/dnsmasq.pid > +} > + > +del_br() > +{ > + echo "cleanup bridge setup" > + kill -9 `cat /tmp/dnsmasq.pid` > + ifconfig $brname down > + /usr/sbin/brctl delbr $brname > + iptables -t nat -D POSTROUTING -s $subnet.254/24 ! -d $subnet.254/24 -j > MASQUERADE > +} > + > + > +if [ $# = 0 ]; then > + echo "./set_private_br.sh add|del [brname] [subnet]" > + exit > +fi > +if [ $# > 1 ]; then > + brname="$2" > +fi > +if [ $# > 2 ]; then > + subnet="$3" > +fi > +if [ $1 = 'add' ]; then > + add_br > +elif [ $1 = 'del' ]; then > + del_br 2>/dev/null > +fi > _______________________________________________ Autotest mailing list Autotest@test.kernel.org http://test.kernel.org/cgi-bin/mailman/listinfo/autotest