$NetBSD: patch-hotplug_NetBSD_block,v 1.3 2016/05/21 20:12:18 bad Exp $ Use a lock around the allocation of an unused vnd because xl(1) starts the hotplug scripts in parallel. Use "stat -L" to get device major/minor numbers through symlinks e.g. for lvm volumes. --- hotplug/NetBSD/block.orig 2014-09-02 08:22:57.000000000 +0200 +++ hotplug/NetBSD/block 2016-05-21 17:03:35.000000000 +0200 @@ -6,6 +6,7 @@ DIR=$(dirname "$0") . "${DIR}/hotplugpath.sh" +. "${DIR}/locking.sh" PATH=${BINDIR}:${SBINDIR}:${LIBEXEC}:${PRIVATE_BINDIR}:/bin:/usr/bin:/sbin:/usr/sbin export PATH @@ -62,6 +63,7 @@ available_disks="$available_disks $disk" eval $disk=free done + claim_lock block # Mark the used vnd(4) devices as ``used''. for disk in `sysctl hw.disknames`; do case $disk in @@ -77,6 +79,7 @@ break fi done + release_lock block if [ x$device = x ] ; then error "no available vnd device" fi @@ -86,7 +89,7 @@ device=$xparams ;; esac - physical_device=$(stat -f '%r' "$device") + physical_device=$(stat -L -f '%r' "$device") xenstore-write $xpath/physical-device $physical_device xenstore-write $xpath/hotplug-status connected exit 0