[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Move the block-phy and block-file handling into a common



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 1b0dbfedc0432e643f61ec6bcb93ddaf50ee0caf
# Parent  e31e64e00ac33ba4069f8fe39c77a2243c1b98fb
Move the block-phy and block-file handling into a common
block script that gets called by the hotplug agent.

Signed-off-by: Jeremy Katz <katzj@xxxxxxxxxx>

diff -r e31e64e00ac3 -r 1b0dbfedc043 tools/examples/Makefile
--- a/tools/examples/Makefile   Fri Oct  7 12:11:41 2005
+++ b/tools/examples/Makefile   Fri Oct  7 12:13:58 2005
@@ -22,8 +22,7 @@
 XEN_SCRIPTS = network-bridge vif-bridge
 XEN_SCRIPTS += network-route vif-route
 XEN_SCRIPTS += network-nat vif-nat
-XEN_SCRIPTS += block-phy
-XEN_SCRIPTS += block-file
+XEN_SCRIPTS += block
 XEN_SCRIPTS += block-enbd
 
 XEN_HOTPLUG_DIR = /etc/hotplug
diff -r e31e64e00ac3 -r 1b0dbfedc043 tools/examples/xen-backend.agent
--- a/tools/examples/xen-backend.agent  Fri Oct  7 12:11:41 2005
+++ b/tools/examples/xen-backend.agent  Fri Oct  7 12:13:58 2005
@@ -11,20 +11,14 @@
   add)
     case "$XENBUS_TYPE" in
       vbd)
-        t=$(xenstore-read "$XENBUS_PATH"/type)
-        params=$(xenstore-read "$XENBUS_PATH"/params)
-        [ -x /etc/xen/scripts/block-"$t" ] && \
-            /etc/xen/scripts/block-"$t" bind $params
+       /etc/xen/scripts/block bind
         ;;
     esac
     ;;
   remove)
     case "$XENBUS_TYPE" in
       vbd)
-        t=$(xenstore-read "$XENBUS_PATH"/type)
-        node=$(xenstore-read "$XENBUS_PATH"/node)
-        [ -x /etc/xen/scripts/block-"$t" ] && \
-            /etc/xen/scripts/block-"$t" unbind $node
+       /etc/xen/scripts/block unbind
         ;;
     esac
     # remove device backend store entries
diff -r e31e64e00ac3 -r 1b0dbfedc043 tools/examples/block
--- /dev/null   Fri Oct  7 12:11:41 2005
+++ b/tools/examples/block      Fri Oct  7 12:13:58 2005
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+set -e
+
+export PATH=/sbin:/bin:/usr/bin:/usr/sbin:$PATH
+
+expand_dev() {
+  local dev
+  case $1 in
+  /*)
+    dev=$1
+    ;;
+  *)
+    dev=/dev/$1
+    ;;
+  esac
+  echo -n $dev
+}
+
+write_dev() {
+  local major
+  local minor
+  local pdev
+       
+  major=$(stat -L -c %t "$1")
+  minor=$(stat -L -c %T "$1")
+  pdev=$(printf "0x%02x%02x" 0x$major 0x$minor)
+  xenstore-write "$XENBUS_PATH"/physical-device $pdev \
+      "$XENBUS_PATH"/node $1
+}
+
+t=$(xenstore-read "$XENBUS_PATH"/type)
+
+case $1 in 
+  bind)
+    p=$(xenstore-read "$XENBUS_PATH"/params)
+    case $t in 
+      phy)
+        dev=$(expand_dev $p)
+       write_dev "$dev"
+       exit 0
+       ;;
+
+      file)
+       for dev in /dev/loop* ; do
+         echo "dev is $dev, p is $p"
+         if losetup $dev $p; then
+           write_dev "$dev"
+            exit 0
+         fi
+       done
+       exit 1
+       ;;
+
+      *)
+        [ -x /etc/xen/scripts/block-"$t" ] && \
+           /etc/xen/scripts/block-"$t" bind $p
+       ;;
+    esac
+    ;;
+
+  unbind)
+    node=$(xenstore-read "$XENBUS_PATH"/node)
+    case $t in 
+      phy)
+       exit 0
+       ;;
+
+      file)
+       losetup -d $node
+       exit 0
+       ;;
+
+      *)
+        [ -x /etc/xen/scripts/block-"$t" ] && \
+           /etc/xen/scripts/block-"$t" unbind $node
+       ;;
+
+    esac
+    ;;
+
+esac
diff -r e31e64e00ac3 -r 1b0dbfedc043 tools/examples/block-file
--- a/tools/examples/block-file Fri Oct  7 12:11:41 2005
+++ /dev/null   Fri Oct  7 12:13:58 2005
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-# Usage: block_loop [bind file|unbind node]
-#
-# The file argument to the bind command is the file we are to bind to a
-# loop device.
-#
-# The node argument to unbind is the name of the device node we are to
-# unbind.
-
-set -e
-
-case $1 in
-  bind)
-    for dev in /dev/loop*; do
-      if losetup $dev $2; then
-        major=$(stat -L -c %t "$dev")
-        minor=$(stat -L -c %T "$dev")
-        pdev=$(printf "0x%02x%02x" 0x$major 0x$minor)
-        xenstore-write "$XENBUS_PATH"/physical-device $pdev \
-          "$XENBUS_PATH"/node $dev
-        exit 0
-      fi
-    done
-    exit 1
-    ;;
-  unbind)
-    losetup -d $2
-    exit 0
-    ;;
-esac
diff -r e31e64e00ac3 -r 1b0dbfedc043 tools/examples/block-phy
--- a/tools/examples/block-phy  Fri Oct  7 12:11:41 2005
+++ /dev/null   Fri Oct  7 12:13:58 2005
@@ -1,30 +0,0 @@
-#! /bin/sh
-
-set -e
-
-expand_dev() {
-  local dev
-  case $1 in
-  /*)
-    dev=$1
-    ;;
-  *)
-    dev=/dev/$1
-    ;;
-  esac
-  echo -n $dev
-}
-
-case $1 in
-  bind)
-    dev=$(expand_dev $2)
-    major=$(stat -L -c %t "$dev")
-    minor=$(stat -L -c %T "$dev")
-    pdev=$(printf "0x%02x%02x" 0x$major 0x$minor)
-    xenstore-write "$XENBUS_PATH"/physical-device $pdev \
-        "$XENBUS_PATH"/node $dev
-    exit 0
-    ;;
-  unbind)
-    ;;
-esac

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.