From 87e62fdc88af2e0eb5000e6ad9225eba56ee7be7 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 63903f8705..7815554d94 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 @@ -d57788f9f064c19567efb471f40cc28fcb7aff695c77bbebbbd1694cc7c64e03 +1acb3c5bf8b92b3d91198ac09e96bb12bebd023fdc8e2c954afb3bf6be33252f 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 5356dc84cb..b0e2d46cd0 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 @@ -e0030675e07133efc02f44d4582f117aa0bb22658c0f226132348d1f6fff4a9e +181ffd9f2a8de80ddf726b46ffd0f7917e5e6e7762313bf274b5698937fc4cac 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 c8aade83ff..809079324c 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 @@ -e9dce7cb9e9d9bf9b768dda3b91d14dd1a225a4fe5be0395a6ae962bdd2fde96 +eb48e8f951bd51b1dfecf74810268f558c708e501b88cb1dd647cf50574f2805 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 5dc29bbf74..21ff27beac 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 @@ -091c62c2b9035bdf918da904d91ee29dd4f48015439c9542ad3a3c800f52a944 +39454961db2b1181a4328cbe7382f0ec8a9bf5eb5b3d094df09814eea4ebbbee 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 48ff7fdc63..755c917761 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 @@ -a3aaa464930fd125afeccd9f10b972db99648d253a506c2e4bc076a3e7dc41ac +84fc771b7c4bfa334292fc6b9a10e9087d6a51fd4c5595dbeb50184b7ab84bc9 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 ab8f5d50d4..ad0dd10064 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 @@ -9b7c91e8b441d5015b5ee76c34403d8667fc5f1317dd510f881402c7f41ee057 +9b29ea28cb2466adb1087994e9c3b63e595b3bc8dad005a6e9e45662a6994370 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 b34232d19e..61bd6cabf3 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 @@ -465c5baadc3d2e6d1eff7744b81e8ccf109dd1d55434bfff413ca66049c523ed +ace11d19b14caa8a3da82e8f4b57a4461424a80e5a4832e6a5ab41a7486986f1 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 42976b002c..ffdfda1da0 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 @@ -b36993b5ee6006d83f6ba407ed12af4105b9e3b2475cd5b3fea3db3bd2cdd4a4 +85ebf6180c6003d17ac3d8eab4d581d3606ed30f24f7497dbdb00a2fbd5d0a08 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 9a8b0c0d09..472c72c9e5 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 @@ -bd3c506629c32fec368e032776a18c6172d906f353caaf8fd6802bfee21ee148 +378ac23acb0ca162ea7b97e02b74ccaf27ee48059c84806c1c8e04377506d370 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 3b0f21463f..f7ae2ac117 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 @@ -ad43eee13069129cf354729cb367315cad37b9565014c551eb53584679b5428e +b654d80fd59a51c667e6ab3ca1829e833fe3529c09f17d292227a1eeead39f08 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 586b31a87e..79bc87c1a7 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 @@ -c1e253c541aefc5f2767464d2354f64c1749b23cb2ffd2170ca4bcbefd76f9d0 +2c8a83745707ee18fda83a458a6e1d46f1562a3d90f8b17e4b8077bbc68ba6f5 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 a9bab9b45e..f64205d459 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 @@ -7a4b7cad00e2c6fa05bf6b818980cc45c226225e733f81cc3d5c09f7464a9292 +5b528b8fb6c76feddbc395d9835b08ce7271743173a010cbbb31e62978b4c1ea 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 1672427d45..802b2242d0 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 @@ -dcdf47c939dc3e14a214ef2b8d7bea771ba94954ecca009563254e8337b17c9c +50e93d78fc06b6e3c2198d6120aab68ed5347e93bff01db019e465eba321258e 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 1637e62560..77d228b4a1 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 @@ -8f32e2cd50e5771ed2f46daba3329c6e4677bb4f299965a557009609b07c1ace +22bb4d3fb20782b8283721bfd71aed37fa889364a1475ec8c77bfdfa5231cab1 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 2098cbf46d..f1a63528d9 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 @@ -6682188158cd32a0cace1997e230d7d64cb57a030fa9f2cb764c14b32365bb29 +37ee3af12b427b9af3bbcf39c7c572e9f294b350074e66b902afacfbd65aa61f 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 b3a8f77f78..61ab444e0c 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 @@ -1c5b7d71eab9e6f83d4e4fb67b5049a431fe2f73ed19ef8df4110ae5a48ef1d8 +6e54f84e3b4760eedd211cbfe151f266840460bc42b435efad87de1f947ad929 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 eda36de1ff..63efaf9503 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 @@ -e537082d0b5cedfe516b49c85f15596c992c6feffcd7c374a09bff1109e46972 +ed615b9c653d48c00ad3acf24c63cb0ff73b50439ac80a653e7a2152c14a8187 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 0930a5afaa..acbcfed1d2 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 @@ -1206b032e04fccf8c008e5b566bcd033944eb19a9c1ec58eac29059f7080c5fd +0d614f7346e7919657ecb513c848d15d34c59f2158816451d8cd122cef8f9f82 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 b62a4de717..7a5d6aae73 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 @@ -924a459576559e00ad422f6ad113609bfb4c7ae31d841939189b6442b20f8846 +ea8235db3c25491a5a3c4605337846c7a58fc46fd65720679165295597415d8a