Disk-image-create should allow sending compat flags to qemu-img
Add a --options flag that allows disk-image-create to send custom options to qemu-img calls. It is useful for forcing compat into qemu-img created images. Usage: disk-image-create --qemu-img-options compat=0.10 base ubuntu Change-Id: I73ee2c86abc115220d51ffebbbe9ce3c4d92f188 Closes-Bug: #1329746
This commit is contained in:
parent
3ee469f299
commit
fabbb8da58
@ -61,6 +61,8 @@ function show_options () {
|
||||
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 " --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
|
||||
echo " -n skip the default inclusion of the 'base' element"
|
||||
echo " -p package[,package,package] -- list of packages to install in the image"
|
||||
@ -84,7 +86,7 @@ function show_options () {
|
||||
|
||||
INSTALL_PACKAGES=""
|
||||
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
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
@ -107,6 +109,7 @@ while true ; do
|
||||
--min-tmpfs) export DIB_MIN_TMPFS=$2; shift 2;;
|
||||
--no-tmpfs) shift; export DIB_NO_TMPFS=1;;
|
||||
--offline) shift; export DIB_OFFLINE=1;;
|
||||
--qemu-img-options) QEMU_IMG_OPTIONS=$2; shift 2;;
|
||||
--) shift ; break ;;
|
||||
*) echo "Internal error!" ; exit 1 ;;
|
||||
esac
|
||||
|
@ -109,7 +109,12 @@ function finalise_base () {
|
||||
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 $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
|
||||
|
||||
TMP_IMAGE_PATH=$1-new
|
||||
|
Loading…
Reference in New Issue
Block a user