Browse code

Fix issue #98 - wait till nbd is connected using method in nova's disk.py

Anthony Young authored on 2011/10/25 15:20:12
Showing 1 changed files
... ...
@@ -235,15 +235,13 @@ rm -f $VM_DIR/disk
235 235
 # Create our instance fs
236 236
 qemu-img create -f qcow2 -b $VM_IMAGE disk
237 237
 
238
-# FIXME: we are sleeping because these qemu commands appear to not complete
239
-# before they return...  We should apply fix that is done in nova's disk.py
240
-sleep 5
241
-
242
-# FIXME: we are sleeping because these qemu commands appear to not complete
243
-# before they return...  We should apply fix that is done in nova's disk.py
238
+# Connect our nbd and wait till it is mountable
244 239
 qemu-nbd -c $NBD disk
245
-
246
-sleep 5
240
+NBD_DEV=`basename $NBD`
241
+if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then
242
+    echo "Couldn't connect $NBD"
243
+    exit 1
244
+fi
247 245
 
248 246
 # Mount the instance
249 247
 mount $NBD $ROOTFS -o offset=32256 -t ext4