From 872ad17c22b53f52ef88c705e9468da220f7c0eb Mon Sep 17 00:00:00 2001 From: Adrian Vladu Date: Mon, 25 Mar 2024 13:48:03 +0000 Subject: [PATCH] image_to_vm: add support for hyper-v vhdx format Add support for Gen 2 Hyper-V VMs. See: https://github.com/flatcar/Flatcar/issues/1009 Uses PR: https://github.com/flatcar/bootengine/pull/92 Signed-off-by: Adrian Vladu --- build_library/release_util.sh | 2 +- build_library/vm_image_util.sh | 15 ++++++++++++++- .../changes/2024-03-26-hyperv-vhdx-images.md | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 changelog/changes/2024-03-26-hyperv-vhdx-images.md diff --git a/build_library/release_util.sh b/build_library/release_util.sh index 21d5aa58057..ff7be260b0d 100644 --- a/build_library/release_util.sh +++ b/build_library/release_util.sh @@ -89,7 +89,7 @@ compress_disk_images() { # We want to compress images, but we also want to remove the uncompressed files # from the list of uploadable files. for filename in "${local_files_to_evaluate[@]}"; do - if [[ "${filename}" =~ \.(img|bin|vdi|vhd|vmdk)$ ]]; then + if [[ "${filename}" =~ \.(img|bin|vdi|vhd|vhdx|vmdk)$ ]]; then # Parse the formats as an array. This will yield an extra empty # array element at the end. readarray -td, FORMATS<<<"${FLAGS_image_compression_formats}," diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 8e8010cdf67..689fac48ab5 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -16,6 +16,7 @@ VALID_IMG_TYPES=( exoscale gce hyperv + hyperv_vhdx iso openstack openstack_mini @@ -297,6 +298,11 @@ IMG_azure_OEM_SYSEXT=oem-azure IMG_hyperv_DISK_FORMAT=vhd IMG_hyperv_OEM_PACKAGE=oem-hyperv +## hyper-v vhdx +IMG_hyperv_vhdx_DISK_FORMAT=vhdx +IMG_hyperv_vhdx_OEM_PACKAGE=oem-hyperv + + ## cloudsigma IMG_cloudsigma_DISK_FORMAT=qcow2 IMG_cloudsigma_OEM_PACKAGE=oem-cloudsigma @@ -431,7 +437,9 @@ _disk_ext() { vmdk_scsi) echo vmdk;; vmdk_stream) echo vmdk;; hdd) echo hdd;; - vhd*) echo vhd;; + vhd) echo vhd;; + vhd_fixed) echo vhd;; + vhdx) echo vhdx;; *) echo "${disk_format}";; esac } @@ -650,6 +658,11 @@ _write_vhd_fixed_disk() { assert_image_size "$2" vpc } +_write_vhdx_disk() { + qemu-img convert -f raw "$1" -O vhdx -o subformat=dynamic "$2" + assert_image_size "$2" vhdx +} + _write_vmdk_ide_disk() { qemu-img convert -f raw "$1" -O vmdk -o adapter_type=ide "$2" assert_image_size "$2" vmdk diff --git a/changelog/changes/2024-03-26-hyperv-vhdx-images.md b/changelog/changes/2024-03-26-hyperv-vhdx-images.md new file mode 100644 index 00000000000..5623403cc93 --- /dev/null +++ b/changelog/changes/2024-03-26-hyperv-vhdx-images.md @@ -0,0 +1 @@ +- Added Hyper-V VHDX image ([flatcar/scripts#1791](https://github.com/flatcar/scripts/pull/1791))