debuggers.hg
changeset 6780:e9d01c5dc7b4
Move block device bind/unbind into hotplug scripts.
Fixes file: devices since unbind now runs after the backend driver
closes the loopback device.
Also moves name -> node translation into the backend domain.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Fixes file: devices since unbind now runs after the backend driver
closes the loopback device.
Also moves name -> node translation into the backend domain.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author | cl349@firebug.cl.cam.ac.uk |
---|---|
date | Mon Sep 12 19:49:03 2005 +0000 (2005-09-12) |
parents | 968541972a7c |
children | 3aa853185afe |
files | tools/examples/Makefile tools/examples/block-enbd tools/examples/block-file tools/examples/block-phy tools/examples/xen-backend.agent tools/python/xen/xend/XendDomainInfo.py |
line diff
1.1 --- a/tools/examples/Makefile Mon Sep 12 19:46:30 2005 +0000 1.2 +++ b/tools/examples/Makefile Mon Sep 12 19:49:03 2005 +0000 1.3 @@ -21,6 +21,7 @@ XEN_CONFIGS += xmexample.vmx 1.4 XEN_SCRIPT_DIR = /etc/xen/scripts 1.5 XEN_SCRIPTS = network-bridge vif-bridge 1.6 XEN_SCRIPTS += network-route vif-route 1.7 +XEN_SCRIPTS += block-phy 1.8 XEN_SCRIPTS += block-file 1.9 XEN_SCRIPTS += block-enbd 1.10
2.1 --- a/tools/examples/block-enbd Mon Sep 12 19:46:30 2005 +0000 2.2 +++ b/tools/examples/block-enbd Mon Sep 12 19:49:03 2005 +0000 2.3 @@ -3,31 +3,31 @@ 2.4 # Usage: block-enbd [bind server ctl_port |unbind node] 2.5 # 2.6 # The file argument to the bind command is the file we are to bind to a 2.7 -# loop device. We print the path to the loop device node to stdout. 2.8 +# loop device. 2.9 # 2.10 # The node argument to unbind is the name of the device node we are to 2.11 # unbind. 2.12 # 2.13 # This assumes you're running a correctly configured server at the other end! 2.14 2.15 -case $1 in 2.16 - bind) 2.17 - for dev in /dev/nd*; do 2.18 - if nbd-client $2:$3 $dev; then 2.19 - echo $dev 2.20 - exit 0 2.21 - fi 2.22 - done 2.23 - exit 1 2.24 - ;; 2.25 +set -e 2.26 2.27 - unbind) 2.28 - nbd-client -d $2 2.29 - exit 0 2.30 - ;; 2.31 - 2.32 - *) 2.33 - echo 'Unknown command: ' $1 >&2 2.34 - echo 'Valid commands are: bind, unbind' >&2 2.35 - exit 1 2.36 +case $1 in 2.37 + bind) 2.38 + for dev in /dev/nd*; do 2.39 + if nbd-client $2:$3 $dev; then 2.40 + major=$(stat -L -c %t "$dev") 2.41 + minor=$(stat -L -c %T "$dev") 2.42 + pdev=$(printf "0x%02x%02x" 0x$major 0x$minor) 2.43 + xenstore-write "$XENBUS_PATH"/physical-device $pdev \ 2.44 + "$XENBUS_PATH"/node $dev 2.45 + exit 0 2.46 + fi 2.47 + done 2.48 + exit 1 2.49 + ;; 2.50 + unbind) 2.51 + nbd-client -d $2 2.52 + exit 0 2.53 + ;; 2.54 esac
3.1 --- a/tools/examples/block-file Mon Sep 12 19:46:30 2005 +0000 3.2 +++ b/tools/examples/block-file Mon Sep 12 19:49:03 2005 +0000 3.3 @@ -3,29 +3,29 @@ 3.4 # Usage: block_loop [bind file|unbind node] 3.5 # 3.6 # The file argument to the bind command is the file we are to bind to a 3.7 -# loop device. We print the path to the loop device node to stdout. 3.8 +# loop device. 3.9 # 3.10 # The node argument to unbind is the name of the device node we are to 3.11 # unbind. 3.12 3.13 -case $1 in 3.14 - bind) 3.15 - for dev in /dev/loop*; do 3.16 - if losetup $dev $2; then 3.17 - echo $dev 3.18 - exit 0 3.19 - fi 3.20 - done 3.21 - exit 1 3.22 - ;; 3.23 +set -e 3.24 3.25 - unbind) 3.26 - losetup -d $2 3.27 - exit 0 3.28 - ;; 3.29 - 3.30 - *) 3.31 - echo 'Unknown command: ' $1 >&2 3.32 - echo 'Valid commands are: bind, unbind' >&2 3.33 - exit 1 3.34 +case $1 in 3.35 + bind) 3.36 + for dev in /dev/loop*; do 3.37 + if losetup $dev $2; then 3.38 + major=$(stat -L -c %t "$dev") 3.39 + minor=$(stat -L -c %T "$dev") 3.40 + pdev=$(printf "0x%02x%02x" 0x$major 0x$minor) 3.41 + xenstore-write "$XENBUS_PATH"/physical-device $pdev \ 3.42 + "$XENBUS_PATH"/node $dev 3.43 + exit 0 3.44 + fi 3.45 + done 3.46 + exit 1 3.47 + ;; 3.48 + unbind) 3.49 + losetup -d $2 3.50 + exit 0 3.51 + ;; 3.52 esac
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/tools/examples/block-phy Mon Sep 12 19:49:03 2005 +0000 4.3 @@ -0,0 +1,30 @@ 4.4 +#! /bin/sh 4.5 + 4.6 +set -e 4.7 + 4.8 +expand_dev() { 4.9 + local dev 4.10 + case $1 in 4.11 + /*) 4.12 + dev=$1 4.13 + ;; 4.14 + *) 4.15 + dev=/dev/$1 4.16 + ;; 4.17 + esac 4.18 + echo -n $dev 4.19 +} 4.20 + 4.21 +case $1 in 4.22 + bind) 4.23 + dev=$(expand_dev $2) 4.24 + major=$(stat -L -c %t "$dev") 4.25 + minor=$(stat -L -c %T "$dev") 4.26 + pdev=$(printf "0x%02x%02x" 0x$major 0x$minor) 4.27 + xenstore-write "$XENBUS_PATH"/physical-device $pdev \ 4.28 + "$XENBUS_PATH"/node $dev 4.29 + exit 0 4.30 + ;; 4.31 + unbind) 4.32 + ;; 4.33 +esac
5.1 --- a/tools/examples/xen-backend.agent Mon Sep 12 19:46:30 2005 +0000 5.2 +++ b/tools/examples/xen-backend.agent Mon Sep 12 19:49:03 2005 +0000 5.3 @@ -9,8 +9,26 @@ PATH=/etc/xen/scripts:$PATH 5.4 5.5 case "$ACTION" in 5.6 add) 5.7 + case "$XENBUS_TYPE" in 5.8 + vbd) 5.9 + t=$(xenstore-read "$XENBUS_PATH"/type) 5.10 + params=$(xenstore-read "$XENBUS_PATH"/params) 5.11 + [ -x /etc/xen/scripts/block-"$t" ] && \ 5.12 + /etc/xen/scripts/block-"$t" bind $params 5.13 + ;; 5.14 + esac 5.15 ;; 5.16 remove) 5.17 + case "$XENBUS_TYPE" in 5.18 + vbd) 5.19 + t=$(xenstore-read "$XENBUS_PATH"/type) 5.20 + node=$(xenstore-read "$XENBUS_PATH"/node) 5.21 + [ -x /etc/xen/scripts/block-"$t" ] && \ 5.22 + /etc/xen/scripts/block-"$t" unbind $node 5.23 + ;; 5.24 + esac 5.25 + # remove device backend store entries 5.26 + xenstore-rm "$XENBUS_PATH" 5.27 ;; 5.28 online) 5.29 case "$PHYSDEVDRIVER" in
6.1 --- a/tools/python/xen/xend/XendDomainInfo.py Mon Sep 12 19:46:30 2005 +0000 6.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Mon Sep 12 19:49:03 2005 +0000 6.3 @@ -413,17 +413,13 @@ class XendDomainInfo: 6.4 db['backend'] = backdb.getPath() 6.5 db['backend-id'] = "%i" % backdom.id 6.6 6.7 + (type, params) = string.split(sxp.child_value(devconfig, 'uname'), ':', 1) 6.8 + backdb['type'] = type 6.9 + backdb['params'] = params 6.10 backdb['frontend'] = db.getPath() 6.11 - (type, params) = string.split(sxp.child_value(devconfig, 'uname'), ':', 1) 6.12 - node = Blkctl.block('bind', type, params) 6.13 backdb['frontend-id'] = "%i" % self.id 6.14 - backdb['physical-device'] = "%li" % blkdev_name_to_number(node) 6.15 backdb.saveDB(save=True) 6.16 6.17 - # Ok, super gross, this really doesn't belong in the frontend db... 6.18 - db['type'] = type 6.19 - db['node'] = node 6.20 - db['params'] = params 6.21 db.saveDB(save=True) 6.22 6.23 return 6.24 @@ -808,9 +804,6 @@ class XendDomainInfo: 6.25 if type == 'vbd': 6.26 typedb = ddb.addChild(type) 6.27 for dev in typedb.keys(): 6.28 - devdb = typedb.addChild(str(dev)) 6.29 - Blkctl.block('unbind', devdb['type'].getData(), 6.30 - devdb['node'].getData()) 6.31 typedb[dev].delete() 6.32 typedb.saveDB(save=True) 6.33 if type == 'vtpm':