From 68565361445d42bcdc5258294392c6a40310385c Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 24 Oct 2011 23:20:12 -0700 Subject: [PATCH] Fix issue #98 - wait till nbd is connected using method in nova's disk.py --- tools/build_kvm.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 26a195e..32c7bf6 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -235,15 +235,13 @@ rm -f $VM_DIR/disk # Create our instance fs qemu-img create -f qcow2 -b $VM_IMAGE disk -# FIXME: we are sleeping because these qemu commands appear to not complete -# before they return... We should apply fix that is done in nova's disk.py -sleep 5 - -# FIXME: we are sleeping because these qemu commands appear to not complete -# before they return... We should apply fix that is done in nova's disk.py +# Connect our nbd and wait till it is mountable qemu-nbd -c $NBD disk - -sleep 5 +NBD_DEV=`basename $NBD` +if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then + echo "Couldn't connect $NBD" + exit 1 +fi # Mount the instance mount $NBD $ROOTFS -o offset=32256 -t ext4