mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
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@xensource.com>
69 lines
975 B
Bash
69 lines
975 B
Bash
#!/bin/sh
|
|
|
|
dir=$(dirname "$0")
|
|
. "$dir/block-common.sh"
|
|
|
|
case "$command" in
|
|
online | offline)
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
expand_dev() {
|
|
local dev
|
|
case $1 in
|
|
/*)
|
|
dev=$1
|
|
;;
|
|
*)
|
|
dev=/dev/$1
|
|
;;
|
|
esac
|
|
echo -n $dev
|
|
}
|
|
|
|
t=$(xenstore_read_default "$XENBUS_PATH"/type "MISSING")
|
|
|
|
case "$command" in
|
|
add)
|
|
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
|
|
;;
|
|
esac
|
|
;;
|
|
|
|
remove)
|
|
case $t in
|
|
phy)
|
|
exit 0
|
|
;;
|
|
|
|
file)
|
|
node=$(xenstore_read "$XENBUS_PATH"/node)
|
|
losetup -d $node
|
|
exit 0
|
|
;;
|
|
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
|