Skip to content

Commit fa2ed08

Browse files
committed
MTV-1632 | Add secureboot to vsphere
Issue: When creating the VM from vSphere on kubevirt the MTV always defaulted the secureboot to false. Fix: Add the secureboot to the inventory and to main controller to pass it to the KubeVirt. Ref: https://issues.redhat.com/browse/MTV-1632 Signed-off-by: Martin Necas <mnecas@redhat.com>
1 parent ea38999 commit fa2ed08

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

pkg/controller/plan/adapter/vsphere/builder.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -668,15 +668,9 @@ func (r *Builder) mapFirmware(vm *model.VM, object *cnv.VirtualMachineSpec) {
668668
}
669669
switch vm.Firmware {
670670
case Efi:
671-
// We don't distinguish between UEFI and UEFI with secure boot, but we anyway would have
672-
// disabled secure boot, even if we knew it was enabled on the source, because the guest
673-
// OS won't be able to boot without getting the NVRAM data. By starting the VM without
674-
// secure boot we ease the procedure users need to do in order to make a guest OS that
675-
// was previously configured with secure boot bootable.
676-
secureBootEnabled := false
677671
firmware.Bootloader = &cnv.Bootloader{
678672
EFI: &cnv.EFI{
679-
SecureBoot: &secureBootEnabled,
673+
SecureBoot: &vm.SecureBoot,
680674
}}
681675
default:
682676
firmware.Bootloader = &cnv.Bootloader{BIOS: &cnv.BIOS{}}

pkg/controller/provider/container/vsphere/collector.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const (
101101
fUUID = "config.uuid"
102102
fFirmware = "config.firmware"
103103
fFtInfo = "config.ftInfo"
104+
fBootOptions = "config.bootOptions"
104105
fCpuAffinity = "config.cpuAffinity"
105106
fCpuHotAddEnabled = "config.cpuHotAddEnabled"
106107
fCpuHotRemoveEnabled = "config.cpuHotRemoveEnabled"
@@ -729,6 +730,7 @@ func (r *Collector) vmPathSet() []string {
729730
fFirmware,
730731
fFtInfo,
731732
fCpuAffinity,
733+
fBootOptions,
732734
fCpuHotAddEnabled,
733735
fCpuHotRemoveEnabled,
734736
fMemoryHotAddEnabled,

pkg/controller/provider/container/vsphere/model.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,12 @@ func (v *VmAdapter) Apply(u types.ObjectUpdate) {
565565
if a, cast := p.Val.(types.VirtualMachineAffinityInfo); cast {
566566
v.model.CpuAffinity = a.AffinitySet
567567
}
568+
case fBootOptions:
569+
if a, cast := p.Val.(types.VirtualMachineBootOptions); cast {
570+
if a.EfiSecureBootEnabled != nil {
571+
v.model.SecureBoot = *a.EfiSecureBootEnabled
572+
}
573+
}
568574
case fCpuHotAddEnabled:
569575
if b, cast := p.Val.(bool); cast {
570576
v.model.CpuHotAddEnabled = b

pkg/controller/provider/model/vsphere/model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ type VM struct {
268268
Concerns []Concern `sql:""`
269269
GuestNetworks []GuestNetwork `sql:""`
270270
GuestIpStacks []GuestIpStack `sql:""`
271+
SecureBoot bool `sql:""`
271272
}
272273

273274
// Determine if current revision has been validated.

pkg/controller/provider/web/vsphere/vm.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ type VM struct {
235235
NICs []model.NIC `json:"nics"`
236236
GuestNetworks []model.GuestNetwork `json:"guestNetworks"`
237237
GuestIpStacks []model.GuestIpStack `json:"guestIpStacks"`
238+
SecureBoot bool `json:"secureBoot"`
238239
}
239240

240241
// Build the resource using the model.
@@ -265,6 +266,7 @@ func (r *VM) With(m *model.VM) {
265266
r.NICs = m.NICs
266267
r.GuestNetworks = m.GuestNetworks
267268
r.GuestIpStacks = m.GuestIpStacks
269+
r.SecureBoot = m.SecureBoot
268270
}
269271

270272
// Build self link (URI).

0 commit comments

Comments
 (0)