From 07568fb41821d589a151e76b62f971bb919aa060 Mon Sep 17 00:00:00 2001 From: Jeremi Piotrowski Date: Tue, 1 Feb 2022 17:50:42 +0000 Subject: [PATCH 1/2] build_library: vm_image_util: create fixed-size VHDs for Azure Azure requires disks to be fixed-size VHD files when uploading to blob storage in order to create image/gallery objects from them. This is documented here[1]. To prevent mistakes from happening create disks in that format directly so that any azure compatible tool can upload them, though azcopy is recommend because it handles their sparseness best. This has not been an issue for us so far because kola uses code from an older utility that transparently handled the dynamic-to-fixed-size conversion for VHD files (azure-vhd-utils). But people working with these things for the first time fall into this trap. [1]: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/create-upload-generic#resizing-vhds. Signed-off-by: Jeremi Piotrowski --- build_library/vm_image_util.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index a63edb85be..e9fbaf71be 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -283,12 +283,12 @@ IMG_exoscale_DISK_FORMAT=qcow2 IMG_exoscale_OEM_PACKAGE=oem-exoscale ## azure -IMG_azure_DISK_FORMAT=vhd +IMG_azure_DISK_FORMAT=vhd_fixed IMG_azure_DISK_LAYOUT=azure IMG_azure_OEM_PACKAGE=oem-azure ## azure pro -IMG_azure_pro_DISK_FORMAT=vhd +IMG_azure_pro_DISK_FORMAT=vhd_fixed IMG_azure_pro_DISK_LAYOUT=azure IMG_azure_pro_OEM_PACKAGE=oem-azure-pro @@ -429,6 +429,7 @@ _disk_ext() { vmdk_scsi) echo vmdk;; vmdk_stream) echo vmdk;; hdd) echo hdd;; + vhd*) echo vhd;; *) echo "${disk_format}";; esac } @@ -579,6 +580,11 @@ _write_vhd_disk() { assert_image_size "$2" vpc } +_write_vhd_fixed_disk() { + qemu-img convert -f raw "$1" -O vpc -o subformat=fixed,force_size "$2" + assert_image_size "$2" vpc +} + _write_vmdk_ide_disk() { qemu-img convert -f raw "$1" -O vmdk -o adapter_type=ide "$2" assert_image_size "$2" vmdk From 323c1b28b1992c56c3b0a7464e0278b6a975bd55 Mon Sep 17 00:00:00 2001 From: Jeremi Piotrowski Date: Wed, 2 Feb 2022 10:01:19 +0100 Subject: [PATCH 2/2] changelog: Add entry for Azure VHD format change --- changelog/changes/2022-02-01-azure-fixed-vhd.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/changes/2022-02-01-azure-fixed-vhd.md diff --git a/changelog/changes/2022-02-01-azure-fixed-vhd.md b/changelog/changes/2022-02-01-azure-fixed-vhd.md new file mode 100644 index 0000000000..c33fce1e30 --- /dev/null +++ b/changelog/changes/2022-02-01-azure-fixed-vhd.md @@ -0,0 +1 @@ +- Azure VHD disks are now created using subformat=fixed, which makes them suitable for immediate upload to Azure using any tool.