Skip to content

Commit

Permalink
Create TPM device based on ovirt source
Browse files Browse the repository at this point in the history
When having TPM device from the source, create it also for the
destination VM. The data is persist in ovirt. Therefore, if supported
by kubevirt the TPM will be persistent TPM, otherwise the TPM without
persistent data.

In order to have the TPM persistent it is required to have kubvirt
v1.0.0 and adding configuration manually as described in:
https://kubevirt.io/user-guide/virtual_machines/persistent_tpm_and_uefi_state/

It is also supported in CNV running on OCP 4.14, and you need to follow:
https://access.redhat.com/documentation/en-us/openshift_container_platform/4.14/html/virtualization/virtual-machines#virt-using-vtpm-devices

Signed-off-by: Liran Rotenberg <[email protected]>
  • Loading branch information
liranr23 committed Nov 27, 2023
1 parent 79ac6f7 commit bc86219
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/controller/plan/adapter/ovirt/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func (r *Builder) VirtualMachine(vmRef ref.Ref, object *cnv.VirtualMachineSpec,
r.mapMemory(vm, object)
r.mapClock(vm, object)
r.mapInput(object)
r.mapDevices(vm, object)
err = r.mapNetworks(vm, object)
if err != nil {
return
Expand Down Expand Up @@ -485,6 +486,13 @@ func (r *Builder) mapDisks(vm *model.Workload, persistentVolumeClaims []core.Per
object.Template.Spec.Domain.Devices.Disks = kDisks
}

func (r *Builder) mapDevices(vm *model.Workload, 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.Workload{}
Expand Down

0 comments on commit bc86219

Please sign in to comment.