Skip to contentSkip to conversation

support udev or hotplug based on the system [1/3]

PATCH New Jeremy Katz 1 participant 1 message Oct 6, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support udev or hotplug based on the system [1/3]

This patches moves the block-phy and block-file handling into a common block script that gets called by the hotplug agent.

Jeremy

# HG changeset patch
# User [email protected]
# Node ID b955507c41895ace00ef82f074e9366fd17eae97
# Parent 709301c07a9c0339df4780a039a3b0b405826ca8
make block devices handled by a common script, call it from the hotplug agent instead of figuring out the type in the hotplug script

tools/examples/xen-backend.agent +2 -8
diff -r 709301c07a9c -r b955507c4189 tools/examples/xen-backend.agent
@@ -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
tools/examples/block new file +82 -0

82 lines not on this page · raw message

tools/examples/block-file deleted +0 -31
diff -r 709301c07a9c -r b955507c4189 tools/examples/block-file
@@ -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
tools/examples/block-phy deleted +0 -30
diff -r 709301c07a9c -r b955507c4189 tools/examples/block-phy
@@ -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
tools/examples/Makefile +2 -2
diff -r ac8418a409c8 -r ab11cecfc9a8 tools/examples/Makefile
@@ -15,14 +15,14 @@
 XEN_CONFIGS = xend-config.sxp
 XEN_CONFIGS += xmexample1 
 XEN_CONFIGS += xmexample2
+XEN_CONFIGS += xmexample3
 XEN_CONFIGS += xmexample.vmx
 
 # Xen script dir and scripts to go there.
 XEN_SCRIPT_DIR = /etc/xen/scripts
 XEN_SCRIPTS = network-bridge vif-bridge
 XEN_SCRIPTS += network-route vif-route
-XEN_SCRIPTS += block-phy
-XEN_SCRIPTS += block-file
+XEN_SCRIPTS += block
 XEN_SCRIPTS += block-enbd
 
 XEN_HOTPLUG_DIR = /etc/hotplug

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel