Merge "Disk-image-create should allow sending compat flags to qemu-img"

This commit is contained in:
Jenkins 2014-06-28 00:14:07 +00:00 committed by Gerrit Code Review
commit d92cbb7b1e
2 changed files with 10 additions and 2 deletions

View File

@ -61,6 +61,8 @@ function show_options () {
echo " --min-tmpfs size -- minimum size in GB needed in tmpfs to build the image" echo " --min-tmpfs size -- minimum size in GB needed in tmpfs to build the image"
echo " --no-tmpfs -- do not use tmpfs to speed image build" echo " --no-tmpfs -- do not use tmpfs to speed image build"
echo " --offline -- do not update cached resources" echo " --offline -- do not update cached resources"
echo " --qemu-img-options -- option flags to be passed directly to qemu-img."
echo " Options need to be comma separated, and follow the key=value pattern."
if [ "$IS_RAMDISK" == "0" ]; then if [ "$IS_RAMDISK" == "0" ]; then
echo " -n skip the default inclusion of the 'base' element" echo " -n skip the default inclusion of the 'base' element"
echo " -p package[,package,package] -- list of packages to install in the image" echo " -p package[,package,package] -- list of packages to install in the image"
@ -84,7 +86,7 @@ function show_options () {
INSTALL_PACKAGES="" INSTALL_PACKAGES=""
COMPRESS_IMAGE="true" COMPRESS_IMAGE="true"
TEMP=`getopt -o a:ho:t:xucnp: -l no-tmpfs,offline,help,min-tmpfs:,image-size:,image-cache:,max-online-resize: -n $SCRIPTNAME -- "$@"` TEMP=`getopt -o a:ho:t:xucnp: -l no-tmpfs,offline,help,min-tmpfs:,image-size:,image-cache:,max-online-resize:,qemu-img-options: -n $SCRIPTNAME -- "$@"`
if [ $? -ne 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi if [ $? -ne 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential! # Note the quotes around `$TEMP': they are essential!
@ -107,6 +109,7 @@ while true ; do
--min-tmpfs) export DIB_MIN_TMPFS=$2; shift 2;; --min-tmpfs) export DIB_MIN_TMPFS=$2; shift 2;;
--no-tmpfs) shift; export DIB_NO_TMPFS=1;; --no-tmpfs) shift; export DIB_NO_TMPFS=1;;
--offline) shift; export DIB_OFFLINE=1;; --offline) shift; export DIB_OFFLINE=1;;
--qemu-img-options) QEMU_IMG_OPTIONS=$2; shift 2;;
--) shift ; break ;; --) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;; *) echo "Internal error!" ; exit 1 ;;
esac esac

View File

@ -109,7 +109,12 @@ function finalise_base () {
function compress_and_save_image () { function compress_and_save_image () {
# Recreate our image to throw away unnecessary data # Recreate our image to throw away unnecessary data
test $IMAGE_TYPE != qcow2 && COMPRESS_IMAGE="" test $IMAGE_TYPE != qcow2 && COMPRESS_IMAGE=""
qemu-img convert ${COMPRESS_IMAGE:+-c} -f raw $TMP_IMAGE_PATH -O $IMAGE_TYPE $1-new if [ -n "$QEMU_IMG_OPTIONS" ]; then
EXTRA_OPTIONS="-o $QEMU_IMG_OPTIONS"
else
EXTRA_OPTIONS=""
fi
qemu-img convert ${COMPRESS_IMAGE:+-c} -f raw $TMP_IMAGE_PATH -O $IMAGE_TYPE $EXTRA_OPTIONS $1-new
rm $TMP_IMAGE_PATH rm $TMP_IMAGE_PATH
TMP_IMAGE_PATH=$1-new TMP_IMAGE_PATH=$1-new