From 96b197e933d3d8a74b776bd5c8160f41e748053a 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/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 +- 30 files changed, 76 insertions(+), 22 deletions(-) diff --git a/data/distrodefs/eln-11/disk.yaml b/data/distrodefs/eln-11/disk.yaml index f7d41cb2d0..ab973cfcc7 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 8579ee748a..2108e3ea7b 100644 --- a/data/distrodefs/fedora/imagetypes.yaml +++ b/data/distrodefs/fedora/imagetypes.yaml @@ -1568,6 +1568,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 89849827dc..09c8bb14f2 100644 --- a/data/distrodefs/rhel-10/imagetypes.yaml +++ b/data/distrodefs/rhel-10/imagetypes.yaml @@ -1556,6 +1556,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 9bd4f53c61..39b20c4c44 100644 --- a/data/distrodefs/rhel-8/imagetypes.yaml +++ b/data/distrodefs/rhel-8/imagetypes.yaml @@ -2485,6 +2485,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 805434e7f1..2e7cad8b31 100644 --- a/data/distrodefs/rhel-9/imagetypes.yaml +++ b/data/distrodefs/rhel-9/imagetypes.yaml @@ -2098,6 +2098,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 b747adcf04..f4c15c6aa5 100644 --- a/pkg/distro/generic/images.go +++ b/pkg/distro/generic/images.go @@ -670,6 +670,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 b3984e6965..2974b91a09 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 @@ -470a47f6d49486c9a41bb6be60c03a665a26d11a7e3bc6c3e0d4e90a9cb275ab +6b0c6bd60c6566724498cd74431d40c325d08e198aeb6c2adee1753f01e77330 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 81ed659c20..4feac2fc8e 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 @@ -0e44098eb30c19f7a6b08441fa3c2d6241f77163a4b74c5772808872c8f8998c +6b60ec747e8eee9be740e3b324867821adb79cc95f9ecce9bf992a9c35facec7 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 69a359053e..5946f92259 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 @@ -b256a9d581a74e9be0feb882e3b00dfed256367ac1bcf17a907d64d9fc58e98d +169909527eec52cc9e97fce75fd3739293c9e6d1a618be4f9864916621553820 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 f8bf76a13a..2cd15a9886 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 @@ -c0119ea05de37fbdb79ce68e6e217e6a41b0f27636699c8a566a3e879918ea5f +9ee6a017881cb0e4c4febff724a2606f3fb9f9c544a7e440b63e6f4dd2252751 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 7f18e09200..f7c4ebcde1 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 @@ -ed479271b377c4bb8837be0115ad98f3570c810e353119ddd94a1a6609b86bc0 +d695c687abdb6d22d873b816501a169793f53892085a20e307eb63889a0dc147 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 2168913075..6b3f533fda 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 @@ -a0d0752aa5bd20279e4ce64ba353fbe89b857ce547a47601f7e86cfc05073a60 +1fc82e6a21d8481d7436866c6c7aec5412a4e5d653b590d2c6b62a0259bec695 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 30c90443c5..c162af228e 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 @@ -35a0906c98bf0a18416fa9c0be12cad084ae5a92bbf896dfbf4e27008d38a4e9 +70a34166e0dd3ae1da6d3ddcb07b0a11781b5fe65009085d31a32abc47278e1d 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 0bf9b9e91d..98f5a0e5ab 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 @@ -19e7b6000e590ca6a194b186a522f578154708367852d2efd7a71bdd0e3dc25a +7e745d618aa3981c747fd38033c1cf0d90fb359379a1296676cb061f2f891cc4 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 5d28b30d70..00b3542467 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 @@ -ebdf07eb6c4e7b0c26610b1a159054044804d0219cad633a15015d2635fd8337 +a800389b674cb45e850936ba15665b48f976c69c75611167936c03123563d7d2 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 0508a9d62b..23af4f4e34 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 @@ -edb7cf94de958350f3fb31f1949a1fa41a8ddeaa01cc91d797b5cfb8ed37f04b +bc5ca6c32bb265a13f34a2f3c268410faa0cb75a866133c1c4aac8537a84999e 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 e475d61a45..8344f4b97f 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 @@ -72778bfd95391cf815e88c9d944b6308840dd3680f82f1e6982fd2f33f2b90bd +58d93bba3674e97fb7ed43720a2640fe4cecafcf7aafa14905e96bceec702cda 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 108fbf193f..90478323d0 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 @@ -40cad97ec2838ec29b1dc22453a28607d6a33038e8a8124e4f1a53f106f4403e +9a44d4d78aedc69a6f19a1d43191890863baf5a8fc8a08680a85bf1f5987f121 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 eff45f53fc..e5e14c2470 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 @@ -88ab8730ec73a8f8cd84f85c4402770a040321bcf9a91755bb13b36a284fe768 +f4429a15c096e2eb202656cc488e7b95d659e832d3d5d5ccc61d11dcda77d6ac 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 7cf60e8d1c..63fe3569d6 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 @@ -c4773cbaee4870a13969173d4d166b57ddade134d8bccd932141d4af9f144955 +f8a766909d6db0998caf98fe8585ec86bb0cc2c5e51c3207029461068cbf8c50 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 702c9c9e5e..f6ade2cec2 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 @@ -2e6cfb76074ee1028fd81f7455ed38fdede6a7bc5127d93d64544ae4cc5ea5cf +94244f12a07bb7721f50aa85eac1196c6d84150df087a014a9f8bca6d0be8188 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 8fd37f846a..d6fb066982 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 @@ -e4ed9ad5b24a28d99c03c4deea07475065a89cc1af66bcb31e4d3af3472f371c +7108f63b357505a947cece13e27aa961d4cb662a523190ad684cad07a0bef37f 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 93cf25335c..4b7a5aa20a 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 @@ -b4dc34a0fbec88d8b3a0a2ce1e36271b5279d8943f3a8f2a3c01744fbd736545 +d97bb15434a7ff85c38bbc95f97c4f9782917d40703c895ceefbc1f6f245a913 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 450b0ed729..9f985931db 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 @@ -9a50f8aff106ef22d67ab4f12c6357d4efc26262314f500abe3cb56d680ca79e +20200b9723219af290a9e6f25abf82a57c8c5ae7f2ce12f90697c507738e14c1 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 2ebcb6f7e6..b86352fcbc 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 @@ -e4e2f1dd534fee3f2d7ee955dca825ddc1b65fa04c4b8776eeb5864c28e0bc43 +4f54849a966151567ccfb3c0e37cbae15cb9605eeaa777c5a33a68cc9005cf32