From ab3793175b32d6b063045609d888c7307e1d5cb6 Mon Sep 17 00:00:00 2001 From: Liran Rotenberg Date: Mon, 27 Nov 2023 19:38:59 +0200 Subject: [PATCH] Add TPM to vsphere builder When having TPM device from the source, create it also for the destination VM. The data is persist in ovirt. If supported by kubevirt the TPM will be persistent TPM, otherwise the TPM without persistent data. Signed-off-by: Liran Rotenberg --- pkg/controller/plan/adapter/vsphere/builder.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/controller/plan/adapter/vsphere/builder.go b/pkg/controller/plan/adapter/vsphere/builder.go index 6ab8461d2..5382f0c63 100644 --- a/pkg/controller/plan/adapter/vsphere/builder.go +++ b/pkg/controller/plan/adapter/vsphere/builder.go @@ -462,6 +462,7 @@ func (r *Builder) VirtualMachine(vmRef ref.Ref, object *cnv.VirtualMachineSpec, r.mapMemory(vm, object) r.mapClock(host, object) r.mapInput(object) + r.mapDevices(vm, object) err = r.mapNetworks(vm, object) if err != nil { return @@ -639,6 +640,13 @@ func (r *Builder) mapDisks(vm *model.VM, persistentVolumeClaims []core.Persisten object.Template.Spec.Domain.Devices.Disks = kDisks } +func (r *Builder) mapDevices(vm *model.VM, object *cnv.VirtualMachineSpec) { + if vm.TpmEnabled { + persistData := true + object.Template.Spec.Domain.Devices.TPM = &cnv.TPMDevice{Persistent: &persistData} + } +} + // Build tasks. func (r *Builder) Tasks(vmRef ref.Ref) (list []*plan.Task, err error) { vm := &model.VM{}