manage-vdi: Wait until devices have been created before mounting

kpartx creates partition devices asynchronously - it may exit before
the devices have been created.  This may cause a subsequent mount call
to fail, because the device it is trying to mount does not yet exist.
kpartx now has a -s option which makes it wait for the devices to be
created before returning, but the version XenServer's dom0 doesn't have
this option.   Work around this by retrying the mount.

When dom0's kpartx is updated, we will be able to use the -s option.

Change-Id: I823a8eac4f3a2ef313d06e21da0f38ed46d7386a
This commit is contained in:
Euan Harris 2013-07-04 16:25:33 +01:00
parent 314ae87a91
commit a3ec804ad9

View File

@ -41,7 +41,17 @@ function get_mount_device() {
echo "Failed to find mapping"
exit -1
fi
echo "/dev/mapper/${mapping}"
local device="/dev/mapper/${mapping}"
for (( i = 0; i < 5; i++ )) ; do
if [ -b $device ] ; then
echo $device
return
fi
sleep 1
done
echo "ERROR: timed out waiting for dev-mapper"
exit 1
else
echo "/dev/$dev$part"
fi