Amos Kong writes:
> private_br.sh : script used to add/remove setup of private bridge and dnsmasq
> qemu-ifup-vbr0 : network script of qemu, it uses fix bridge 'vbr0'
>
> Signed-off-by: Amos Kong <[email protected]>
> ---
> 0 files changed, 0 insertions(+), 0 deletions(-)
>
> diff --git a/client/tests/kvm/scripts/private_br.sh
> b/client/tests/kvm/scripts/private_br.sh
> new file mode 100755
> index 0000000..2684e96
> --- /dev/null
> +++ b/client/tests/kvm/scripts/private_br.sh
> @@ -0,0 +1,44 @@
> +#!/bin/bash
> +
> +# Script used to add/remove setup of private bridge and dnsmasq
> +# @author Amos Kong <[email protected]>
> +
> +brname='vbr0'
> +
> +add_br()
> +{
> + echo "add new private bridge"
> + /usr/sbin/brctl addbr $brname
> + echo 1 > /proc/sys/net/ipv6/conf/$brname/disable_ipv6
Is there any reason that we need to disble ipv6?
> + echo 1 > /proc/sys/net/ipv4/ip_forward
> + /usr/sbin/brctl stp $brname on
> + /usr/sbin/brctl setfd $brname 0
Looks like you've done this is ifup script.
> + ifconfig $brname 192.168.58.1
> + ifconfig $brname up
ifconfig $brname 192.168.58.1 up
> + # add iptable entry as libvirt, then guest can access public network
> + iptables -t nat -A POSTROUTING -s 192.168.58.254/24 ! -d
> 192.168.58.254/24 -j MASQUERADE
> + /etc/init.d/dnsmasq stop
> + /etc/init.d/tftpd-hpa stop 2>/dev/null
> + dnsmasq --strict-order --bind-interfaces --listen-address 192.168.58.1
> --dhcp-range 192.168.58.2,192.168.58.254 $tftp_cmd
> +}
It's better to let user can config the address and range and find a solution to
notify the post-script of unattended installation.
> +
> +del_br()
> +{
> + echo "cleanup bridge setup"
> + kill -9 `pgrep dnsmasq|tail -1`
This obviously does not work with multiple dnsmasq processes, consider the cases
when the libvirt is running.
> + ifconfig $brname down
> + /usr/sbin/brctl delbr $brname
> + iptables -t nat -D POSTROUTING -s 192.168.58.254/24 ! -d
> 192.168.58.254/24 -j MASQUERADE
> +}
> +
> +
> +# clean original setup first
> +del_br 2>/dev/null
> +
> +if [[ $# > 0 ]];then
> + if [[ $# = 2 ]];then
> + # setup tftp function
> + tftp_cmd=" --enable-tftp --tftp-root $1 --dhcp-boot $2
> --dhcp-no-override"
> + fi
> + add_br
> +fi
> diff --git a/client/tests/kvm/scripts/qemu-ifup-vbr0
> b/client/tests/kvm/scripts/qemu-ifup-vbr0
> new file mode 100755
> index 0000000..a91c37f
> --- /dev/null
> +++ b/client/tests/kvm/scripts/qemu-ifup-vbr0
> @@ -0,0 +1,6 @@
> +#!/bin/sh
> +switch=vbr0
> +/sbin/ifconfig $1 0.0.0.0 up
> +/usr/sbin/brctl addif ${switch} $1
> +/usr/sbin/brctl setfd ${switch} 0
> +/usr/sbin/brctl stp ${switch} off
To maximize the flexibility, I just wonder we may use things like tunctl and
merge it into kvm-autotest itself instread of pre_command to create and
configure
the tap and bridge.
>
> _______________________________________________
> Autotest mailing list
> [email protected]
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest