Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core, kubevirt): virt-launcher with efi and cpu >= 12 not starting #610

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions images/virt-artifact/patches/029-use-OFVM_CODE-for-linux.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
diff --git a/pkg/virt-launcher/virtwrap/manager.go b/pkg/virt-launcher/virtwrap/manager.go
index 2513ad62a8..4a1d22de46 100644
--- a/pkg/virt-launcher/virtwrap/manager.go
+++ b/pkg/virt-launcher/virtwrap/manager.go
@@ -966,17 +966,36 @@ func (l *LibvirtDomainManager) generateConverterContext(vmi *v1.VirtualMachineIn

var efiConf *converter.EFIConfiguration
if vmi.IsBootloaderEFI() {
+ const ann = "virtualization.deckhouse.io/os-type"
+ const windows = "Windows"
+
secureBoot := vmi.Spec.Domain.Firmware.Bootloader.EFI.SecureBoot == nil || *vmi.Spec.Domain.Firmware.Bootloader.EFI.SecureBoot
sev := kutil.IsSEVVMI(vmi)

+ forceCCEFI := false
+ if !sev {
+ if a := vmi.GetAnnotations()[ann]; a != windows {
+ /*
+ Kubevirt uses OVFM_CODE.secboot.fd in 2 combinations: OVFM_CODE.secboot.fd + OVFM_VARS.secboot.fd when secboot is enabled and OVFM_CODE.secboot.fd + OVFM_VARS.fd when secboot is disabled.
+ It works fine with original CentOS based virt-launcher in both secboot modes.
+ We use ALTLinux based virt-launcher, and it fails to start Linux VM with more than 12 CPUs in secboot disabled mode.
+
+ Kubevirt uses flags to detect firmware combinations in converter.
+ EFIConfiguration, so we can't set needed files directly.
+ But there is combination for SEV: OVFM_CODE.cc.fd + OVMF_VARS.fd that works for Linux, because OVFM_CODE.cc.fd is actually a symlink to OVFM_CODE.fd.
+ So, we set true for the second flag to force OVFM_CODE.cc.fd + OVMF_VARS.fd for non-Windows virtual machines.
+ */
+ forceCCEFI = true
+ }
+ }
if !l.efiEnvironment.Bootable(secureBoot, sev) {
log.Log.Errorf("EFI OVMF roms missing for booting in EFI mode with SecureBoot=%v, SEV=%v", secureBoot, sev)
return nil, fmt.Errorf("EFI OVMF roms missing for booting in EFI mode with SecureBoot=%v, SEV=%v", secureBoot, sev)
}

efiConf = &converter.EFIConfiguration{
- EFICode: l.efiEnvironment.EFICode(secureBoot, sev),
- EFIVars: l.efiEnvironment.EFIVars(secureBoot, sev),
+ EFICode: l.efiEnvironment.EFICode(secureBoot, sev || forceCCEFI),
+ EFIVars: l.efiEnvironment.EFIVars(secureBoot, sev || forceCCEFI),
SecureLoader: secureBoot,
}
}
11 changes: 11 additions & 0 deletions images/virt-artifact/patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,14 @@ How does it work?

By default, the virtual-operator adds a nodePlacement with the RequireControlPlanePreferNonWorker.
But we set up the placement ourselves, so we replace the policy with AnyNode.

#### `029-use-OFVM_CODE-for-linux.patch`

Kubevirt uses OVFM_CODE.secboot.fd in 2 combinations: OVFM_CODE.secboot.fd + OVFM_VARS.secboot.fd when secboot is enabled and OVFM_CODE.secboot.fd + OVFM_VARS.fd when secboot is disabled.
It works fine with original CentOS based virt-launcher in both secboot modes.
We use ALTLinux based virt-launcher, and it fails to start Linux VM with more than 12 CPUs in secboot disabled mode.

Kubevirt uses flags to detect firmware combinations in converter.
EFIConfiguration, so we can't set needed files directly.
But there is combination for SEV: OVFM_CODE.cc.fd + OVMF_VARS.fd that works for Linux, because OVFM_CODE.cc.fd is actually a symlink to OVFM_CODE.fd.
So, we set true for the second flag to force OVFM_CODE.cc.fd + OVMF_VARS.fd for non-Windows virtual machines._
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ const (
// LastPropagatedVMLabelsAnnotation is a marshalled map of previously applied virtual machine labels.
LastPropagatedVMLabelsAnnotation = AnnAPIGroup + "/last-propagated-vm-labels"

AnnOsType = AnnAPIGroupV + "/os-type"

// LabelsPrefix is a prefix for virtualization-controller labels.
LabelsPrefix = "virtualization.deckhouse.io"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
virtv1 "kubevirt.io/api/core/v1"

"github.com/deckhouse/virtualization-controller/pkg/common"
"github.com/deckhouse/virtualization-controller/pkg/common/annotations"
"github.com/deckhouse/virtualization-controller/pkg/common/array"
"github.com/deckhouse/virtualization-controller/pkg/common/pointer"
"github.com/deckhouse/virtualization-controller/pkg/common/resource_builder"
Expand Down Expand Up @@ -432,6 +433,9 @@ func (b *KVVM) SetProvisioning(p *virtv2.Provisioning) error {
func (b *KVVM) SetOsType(osType virtv2.OsType) error {
switch osType {
case virtv2.Windows:
// Need for `029-use-OFVM_CODE-for-linux.patch`
b.SetKVVMIAnnotation(annotations.AnnOsType, string(virtv2.Windows))

b.Resource.Spec.Template.Spec.Domain.Machine = &virtv1.Machine{
Type: "q35",
}
Expand Down