WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] tools/hotplug, Use udev rules instead of

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] tools/hotplug, Use udev rules instead of qemu script to setup the bridge.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 11 Aug 2010 13:55:54 -0700
Delivery-date: Wed, 11 Aug 2010 13:59:38 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Anthony Perard <anthony.perard@xxxxxxxxxx>
# Date 1281368762 -3600
# Node ID 0232bc7c9544c1941c667e625526bc0bc4aa2a97
# Parent  88adea5b4546ba2880d55e399058322b38c08124
tools/hotplug, Use udev rules instead of qemu script to setup the bridge.
From: Anthony PERARD <anthony.perard@xxxxxxxxxx>

This patch adds a second argument to vif-bridge script. It can be "vif"
or "tap". "vif" give the default behavior and "tap" just add the
interface to the found bridge when the action is "add".

Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 tools/hotplug/Linux/vif-bridge        |   20 +++++---
 tools/hotplug/Linux/vif-common.sh     |   76 ++++++++++++++++++++++++----------
 tools/hotplug/Linux/xen-backend.rules |    5 +-
 tools/libxl/libxl.c                   |    6 +-
 4 files changed, 73 insertions(+), 34 deletions(-)

diff -r 88adea5b4546 -r 0232bc7c9544 tools/hotplug/Linux/vif-bridge
--- a/tools/hotplug/Linux/vif-bridge    Mon Aug 09 16:46:01 2010 +0100
+++ b/tools/hotplug/Linux/vif-bridge    Mon Aug 09 16:46:02 2010 +0100
@@ -81,20 +81,26 @@ fi
 
 case "$command" in
     online)
-       setup_bridge_port "$vif"
-       add_to_bridge "$bridge" "$vif"
+        setup_bridge_port "$dev"
+        add_to_bridge "$bridge" "$dev"
         ;;
 
     offline)
-        do_without_error brctl delif "$bridge" "$vif"
-        do_without_error ifconfig "$vif" down
+        do_without_error brctl delif "$bridge" "$dev"
+        do_without_error ifconfig "$dev" down
+        ;;
+
+    add)
+        add_to_bridge "$bridge" "$dev"
         ;;
 esac
 
-handle_iptable
+if [ "$type_if" = vif ]; then
+    handle_iptable
+fi
 
-log debug "Successful vif-bridge $command for $vif, bridge $bridge."
-if [ "$command" == "online" ]
+log debug "Successful vif-bridge $command for $dev, bridge $bridge."
+if [ "$type_if" = vif -a "$command" = "online" ]
 then
   success
 fi
diff -r 88adea5b4546 -r 0232bc7c9544 tools/hotplug/Linux/vif-common.sh
--- a/tools/hotplug/Linux/vif-common.sh Mon Aug 09 16:46:01 2010 +0100
+++ b/tools/hotplug/Linux/vif-common.sh Mon Aug 09 16:46:02 2010 +0100
@@ -31,12 +31,6 @@ then
   exit 1
 fi
 
-case "$command" in
-    add | remove)
-        exit 0
-        ;;
-esac
-
 
 # Parameters may be read from the environment, the command line arguments, and
 # the store, with overriding in that order.  The environment is given by the
@@ -45,24 +39,62 @@ esac
 
 evalVariables "$@"
 
