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] Rename the commands inside the hotplug scripts to match

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Rename the commands inside the hotplug scripts to match those used by hotplug
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 14 Nov 2005 18:58:07 +0000
Delivery-date: Mon, 14 Nov 2005 18:58:14 +0000
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/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/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 emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID e2e7f47e6f79721d97fd7a1f84c5299661aa9ad9
# Parent  9523e6d105119360ce0fd4208d8e6fee19f2bfba
Rename the commands inside the hotplug scripts to match those used by hotplug
and udev.  Pass all commands through from xen-backend.agent or
xen-backend.rules rather than second-guessing the individual scripts.  This
should make it easier to tear down devices cleanly, especially the dangling
vifs we are seeing at the moment.

Cope with a missing type node inside the block script, as we don't want to
resurrect a removed node by writing a hotplug error message.

Log failure of iptables command.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r 9523e6d10511 -r e2e7f47e6f79 tools/examples/block
--- a/tools/examples/block      Fri Nov 11 16:59:20 2005
+++ b/tools/examples/block      Fri Nov 11 17:01:44 2005
@@ -2,6 +2,12 @@
 
 dir=$(dirname "$0")
 . "$dir/block-common.sh"
+
+case "$command" in
+    online | offline)
+        exit 0
+        ;;
+esac
 
 expand_dev() {
   local dev
@@ -16,10 +22,10 @@
   echo -n $dev
 }
 
-t=$(xenstore_read "$XENBUS_PATH"/type || true)
+t=$(xenstore_read_default "$XENBUS_PATH"/type "MISSING")
 
 case "$command" in 
-  bind)
+  add)
     p=$(xenstore_read "$XENBUS_PATH"/params)
     case $t in 
       phy)
@@ -38,32 +44,25 @@
        done
        exit 1
        ;;
-
-      *)
-        [ -x /etc/xen/scripts/block-"$t" ] && \
-           /etc/xen/scripts/block-"$t" bind $p
-       ;;
     esac
     ;;
 
-  unbind)
-    node=$(xenstore_read "$XENBUS_PATH"/node)
+  remove)
     case $t in 
       phy)
        exit 0
        ;;
 
       file)
+        node=$(xenstore_read "$XENBUS_PATH"/node)
        losetup -d $node
        exit 0
        ;;
-
-      *)
-        [ -x /etc/xen/scripts/block-"$t" ] && \
-           /etc/xen/scripts/block-"$t" unbind $node
-       ;;
-
     esac
     ;;
 
 esac
+
+# If we've reached here, $t is neither phy nor file, so fire a helper script.
+[ -x /etc/xen/scripts/block-"$t" ] && \
+  /etc/xen/scripts/block-"$t" "$command" $node
diff -r 9523e6d10511 -r e2e7f47e6f79 tools/examples/block-common.sh
--- a/tools/examples/block-common.sh    Fri Nov 11 16:59:20 2005
+++ b/tools/examples/block-common.sh    Fri Nov 11 17:01:44 2005
@@ -19,9 +19,12 @@
 dir=$(dirname "$0")
 . "$dir/xen-hotplug-common.sh"
 
-command="$1"
+findCommand "$@"
 
-if [ "$command" != "bind" ] && [ "$command" != "unbind" ]
+if [ "$command" != "online" ]  &&
+   [ "$command" != "offline" ] &&
+   [ "$command" != "add" ]     &&
+   [ "$command" != "remove" ]
 then
   log err "Invalid command: $command"
   exit 1
diff -r 9523e6d10511 -r e2e7f47e6f79 tools/examples/vif-bridge
--- a/tools/examples/vif-bridge Fri Nov 11 16:59:20 2005
+++ b/tools/examples/vif-bridge Fri Nov 11 17:01:44 2005
@@ -9,7 +9,7 @@
 # places, then this script is the default.
 #
 # Usage:
-# vif-bridge (up|down)
+# vif-bridge (add|remove|online|offline)
 #
 # Environment vars:
 # vif         vif interface name (required).
@@ -47,7 +47,7 @@
 fi
 
 case "$command" in
-    up)
+    online)
         if brctl show "$bridge" | grep "$vif" >&/dev/null
         then
           log debug "$vif already attached to $bridge"
@@ -58,9 +58,9 @@
           fatal "brctl addif $bridge $vif failed"
 
         ifconfig "$vif" up || fatal "ifconfig $vif up failed"
-        success
         ;;
-    down)
+
+    remove)
         # vifs are auto-removed from bridge.
         ifconfig "$vif" down || fatal "ifconfig $vif down failed"
         ;;
@@ -69,3 +69,4 @@
 handle_iptable
 
 log debug "Successful vif-bridge operation for $vif, bridge $bridge."
+success
diff -r 9523e6d10511 -r e2e7f47e6f79 tools/examples/vif-common.sh
--- a/tools/examples/vif-common.sh      Fri Nov 11 16:59:20 2005
+++ b/tools/examples/vif-common.sh      Fri Nov 11 17:01:44 2005
@@ -22,11 +22,20 @@
 
 findCommand "$@"
 
