From e4f030fef125578c447448735d0a2dd1d79ab4fb Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Fri, 21 Oct 2011 14:28:03 -0500 Subject: [PATCH 1/3] Add CONTAINER_NAME to BASE_IMAGE_COPY value --- tools/build_kvm.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 207f86b..7511898 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -45,14 +45,14 @@ source ./stackrc DIST_NAME=${DIST_NAME:-natty} IMAGE_FNAME=$DIST_NAME.raw +# Name of our instance, used by libvirt +CONTAINER_NAME=${CONTAINER_NAME:-kvmstack} + # Original version of built image BASE_IMAGE=$KVMSTACK_DIR/images/natty.raw # Copy of base image, which we pre-install with tasty treats -BASE_IMAGE_COPY=$IMAGES_DIR/$DIST_NAME.raw.copy - -# Name of our instance, used by libvirt -CONTAINER_NAME=${CONTAINER_NAME:-kvmstack} +BASE_IMAGE_COPY=$IMAGES_DIR/$DIST_NAME.$CONTAINER_NAME.raw.copy # Mop up after previous runs virsh destroy $CONTAINER_NAME From ad57a3a8e81e42f0a4dba0e5f836cce4044a78d4 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Fri, 21 Oct 2011 14:29:30 -0500 Subject: [PATCH 2/3] Change hard-coded natty to DIST_NAME --- tools/build_kvm.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 7511898..6c364cb 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -49,7 +49,7 @@ IMAGE_FNAME=$DIST_NAME.raw CONTAINER_NAME=${CONTAINER_NAME:-kvmstack} # Original version of built image -BASE_IMAGE=$KVMSTACK_DIR/images/natty.raw +BASE_IMAGE=$KVMSTACK_DIR/images/$DIST_NAME.raw # Copy of base image, which we pre-install with tasty treats BASE_IMAGE_COPY=$IMAGES_DIR/$DIST_NAME.$CONTAINER_NAME.raw.copy @@ -70,8 +70,8 @@ mkdir -p $COPY_DIR # Create the base image if it does not yet exist if [ ! -e $IMAGES_DIR/$IMAGE_FNAME ]; then cd $TOOLS_DIR - ./make_image.sh -m -r 5000 natty raw - mv natty.raw $BASE_IMAGE + ./make_image.sh -m -r 5000 $DIST_NAME raw + mv $DIST_NAME.raw $BASE_IMAGE cd $TOP_DIR fi @@ -306,7 +306,7 @@ chmod 755 $RUN_SH RC_LOCAL=$ROOTFS/etc/init.d/local cat > $RC_LOCAL < Date: Fri, 21 Oct 2011 14:58:44 -0500 Subject: [PATCH 3/3] Rename BASE_IMAGE_COPY to VM_IMAGE --- tools/build_kvm.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 6c364cb..c047803 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -52,7 +52,7 @@ CONTAINER_NAME=${CONTAINER_NAME:-kvmstack} BASE_IMAGE=$KVMSTACK_DIR/images/$DIST_NAME.raw # Copy of base image, which we pre-install with tasty treats -BASE_IMAGE_COPY=$IMAGES_DIR/$DIST_NAME.$CONTAINER_NAME.raw.copy +VM_IMAGE=$IMAGES_DIR/$DIST_NAME.$CONTAINER_NAME.raw # Mop up after previous runs virsh destroy $CONTAINER_NAME @@ -76,8 +76,8 @@ if [ ! -e $IMAGES_DIR/$IMAGE_FNAME ]; then fi # Create a copy of the base image -if [ ! -e $BASE_IMAGE_COPY ]; then - cp -p $BASE_IMAGE $BASE_IMAGE_COPY +if [ ! -e $VM_IMAGE ]; then + cp -p $BASE_IMAGE $VM_IMAGE fi # Unmount the copied base image @@ -108,7 +108,7 @@ trap kill_unmount SIGINT DEST=${DEST:-/opt/stack} # Mount the file system -mount -o loop,offset=32256 $BASE_IMAGE_COPY $COPY_DIR +mount -o loop,offset=32256 $VM_IMAGE $COPY_DIR # git clone only if directory doesn't exist already. Since ``DEST`` might not # be owned by the installation user, we create the directory and change the @@ -231,7 +231,7 @@ cd $VM_DIR rm -f $VM_DIR/disk # Create our instance fs -qemu-img create -f qcow2 -b $BASE_IMAGE_COPY disk +qemu-img create -f qcow2 -b $VM_IMAGE disk sleep 5