Coert,<br> To set up the networking, I basically used the following document:<br><a href="http://et.redhat.com/~jmh/docs/Xen_networking.pdf">http://et.redhat.com/~jmh/docs/Xen_networking.pdf</a><br><br>In this document, there is a reference to a different script for xen to use to configure the networks. This script works, but I made two modifications:<br>
1) tweaked script so you could have an IP address on bond0 (untagged traffic) and make that network accessible to the guests<br>2) added code so the networks could be configured with a configuration file rather than editing the script<br>
<br>This is what the /etc/xen/net_bond.cfg file looks like:<br># This file shows the mapping between the server interface, xen bridge and virtual interface. The current code requires all three to be specified.<br># bonded interface xen bridge name vif name<br>
bond0.3 xenbr0 vif0.0<br>bond0.2 xenbr1 vif1.0<br>bond0.4 xenbr2 vif2.0<br>bond0.7 xenbr3 vif3.0<br>
bond0.5 xenbr4 vif4.0<br>bond0.6 xenbr5 vif5.0<br>bond0 xenbr6 vif6.0<br><br><br>This is what that script looks like now:<br>
#!/bin/sh<br><br># Usage: transfer_addrs src dst<br># Copy all IP addresses (including aliases) from device $src to device $dst.<br>transfer_addrs () {<br> local src=$1<br> local dst=$2<br> # Don't bother if $dst already has IP addresses.<br>
if ip addr show dev ${dst} | egrep -q '^ *inet ' ; then<br> return<br> fi<br> # Address lines start with 'inet' and have the device in them.<br> # Replace 'inet' with 'ip addr add' and change the device name $src<br>
# to 'dev $src'.<br> ip addr show dev ${src} | egrep '^ *inet ' | sed -e "<br>s/inet/ip addr add/<br>s@\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/[0-9]\+\)@\1@<br>s/${src}/dev ${dst}/<br>" | sh -e<br>
# Remove automatic routes on destination device<br> ip route list | sed -ne "<br>/dev ${dst}\( \|$\)/ {<br> s/^/ip route del /<br> p<br>}" | sh -e<br>}<br><br># Usage: transfer_routes src dst<br># Get all IP routes to device $src, delete them, and<br>
# add the same routes to device $dst.<br># The original routes have to be deleted, otherwise adding them<br># for $dst fails (duplicate routes).<br>transfer_routes () {<br> local src=$1<br> local dst=$2<br> # List all routes and grep the ones with $src in.<br>
# Stick 'ip route del' on the front to delete.<br> # Change $src to $dst and use 'ip route add' to add.<br> ip route list | sed -ne "<br>/dev ${src}\( \|$\)/ {<br> h<br> s/^/ip route del /<br>
P<br> g<br> s/${src}/${dst}/<br> s/^/ip route add /<br> P<br> d<br>}" | sh -e<br>}<br><br><br><br># Usage: create_bridge bridge<br>create_bridge () {<br> local bridge=$1<br><br> # Don't create the bridge if it already exists.<br>
if ! brctl show | grep -q ${bridge} ; then<br> brctl addbr ${bridge}<br> brctl stp ${bridge} off<br> brctl setfd ${bridge} 0<br> fi<br> ip link set ${bridge} up<br>}<br><br># Usage: add_to_bridge bridge dev<br>
add_to_bridge () {<br> local bridge=$1<br> local dev=$2<br> # Don't add $dev to $bridge if it's already on a bridge.<br> if ! brctl show | grep -q ${dev}$ ; then<br> brctl addif ${bridge} ${dev}<br>
fi<br>}<br><br># Usage: show_status dev bridge<br># Print ifconfig and routes.<br>show_status () {<br> local dev=$1<br> local bridge=$2<br><br> echo '============================================================'<br>
ip addr show ${dev}<br> ip addr show ${bridge}<br> echo ' '<br> brctl show ${bridge}<br> echo ' '<br> ip route list<br> echo ' '<br> route -n<br> echo '============================================================'<br>
}<br><br>op_start () {<br> if [ -f /etc/xen/net_bond.cfg ] ; then<br> grep ^bond /etc/xen/net_bond.cfg | while read bond bridge vif<br> do<br> create_bridge $bridge<br> add_to_bridge $bridge $vif<br>
add_to_bridge2 $bridge $bond<br><br> transfer_addrs $bond $bridge<br> transfer_routes $bond $bridge<br> done<br> fi<br><br>}<br><br>op_stop () {<br> if [ -f /etc/xen/net_bond.cfg ] ; then<br>
grep ^bond /etc/xen/net_bond.cfg | while read bond bridge vif<br> do<br> transfer_routes $bridge $bond<br> ip link set $bridge down<br> brctl delbr $bridge<br>
done<br> fi<br>}<br><br># adds $dev to $bridge but waits for $dev to be in running state first<br>add_to_bridge2() {<br> local bridge=$1<br> local dev=$2<br> local maxtries=10<br><br> echo -n "Waiting for ${dev} to negotiate link."<br>
for i in `seq ${maxtries}` ; do<br> if ifconfig ${dev} | grep -q RUNNING ; then<br> break<br> else<br> echo -n '.'<br> sleep 1<br> fi<br> done<br><br> if [ ${i} -eq ${maxtries} ] ; then echo '(link isnt in running state)' ; fi<br>
<br> add_to_bridge ${bridge} ${dev}<br>}<br><br>case "${1}" in<br> start)<br> op_start<br> ;;<br><br> stop)<br> op_stop<br> ;;<br><br> status)<br> show_status ${netdev} ${bridge}<br>
;;<br><br> *)<br> echo "Unknown command: ${1}" >&2<br> echo 'Valid commands are: start, stop, status' >&2<br> exit 1<br>esac<br><br>David<br><br><br><div class="gmail_quote">
On Mon, Aug 3, 2009 at 3:17 AM, Coert Waagmeester <span dir="ltr"><<a href="mailto:lgroups@waagmeester.co.za">lgroups@waagmeester.co.za</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5"><br>
On Fri, 2009-07-31 at 11:08 -0400, David Knierim wrote:<br>
> I am running CentOS 5.3 x86_64 as my dom0 and CentOS 5.3 on my domU's.<br>
> On the dom0, I have two interfaces that are bonded and have tagged<br>
> VLANs. I can get the networks to the domU's by creating a bridge for<br>
> each of the VLANS (bond0.3, bond0.4, etc). On the domU, the<br>
> interfaces show up as eth0, eth1, etc.<br>
><br>
> Is there a way to set up the network on the dom0 so my domU's see a<br>
> single interface with tagged VLAN support??<br>
><br>
> Thanks!<br>
> David<br>
</div></div>> _______________________________________________<br>
> CentOS-virt mailing list<br>
> <a href="mailto:CentOS-virt@centos.org">CentOS-virt@centos.org</a><br>
> <a href="http://lists.centos.org/mailman/listinfo/centos-virt" target="_blank">http://lists.centos.org/mailman/listinfo/centos-virt</a><br>
<br>
Hello David,<br>
<br>
Sorry this is not an answer to your question, but how did you set up the<br>
bonds with xen?<br>
<br>
I tried doing the same, and did not win....<br>
<br>
<br>
Regards,<br>
<br>
Coert<br>
<br>
_______________________________________________<br>
CentOS-virt mailing list<br>
<a href="mailto:CentOS-virt@centos.org">CentOS-virt@centos.org</a><br>
<a href="http://lists.centos.org/mailman/listinfo/centos-virt" target="_blank">http://lists.centos.org/mailman/listinfo/centos-virt</a><br>
</blockquote></div><br>