Skip to content

Commit

Permalink
image_to_vm: add support for hyper-v vhdx format
Browse files Browse the repository at this point in the history
Add support for Gen 2 Hyper-V VMs.

See: flatcar/Flatcar#1009

Uses PR: flatcar/bootengine#92

Signed-off-by: Adrian Vladu <[email protected]>
  • Loading branch information
ader1990 committed Mar 27, 2024
1 parent 21a7da4 commit e9c43d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build_library/release_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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},"
Expand Down
15 changes: 14 additions & 1 deletion build_library/vm_image_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ VALID_IMG_TYPES=(
exoscale
gce
hyperv
hyperv_vhdx
iso
openstack
openstack_mini
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions changelog/changes/2024-03-26-hyperv-vhdx-images.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added Hyper-V VHDX image ([flatcar/scripts#1791](https://github.com/flatcar/scripts/pull/1791))

0 comments on commit e9c43d9

Please sign in to comment.