+# Older versions of Xen do not pass in the type as an argument,
+# so the default value is vif.
+: ${type_if:=vif}
+
+case "$type_if" in
+    vif)
+        dev=$vif
+        ;;
+    tap)
+        dev=$INTERFACE
+        ;;
+    *)
+        log err "unknown interface type $type_if"
+        exit 1
+        ;;
+esac
+
+case "$command" in
+    online | offline)
+        test "$type_if" != vif && exit 0
+        ;;
+    add | remove)
+        test "$type_if" != tap && exit 0
+        ;;
+esac
+
+
+if [ "$type_if" = vif ]; then
+    # Check presence of compulsory args.
+    XENBUS_PATH="${XENBUS_PATH:?}"
+    vif="${vif:?}"
+
+    vifname=$(xenstore_read_default "$XENBUS_PATH/vifname" "")
+    if [ "$vifname" ]
+    then
+        if [ "$command" == "online" ] && ! ip link show "$vifname" >&/dev/null
+        then
+            do_or_die ip link set "$vif" name "$vifname"
+        fi
+        vif="$vifname"
+    fi
+elif [ "$type_if" = tap ]; then
+    # Check presence of compulsory args.
+    : ${INTERFACE:?}
+
+    # Get xenbus_path from device name.
+    # The name is built like that: "tap${domid}.${devid}".
+    dev_=${dev#tap}
+    domid=${dev_%.*}
+    devid=${dev_#*.}
+
+    XENBUS_PATH="/local/domain/0/backend/vif/$domid/$devid"
+fi
+
 ip=${ip:-}
 ip=$(xenstore_read_default "$XENBUS_PATH/ip" "$ip")
-
-# Check presence of compulsory args.
-XENBUS_PATH="${XENBUS_PATH:?}"
-vif="${vif:?}"
-
-
-vifname=$(xenstore_read_default "$XENBUS_PATH/vifname" "")
-if [ "$vifname" ]
-then
-  if [ "$command" == "online" ] && ! ip link show "$vifname" >&/dev/null
-  then
-    do_or_die ip link set "$vif" name "$vifname"
-  fi
-  vif="$vifname"
-fi
-
 
 frob_iptable()
 {
diff -r 88adea5b4546 -r 0232bc7c9544 tools/hotplug/Linux/xen-backend.rules
--- a/tools/hotplug/Linux/xen-backend.rules     Mon Aug 09 16:46:01 2010 +0100
+++ b/tools/hotplug/Linux/xen-backend.rules     Mon Aug 09 16:46:02 2010 +0100
@@ -2,10 +2,11 @@ SUBSYSTEM=="xen-backend", KERNEL=="vbd*"
 SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xen/scripts/block 
$env{ACTION}"
 SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm 
$env{ACTION}"
 SUBSYSTEM=="xen-backend", KERNEL=="vif2-*", RUN+="/etc/xen/scripts/vif2 
$env{ACTION}"
-SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ACTION=="online", 
RUN+="/etc/xen/scripts/vif-setup online"
-SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ACTION=="offline", 
RUN+="/etc/xen/scripts/vif-setup offline"
+SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ACTION=="online", 
RUN+="/etc/xen/scripts/vif-setup online type_if=vif"
+SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ACTION=="offline", 
RUN+="/etc/xen/scripts/vif-setup offline type_if=vif"
 SUBSYSTEM=="xen-backend", KERNEL=="vscsi*", RUN+="/etc/xen/scripts/vscsi 
$env{ACTION}"
 SUBSYSTEM=="xen-backend", ACTION=="remove", 
RUN+="/etc/xen/scripts/xen-hotplug-cleanup"
 KERNEL=="evtchn", NAME="xen/%k"
 KERNEL=="blktap[0-9]*", NAME="xen/%k"
 KERNEL=="pci_iomul", NAME="xen/%k"
+SUBSYSTEM=="net", KERNEL=="tap*", ACTION=="add", 
RUN+="/etc/xen/scripts/vif-setup $env{ACTION} type_if=tap"
diff -r 88adea5b4546 -r 0232bc7c9544 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Aug 09 16:46:01 2010 +0100
+++ b/tools/libxl/libxl.c       Mon Aug 09 16:46:02 2010 +0100
@@ -1075,7 +1075,7 @@ static char ** libxl_build_device_model_
                 flexarray_set(dm_args, num++, libxl_sprintf(ctx, 
"nic,vlan=%d,macaddr=%s,model=%s",
                             vifs[i].devid, smac, vifs[i].model));
                 flexarray_set(dm_args, num++, "-net");
-                flexarray_set(dm_args, num++, libxl_sprintf(ctx, 
"tap,vlan=%d,ifname=%s,bridge=%s",
+                flexarray_set(dm_args, num++, libxl_sprintf(ctx, 
"tap,vlan=%d,ifname=%s,bridge=%s,script=no",
                             vifs[i].devid, vifs[i].ifname, vifs[i].bridge));
                 ioemu_vifs++;
             }
@@ -1206,8 +1206,8 @@ static char ** libxl_build_device_model_
                 flexarray_set(dm_args, num++, libxl_sprintf(ctx, 
"nic,vlan=%d,macaddr=%s,model=%s",
                             vifs[i].devid, smac, vifs[i].model));
                 flexarray_set(dm_args, num++, "-net");
-                flexarray_set(dm_args, num++, libxl_sprintf(ctx, 
"tap,vlan=%d,ifname=%s,script=%s",
-                            vifs[i].devid, vifs[i].ifname, 
"/etc/xen/scripts/qemu-ifup"));
+                flexarray_set(dm_args, num++, libxl_sprintf(ctx, 
"tap,vlan=%d,ifname=%s,script=no",
+                            vifs[i].devid, vifs[i].ifname));
                 ioemu_vifs++;
             }
         }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] tools/hotplug, Use udev rules instead of qemu script to setup the bridge., Xen patchbot-unstable <=