From 228f246a838ace75b620292f46f746aee1035c48 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 17:36:14 -0700 Subject: [PATCH] work towards booting --- tools/build_uec.sh | 69 +++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index aae4fb8..24422af 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash -# Make sure that we have the proper version of ubuntu +# Ubuntu distro to install +DIST_NAME=${DIST_NAME:-oneiric} + +# Make sure that we have the proper version of ubuntu (only works on natty/oneiric) UBUNTU_VERSION=`cat /etc/lsb-release | grep CODENAME | sed 's/.*=//g'` if [ ! "oneiric" = "$UBUNTU_VERSION" ]; then if [ ! "natty" = "$UBUNTU_VERSION" ]; then @@ -9,13 +12,14 @@ if [ ! "oneiric" = "$UBUNTU_VERSION" ]; then fi fi -# exit on error to stop unexpected errors -set -o errexit - # Keep track of the current directory TOOLS_DIR=$(cd $(dirname "$0") && pwd) TOP_DIR=`cd $TOOLS_DIR/..; pwd` +# exit on error to stop unexpected errors +set -o errexit +set -o xtrace + # Abort if localrc is not set if [ ! -e $TOP_DIR/localrc ]; then echo "You must have a localrc with ALL necessary passwords defined before proceeding." @@ -30,18 +34,19 @@ dpkg -l kvm libvirt-bin kpartx || apt-get install -y --force-yes kvm libvirt-bin WORK_DIR=${WORK_DIR:-/opt/kvmstack} # Where to store images -IMAGES_DIR=$WORK_DIR/images +image_dir=$WORK_DIR/images/$DIST_NAME +mkdir -p $image_dir # Original version of built image -DIST_NAME=${DIST_NAME:oneiric} -UEC_NAME=$DIST_NAME-server-cloudimg-amd64 -UEC_URL=http://uec-images.ubuntu.com/$DIST_NAME/current/$UEC_NAME-disk1.img -BASE_IMAGE=$IMAGES_DIR/$DIST_NAME.raw +uec_url=http://uec-images.ubuntu.com/$DIST_NAME/current/$DIST_NAME-server-cloudimg-amd64.tar.gz +tarball=$image_dir/$(basename $UEC_URL) # download the base uec image if we haven't already -if [ ! -e $BASE_IMAGE ]; then - mkdir -p $IMAGES_DIR - curl $UEC_URL -O $BASE_IMAGE +if [ ! -f $tarball ]; then + curl $uec_url -o $tarball + tar -Sxvzf $tarball $image_dir + cp $image_dir/*.img $image_dir/disk + cp $image_dir/*-vmlinuz-virtual $image_dir/kernel fi cd $TOP_DIR @@ -59,14 +64,16 @@ GUEST_NAME=${GUEST_NAME:-devstack} virsh destroy $GUEST_NAME || true # Where this vm is stored -VM_DIR=$WORK_DIR/instances/$GUEST_NAME +vm_dir=$WORK_DIR/instances/$GUEST_NAME # Create vm dir and remove old disk -mkdir -p $VM_DIR -rm -f $VM_DIR/disk.img +mkdir -p $vm_dir +rm -f $vm_dir/disk # Create a copy of the base image -qemu-img create -f qcow2 -b ${BASE_IMAGE} $VM_DIR/disk.img +# qemu-img create -f qcow2 -b ${BASE_IMAGE} $vm_dir/disk +cp $image_dir/disk $vm_dir/disk +cp $image_dir/kernel $vm_dir/kernel # Back to devstack cd $TOP_DIR @@ -82,7 +89,7 @@ GUEST_RAM=${GUEST_RAM:-1524288} GUEST_CORES=${GUEST_CORES:-1} # libvirt.xml configuration -NET_XML=$VM_DIR/net.xml +NET_XML=$vm_dir/net.xml cat > $NET_XML < devstack-$GUEST_NETWORK @@ -94,20 +101,19 @@ EOF if [[ "$GUEST_RECREATE_NET" == "yes" ]]; then virsh net-destroy devstack-$GUEST_NETWORK || true - virsh net-create $VM_DIR/net.xml + virsh net-create $vm_dir/net.xml fi # libvirt.xml configuration -LIBVIRT_XML=$VM_DIR/libvirt.xml +LIBVIRT_XML=$vm_dir/libvirt.xml cat > $LIBVIRT_XML < $GUEST_NAME $GUEST_RAM - hvm - - $VM_DIR/kernel - root=/dev/vda ro init=/usr/lib/cloud-init/uncloud-init ds=nocloud ubuntu-pass=ubuntu + hvm + $vm_dir/kernel + root=/dev/vda console=ttyS0 init=/usr/lib/cloud-init/uncloud-init ds=nocloud ubuntu-pass=ubuntu @@ -117,7 +123,7 @@ cat > $LIBVIRT_XML < - + @@ -127,7 +133,7 @@ cat > $LIBVIRT_XML < - + @@ -147,11 +153,12 @@ cat > $LIBVIRT_XML <