From dbfca7a816f45129693a50766dd239a6ef56df1b Mon Sep 17 00:00:00 2001 From: Ghe Rivero Date: Mon, 26 Aug 2013 09:59:41 +0000 Subject: [PATCH] Combine compress and save image into one function When compressing an image, this is done in the same dir where the raw image resides, doubling the amount of space needed (scarce when using tmpfs), and then it's moved to the .cache folder in disk. Combining these two functions, we reduce the amount of space needed in the tmpfs partition (when in use), and the compressed image is created directly on the .cache folder disk, so there is no need to move the compressed image after the process into disk. Change-Id: I451d24bdd6fa0983414244135dff5e96c0549833 --- bin/disk-image-create | 3 +-- lib/img-functions | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/disk-image-create b/bin/disk-image-create index aadc7b6cb..67b9fcb8a 100755 --- a/bin/disk-image-create +++ b/bin/disk-image-create @@ -148,8 +148,7 @@ finalise_base unmount_image if [ "$IS_RAMDISK" == "0" ]; then - compress_image - save_image $IMAGE_NAME.$IMAGE_TYPE + compress_and_save_image $IMAGE_NAME.$IMAGE_TYPE else remove_image fi diff --git a/lib/img-functions b/lib/img-functions index 23a19d192..612c2d8ba 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -106,12 +106,13 @@ function finalise_base () { fi } -function compress_image () { +function compress_and_save_image () { # Recreate our image to throw away unnecessary data test $IMAGE_TYPE != qcow2 && COMPRESS_IMAGE="" - qemu-img convert ${COMPRESS_IMAGE:+-c} -f raw $TMP_IMAGE_PATH -O $IMAGE_TYPE $TMP_IMAGE_PATH-new + qemu-img convert ${COMPRESS_IMAGE:+-c} -f raw $TMP_IMAGE_PATH -O $IMAGE_TYPE $1-new rm $TMP_IMAGE_PATH - mv $TMP_IMAGE_PATH-new $TMP_IMAGE_PATH + + TMP_IMAGE_PATH=$1-new save_image $1 } function remove_image () {