vm_image_util: add IMAGE_DISK_EXTENSION variable

This variable allows to override the disk extension which is initially
based on the DISK_FORMAT.

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
This commit is contained in:
Mathieu Tortuyaux 2024-04-24 10:55:56 +02:00
parent 038ec80ec0
commit 5c2a8cf8b9
No known key found for this signature in database
GPG Key ID: AC5CCFB52545D9B8

View File

@ -110,6 +110,9 @@ IMG_DEFAULT_FS_HOOK=
# May be raw, qcow2 (qemu), or vmdk (vmware, virtualbox)
IMG_DEFAULT_DISK_FORMAT=raw
# Extension to set before the compression extension.
IMG_DEFAULT_DISK_EXTENSION=
# Name of the partition layout from disk_layout.json
IMG_DEFAULT_DISK_LAYOUT=base
@ -421,6 +424,11 @@ _dst_path() {
# Get the proper disk format extension.
_disk_ext() {
local disk_format=$(_get_vm_opt DISK_FORMAT)
local disk_extension=$(_get_vm_opt DISK_EXTENSION)
if [[ -n ${disk_extension} ]]; then
echo "${disk_extension}"
return 0
fi
case ${disk_format} in
raw) echo bin;;
qcow2) echo img;;