Browse code

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

Euan Harris authored on 2013/07/05 00:25:33
Showing 1 changed files
... ...
@@ -41,7 +41,17 @@ function get_mount_device() {
41 41
        echo "Failed to find mapping"
42 42
        exit -1
43 43
     fi
44
-    echo "/dev/mapper/${mapping}"
44
+
45
+    local device="/dev/mapper/${mapping}"
46
+    for (( i = 0; i < 5; i++ )) ; do
47
+        if [ -b $device ] ; then
48
+            echo $device
49
+            return
50
+        fi
51
+        sleep 1
52
+    done
53
+    echo "ERROR: timed out waiting for dev-mapper"
54
+    exit 1
45 55
   else
46 56
     echo "/dev/$dev$part"
47 57
   fi