Use a bridge to connect the vif and tap interfaces for HVMs; this
authorQuentin Smith <quentin@mit.edu>
Fri, 31 Dec 2010 07:36:01 +0000 (02:36 -0500)
committerQuentin Smith <quentin@mit.edu>
Fri, 31 Dec 2010 07:36:01 +0000 (02:36 -0500)
allows HVMs to use paravirt drivers for improved performance (such as
on Windows).

debian/changelog
vif-invirtroute

index 693f2de..6b52d86 100644 (file)
@@ -1,3 +1,11 @@
+invirt-xen-config (0.0.32) unstable; urgency=low
+
+  * Use a bridge to connect the vif and tap interfaces for HVMs; this
+    allows HVMs to use paravirt drivers for improved performance (such as
+    on Windows).
+
+ -- Quentin Smith <quentin@mit.edu>  Fri, 31 Dec 2010 02:35:40 -0500
+
 invirt-xen-config (0.0.31) unstable; urgency=low
 
   * Only run arpspoof when NICs are brought online (this potentially fixes
index 4663664..83a1e08 100755 (executable)
@@ -30,20 +30,27 @@ dir=$(dirname "$0")
 main_ip=$(dom0_ip)
 dev=${dev:-${vif}}
 
+brname=dom${vif#vif}
+
 case "$command" in
     online)
-        ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up
-        echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
-       echo 1 >/proc/sys/net/ipv4/conf/${dev}/rp_filter 
-       xenstore-write "$XENBUS_PATH/feature-gso-tcpv4" 0
-        if [ x${qemu_online} != xyes ]; then
-          ethtool -K ${dev} tx off
-        fi
+        setup_bridge_port ${dev}
+        setup_bridge_port ${vif}
+        create_bridge ${brname}
+        add_to_bridge ${brname} ${dev}
+        add_to_bridge ${brname} ${vif}
+        ifconfig ${brname} ${main_ip} netmask 255.255.255.255 up
+        echo 1 >/proc/sys/net/ipv4/conf/${brname}/proxy_arp
+        echo 1 >/proc/sys/net/ipv4/conf/${brname}/rp_filter
+        xenstore-write "$XENBUS_PATH/feature-gso-tcpv4" 0
+        ethtool -K ${vif} tso off
         ipcmd='add'
         cmdprefix=''
         ;;
     offline)
-        do_without_error ifdown ${vif}
+        do_without_error brctl delif ${brname} ${vif}
+        do_without_error brctl delif ${brname} ${dev}
+        do_without_error ifconfig ${brname} down
         ipcmd='del'
         cmdprefix='do_without_error'
         ;;
@@ -55,7 +62,7 @@ if [  ${vif_type} != "ioemu"  -o  x${qemu_online} = xyes ] ; then
     # If we've been given a list of IP addresses, then add routes from dom0 to
     # the guest using those addresses.
        for addr in ${ip} ; do
-           ${cmdprefix} ip route ${ipcmd} ${addr} dev ${dev} src ${main_ip}
+           ${cmdprefix} ip route ${ipcmd} ${addr} dev ${brname} src ${main_ip}
            if [ "$command" == "online" ]; then
                arpspoof -i $(invirt-getconf xen.iface) -t 18.181.0.1 ${addr}&
                sleep 5
@@ -65,6 +72,11 @@ if [  ${vif_type} != "ioemu"  -o  x${qemu_online} = xyes ] ; then
     fi
 fi
 
+if [ "$command" == "offline" ]
+then
+    do_without_error brctl delbr ${brname}
+fi
+
 log debug "Successful vif-route $command for $vif."
 if [ "$command" == "online" ]
 then