Files
xen/tools/hotplug/NetBSD/block
T
Olaf Hering 2c96ecb1a4 Use configure --libexecdir=BASEDIR to set LIBEXEC
The current usage of LIBEXEC is bogus. It describes the directory for
private xen executables. Other places create their own, similar
libexecdir path as $prefix/lib/xen/*.

Additional two other variables are used to describe similar paths:
PRIVATE_BINDIR and PRIVATE_PREFIX

The autoconf documentation refers to libexec as a directory for
executables and stuff which is called by other programs, not by the
user.

Adjust all places that want libexecdir as a target path. LIBEXEC refers
now to the base directory. Three convenience variables are used to refer
to paths to private binaries, libs and include files.

In the systemd files LIBEXEC_BIN is substituted, so this variable has to
be present in autoconf. All other variables are expanded in Paths.mk
because they are only used in Makefiles.

Most users of LIBEXEC are updated to use LIBEXEC_BIN because that is
what they want.

Users of PRIVATE_BINDIR are updated to use LIBEXEC_BIN because that is
what they want. PRIVATE_BINDIR and PRIVATE_PREFIX usage is removed by
this patch, in favour of LIBXEC_BIN and LIBEXEC

An internal libxl function was removed. A single helper to retrieve
LIBEXEC_BIN remains.

As suggested by the autoconf documentation, configure appends the
package name to LIBEXEC to make sure the provided directory really
refers to xen. This makes sure "make uninstall" preserves the real
libexecdir.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
[ ijc -- ran autogen.sh as requested, updated QEMU_TRADITIONAL_REVISION to
         pickup version which uses LIBEXEC_BIN ]
2014-10-06 16:59:56 +01:00

98 lines
2.0 KiB
Bash

#!/bin/sh -e
# $NetBSD: block-nbsd,v 1.1.1.1 2008/08/07 20:26:57 cegger Exp $
# Called by xenbackendd
# Usage: block xsdir_backend_path state
DIR=$(dirname "$0")
. "${DIR}/hotplugpath.sh"
PATH=${BINDIR}:${SBINDIR}:${LIBEXEC_BIN}:/bin:/usr/bin:/sbin:/usr/sbin
export PATH
error() {
echo "$@" >&2
xenstore-write $xpath/hotplug-status error \
$xpath/hotplug-error "$@"
exit 1
}
xpath=$1
xstatus=$2
xparams=$(xenstore-read "$xpath/params")
if [ -b "$xparams" ]; then
xtype="phy"
elif [ -f "$xparams" ]; then
xtype="file"
elif [ -z "$xparams" ]; then
error "$xpath/params is empty, unable to attach block device."
else
error "$xparams is not a valid file type to use as block device." \
"Only block and regular image files accepted."
fi
case $xstatus in
6)
# device removed
case $xtype in
file)
vnd=$(xenstore-read "$xpath/vnd" || echo none)
if [ $vnd != none ]; then
vnconfig -u $vnd
fi
;;
phy)
;;
*)
echo "unknown type $xtype" >&2
;;
esac
xenstore-rm $xpath
exit 0
;;
2)
case $xtype in
file)
# Store the list of available vnd(4) devices in
#``available_disks'', and mark them as ``free''.
list=`ls -1 /dev/vnd[0-9]*d | sed "s,/dev/vnd,,;s,d,," | sort -n`
for i in $list; do
disk="vnd$i"
available_disks="$available_disks $disk"
eval $disk=free
done
# Mark the used vnd(4) devices as ``used''.
for disk in `sysctl hw.disknames`; do
case $disk in
vnd[0-9]*) eval $disk=used ;;
esac
done
# Configure the first free vnd(4) device.
for disk in $available_disks; do
eval status=\$$disk
if [ "$status" = "free" ] && \
vnconfig /dev/${disk}d $xparams >/dev/null; then
device=/dev/${disk}d
break
fi
done
if [ x$device = x ] ; then
error "no available vnd device"
fi
xenstore-write $xpath/vnd $device
;;
phy)
device=$xparams
;;
esac
physical_device=$(stat -f '%r' "$device")
xenstore-write $xpath/physical-device $physical_device
xenstore-write $xpath/hotplug-status connected
exit 0
;;
*)
exit 0
;;
esac