From 01a0d395cbdeec8bf83709e80b3b98feafa17aba Mon Sep 17 00:00:00 2001 From: Sanne Raymaekers Date: Tue, 30 Jun 2026 15:34:54 +0200 Subject: [PATCH] ova: set os type and virtual hardware version Setting the appropriate os type and virtual hardware version can dramatically impact performance on platforms like vSphere. --- data/dependencies/deps_test.go | 2 +- data/dependencies/osbuild | 2 +- data/distrodefs/eln-11/disk.yaml | 7 +++++++ data/distrodefs/fedora/imagetypes.yaml | 4 ++++ data/distrodefs/rhel-10/imagetypes.yaml | 7 +++++++ data/distrodefs/rhel-8/imagetypes.yaml | 4 ++++ data/distrodefs/rhel-9/imagetypes.yaml | 4 ++++ pkg/distro/disk_config.go | 2 ++ pkg/distro/generic/images.go | 3 +++ pkg/image/disk.go | 2 ++ pkg/manifest/disk.go | 2 ++ pkg/manifest/ovf.go | 14 ++++++++++++-- pkg/osbuild/ovf_stage.go | 11 ++++++++++- .../manifest-checksums/centos_10-x86_64-ova-empty | 2 +- .../manifest-checksums/centos_9-x86_64-ova-empty | 2 +- .../manifest-checksums/eln_11-x86_64-ova-empty | 2 +- .../fedora_43-x86_64-generic_ova-empty | 2 +- .../fedora_44-x86_64-generic_ova-empty | 2 +- .../fedora_45-x86_64-generic_ova-empty | 2 +- .../manifest-checksums/rhel_10.0-x86_64-ova-empty | 2 +- .../manifest-checksums/rhel_10.2-x86_64-ova-empty | 2 +- .../manifest-checksums/rhel_10.3-x86_64-ova-empty | 2 +- .../manifest-checksums/rhel_8.10-x86_64-ova-empty | 2 +- .../manifest-checksums/rhel_8.4-x86_64-ova-empty | 2 +- .../manifest-checksums/rhel_8.6-x86_64-ova-empty | 2 +- .../manifest-checksums/rhel_8.8-x86_64-ova-empty | 2 +- .../manifest-checksums/rhel_9.0-x86_64-ova-empty | 2 +- .../manifest-checksums/rhel_9.2-x86_64-ova-empty | 2 +- .../manifest-checksums/rhel_9.4-x86_64-ova-empty | 2 +- .../manifest-checksums/rhel_9.6-x86_64-ova-empty | 2 +- .../manifest-checksums/rhel_9.8-x86_64-ova-empty | 2 +- .../manifest-checksums/rhel_9.9-x86_64-ova-empty | 2 +- 32 files changed, 78 insertions(+), 24 deletions(-) diff --git a/data/dependencies/deps_test.go b/data/dependencies/deps_test.go index 2a2d4c83b6..daf2da94f1 100644 --- a/data/dependencies/deps_test.go +++ b/data/dependencies/deps_test.go @@ -8,5 +8,5 @@ import ( ) func TestMinimumOSBuildVersion(t *testing.T) { - assert.Equal(t, "183", dependencies.MinimumOSBuildVersion()) + assert.Equal(t, "185", dependencies.MinimumOSBuildVersion()) } diff --git a/data/dependencies/osbuild b/data/dependencies/osbuild index 80945bc436..1edbdbab42 100644 --- a/data/dependencies/osbuild +++ b/data/dependencies/osbuild @@ -1 +1 @@ -183 \ No newline at end of file +185 \ No newline at end of file diff --git a/data/distrodefs/eln-11/disk.yaml b/data/distrodefs/eln-11/disk.yaml index 391e5c6101..c5f430d293 100644 --- a/data/distrodefs/eln-11/disk.yaml +++ b/data/distrodefs/eln-11/disk.yaml @@ -651,6 +651,13 @@ image_types: platforms: - <<: *x86_64_bios_platform image_format: "ova" + disk_config: + ovf_vmware: + # Ideally we would use rhel10_64Guest, but this requires vmx-22 (vcenter 9+). And many users + # are trying to use vcenter 8 for as long as possible. If this should change at some point + # in future, it should become part of the blueprint. + os_type: "rhel9_64Guest" + virtual_hardware_version: "vmx-21" blueprint: supported_options: *supported_options_disk diff --git a/data/distrodefs/fedora/imagetypes.yaml b/data/distrodefs/fedora/imagetypes.yaml index 963ab50e52..d71cde131d 100644 --- a/data/distrodefs/fedora/imagetypes.yaml +++ b/data/distrodefs/fedora/imagetypes.yaml @@ -1538,6 +1538,10 @@ image_types: name_aliases: ["ova", "vsphere-ova"] filename: "image.ova" mime_type: "application/ovf" + disk_config: + ovf_vmware: + os_type: "fedora64Guest" + virtual_hardware_version: "vmx-21" exports: ["archive"] platforms: - <<: *x86_64_bios_platform diff --git a/data/distrodefs/rhel-10/imagetypes.yaml b/data/distrodefs/rhel-10/imagetypes.yaml index 415c95acf7..2afacccf33 100644 --- a/data/distrodefs/rhel-10/imagetypes.yaml +++ b/data/distrodefs/rhel-10/imagetypes.yaml @@ -1526,6 +1526,13 @@ image_types: platforms: - <<: *x86_64_bios_platform image_format: "ova" + disk_config: + ovf_vmware: + # Ideally we would use rhel10_64Guest, but this requires vmx-22 (vcenter 9+). And many users + # are trying to use vcenter 8 for as long as possible. If this should change at some point + # in future, it should become part of the blueprint. + os_type: "rhel9_64Guest" + virtual_hardware_version: "vmx-21" blueprint: supported_options: *supported_options_disk diff --git a/data/distrodefs/rhel-8/imagetypes.yaml b/data/distrodefs/rhel-8/imagetypes.yaml index a6dfc39643..9f0f1d5c19 100644 --- a/data/distrodefs/rhel-8/imagetypes.yaml +++ b/data/distrodefs/rhel-8/imagetypes.yaml @@ -2473,6 +2473,10 @@ image_types: platforms: - <<: *x86_64_bios_platform image_format: "ova" + disk_config: + ovf_vmware: + os_type: "rhel8_64Guest" + virtual_hardware_version: "vmx-15" blueprint: supported_options: *supported_options_disk diff --git a/data/distrodefs/rhel-9/imagetypes.yaml b/data/distrodefs/rhel-9/imagetypes.yaml index 8a1c1f83c5..617edfaa71 100644 --- a/data/distrodefs/rhel-9/imagetypes.yaml +++ b/data/distrodefs/rhel-9/imagetypes.yaml @@ -2068,6 +2068,10 @@ image_types: platforms: - <<: *x86_64_bios_platform image_format: "ova" + disk_config: + ovf_vmware: + os_type: "rhel9_64Guest" + virtual_hardware_version: "vmx-18" blueprint: supported_options: *supported_options_disk diff --git a/pkg/distro/disk_config.go b/pkg/distro/disk_config.go index db3d0665c1..a5bfde35df 100644 --- a/pkg/distro/disk_config.go +++ b/pkg/distro/disk_config.go @@ -14,6 +14,8 @@ type DiskConfig struct { // Mostly for RHEL7 compat though might be purposed in the future PartitioningTool *osbuild.PartTool `yaml:"partitioning_tool,omitempty"` + + OVFVMWare *osbuild.OVFVMWareStageOptions `yaml:"ovf_vmware,omitempty"` } // InheritFrom inherits unset values from the provided parent configuration and diff --git a/pkg/distro/generic/images.go b/pkg/distro/generic/images.go index 52070ccddc..2f20760d90 100644 --- a/pkg/distro/generic/images.go +++ b/pkg/distro/generic/images.go @@ -666,6 +666,9 @@ func diskCustomizations(t *imageType) (manifest.DiskCustomizations, error) { if diskConfig.PartitioningTool != nil { diskCust.PartitioningTool = *diskConfig.PartitioningTool } + if diskConfig.OVFVMWare != nil { + diskCust.OVFVMWare = *diskConfig.OVFVMWare + } } return diskCust, nil diff --git a/pkg/image/disk.go b/pkg/image/disk.go index 87979a018e..a242b3e367 100644 --- a/pkg/image/disk.go +++ b/pkg/image/disk.go @@ -99,6 +99,8 @@ func (img *DiskImage) InstantiateManifest(m *manifest.Manifest, case platform.FORMAT_OVA: vmdkPipeline := manifest.NewVMDK(buildPipeline, rawImagePipeline) ovfPipeline := manifest.NewOVF(buildPipeline, vmdkPipeline) + ovfPipeline.VMWareOSType = img.DiskCustomizations.OVFVMWare.OSType + ovfPipeline.VMWareVirtualHardwareVersion = img.DiskCustomizations.OVFVMWare.VirtualHardwareVersion tarPipeline := manifest.NewTar(buildPipeline, ovfPipeline, "archive") tarPipeline.Format = osbuild.TarArchiveFormatUstar tarPipeline.SetFilename(img.filename) diff --git a/pkg/manifest/disk.go b/pkg/manifest/disk.go index 786d9344ec..f7a758d4c0 100644 --- a/pkg/manifest/disk.go +++ b/pkg/manifest/disk.go @@ -11,6 +11,8 @@ type DiskCustomizations struct { // Which partitioning tooling is used to create the disk image(s) PartitioningTool osbuild.PartTool + + OVFVMWare osbuild.OVFVMWareStageOptions } func NewDiskCustomizations() DiskCustomizations { diff --git a/pkg/manifest/ovf.go b/pkg/manifest/ovf.go index 19a15c418e..299d026d2e 100644 --- a/pkg/manifest/ovf.go +++ b/pkg/manifest/ovf.go @@ -11,6 +11,9 @@ type OVF struct { Base imgPipeline *VMDK + + VMWareOSType string + VMWareVirtualHardwareVersion string } // NewOVF creates a new OVF pipeline. imgPipeline is the pipeline producing the vmdk image. @@ -47,9 +50,16 @@ func (p *OVF) serialize() (osbuild.Pipeline, error) { osbuild.NewPipelineTreeInputs(inputName, p.imgPipeline.Name()), )) - pipeline.AddStage(osbuild.NewOVFStage(&osbuild.OVFStageOptions{ + options := &osbuild.OVFStageOptions{ Vmdk: p.imgPipeline.Filename(), - })) + } + if p.VMWareOSType != "" || p.VMWareVirtualHardwareVersion != "" { + options.VMWare = &osbuild.OVFVMWareStageOptions{ + OSType: p.VMWareOSType, + VirtualHardwareVersion: p.VMWareVirtualHardwareVersion, + } + } + pipeline.AddStage(osbuild.NewOVFStage(options)) return pipeline, nil } diff --git a/pkg/osbuild/ovf_stage.go b/pkg/osbuild/ovf_stage.go index 830c4e9452..10d6c5b092 100644 --- a/pkg/osbuild/ovf_stage.go +++ b/pkg/osbuild/ovf_stage.go @@ -6,6 +6,7 @@ import ( ) const vmdkRegex = "^[a-zA-Z0-9+_.-]*$" +const vhwvRegex = "^vmx-[0-9]+$" type OVFStageOptions struct { Vmdk string `json:"vmdk"` @@ -14,7 +15,8 @@ type OVFStageOptions struct { } type OVFVMWareStageOptions struct { - OSType string `json:"os_type,omitempty"` + OSType string `json:"os_type,omitempty" yaml:"os_type,omitempty"` + VirtualHardwareVersion string `json:"virtual_hardware_version,omitempty" yaml:"virtual_hardware_version,omitempty"` } type OVFVirtualBoxStageOptions struct { @@ -33,6 +35,13 @@ func (o OVFStageOptions) validate() error { return fmt.Errorf("'vmdk' name %q doesn't conform to schema (%s)", o.Vmdk, exp.String()) } + if o.VMWare != nil && o.VMWare.VirtualHardwareVersion != "" { + exp = regexp.MustCompile(vhwvRegex) + if !exp.MatchString(o.VMWare.VirtualHardwareVersion) { + return fmt.Errorf("'vmdk' name %q doesn't conform to schema (%s)", o.Vmdk, exp.String()) + } + } + return nil } diff --git a/test/data/manifest-checksums/centos_10-x86_64-ova-empty b/test/data/manifest-checksums/centos_10-x86_64-ova-empty index ebc98629e6..70b5c084f2 100644 --- a/test/data/manifest-checksums/centos_10-x86_64-ova-empty +++ b/test/data/manifest-checksums/centos_10-x86_64-ova-empty @@ -1 +1 @@ -935e1dbf0093e077d386ae8829d80c14fcd2562cfc744f8f735d9b9a31d79d1d +e7f4253fb89f30a9e64a49a500b0711a25d56ffe3e129861cc195e4a80fc5b97 diff --git a/test/data/manifest-checksums/centos_9-x86_64-ova-empty b/test/data/manifest-checksums/centos_9-x86_64-ova-empty index ea2cad208c..dad4c76731 100644 --- a/test/data/manifest-checksums/centos_9-x86_64-ova-empty +++ b/test/data/manifest-checksums/centos_9-x86_64-ova-empty @@ -1 +1 @@ -aa9d13dbe554dd1cad9ec84a22a486b24dc4c0c88c8708266326817962553e0c +fbafcffe1d1f028a646eea66c5883d32b815b739c26692a94c6b8ae59ea0e159 diff --git a/test/data/manifest-checksums/eln_11-x86_64-ova-empty b/test/data/manifest-checksums/eln_11-x86_64-ova-empty index 3fbebb125d..73c7b1f84f 100644 --- a/test/data/manifest-checksums/eln_11-x86_64-ova-empty +++ b/test/data/manifest-checksums/eln_11-x86_64-ova-empty @@ -1 +1 @@ -ebaebb5c61ba866755e07eded011ba3c4bc8c0574f8c5393907abf00d40691bf +e1e678af0a27940b22e31589c1a5922e4456ac9dddc33d4731acc1c888520d63 diff --git a/test/data/manifest-checksums/fedora_43-x86_64-generic_ova-empty b/test/data/manifest-checksums/fedora_43-x86_64-generic_ova-empty index ae065bd810..4ae0c2f9ce 100644 --- a/test/data/manifest-checksums/fedora_43-x86_64-generic_ova-empty +++ b/test/data/manifest-checksums/fedora_43-x86_64-generic_ova-empty @@ -1 +1 @@ -33503d008a1d5152ebf8bb5e19fbceb9b9927db3e10d998652cc9afbb3c0fcde +fab793163c4a734a000eb6195445ea95d82c16b10c2189b4027c9fe0649c2ed5 diff --git a/test/data/manifest-checksums/fedora_44-x86_64-generic_ova-empty b/test/data/manifest-checksums/fedora_44-x86_64-generic_ova-empty index 0cbc362137..eedb87836c 100644 --- a/test/data/manifest-checksums/fedora_44-x86_64-generic_ova-empty +++ b/test/data/manifest-checksums/fedora_44-x86_64-generic_ova-empty @@ -1 +1 @@ -87b90d73662bc10ad250548944dd9d425121b7a6b632e45e972c4a3a6de9e4a5 +81e62d5c673eb7fa424e4d14485bad5e494875c34195468037e887be6fab4fcb diff --git a/test/data/manifest-checksums/fedora_45-x86_64-generic_ova-empty b/test/data/manifest-checksums/fedora_45-x86_64-generic_ova-empty index e690cbcd8b..da7e274ee8 100644 --- a/test/data/manifest-checksums/fedora_45-x86_64-generic_ova-empty +++ b/test/data/manifest-checksums/fedora_45-x86_64-generic_ova-empty @@ -1 +1 @@ -30f5835b6d14d6ad95b6572aaec3de2b6ab1872933042f8c8f911c5184bb33ca +80a6f50ac12126fd09b226acbbe2a35f48cc7e008af11721a3beacd5dd3754a3 diff --git a/test/data/manifest-checksums/rhel_10.0-x86_64-ova-empty b/test/data/manifest-checksums/rhel_10.0-x86_64-ova-empty index be4ed30655..d91f55c57f 100644 --- a/test/data/manifest-checksums/rhel_10.0-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_10.0-x86_64-ova-empty @@ -1 +1 @@ -f74c6d343a212cdfeb098c2938287e79d6399beadf74ff7a0ca0a0bcf7731c1d +11039515d5b5b371d52f41c4900ec648cf767c5b14d1ed619962b6b3e075566f diff --git a/test/data/manifest-checksums/rhel_10.2-x86_64-ova-empty b/test/data/manifest-checksums/rhel_10.2-x86_64-ova-empty index 56d83d64d5..3cd3ccfce9 100644 --- a/test/data/manifest-checksums/rhel_10.2-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_10.2-x86_64-ova-empty @@ -1 +1 @@ -4a0b141eb68e7636f3bc88f8a77a7e290430bcc74abd09a86ca436ffcfe18147 +30a18bd7b65cbec1b22ef9e410b6056a573ce1209430f33b7a866e5167e5c282 diff --git a/test/data/manifest-checksums/rhel_10.3-x86_64-ova-empty b/test/data/manifest-checksums/rhel_10.3-x86_64-ova-empty index f8da2825f7..029408e6da 100644 --- a/test/data/manifest-checksums/rhel_10.3-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_10.3-x86_64-ova-empty @@ -1 +1 @@ -1b5061b7bdb209569dfab50f04257a82008761fea8ca2d767ec9aab76d4a0a35 +a4a2b666922e2bbfdb43669efabcf0b6c3d6cdd51233fa7100f4f8855e82d03a diff --git a/test/data/manifest-checksums/rhel_8.10-x86_64-ova-empty b/test/data/manifest-checksums/rhel_8.10-x86_64-ova-empty index cfb8c5ae16..bdbb95872f 100644 --- a/test/data/manifest-checksums/rhel_8.10-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_8.10-x86_64-ova-empty @@ -1 +1 @@ -973b457e05c993ebaf6479eec7c8d8173ec2f2ea2703bda1af07134bd9658208 +b59d28fd13541a3c868c216c94ceb7a9338b7dddd19cbd6a777c48be9424fa3b diff --git a/test/data/manifest-checksums/rhel_8.4-x86_64-ova-empty b/test/data/manifest-checksums/rhel_8.4-x86_64-ova-empty index 1c2fb03fea..9eadf317c7 100644 --- a/test/data/manifest-checksums/rhel_8.4-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_8.4-x86_64-ova-empty @@ -1 +1 @@ -5809c2d5839136b5591b4504105ac3ea9f174b9ad8f33dc2e72cc11915d59e98 +989059a0b84e5e70e99eb86fbcda3faa4c3905ea55cc3ed18aa7f9cfa2cfdbdb diff --git a/test/data/manifest-checksums/rhel_8.6-x86_64-ova-empty b/test/data/manifest-checksums/rhel_8.6-x86_64-ova-empty index eae1b39bdc..c85493d206 100644 --- a/test/data/manifest-checksums/rhel_8.6-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_8.6-x86_64-ova-empty @@ -1 +1 @@ -8d171497073a8523d82509facdcaf5d35d2e8030396b31f90dd6f80427328a2b +c073587b7d891c9f162ef8984670443e444a0fc9dd1f6a780ce672dbc43822e7 diff --git a/test/data/manifest-checksums/rhel_8.8-x86_64-ova-empty b/test/data/manifest-checksums/rhel_8.8-x86_64-ova-empty index 6c93288a74..1d54cf647a 100644 --- a/test/data/manifest-checksums/rhel_8.8-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_8.8-x86_64-ova-empty @@ -1 +1 @@ -f59923609ec2cd9b69c93f158c942691fcffc75a8dd7bb97d67c2a9d6f0fcbc0 +47bb6ecfbb47e908c0aec019781261f57944b6dd8d7396d5abfd4fb07eb0a98d diff --git a/test/data/manifest-checksums/rhel_9.0-x86_64-ova-empty b/test/data/manifest-checksums/rhel_9.0-x86_64-ova-empty index fe3a80fce6..d82359d877 100644 --- a/test/data/manifest-checksums/rhel_9.0-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_9.0-x86_64-ova-empty @@ -1 +1 @@ -3c66269c5f2703c1fcbeac40cbd6c88cdec82c78b8e096d2a550df0930eacc25 +c8d9fd505c0a031ff9e461f86fb8ca572c9722bd4ee52599b2cc069662bc3bef diff --git a/test/data/manifest-checksums/rhel_9.2-x86_64-ova-empty b/test/data/manifest-checksums/rhel_9.2-x86_64-ova-empty index b952b661e5..3950a5c1d6 100644 --- a/test/data/manifest-checksums/rhel_9.2-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_9.2-x86_64-ova-empty @@ -1 +1 @@ -5e804d506bbf45b763dd5324d72d7eaefdf29df825f6cbd9d17751e48bf87314 +3f59a1da1682195197565b7963812c3b60712d3c8695e944be20a33c2c27691b diff --git a/test/data/manifest-checksums/rhel_9.4-x86_64-ova-empty b/test/data/manifest-checksums/rhel_9.4-x86_64-ova-empty index c96c7482db..056c759d8e 100644 --- a/test/data/manifest-checksums/rhel_9.4-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_9.4-x86_64-ova-empty @@ -1 +1 @@ -55835676a7ff635437f379d4cc2be3fc4c3a4ff6f9b4ef4b0ab55f21f559f0d0 +f313091c2e6fb2b41ccee72aa537bf87261c954d072a5feee2eddc1161ba5d6f diff --git a/test/data/manifest-checksums/rhel_9.6-x86_64-ova-empty b/test/data/manifest-checksums/rhel_9.6-x86_64-ova-empty index a576ee5c42..4c1e37de5d 100644 --- a/test/data/manifest-checksums/rhel_9.6-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_9.6-x86_64-ova-empty @@ -1 +1 @@ -dc68343566e4bf2c6ae6b81f5da76c83ad49b2822faa45107b3ab970185327d8 +1943ec4082ac077549575e2a6a5958bae76623f3a812b931ef13181d660152d1 diff --git a/test/data/manifest-checksums/rhel_9.8-x86_64-ova-empty b/test/data/manifest-checksums/rhel_9.8-x86_64-ova-empty index 20f0619efb..017f7e687a 100644 --- a/test/data/manifest-checksums/rhel_9.8-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_9.8-x86_64-ova-empty @@ -1 +1 @@ -b3b28e4ee78ecdda339a45dd826b74449ef1feb5e5851b5eadf0ce448f66871d +56981ed79d46a827fd60db8bf41631a936fb95fe880ecc53b383f526f4fcb3df diff --git a/test/data/manifest-checksums/rhel_9.9-x86_64-ova-empty b/test/data/manifest-checksums/rhel_9.9-x86_64-ova-empty index bb481929f7..33f454ae64 100644 --- a/test/data/manifest-checksums/rhel_9.9-x86_64-ova-empty +++ b/test/data/manifest-checksums/rhel_9.9-x86_64-ova-empty @@ -1 +1 @@ -b8997c5f50acdda59a9bc43a8d099cb12d80af741f6ab4921f42b4d8fbc2e2a6 +9f83b6a202b5e5d934683eac512e768e48d8fa42e71181a9261dfb47b1073e74