debuggers.hg
changeset 21990:0232bc7c9544
tools/hotplug, Use udev rules instead of qemu script to setup the bridge.
From: Anthony PERARD <anthony.perard@citrix.com>
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@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
tools/hotplug/Linux/vif-bridge | 20 ++++++---
tools/hotplug/Linux/vif-common.sh | 70 ++++++++++++++++++++++++---------
tools/hotplug/Linux/xen-backend.rules | 5 +-
tools/libxl/libxl.c | 6 +-
4 files changed, 70 insertions(+), 31 deletions(-)
From: Anthony PERARD <anthony.perard@citrix.com>
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@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
tools/hotplug/Linux/vif-bridge | 20 ++++++---
tools/hotplug/Linux/vif-common.sh | 70 ++++++++++++++++++++++++---------
tools/hotplug/Linux/xen-backend.rules | 5 +-
tools/libxl/libxl.c | 6 +-
4 files changed, 70 insertions(+), 31 deletions(-)
author | Anthony Perard <anthony.perard@citrix.com> |
---|---|
date | Mon Aug 09 16:46:02 2010 +0100 (2010-08-09) |
parents | 88adea5b4546 |
children | 72ae90e325ea |
files | tools/hotplug/Linux/vif-bridge tools/hotplug/Linux/vif-common.sh tools/hotplug/Linux/xen-backend.rules tools/libxl/libxl.c |
line diff
1.1 --- a/tools/hotplug/Linux/vif-bridge Mon Aug 09 16:46:01 2010 +0100 1.2 +++ b/tools/hotplug/Linux/vif-bridge Mon Aug 09 16:46:02 2010 +0100 1.3 @@ -81,20 +81,26 @@ fi 1.4 1.5 case "$command" in 1.6 online) 1.7 - setup_bridge_port "$vif" 1.8 - add_to_bridge "$bridge" "$vif" 1.9 + setup_bridge_port "$dev" 1.10 + add_to_bridge "$bridge" "$dev" 1.11 ;; 1.12 1.13 offline) 1.14 - do_without_error brctl delif "$bridge" "$vif" 1.15 - do_without_error ifconfig "$vif" down 1.16 + do_without_error brctl delif "$bridge" "$dev" 1.17 + do_without_error ifconfig "$dev" down 1.18 + ;; 1.19 + 1.20 + add) 1.21 + add_to_bridge "$bridge" "$dev" 1.22 ;; 1.23 esac 1.24 1.25 -handle_iptable 1.26 +if [ "$type_if" = vif ]; then 1.27 + handle_iptable 1.28 +fi 1.29 1.30 -log debug "Successful vif-bridge $command for $vif, bridge $bridge." 1.31 -if [ "$command" == "online" ] 1.32 +log debug "Successful vif-bridge $command for $dev, bridge $bridge." 1.33 +if [ "$type_if" = vif -a "$command" = "online" ] 1.34 then 1.35 success 1.36 fi
2.1 --- a/tools/hotplug/Linux/vif-common.sh Mon Aug 09 16:46:01 2010 +0100 2.2 +++ b/tools/hotplug/Linux/vif-common.sh Mon Aug 09 16:46:02 2010 +0100 2.3 @@ -31,12 +31,6 @@ then 2.4 exit 1 2.5 fi 2.6 2.7 -case "$command" in 2.8 - add | remove) 2.9 - exit 0 2.10 - ;; 2.11 -esac 2.12 - 2.13 2.14 # Parameters may be read from the environment, the command line arguments, and 2.15 # the store, with overriding in that order. The environment is given by the 2.16 @@ -45,24 +39,62 @@ esac 2.17 2.18 evalVariables "$@" 2.19 2.20 -ip=${ip:-} 2.21 -ip=$(xenstore_read_default "$XENBUS_PATH/ip" "$ip") 2.22 +# Older versions of Xen do not pass in the type as an argument, 2.23 +# so the default value is vif. 2.24 +: ${type_if:=vif} 2.25 2.26 -# Check presence of compulsory args. 2.27 -XENBUS_PATH="${XENBUS_PATH:?}" 2.28 -vif="${vif:?}" 2.29 +case "$type_if" in 2.30 + vif) 2.31 + dev=$vif 2.32 + ;; 2.33 + tap) 2.34 + dev=$INTERFACE 2.35 + ;; 2.36 + *) 2.37 + log err "unknown interface type $type_if" 2.38 + exit 1 2.39 + ;; 2.40 +esac 2.41 + 2.42 +case "$command" in 2.43 + online | offline) 2.44 + test "$type_if" != vif && exit 0 2.45 + ;; 2.46 + add | remove) 2.47 + test "$type_if" != tap && exit 0 2.48 + ;; 2.49 +esac 2.50 2.51 2.52 -vifname=$(xenstore_read_default "$XENBUS_PATH/vifname" "") 2.53 -if [ "$vifname" ] 2.54 -then 2.55 - if [ "$command" == "online" ] && ! ip link show "$vifname" >&/dev/null 2.56 - then 2.57 - do_or_die ip link set "$vif" name "$vifname" 2.58 - fi 2.59 - vif="$vifname" 2.60 +if [ "$type_if" = vif ]; then 2.61 + # Check presence of compulsory args. 2.62 + XENBUS_PATH="${XENBUS_PATH:?}" 2.63 + vif="${vif:?}" 2.64 + 2.65 + vifname=$(xenstore_read_default "$XENBUS_PATH/vifname" "") 2.66 + if [ "$vifname" ] 2.67 + then 2.68 + if [ "$command" == "online" ] && ! ip link show "$vifname" >&/dev/null 2.69 + then 2.70 + do_or_die ip link set "$vif" name "$vifname" 2.71 + fi 2.72 + vif="$vifname" 2.73 + fi 2.74 +elif [ "$type_if" = tap ]; then 2.75 + # Check presence of compulsory args. 2.76 + : ${INTERFACE:?} 2.77 + 2.78 + # Get xenbus_path from device name. 2.79 + # The name is built like that: "tap${domid}.${devid}". 2.80 + dev_=${dev#tap} 2.81 + domid=${dev_%.*} 2.82 + devid=${dev_#*.} 2.83 + 2.84 + XENBUS_PATH="/local/domain/0/backend/vif/$domid/$devid" 2.85 fi 2.86 2.87 +ip=${ip:-} 2.88 +ip=$(xenstore_read_default "$XENBUS_PATH/ip" "$ip") 2.89 2.90 frob_iptable() 2.91 {
3.1 --- a/tools/hotplug/Linux/xen-backend.rules Mon Aug 09 16:46:01 2010 +0100 3.2 +++ b/tools/hotplug/Linux/xen-backend.rules Mon Aug 09 16:46:02 2010 +0100 3.3 @@ -2,10 +2,11 @@ SUBSYSTEM=="xen-backend", KERNEL=="tap*" 3.4 SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xen/scripts/block $env{ACTION}" 3.5 SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm $env{ACTION}" 3.6 SUBSYSTEM=="xen-backend", KERNEL=="vif2-*", RUN+="/etc/xen/scripts/vif2 $env{ACTION}" 3.7 -SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ACTION=="online", RUN+="/etc/xen/scripts/vif-setup online" 3.8 -SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ACTION=="offline", RUN+="/etc/xen/scripts/vif-setup offline" 3.9 +SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ACTION=="online", RUN+="/etc/xen/scripts/vif-setup online type_if=vif" 3.10 +SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ACTION=="offline", RUN+="/etc/xen/scripts/vif-setup offline type_if=vif" 3.11 SUBSYSTEM=="xen-backend", KERNEL=="vscsi*", RUN+="/etc/xen/scripts/vscsi $env{ACTION}" 3.12 SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/etc/xen/scripts/xen-hotplug-cleanup" 3.13 KERNEL=="evtchn", NAME="xen/%k" 3.14 KERNEL=="blktap[0-9]*", NAME="xen/%k" 3.15 KERNEL=="pci_iomul", NAME="xen/%k" 3.16 +SUBSYSTEM=="net", KERNEL=="tap*", ACTION=="add", RUN+="/etc/xen/scripts/vif-setup $env{ACTION} type_if=tap"
4.1 --- a/tools/libxl/libxl.c Mon Aug 09 16:46:01 2010 +0100 4.2 +++ b/tools/libxl/libxl.c Mon Aug 09 16:46:02 2010 +0100 4.3 @@ -1075,7 +1075,7 @@ static char ** libxl_build_device_model_ 4.4 flexarray_set(dm_args, num++, libxl_sprintf(ctx, "nic,vlan=%d,macaddr=%s,model=%s", 4.5 vifs[i].devid, smac, vifs[i].model)); 4.6 flexarray_set(dm_args, num++, "-net"); 4.7 - flexarray_set(dm_args, num++, libxl_sprintf(ctx, "tap,vlan=%d,ifname=%s,bridge=%s", 4.8 + flexarray_set(dm_args, num++, libxl_sprintf(ctx, "tap,vlan=%d,ifname=%s,bridge=%s,script=no", 4.9 vifs[i].devid, vifs[i].ifname, vifs[i].bridge)); 4.10 ioemu_vifs++; 4.11 } 4.12 @@ -1206,8 +1206,8 @@ static char ** libxl_build_device_model_ 4.13 flexarray_set(dm_args, num++, libxl_sprintf(ctx, "nic,vlan=%d,macaddr=%s,model=%s", 4.14 vifs[i].devid, smac, vifs[i].model)); 4.15 flexarray_set(dm_args, num++, "-net"); 4.16 - flexarray_set(dm_args, num++, libxl_sprintf(ctx, "tap,vlan=%d,ifname=%s,script=%s", 4.17 - vifs[i].devid, vifs[i].ifname, "/etc/xen/scripts/qemu-ifup")); 4.18 + flexarray_set(dm_args, num++, libxl_sprintf(ctx, "tap,vlan=%d,ifname=%s,script=no", 4.19 + vifs[i].devid, vifs[i].ifname)); 4.20 ioemu_vifs++; 4.21 } 4.22 }