execute "qemu-nbd -c $NBDEV $BASEIMG"
do_on_exit qemu-nbd -d $NBDEV
+# wait for disk to become ready with newer QEMU versions
+sleep 1
+
log_action "Partitioning disk"
sfdisk /dev/nbd0 >>$LOGFILE 2>&1 << EOF
;
log_action "Connecting root image to NBD device $NBDEV"
execute "qemu-nbd -c $NBDEV $ROOTIMG"
do_on_exit qemu-nbd -d $NBDEV
+# wait for disk to become ready with newer QEMU versions
+sleep 1
blockdev --rereadpt $NBDEV
log_action "Mounting $NBDPARTITION to $LOOPDIR"
log_action "Creating guest image for $host"
execute "qemu-img create -b $ROOTIMG -f $IMGEXT -F $IMGEXT $IMGDIR/$host.$IMGEXT" 0
execute "qemu-nbd -c $NBDEV $IMGDIR/$host.$IMGEXT" 0
+ # wait for disk to become ready with newer QEMU versions
+ sleep 1
blockdev --rereadpt $NBDEV
execute "mount $NBDPARTITION $LOOPDIR" 0
execute "mount -t proc none $LOOPDIR/proc" 0
esac
do_on_exit qemu-nbd -d $NBDEV
+# wait for disk to become ready with newer QEMU versions
+sleep 1
blockdev --rereadpt $NBDEV
log_action "Mounting $NBDPARTITION to $LOOPDIR"
esac
do_on_exit qemu-nbd -d $NBDEV
+# wait for disk to become ready with newer QEMU versions
+sleep 1
blockdev --rereadpt $NBDEV
log_action "Mounting $NBDPARTITION to $LOOPDIR"