From a3ec804ad90fd13944c1b6bd5e55e85e6ecdb62c Mon Sep 17 00:00:00 2001 From: Euan Harris Date: Thu, 4 Jul 2013 16:25:33 +0100 Subject: [PATCH] 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 --- tools/xen/scripts/manage-vdi | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/xen/scripts/manage-vdi b/tools/xen/scripts/manage-vdi index 05c4b0745c..6dcb2117a8 100755 --- a/tools/xen/scripts/manage-vdi +++ b/tools/xen/scripts/manage-vdi @@ -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