Short circuit qemu-img convert for raw images
We currently use qemu-img convert with a raw source and dest when building raw images. We can just mv the file for increased speed. Change-Id: I3da095cb9ecad7224a121a434a9fb204132bf6df
This commit is contained in:
		@@ -45,7 +45,7 @@ function show_options () {
 | 
			
		||||
    echo "Options:"
 | 
			
		||||
    echo "    -a i386|amd64|armhf -- set the architecture of the image(default amd64)"
 | 
			
		||||
    echo "    -o imagename -- set the imagename of the output image file(default image)"
 | 
			
		||||
    echo "    -t qcow2,tar -- set the image types of the output image files (default qcow2)"
 | 
			
		||||
    echo "    -t qcow2,tar,raw -- set the image types of the output image files (default qcow2)"
 | 
			
		||||
    echo "       File types should be comma separated"
 | 
			
		||||
    echo "    -x -- turn on tracing"
 | 
			
		||||
    echo "    -u -- uncompressed; do not compress the image - larger but faster"
 | 
			
		||||
@@ -247,14 +247,24 @@ done
 | 
			
		||||
 | 
			
		||||
unmount_image
 | 
			
		||||
 | 
			
		||||
has_raw_type=
 | 
			
		||||
if [ "$IS_RAMDISK" == "0" ]; then
 | 
			
		||||
  for IMAGE_TYPE in ${IMAGE_TYPES[@]} ; do
 | 
			
		||||
    # We have to do raw last because it is destructive
 | 
			
		||||
    if [ "$IMAGE_NAME" = "raw" ]; then
 | 
			
		||||
      has_raw_type=1
 | 
			
		||||
    else
 | 
			
		||||
      compress_and_save_image $IMAGE_NAME.$IMAGE_TYPE
 | 
			
		||||
    fi
 | 
			
		||||
  done
 | 
			
		||||
fi
 | 
			
		||||
if [ -n "$has_raw_type" ]; then
 | 
			
		||||
  IMAGE_TYPE="raw"
 | 
			
		||||
  compress_and_save_image $IMAGE_NAME.$IMAGE_TYPE
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Always cleanup after ourselves
 | 
			
		||||
rm $TMP_IMAGE_PATH
 | 
			
		||||
rm -f $TMP_IMAGE_PATH
 | 
			
		||||
cleanup_dirs
 | 
			
		||||
 | 
			
		||||
case "$IMAGE_ELEMENT" in
 | 
			
		||||
 
 | 
			
		||||
@@ -115,8 +115,12 @@ function compress_and_save_image () {
 | 
			
		||||
    else
 | 
			
		||||
        EXTRA_OPTIONS=""
 | 
			
		||||
    fi
 | 
			
		||||
    if [ "$IMAGE_TYPE" = "raw" ]; then
 | 
			
		||||
        mv $TMP_IMAGE_PATH $1-new
 | 
			
		||||
    else
 | 
			
		||||
        echo "Converting image using qemu-img convert"
 | 
			
		||||
        qemu-img convert ${COMPRESS_IMAGE:+-c} -f raw $TMP_IMAGE_PATH -O $IMAGE_TYPE $EXTRA_OPTIONS $1-new
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    OUT_IMAGE_PATH=$1-new
 | 
			
		||||
    finish_image $1
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user