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

Keep the custom CPU model #686

Merged
merged 3 commits into from
Dec 25, 2023
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
16 changes: 16 additions & 0 deletions pkg/controller/plan/adapter/ovirt/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,23 @@ func (r *Builder) mapCPU(vm *model.Workload, object *cnv.VirtualMachineSpec) {
if vm.CpuPinningPolicy == model.Dedicated {
object.Template.Spec.Domain.CPU.DedicatedCPUPlacement = true
}
if vm.CustomCpuModel != "" {
r.setCpuFlags(vm.CustomCpuModel, object)
}
ahadas marked this conversation as resolved.
Show resolved Hide resolved
}

func (r *Builder) setCpuFlags(fullCpu string, object *cnv.VirtualMachineSpec) {
cpuTypeAndFlags := strings.Split(fullCpu, ",")
object.Template.Spec.Domain.CPU.Model = cpuTypeAndFlags[0]
for _, val := range cpuTypeAndFlags[1:] {
if flag, found := strings.CutPrefix(val, "+"); found {
object.Template.Spec.Domain.CPU.Features = append(object.Template.Spec.Domain.CPU.Features, cnv.CPUFeature{Name: flag, Policy: "require"})
} else if flag, found = strings.CutPrefix(val, "-"); found {
object.Template.Spec.Domain.CPU.Features = append(object.Template.Spec.Domain.CPU.Features, cnv.CPUFeature{Name: flag, Policy: "disable"})
} else {
object.Template.Spec.Domain.CPU.Features = append(object.Template.Spec.Domain.CPU.Features, cnv.CPUFeature{Name: flag})
}
ahadas marked this conversation as resolved.
Show resolved Hide resolved
}
}

func (r *Builder) mapFirmware(vm *model.Workload, cluster *model.Cluster, object *cnv.VirtualMachineSpec) {
Expand Down
4 changes: 3 additions & 1 deletion pkg/controller/provider/container/ovirt/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ type VM struct {
Enabled string `json:"enabled"`
} `json:"boot_menu"`
} `json:"bios"`
Display struct {
CustomCpuModel string `json:"custom_cpu_model"`
Display struct {
Type string `json:"type"`
} `json:"display"`
HasIllegalImages string `json:"has_illegal_images"`
Expand Down Expand Up @@ -358,6 +359,7 @@ func (r *VM) ApplyTo(m *model.VM) {
m.StorageErrorResumeBehaviour = r.StorageErrorResumeBehaviour
m.HaEnabled = r.bool(r.HA.Enabled)
m.IOThreads = r.int16(r.IO.Threads)
m.CustomCpuModel = r.CustomCpuModel
r.addCpuAffinity(m)
r.addNICs(m)
r.addDiskAttachment(m)
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/provider/model/ovirt/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ type VM struct {
Concerns []Concern `sql:"" eq:"-"`
Guest Guest `sql:""`
OSType string `sql:""`
CustomCpuModel string `sql:""`
}

// Determine if current revision has been validated.
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/provider/web/ovirt/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ type VM struct {
Snapshots []Snapshot `json:"snapshots"`
Guest Guest `json:"guest"`
OSType string `json:"osType"`
CustomCpuModel string `json:"customCpuModel"`
}

type VNIC = model.NIC
Expand Down Expand Up @@ -303,6 +304,7 @@ func (r *VM) With(m *model.VM) {
r.Snapshots = m.Snapshots
r.Guest = m.Guest
r.OSType = m.OSType
r.CustomCpuModel = m.CustomCpuModel
}

// Build self link (URI).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.konveyor.forklift.ovirt

default custom_cpu_model = false

custom_cpu_model = true {
count(input.customCpuModel) != 0
}

concerns[flag] {
custom_cpu_model
flag := {
"category": "Warning",
"label": "Custom CPU Model detected",
"assessment": "The VM is configured with a custom CPU model. This configuration will apply to the migrated VM and may not be supported by OpenShift Virtualization."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.konveyor.forklift.ovirt

test_without_customcpu {
mock_vm := { "name": "test" }
results = concerns with input as mock_vm
count(results) == 0
}

test_with_customcpu {
mock_vm := { "name": "test",
"customCpuModel": "Icelake-Server-noTSX,-mpx"
}
results = concerns with input as mock_vm
count(results) == 1
}
Loading