-if [ "$command" != "up" ] && [ "$command" != "down" ]
+if [ "$command" != "online" ]  &&
+   [ "$command" != "offline" ] &&
+   [ "$command" != "add" ]     &&
+   [ "$command" != "remove" ]
 then
   log err "Invalid command: $command"
   exit 1
 fi
+
+case "$command" in
+    add | offline)
+        exit 0
+        ;;
+esac
 
 
 # Parameters may be read from the environment, the command line arguments, and
@@ -46,7 +55,7 @@
 
 function frob_iptable()
 {
-  if [ "$command" == "up" ]
+  if [ "$command" == "online" ]
   then
     local c="-A"
   else
diff -r 9523e6d10511 -r e2e7f47e6f79 tools/examples/vif-nat
--- a/tools/examples/vif-nat    Fri Nov 11 16:59:20 2005
+++ b/tools/examples/vif-nat    Fri Nov 11 17:01:44 2005
@@ -9,7 +9,7 @@
 # places, then vif-bridge is the default.
 #
 # Usage:
-# vif-nat (up|down)
+# vif-nat (add|remove|online|offline)
 #
 # Environment vars:
 # vif         vif interface name (required).
@@ -40,12 +40,12 @@
 main_ip=$(ip addr show eth0 | sed -e '/inet /!d;s/^.*inet \([^\s*]\)\s.*$/\1/')
 
 case "$command" in
-    up)
+    online)
         ifconfig ${vif} ${vif_ip} netmask ${netmask} up
         echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp
         ipcmd='a'
         ;;
-    down)
+    remove)
         ifconfig ${vif} down
         ipcmd='d'
         ;;
diff -r 9523e6d10511 -r e2e7f47e6f79 tools/examples/vif-route
--- a/tools/examples/vif-route  Fri Nov 11 16:59:20 2005
+++ b/tools/examples/vif-route  Fri Nov 11 17:01:44 2005
@@ -9,7 +9,7 @@
 # places, then vif-bridge is the default.
 #
 # Usage:
-# vif-route (up|down)
+# vif-route (add|remove|online|offline)
 #
 # Environment vars:
 # vif         vif interface name (required).
@@ -26,12 +26,12 @@
 main_ip=$(ip addr show eth0 | sed -e '/inet /!d;s/^.*inet \([^\s*]\)\s.*$/\1/')
 
 case "$command" in
-    up)
+    online)
         ifconfig ${vif} ${main_ip} netmask 255.255.255.255 up
         echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp
         ipcmd='a'
         ;;
-    down)
+    remove)
         ifdown ${vif}
         ipcmd='d'
         ;;
diff -r 9523e6d10511 -r e2e7f47e6f79 tools/examples/xen-backend.agent
--- a/tools/examples/xen-backend.agent  Fri Nov 11 16:59:20 2005
+++ b/tools/examples/xen-backend.agent  Fri Nov 11 17:01:44 2005
@@ -2,35 +2,25 @@
 
 PATH=/etc/xen/scripts:$PATH
 
+case "$XENBUS_TYPE" in
+  vbd)
+    /etc/xen/scripts/block "$ACTION"
+    ;;
+  vif)
+    [ -n "$script" ] && $script "$ACTION"
+    ;;
+esac
+
 case "$ACTION" in
   add)
-    case "$XENBUS_TYPE" in
-      vbd)
-       /etc/xen/scripts/block bind
-        ;;
-    esac
     ;;
   remove)
-    case "$XENBUS_TYPE" in
-      vbd)
-       /etc/xen/scripts/block unbind
-        ;;
-      vif)
-        [ -n "$script" ] && $script down
-        ;;
-    esac
     # remove device backend store entries
-    xenstore-rm -t "$XENBUS_PATH"
-    xenstore-rm -t "error/$XENBUS_PATH"
+    xenstore-rm -t "$XENBUS_PATH"       || true
+    xenstore-rm -t "error/$XENBUS_PATH" || true
     ;;
   online)
-    case "$XENBUS_TYPE" in
-      vif)
-        [ -n "$script" ] && $script up
-        ;;
-    esac
     ;;
   offline)
     ;;
 esac
-
diff -r 9523e6d10511 -r e2e7f47e6f79 tools/examples/xen-backend.rules
--- a/tools/examples/xen-backend.rules  Fri Nov 11 16:59:20 2005
+++ b/tools/examples/xen-backend.rules  Fri Nov 11 17:01:44 2005
@@ -1,4 +1,5 @@
-SUBSYSTEM=="xen-backend", KERNEL=="vbd*", ACTION=="add", 
RUN+="/etc/xen/scripts/block bind"
-SUBSYSTEM=="xen-backend", KERNEL=="vbd*", ACTION=="remove", 
RUN+="/etc/xen/scripts/block unbind"
-SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} 
up"
+SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xen/scripts/block 
$env{ACTION}"
+SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} 
online"
+SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="offline", 
RUN+="$env{script} offline"
 SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/usr/bin/xenstore-rm -t 
$env{XENBUS_PATH}"
+SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/usr/bin/xenstore-rm -t 
error/$env{XENBUS_PATH}"

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Rename the commands inside the hotplug scripts to match those used by hotplug, Xen patchbot -unstable <=